:root {
    color-scheme: light;
    --brand: #d71920;
    --brand-dark: #a90f14;
    --brand-soft: #fff0f1;
    --ink: #17191d;
    --muted: #656b75;
    --line: #dfe2e7;
    --line-strong: #c8cdd5;
    --surface: #ffffff;
    --surface-soft: #f6f7f9;
    --whatsapp: #25d366;
    --whatsapp-dark: #128c4a;
    --shadow: 0 14px 40px rgba(24, 28, 36, 0.1);
    --radius: 16px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--surface-soft);
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    padding: 0 0 116px;
    overflow-x: hidden;
    color: var(--ink);
    background:
        linear-gradient(180deg, #fff 0, #fff 260px, var(--surface-soft) 260px),
        var(--surface-soft);
    font-size: 1rem;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button,
select,
input[type="checkbox"] {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(215, 25, 32, 0.26);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    transform: translateY(-160%);
    border-radius: 8px;
    color: #fff;
    background: var(--ink);
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.page-header {
    display: grid;
    grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) auto;
    gap: clamp(20px, 4vw, 64px);
    align-items: center;
    width: min(100% - 48px, 1680px);
    margin: 0 auto;
    padding: 32px 0 28px;
}

.brand {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    width: max-content;
}

.brand-mark {
    display: block;
    padding: 8px 12px 7px;
    color: #fff;
    background: var(--brand);
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.055em;
}

.brand-caption {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.header-copy {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

h1 {
    max-width: 880px;
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 3.4rem);
    font-weight: 850;
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.subtitle {
    max-width: 780px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: clamp(0.96rem, 1.4vw, 1.1rem);
}

.freshness {
    display: inline-flex;
    gap: 9px;
    align-items: center;
    justify-self: end;
    max-width: 270px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #3f454e;
    background: #fff;
    font-size: 0.82rem;
    font-weight: 650;
    white-space: nowrap;
}

.freshness-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #25a862;
    box-shadow: 0 0 0 4px rgba(37, 168, 98, 0.12);
}

.freshness.is-warning .freshness-dot {
    background: #d78b19;
    box-shadow: 0 0 0 4px rgba(215, 139, 25, 0.12);
}

.catalog-shell {
    width: min(100% - 48px, 1680px);
    margin: 0 auto;
}

.toolbar {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto auto;
    gap: 14px;
    align-items: end;
    padding: 16px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface);
}

.search-field {
    position: relative;
    display: block;
}

.search-field svg {
    position: absolute;
    top: 50%;
    left: 15px;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    fill: none;
    stroke: #777e89;
    stroke-width: 2;
    stroke-linecap: round;
}

.search-field input,
.sort-field select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--ink);
    background: #fff;
    font-size: 1rem;
}

.search-field input {
    padding: 10px 14px 10px 46px;
}

.search-field input::placeholder {
    color: #8b919a;
}

.sort-field {
    display: grid;
    gap: 5px;
    min-width: 215px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.sort-field select {
    appearance: none;
    padding: 9px 42px 9px 12px;
    background-image:
        linear-gradient(45deg, transparent 50%, #6f7680 50%),
        linear-gradient(135deg, #6f7680 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 20px,
        calc(100% - 13px) 20px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.catalog-count {
    min-width: 110px;
    padding: 12px 0 11px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 750;
    text-align: right;
}

.table-frame {
    position: relative;
    min-height: 270px;
    overflow: clip;
    border: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.catalog-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.catalog-table th,
.catalog-table td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.catalog-table thead th {
    position: sticky;
    z-index: 2;
    top: 0;
    color: #4f5660;
    background: #f2f3f5;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-align: left;
    text-transform: uppercase;
}

.catalog-table tbody tr {
    position: relative;
    transition: background-color 160ms ease, box-shadow 160ms ease;
}

.catalog-table tbody tr:hover {
    background: #fafafa;
}

.catalog-table tbody tr.is-selected {
    background: var(--brand-soft);
    box-shadow: inset 4px 0 0 var(--brand);
}

.catalog-table tbody tr:last-child td {
    border-bottom: 0;
}

.select-column {
    width: 58px;
    padding-right: 4px !important;
    text-align: center !important;
}

.article-column {
    width: 150px;
}

.quantity-column {
    width: 130px;
    text-align: right !important;
}

.price-column {
    width: 190px;
    text-align: right !important;
}

.product-name {
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.article-value {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 6px;
    color: #444a53;
    background: #eef0f3;
    font-size: 0.86rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.muted-value {
    color: #8a9099;
}

.quantity-value,
.price-value {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.quantity-value {
    font-weight: 750;
}

.price-value {
    color: var(--brand-dark);
    font-size: 1.05rem;
    font-weight: 850;
}

.product-checkbox {
    appearance: none;
    display: inline-grid;
    width: 24px;
    height: 24px;
    margin: 0;
    border: 2px solid #aeb4bd;
    border-radius: 7px;
    place-content: center;
    background: #fff;
}

.product-checkbox::before {
    width: 11px;
    height: 6px;
    border-bottom: 2px solid #fff;
    border-left: 2px solid #fff;
    content: "";
    transform: rotate(-45deg) scale(0);
    transition: transform 100ms ease-in-out;
}

.product-checkbox:checked {
    border-color: var(--brand);
    background: var(--brand);
}

.product-checkbox:checked::before {
    transform: rotate(-45deg) scale(1);
}

.loading-state,
.error-state,
.empty-state {
    display: grid;
    min-height: 270px;
    padding: 40px 24px;
    place-items: center;
    align-content: center;
    text-align: center;
}

.loading-state p,
.error-state p,
.empty-state p {
    margin: 10px 0 0;
    color: var(--muted);
}

.error-state h2,
.empty-state h2 {
    margin: 0;
    font-size: 1.2rem;
}

.loader {
    width: 34px;
    height: 34px;
    border: 3px solid #eceef1;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.secondary-button {
    margin-top: 18px;
    padding: 10px 18px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    color: var(--ink);
    background: #fff;
    font-weight: 750;
}

.selection-bar {
    position: fixed;
    z-index: 20;
    right: max(24px, calc((100vw - 1680px) / 2 + 24px));
    bottom: max(18px, env(safe-area-inset-bottom));
    display: flex;
    gap: 18px;
    align-items: center;
    max-width: calc(100vw - 48px);
    padding: 10px 11px 10px 18px;
    border: 1px solid rgba(17, 24, 39, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 50px rgba(14, 20, 30, 0.2);
    backdrop-filter: blur(12px);
}

.selection-summary {
    display: flex;
    gap: 10px;
    align-items: center;
}

.selection-count {
    color: #4a515b;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.clear-button {
    padding: 5px 4px;
    border: 0;
    color: var(--brand-dark);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 750;
}

.whatsapp-button {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 11px 18px;
    border: 0;
    border-radius: 11px;
    color: #fff;
    background: var(--whatsapp-dark);
    font-weight: 850;
    box-shadow: 0 8px 22px rgba(18, 140, 74, 0.25);
    transition: transform 150ms ease, background-color 150ms ease;
}

.whatsapp-button:not(:disabled):hover {
    transform: translateY(-1px);
    background: #0e7e42;
}

.whatsapp-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.whatsapp-button svg {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    fill: currentColor;
}

.noscript-message {
    position: fixed;
    z-index: 50;
    right: 20px;
    bottom: 20px;
    left: 20px;
    padding: 15px;
    border-radius: 10px;
    color: #fff;
    background: #8e1015;
    text-align: center;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1050px) {
    .page-header {
        grid-template-columns: auto 1fr;
        gap: 24px;
    }

    .freshness {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: start;
        margin-top: -8px;
    }

    .toolbar {
        grid-template-columns: minmax(220px, 1fr) minmax(190px, 240px);
    }

    .catalog-count {
        grid-column: 1 / -1;
        padding: 0;
        text-align: left;
    }

    .article-column {
        width: 125px;
    }

    .quantity-column {
        width: 112px;
    }

    .price-column {
        width: 162px;
    }
}

@media (max-width: 760px) {
    body {
        padding-bottom: 152px;
        background:
            linear-gradient(180deg, #fff 0, #fff 330px, var(--surface-soft) 330px),
            var(--surface-soft);
    }

    .page-header,
    .catalog-shell {
        width: min(100% - 28px, 720px);
    }

    .page-header {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 22px 0 24px;
    }

    .header-copy {
        grid-row: 2;
    }

    .freshness {
        grid-row: 3;
        grid-column: auto;
        max-width: 100%;
        margin: -4px 0 0;
        white-space: normal;
    }

    .brand-mark {
        font-size: 1.55rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .toolbar {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 14px;
        border-bottom: 1px solid var(--line);
        border-radius: 14px;
    }

    .sort-field {
        min-width: 0;
    }

    .catalog-count {
        grid-column: auto;
    }

    .table-frame {
        min-height: 240px;
        margin-top: 14px;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .catalog-table,
    .catalog-table tbody {
        display: block;
        width: 100%;
    }

    .catalog-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .catalog-table tbody {
        display: grid;
        gap: 12px;
    }

    .catalog-table tbody tr {
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr) auto;
        gap: 0 12px;
        padding: 16px;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(25, 29, 36, 0.07);
    }

    .catalog-table tbody tr:hover {
        background: #fff;
    }

    .catalog-table tbody tr.is-selected {
        border-color: rgba(215, 25, 32, 0.5);
        background: var(--brand-soft);
        box-shadow: inset 4px 0 0 var(--brand), 0 8px 24px rgba(25, 29, 36, 0.07);
    }

    .catalog-table td {
        display: block;
        width: auto !important;
        min-width: 0;
        padding: 0;
        border: 0;
        text-align: left !important;
    }

    .catalog-table td.select-column {
        grid-row: 1 / span 3;
        grid-column: 1;
        align-self: start;
        padding: 1px 0 0 !important;
    }

    .catalog-table td.product-name {
        grid-row: 1;
        grid-column: 2 / -1;
        padding: 0 0 12px;
        border-bottom: 1px solid var(--line);
        font-size: 1rem;
    }

    .catalog-table td.article-cell,
    .catalog-table td.quantity-cell,
    .catalog-table td.price-cell {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        align-items: center;
        grid-column: 2 / -1;
        padding-top: 10px;
    }

    .catalog-table td.article-cell::before,
    .catalog-table td.quantity-cell::before,
    .catalog-table td.price-cell::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 0.82rem;
        font-weight: 650;
    }

    .article-value {
        justify-self: end;
    }

    .price-value {
        font-size: 1.08rem;
    }

    .loading-state,
    .error-state,
    .empty-state {
        min-height: 240px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fff;
    }

    .selection-bar {
        right: 12px;
        bottom: max(10px, env(safe-area-inset-bottom));
        left: 12px;
        display: grid;
        gap: 8px;
        max-width: none;
        padding: 10px;
        border-radius: 15px;
    }

    .selection-summary {
        justify-content: space-between;
        padding: 0 4px;
    }

    .whatsapp-button {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .page-header,
    .catalog-shell {
        width: min(100% - 20px, 360px);
    }

    .catalog-table tbody tr {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 0 8px;
        padding: 14px 12px;
    }

    .catalog-table td.product-name,
    .catalog-table td.article-cell,
    .catalog-table td.quantity-cell,
    .catalog-table td.price-cell {
        grid-column: 2;
    }

    .selection-count {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
