:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef4fb;
    --text: #223043;
    --muted: #637083;
    --line: #d9e2ee;
    --primary: #1667a8;
    --primary-strong: #0f4f83;
    --accent: #2d8b7f;
    --danger: #b42318;
    --warning: #946200;
    --shadow: 0 12px 30px rgba(26, 45, 69, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
}

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.app-header__inner,
.page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand__name {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.brand__meta {
    color: var(--muted);
    font-size: 14px;
}

.top-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page {
    padding: 28px 0 44px;
}

.page-title {
    margin: 0 0 18px;
    font-size: clamp(26px, 4vw, 36px);
    line-height: 1.15;
}

.page-title--center {
    display: block;
    width: 100%;
    text-align: center;
}

.product-title-block {
    width: 100%;
    text-align: center;
}

.product-title-block .page-title {
    margin-left: auto;
    margin-right: auto;
}

.section-title {
    margin: 0 0 14px;
    font-size: 22px;
}

.notice {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
}

.notice p,
.card p {
    margin: 0 0 10px;
}

.notice p:last-child,
.card p:last-child {
    margin-bottom: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.stack {
    display: grid;
    gap: 16px;
}

.form-row {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.field {
    display: grid;
    gap: 6px;
    flex: 1 1 180px;
    color: var(--text);
    font-weight: 700;
}

.field span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #b8c5d6;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    padding: 10px 12px;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    min-height: auto;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(22, 103, 168, 0.16);
}

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 10px 14px;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover,
button:hover {
    background: var(--primary-strong);
    text-decoration: none;
}

.btn--secondary {
    background: #fff;
    border-color: var(--line);
    color: var(--primary);
}

.btn--secondary:hover {
    background: var(--surface-2);
    color: var(--primary-strong);
}

.btn--muted {
    background: #e7edf5;
    color: var(--text);
}

.btn--danger {
    background: var(--danger);
}

.btn[disabled],
button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.actions--compact {
    margin-top: -4px;
}

.admin-toolbar {
    align-items: stretch;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.admin-toolbar .btn {
    flex: 0 0 auto;
}

.factura-panel {
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    background: #fbfdff;
    padding: 18px;
}

.factura-panel[hidden] {
    display: none;
}

.size-options {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border: 0;
    margin: 8px 0 0;
    padding: 0;
}

.size-options legend {
    margin-right: 4px;
    color: var(--primary-strong);
    font-weight: 700;
}

.size-options label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.search-again {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdff;
    padding: 12px;
}

.search-again summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
    padding: 10px 14px;
}

.search-again summary:hover {
    background: var(--surface-2);
    color: var(--primary-strong);
}

.search-again[open] summary {
    margin-bottom: 14px;
}

.flow-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.flow-step {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-weight: 700;
    padding: 10px 12px;
    text-align: center;
}

.flow-step--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.route-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.route-card {
    display: grid;
    gap: 4px;
    min-height: 92px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    padding: 16px;
    text-decoration: none;
}

.route-card:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.route-card span {
    color: var(--muted);
    font-size: 14px;
}

.muted-text {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.package-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}

.package-card__tools {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.package-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfdff;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    min-height: 44px;
    padding: 10px 12px;
    white-space: nowrap;
}

.package-total {
    color: var(--primary);
    font-size: 20px;
    white-space: nowrap;
}

.products-table table {
    min-width: 880px;
}

.legacy-package {
    display: grid;
    gap: 0;
    border: 1px solid #aebdce;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.legacy-category {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 22px;
}

.legacy-grade-messages {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    border: 1px solid #bfd6ea;
    border-radius: var(--radius);
    background: #f0f7fc;
    color: #18324b;
    padding: 14px 16px;
    font-weight: 700;
}

.legacy-grade-messages p {
    margin: 0;
}

.legacy-list-title {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    text-align: center;
    color: var(--text);
    line-height: 1.45;
}

.legacy-category h2 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
}

.legacy-category a {
    display: inline-flex;
    margin-top: 8px;
    background: #fff;
    font-size: 18px;
    font-weight: 700;
}

.legacy-category--uniformes {
    background: #82c0e7;
    color: #fff;
}

.legacy-category--uniformes a {
    color: #1667a8;
}

.legacy-category--calzado {
    background: #eef4fb;
}

.legacy-package__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #eef4fb;
    border-bottom: 1px solid #aebdce;
    padding: 14px 16px;
}

.legacy-package__heading h3 {
    margin: 0 0 4px;
    color: var(--primary-strong);
    font-size: 22px;
    line-height: 1.1;
}

.legacy-package__heading strong {
    display: block;
    color: #182536;
    font-size: 18px;
    line-height: 1.25;
}

.legacy-package__check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #9fb0c4;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    min-height: 44px;
    padding: 10px 12px;
    white-space: nowrap;
}

.legacy-products-table {
    border: 0;
    border-radius: 0;
}

.legacy-products-table table {
    min-width: 980px;
}

.legacy-products-table th,
.legacy-products-table td {
    border-color: #b9c7d8;
}

.legacy-products-table thead th,
.legacy-products-table tfoot th {
    background: #dfeaf6;
    color: #26384f;
    font-weight: 700;
    text-transform: uppercase;
}

.legacy-products-table tfoot th {
    border-top: 2px solid #aebdce;
}

.legacy-products-table__qty {
    background: #fff8c7;
}

.quantity-input {
    max-width: 88px;
}

.legacy-total-bar {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: grid;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
}

.legacy-total-bar__totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.legacy-total-bar__totals label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.legacy-total-bar__totals input {
    color: var(--primary);
    font-size: 20px;
    font-weight: 700;
    text-align: right;
}

.order-bar {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
}

.order-bar span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.order-bar strong,
.order-total-line strong {
    color: var(--primary);
    font-size: 24px;
}

.print-sheet {
    background: #fff;
    color: #111827;
    padding: 20px;
}

.print-header {
    display: grid;
    align-items: flex-start;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    border-bottom: 2px solid #111827;
    padding-bottom: 12px;
}

.print-header__title {
    grid-column: 2;
    text-align: center;
}

.print-header h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
}

.print-header p {
    margin: 2px 0 0;
}

.print-header .print-action {
    grid-column: 3;
    justify-self: end;
}

.print-folio-message {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 12px 14px;
    line-height: 1.45;
}

.print-folio-message__folio {
    display: inline-block;
    font-size: 20pt;
    padding: 0;
}

.print-folio-message__text {
    display: inline;
    font-size: 12pt;
    padding: 0;
}

.print-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.print-summary div {
    border: 1px solid #111827;
    padding: 7px 8px;
}

.print-summary strong,
.print-summary span {
    display: block;
}

.print-table-wrap {
    overflow-x: auto;
}

.print-block {
    display: grid;
    gap: 8px;
}

.print-block h3 {
    border: 1px solid #c7c7c7;
    border-radius: 4px;
    background: #fff;
    margin: 0;
    padding: 10px 12px;
    font-size: 18px;
}

.print-table {
    min-width: 820px;
    border-collapse: collapse;
    font-size: 13px;
}

.print-table th,
.print-table td {
    border: 1px solid #111827;
    padding: 6px 8px;
}

.print-table th {
    background: #f3f4f6;
    color: #111827;
    text-align: center;
}

.print-table tfoot th {
    background: #fff;
    text-align: right;
}

.print-table td:nth-child(1),
.print-table td:nth-child(3) {
    text-align: center;
}

.print-table td:nth-child(4),
.print-table td:nth-child(5) {
    background: #ededed;
    text-align: right;
}

.print-totals {
    display: grid;
    justify-content: end;
    gap: 6px;
}

.print-totals div {
    display: grid;
    grid-template-columns: 140px 170px;
    align-items: center;
}

.print-totals strong {
    text-align: right;
}

.print-totals span {
    border: 1px solid #c7c7c7;
    background: #ededed;
    padding: 7px 10px;
    text-align: right;
}

.message {
    border-radius: var(--radius);
    padding: 12px 14px;
    background: #ecfdf3;
    color: #14532d;
}

.message--warning {
    background: #fff6db;
    color: var(--warning);
}

.message--error {
    background: #fee4e2;
    color: var(--danger);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.summary-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: #fbfdff;
}

.summary-item strong {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.option-list {
    display: grid;
    gap: 10px;
}

.option {
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}

legend {
    padding: 0 6px;
    font-weight: 700;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef4fb;
    color: #314158;
    font-size: 14px;
}

tr:last-child td {
    border-bottom: 0;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form input {
    max-width: 110px;
}

.admin-folios-wrap {
    max-width: calc(100vw - 32px);
}

.admin-folios-table {
    min-width: 1380px;
}

.admin-folios-table th:nth-child(10),
.admin-folios-table td:nth-child(10) {
    min-width: 390px;
}

.admin-delivery-form {
    display: grid;
    grid-template-columns: 150px 110px auto;
    gap: 8px;
    align-items: center;
}

.admin-delivery-form input {
    min-width: 0;
}

.admin-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-products-table {
    min-width: 1320px;
}

.admin-products-table input {
    min-width: 90px;
}

.admin-products-table td:nth-child(2) input {
    min-width: 360px;
}

.modal {
    width: min(760px, calc(100vw - 32px));
    max-height: min(720px, calc(100vh - 48px));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.modal::backdrop {
    background: rgba(17, 24, 39, 0.45);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.modal__header h3 {
    margin: 0;
}

@media (max-width: 720px) {
    .app-header__inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .top-nav,
    .actions,
    .form-row {
        width: 100%;
    }

    .btn,
    button,
    .top-nav a,
    .search-again summary {
        width: 100%;
    }

    .card {
        padding: 18px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .flow-steps,
    .route-grid {
        grid-template-columns: 1fr;
    }

    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-form input {
        max-width: none;
    }

    .package-card__header,
    .order-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .package-card__tools {
        justify-items: stretch;
    }

    .legacy-package__heading {
        align-items: stretch;
        flex-direction: column;
    }

    .legacy-package__check {
        justify-content: center;
        width: 100%;
    }

    .legacy-total-bar__totals {
        grid-template-columns: 1fr;
    }

    .quantity-input {
        max-width: none;
    }
}

@media print {
    body {
        background: #fff;
        font-size: 12px;
    }

    .app-header,
    .flow-steps,
    .print-action,
    .print-actions {
        display: none !important;
    }

    .page {
        width: 100%;
        padding: 0;
    }

    .print-sheet {
        padding: 0;
    }

    .print-table {
        min-width: 0;
        width: 100%;
        font-size: 11px;
    }

    .print-summary {
        grid-template-columns: repeat(4, 1fr);
    }
}
