:root {
    --color-primary: #e83d8c;
    --color-primary-dark: #c92f73;
    --color-primary-light: #fff0f7;

    --color-cream: #f2e7d6;
    --color-background: #faf8f5;
    --color-surface: #ffffff;

    --color-text: #1c1c1c;
    --color-muted: #76706b;
    --color-border: #e8e2dc;
    --color-shadow: rgba(44, 35, 29, 0.08);

    --sidebar-width: 270px;
    --content-max-width: 1180px;
    --border-radius: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--color-background);
    color: var(--color-text);
    font-family: "Inter", Arial, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

/* Layout principal */

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    align-items: start;
    width: 100%;
    min-height: 100vh;
    background: var(--color-background);
}

/* Menú lateral */

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;

    display: flex;
    flex-direction: column;

    width: var(--sidebar-width);
    height: 100vh;
    margin: 0;
    padding: 28px 20px;

    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
}

.sidebar__brand {
    display: flex;
    justify-content: center;
    padding: 8px 10px 34px;
}

.sidebar__logo {
    display: block;
    width: 100%;
    max-width: 210px;
    height: auto;
    object-fit: contain;
}

.sidebar__navigation {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;

    width: 100%;
    min-height: 48px;
    padding: 0 16px;

    border-radius: 12px;

    color: var(--color-muted);
    font-size: 14px;
    font-weight: 600;

    transition:
        background-color 150ms ease,
        color 150ms ease,
        transform 150ms ease;
}

.sidebar__link:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
    transform: translateX(2px);
}

.sidebar__link--active {
    background: var(--color-primary);
    color: #ffffff;
}

.sidebar__link--active:hover {
    background: var(--color-primary-dark);
    color: #ffffff;
}

.sidebar__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 24px;
    width: 24px;

    font-size: 20px;
    line-height: 1;
}

/* Contenido principal */

.main-content {
    align-self: start;

    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 54px 42px;
}

.page-header,
.card {
    width: 100%;
    max-width: var(--content-max-width);
    margin-right: auto;
    margin-left: auto;
}

/* Encabezado de página */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;

    margin-bottom: 28px;
}

.page-header__eyebrow {
    margin: 0 0 8px;

    color: var(--color-primary);

    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-header__title {
    margin: 0;

    font-size: clamp(28px, 4vw, 38px);
    line-height: 1.15;
}

.page-header__description {
    max-width: 600px;
    margin: 10px 0 0;

    color: var(--color-muted);

    font-size: 15px;
    line-height: 1.6;
}

/* Tarjetas */

.card {
    min-width: 0;
    padding: 32px;

    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);

    box-shadow: 0 14px 40px var(--color-shadow);
}

/* Formularios */

.order-form,
.form-grid,
.form-group {
    min-width: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.form-group--full {
    grid-column: 1 / -1;
}

.form-label {
    color: var(--color-text);
    font-size: 14px;
    font-weight: 600;
}

.form-label__optional {
    margin-left: 4px;

    color: var(--color-muted);

    font-size: 12px;
    font-weight: 400;
}

.form-control {
    display: block;

    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 11px 14px;

    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    outline: none;

    color: var(--color-text);

    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
}

.form-control::placeholder {
    color: #aaa29c;
}

.form-control:hover {
    border-color: #d7cec7;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(232, 61, 140, 0.12);
}

.form-control--textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    justify-content: flex-end;

    margin-top: 28px;
    padding-top: 24px;

    border-top: 1px solid var(--color-border);
}

/* Botones */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 46px;
    padding: 0 20px;

    border: 0;
    border-radius: 10px;
    cursor: pointer;

    font-size: 14px;
    font-weight: 700;

    transition:
        background-color 150ms ease,
        transform 150ms ease,
        box-shadow 150ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:focus-visible {
    outline: 3px solid rgba(232, 61, 140, 0.25);
    outline-offset: 2px;
}

.button--primary {
    background: var(--color-primary);
    color: #ffffff;

    box-shadow: 0 8px 20px rgba(232, 61, 140, 0.2);
}

.button--primary:hover {
    background: var(--color-primary-dark);
}

/* Estado vacío */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 48px 20px;

    text-align: center;
}

.empty-state__icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 64px;
    height: 64px;
    margin-bottom: 20px;

    background: var(--color-primary-light);
    border-radius: 18px;

    color: var(--color-primary);
    font-size: 30px;
}

.empty-state__title {
    margin: 0;

    font-size: 20px;
}

.empty-state__description {
    max-width: 460px;
    margin: 10px 0 24px;

    color: var(--color-muted);

    font-size: 14px;
    line-height: 1.6;
}

/* Tablet y móvil */

@media (max-width: 820px) {
    .app-layout {
        display: block;
        width: 100%;
        min-height: 100vh;
    }

    .sidebar {
        position: static;

        width: 100%;
        height: auto;
        padding: 18px;

        border-right: 0;
        border-bottom: 1px solid var(--color-border);
    }

    .sidebar__brand {
        padding: 0 10px 18px;
    }

    .sidebar__logo {
        max-width: 180px;
    }

    .sidebar__navigation {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar__link {
        justify-content: center;
        padding: 0 10px;
    }

    .main-content {
        width: 100%;
        padding: 32px 18px;
    }
}

@media (max-width: 620px) {
    .page-header {
        display: block;
    }

    .card {
        padding: 22px 18px;
        border-radius: 14px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .form-group--full {
        grid-column: auto;
    }

    .form-actions {
        display: block;
    }

    .button {
        width: 100%;
    }

    .sidebar__link {
        font-size: 13px;
    }
}

@media (max-width: 420px) {
    .sidebar__navigation {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 26px 14px;
    }

    .card {
        padding: 20px 15px;
    }
}

.alert {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto 22px;
    padding: 16px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert--success {
    background: #edf9f1;
    border-color: #b8e3c5;
    color: #246b3a;
}

.alert--error {
    background: #fff1f1;
    border-color: #f0c2c2;
    color: #9b2929;
}

.alert__list {
    margin: 8px 0 0;
    padding-left: 20px;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.table-search {
    width: 100%;
    max-width: 420px;
}

.table-count {
    flex-shrink: 0;
    margin: 0;
    color: var(--color-muted);
    font-size: 14px;
    font-weight: 600;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th,
.orders-table td {
    padding: 16px 14px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}

.orders-table th {
    background: #fcfaf8;
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.orders-table td {
    font-size: 14px;
    line-height: 1.5;
}

.orders-table tbody tr {
    transition: background-color 150ms ease;
}

.orders-table tbody tr:hover {
    background: #fffafd;
}

.orders-table tbody tr:last-child td {
    border-bottom: 0;
}

.orders-table__actions-heading {
    text-align: right !important;
}

.orders-table__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}

.size-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 30px;
    padding: 4px 9px;
    background: var(--color-primary-light);
    border-radius: 999px;
    color: var(--color-primary-dark);
    font-size: 12px;
    font-weight: 700;
}

.text-muted {
    color: var(--color-muted);
}

.delete-form {
    margin: 0;
}

.button--small {
    min-height: 36px;
    padding: 0 13px;
    border-radius: 8px;
    font-size: 12px;
}

.button--secondary {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    box-shadow: none;
}

.button--secondary:hover {
    background: #fbd9e9;
}

.button--danger {
    background: #fff0f0;
    color: #b52c2c;
    box-shadow: none;
}

.button--danger:hover {
    background: #ffdede;
}

.empty-state--small {
    padding: 34px 20px 16px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 900px) {
    .page-header {
        flex-direction: column;
        gap: 16px;
    }

    .page-header>.button {
        width: 100%;
    }

    .card {
        padding: 14px;
    }

    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 14px;
    }

    .table-search {
        max-width: none;
    }

    .table-wrapper {
        width: 100%;
        overflow-x: auto;
        border: 1px solid var(--color-border);
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .orders-table {
        width: 100%;
        min-width: 760px;
        border-collapse: collapse;
    }

    .orders-table th,
    .orders-table td {
        padding: 12px 10px;
        white-space: nowrap;
    }

    .orders-table th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: #fcfaf8;
        font-size: 10px;
    }

    .orders-table td {
        font-size: 12px;
    }

    .orders-table td[data-label="Alumno"] {
        min-width: 140px;
        white-space: normal;
    }

    .orders-table td[data-label="Prenda"] {
        min-width: 120px;
        white-space: normal;
    }

    .orders-table td[data-label="Observación"] {
        min-width: 150px;
        max-width: 220px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .orders-table__actions {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
    }

    .button--small {
        min-height: 32px;
        padding: 0 10px;
        font-size: 11px;
    }

    .size-badge {
        min-width: 34px;
        min-height: 26px;
        padding: 3px 8px;
        font-size: 11px;
    }
}

@media (max-width: 900px) {

    .orders-table th:first-child,
    .orders-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--color-surface);
        box-shadow: 4px 0 8px rgba(44, 35, 29, 0.06);
    }

    .orders-table th:first-child {
        z-index: 3;
        background: #fcfaf8;
    }
}

@media (max-width: 620px) {
    .main-content {
        padding: 22px 10px;
    }

    .page-header {
        margin-bottom: 16px;
    }

    .page-header__eyebrow {
        margin-bottom: 4px;
        font-size: 10px;
    }

    .page-header__title {
        font-size: 26px;
    }

    .page-header__description {
        margin-top: 5px;
        font-size: 12px;
    }

    .card {
        padding: 10px;
        border-radius: 12px;
    }

    .orders-table {
        min-width: 720px;
    }

    .orders-table th,
    .orders-table td {
        padding: 10px 8px;
    }
}

[hidden] {
    display: none !important;
}

.sort-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.sort-button:hover {
    color: var(--color-primary);
}

.sort-button--active {
    color: var(--color-primary);
}

.sort-button__icon {
    font-size: 14px;
    line-height: 1;
}

.button--success {
    background: #eaf8ef;
    color: #247442;
    box-shadow: none;
}

.button--success:hover {
    background: #d5f0df;
}

.ready-form {
    margin: 0;
}

.sweetalert-error-list {
    margin: 0;
    padding-left: 22px;
    text-align: left;
}

.sweetalert-error-list li+li {
    margin-top: 6px;
}

.swal2-popup {
    border-radius: 18px;
    font-family: "Inter", Arial, sans-serif;
}

.swal2-title {
    color: var(--color-text);
}

.swal2-confirm,
.swal2-cancel {
    border-radius: 9px !important;
    font-weight: 700 !important;
}

.delivery-form {
    margin: 0;
}

.button--delivered {
    cursor: default;
    background: #edf9f1;
    color: #247442;
    box-shadow: none;
    opacity: 1;
}

.button--delivered:hover {
    background: #edf9f1;
    transform: none;
}

.button--delivered:disabled {
    cursor: not-allowed;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 28px;
    padding: 4px 10px;

    border-radius: 999px;

    font-size: 12px;
    font-weight: 700;
}

.status-badge--pending {
    background: #fff4df;
    color: #956319;
}

.orders-table__row--delivered {
    background: #fbfdfb;
}

.orders-table__row--delivered:hover {
    background: #f4faf6;
}

.form-actions--between {
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

@media (max-width: 620px) {
    .form-actions--between {
        display: flex;
        flex-direction: column-reverse;
        align-items: stretch;
    }
}

.status-badge--delivered {
    background: #edf9f1;
    color: #247442;
}