:root {
    color-scheme: light;
    --bg: #f5f4ef;
    --surface: #ffffff;
    --surface-soft: #faf9f5;
    --text: #20231f;
    --muted: #70766e;
    --border: #dedfd9;
    --accent: #2d583c;
    --accent-strong: #1e422c;
    --accent-soft: #e7efe9;
    --danger-soft: #f4ece8;
    --shadow: 0 18px 45px rgba(38, 45, 38, .08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(45, 88, 60, .08), transparent 30rem),
        var(--bg);
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 120px;
}

.app-shell--menu {
    width: min(920px, calc(100% - 32px));
    padding-top: clamp(48px, 10vh, 120px);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.8rem);
    line-height: 1;
    letter-spacing: -.045em;
}

.hero__text,
.page-header__text {
    max-width: 680px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 18px;
    margin-top: 42px;
}

.menu-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 16px;
    align-items: center;
    padding: 28px;
    color: inherit;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.menu-card:hover {
    transform: translateY(-2px);
    border-color: #b9c6bc;
    box-shadow: 0 22px 55px rgba(38, 45, 38, .12);
}

.menu-card__icon {
    display: grid;
    grid-row: 1 / 3;
    place-items: center;
    width: 58px;
    height: 58px;
    color: white;
    background: var(--accent);
    border-radius: 18px;
    font-size: 1.3rem;
    font-weight: 900;
}

.menu-card__title {
    font-size: 1.2rem;
    font-weight: 850;
}

.menu-card__text {
    color: var(--muted);
    line-height: 1.45;
}

.menu-card__arrow {
    grid-row: 1 / 3;
    font-size: 1.65rem;
    color: var(--accent);
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 26px;
}

.back-link {
    display: inline-block;
    margin-bottom: 28px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
}

.back-link:hover {
    color: var(--accent);
}

.summary-chip {
    min-width: 110px;
    padding: 14px 18px;
    text-align: right;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.summary-chip span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
}

.summary-chip strong {
    display: block;
    margin-top: 2px;
    font-size: 1.4rem;
}

.toolbar {
    display: flex;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.search-box {
    flex: 1;
}

.search-box span {
    display: block;
    margin: 0 0 7px 3px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 750;
}

.search-box input {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45, 88, 60, .12);
}

.secondary-button {
    height: 50px;
    padding: 0 18px;
    color: var(--accent-strong);
    background: var(--accent-soft);
    border: 0;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
}

.table-card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

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

.purchase-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.purchase-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 15px 18px;
    color: var(--muted);
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
    font-size: .76rem;
    letter-spacing: .04em;
    text-align: left;
    text-transform: uppercase;
}

.purchase-table td {
    padding: 15px 18px;
    border-bottom: 1px solid #ecece7;
    vertical-align: middle;
}

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

.purchase-row {
    transition: background .15s ease;
}

.purchase-row:hover {
    background: #fbfcfa;
}

.purchase-row--selected {
    background: var(--accent-soft);
}

.purchase-row--selected:hover {
    background: #e0ebe3;
}

.product-cell strong,
.supplier-cell strong {
    display: block;
    font-size: .96rem;
}

.product-cell span,
.product-cell small,
.supplier-cell span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .79rem;
}

.money-cell {
    text-align: right !important;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.unit-price {
    font-weight: 800;
}

.quantity-cell {
    text-align: center !important;
}

.stepper {
    display: inline-grid;
    grid-template-columns: 38px 44px 38px;
    align-items: center;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.stepper__button {
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--accent-strong);
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
}

.stepper__button:hover:not(:disabled) {
    background: var(--accent-soft);
}

.stepper__button:disabled {
    color: #bcc0ba;
    cursor: default;
}

.stepper__value {
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.subtotal {
    font-weight: 850;
}

.empty-state {
    padding: 60px !important;
    color: var(--muted);
    text-align: center;
}

.purchase-total {
    position: fixed;
    right: max(16px, calc((100vw - 1500px) / 2));
    bottom: 18px;
    left: max(16px, calc((100vw - 1500px) / 2));
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 22px;
    padding: 16px 20px;
    color: white;
    background: rgba(30, 66, 44, .97);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 18px;
    box-shadow: 0 16px 44px rgba(28, 48, 34, .28);
    backdrop-filter: blur(12px);
}

.purchase-total span {
    display: block;
    color: rgba(255, 255, 255, .72);
    font-size: .78rem;
}

.purchase-total strong {
    display: block;
    margin-top: 2px;
    font-size: 1.15rem;
}

.purchase-total__amount {
    text-align: right;
}

.purchase-total__amount strong {
    font-size: 1.65rem;
    font-variant-numeric: tabular-nums;
}

[hidden] {
    display: none !important;
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 20px, 1500px);
        padding-top: 18px;
    }

    .page-header {
        align-items: start;
    }

    .summary-chip {
        display: none;
    }

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

    .secondary-button {
        width: 100%;
    }

    .purchase-total {
        right: 10px;
        bottom: 10px;
        left: 10px;
        padding: 13px 15px;
    }

    .purchase-total__amount strong {
        font-size: 1.35rem;
    }
}


/* -------------------------------------------------------------------------
   Estrategia de precios
   ------------------------------------------------------------------------- */

.strategy-card {
    display: grid;
    grid-template-columns: minmax(240px, .7fr) minmax(640px, 2fr);
    gap: 24px;
    align-items: center;
    margin-bottom: 16px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.strategy-card__intro {
    min-width: 0;
}

.strategy-card__eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.strategy-card__intro > strong {
    display: block;
    font-size: 1.02rem;
}

.strategy-card__intro > small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.4;
}

.strategy-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
}

.strategy-option {
    position: relative;
    display: block;
    min-width: 0;
    cursor: pointer;
}

.strategy-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.strategy-option > span {
    display: block;
    height: 100%;
    min-height: 72px;
    padding: 12px 13px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.strategy-option:hover > span {
    border-color: #b9c6bc;
}

.strategy-option input:checked + span {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.strategy-option input:focus-visible + span {
    outline: 3px solid rgba(45, 88, 60, .18);
    outline-offset: 2px;
}

.strategy-option strong,
.strategy-option small {
    display: block;
}

.strategy-option strong {
    color: var(--text);
    font-size: .88rem;
}

.strategy-option small {
    margin-top: 5px;
    color: var(--muted);
    font-size: .72rem;
    line-height: 1.25;
}

.choose-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 6px 9px;
    color: var(--accent-strong);
    background: var(--accent-soft);
    border: 0;
    border-radius: 9px;
    font-size: .72rem;
    font-weight: 850;
    cursor: pointer;
}

.choose-option:hover {
    background: #dce9df;
}

/* -------------------------------------------------------------------------
   Modal de histórico
   ------------------------------------------------------------------------- */

.price-dialog {
    width: min(680px, calc(100vw - 28px));
    max-height: min(780px, calc(100vh - 36px));
    padding: 0;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 28px 90px rgba(20, 32, 23, .28);
}

.price-dialog::backdrop {
    background: rgba(25, 31, 27, .48);
    backdrop-filter: blur(2px);
}

.price-dialog__header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: start;
    padding: 22px 22px 17px;
    border-bottom: 1px solid var(--border);
}

.price-dialog__header h2 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -.02em;
}

.price-dialog__header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: .86rem;
}

.dialog-close {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1.4rem;
    cursor: pointer;
}

.dialog-close:hover {
    color: var(--text);
    background: var(--accent-soft);
}

.price-dialog__body {
    overflow-y: auto;
    max-height: min(620px, calc(100vh - 170px));
    padding: 18px 22px 22px;
}

.price-dialog__hint {
    margin: 0 0 13px;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.45;
}

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

.price-option {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    width: 100%;
    padding: 13px 14px;
    color: inherit;
    text-align: left;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 13px;
    cursor: pointer;
}

.price-option:hover {
    border-color: #b9c6bc;
    background: #f7faf7;
}

.price-option--selected {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.price-option__main,
.price-option__right {
    display: block;
}

.price-option__main strong,
.price-option__main small,
.price-option__right strong,
.price-option__right small {
    display: block;
}

.price-option__main strong {
    font-size: .93rem;
}

.price-option__main small {
    margin-top: 3px;
    color: var(--muted);
    font-size: .76rem;
}

.price-option__right {
    flex: 0 0 auto;
    text-align: right;
}

.price-option__right strong {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.price-option__badge {
    margin-bottom: 3px;
    color: var(--accent);
    font-size: .66rem;
    font-weight: 850;
    text-transform: uppercase;
}

@media (max-width: 1040px) {
    .strategy-card {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 520px) {
    .strategy-options {
        grid-template-columns: 1fr;
    }

    .strategy-option > span {
        min-height: auto;
    }

    .price-dialog__header,
    .price-dialog__body {
        padding-right: 16px;
        padding-left: 16px;
    }
}
