:root {
    color-scheme: light;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #dfe3e8;
    --paper: #f4f6f8;
    --surface: #ffffff;
    --mint: #168a54;
    --mint-dark: #0f6b41;
    --sun: #d99a1e;
    --coral: #c2410c;
    --shadow: 0 1px 2px rgba(31, 41, 55, .06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    padding: 12px clamp(18px, 4vw, 40px);
}

.topnav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.topnav form {
    margin: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--mint);
    color: white;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.muted {
    color: var(--muted);
}

.page-shell {
    width: min(1680px, calc(100% - 20px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.page-heading,
.auth-panel {
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--mint-dark);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.1;
}

h2 {
    margin-bottom: 0;
    font-size: 21px;
}

.auth-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 28px;
    align-items: center;
    min-height: 62vh;
}

.form-card,
.panel,
.hero-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.form-card {
    display: grid;
    gap: 16px;
    padding: 22px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: white;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--mint);
    outline: 3px solid rgba(47, 191, 113, .16);
}

textarea {
    min-height: 48px;
    resize: vertical;
}

.primary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 18px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button {
    background: var(--mint);
    color: white;
}

.primary-button:hover {
    background: var(--mint-dark);
}

.ghost-button {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

.danger-button {
    color: #9f2e1d;
}

.danger-button:hover {
    border-color: rgba(255, 119, 92, .45);
    background: rgba(255, 119, 92, .1);
}

.inline-action {
    margin-top: 12px;
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

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

.wide-panel {
    grid-column: 1 / -1;
}

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

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

.metric-card span,
.cart-total span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong {
    font-size: 28px;
    line-height: 1;
}

.panel,
.hero-panel {
    padding: 16px;
}

.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

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

.panel-heading span {
    display: grid;
    min-width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: rgba(248, 193, 74, .24);
    color: #8a5a00;
    font-weight: 900;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.jornada-close-panel {
    margin-bottom: 18px;
}

.compact-form {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) minmax(180px, 1.4fr) auto;
    gap: 12px;
    align-items: end;
}

.close-summary {
    display: grid;
    gap: 8px;
    align-items: end;
}

.close-summary small {
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    border-top: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.data-table td small {
    display: block;
    color: var(--muted);
}

.data-table tr.is-low td {
    background: rgba(255, 119, 92, .06);
}

.data-table tr.preview-error td {
    background: rgba(255, 119, 92, .04);
}

.data-table td.preview-missing {
    border: 1px solid rgba(255, 119, 92, .7);
    background: rgba(255, 119, 92, .1);
    color: #9f2e1d;
    font-weight: 800;
}

.table-input {
    min-height: 32px;
    min-width: 120px;
    padding: 6px 8px;
    font-size: 14px;
}

.compact-input {
    min-width: 72px;
    max-width: 92px;
}

.price-input {
    min-width: 88px;
    max-width: 110px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--mint);
    color: white;
    cursor: pointer;
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
}

.icon-button:hover {
    background: var(--mint-dark);
}

.mini-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(47, 191, 113, .35);
    border-radius: 8px;
    background: white;
    color: var(--mint-dark);
    cursor: pointer;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
}

.mini-icon-button:hover {
    background: rgba(47, 191, 113, .1);
}

.mini-danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 119, 92, .45);
    border-radius: 8px;
    background: white;
    color: #9f2e1d;
    cursor: pointer;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
}

.mini-danger-button:hover {
    background: rgba(255, 119, 92, .1);
}

.mini-note-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 30px;
    border: 1px solid rgba(248, 193, 74, .55);
    border-radius: 8px;
    background: white;
    color: #8a5a00;
    cursor: pointer;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.mini-note-button:hover {
    background: rgba(248, 193, 74, .18);
}

.mini-ok-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.mini-ok-button:hover,
.mini-ok-button.is-done {
    border-color: rgba(47, 191, 113, .35);
    background: rgba(47, 191, 113, .1);
    color: var(--mint-dark);
}

.mini-edit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--muted);
    cursor: pointer;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
}

.mini-edit-button:hover {
    background: #f8fafc;
    color: var(--ink);
}

.editable-cell {
    display: grid;
    gap: 6px;
}

.edit-panel {
    display: none;
    gap: 6px;
}

.editable-cell.is-editing .edit-panel {
    display: grid;
}

.inline-edit-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-ref-form {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.missing-reason {
    display: block;
    max-width: 130px;
    color: #9f2e1d;
    font-size: 11px;
    font-weight: 800;
    white-space: normal;
}

.table-action {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.compact-table .data-table th,
.compact-table .data-table td {
    padding: 9px 8px;
}

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

.list-row {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.sale-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    cursor: pointer;
}

.sale-row.is-in-cart {
    background: rgba(47, 191, 113, .08);
    border-radius: 8px;
    padding: 10px;
}

.list-row strong,
.list-row small,
.sale-row strong,
.sale-row small {
    display: block;
}

.list-row small,
.sale-row small,
.empty,
.form-error {
    color: var(--muted);
}

.pos-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

.inventory-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.reference-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.form-layout {
    width: 100%;
    display: grid;
    gap: 14px;
}

.form-layout .stack-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
}

.form-layout .stack-form p {
    margin: 0;
}

.form-layout .stack-form .errorlist,
.form-layout .form-actions {
    grid-column: 1 / -1;
}

.import-form p:first-of-type {
    grid-column: 1 / -1;
}

.import-form textarea {
    min-height: 320px;
    resize: vertical;
}

.result-panel {
    margin-top: 18px;
}

.bulk-import {
    margin-bottom: 18px;
}

.bulk-import summary {
    cursor: pointer;
    font-weight: 900;
}

.bulk-import form {
    margin-top: 14px;
}

.bulk-import textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.tab {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, .78);
    color: var(--muted);
    font-weight: 800;
}

.tab.active {
    border-color: rgba(47, 191, 113, .45);
    background: rgba(47, 191, 113, .12);
    color: var(--mint-dark);
}

.search-form,
.inventory-row {
    display: grid;
    gap: 10px;
}

.search-form {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 14px;
}

.product-filter {
    grid-template-columns: minmax(190px, 1.5fr) repeat(4, minmax(120px, 1fr)) auto auto;
    align-items: end;
    gap: 8px;
}

.product-filter input,
.product-filter select {
    min-height: 34px;
    padding: 7px 9px;
    border-radius: 7px;
    font-size: 13px;
}

.product-filter .ghost-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.stock-filter {
    grid-template-columns: minmax(150px, 220px) minmax(180px, 1fr) minmax(140px, 180px) auto auto;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
}

.pagination span {
    color: var(--muted);
    font-weight: 800;
}

.bulk-stock-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.bulk-stock-actions select {
    max-width: 180px;
    min-height: 34px;
    padding: 7px 9px;
}

.bulk-stock-actions .ghost-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.suggested-price-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(47, 191, 113, .28);
    border-radius: 8px;
    background: rgba(47, 191, 113, .08);
    color: var(--mint-dark);
    font-size: 14px;
    font-weight: 900;
}

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

.side-stack {
    display: grid;
    gap: 18px;
}

.stock-heading {
    margin-top: 24px;
}

.product-admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.product-admin-row strong,
.product-admin-row small {
    display: block;
}

.product-admin-row small {
    color: var(--muted);
}

.inventory-row {
    grid-template-columns: minmax(160px, 1fr) repeat(3, minmax(80px, 100px)) minmax(70px, auto) auto auto;
    align-items: end;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.stock-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(260px, auto) auto;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.stock-row.is-low {
    border-top-color: rgba(255, 119, 92, .45);
}

.stock-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(72px, 1fr));
    gap: 8px;
}

.stock-metrics span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.stock-metrics strong,
.stock-metrics small {
    display: block;
    text-transform: none;
}

.stock-metrics strong {
    color: var(--ink);
    font-size: 17px;
}

.stock-metrics small {
    color: var(--muted);
    font-size: 12px;
}

.checkbox-label {
    align-items: center;
    grid-template-columns: auto 1fr;
}

.checkbox-label input {
    width: auto;
}

.compact-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
}

.full-button {
    width: 100%;
    margin-top: 10px;
}

.inventory-name strong,
.inventory-name small {
    display: block;
}

.inventory-name small {
    color: var(--muted);
}

.reference-row,
.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reference-row {
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.reference-row strong,
.reference-row small {
    display: block;
}

.reference-row small {
    color: var(--muted);
}

.row-actions form {
    margin: 0;
}

.muted-row {
    color: var(--muted);
    background: #f8fafc;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 8px;
    background: rgba(194, 65, 12, .1);
    color: var(--coral);
    padding: 0 8px;
    font-weight: 900;
}

.inline-cancel-form {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.inline-cancel-form input {
    min-height: 34px;
    padding: 7px 9px;
}

.stack-form p {
    margin: 0 0 12px;
}

.stack-form ul {
    margin: 6px 0 0;
    padding-left: 18px;
    color: var(--coral);
    font-weight: 700;
}

.pos-main {
    min-width: 0;
}

.cart-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
}

.pos-search {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

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

.compact-add-button {
    width: 40px;
    min-width: 40px;
    padding: 0;
    font-size: 21px;
    line-height: 1;
}

.cart-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.quantity-badge {
    display: inline-grid;
    min-width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 8px;
    background: var(--mint);
    color: white;
    font-size: 13px;
    font-weight: 900;
}

.cart-items,
.quantity-controls {
    display: grid;
    gap: 8px;
}

.cart-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.cart-row strong,
.cart-row small {
    display: block;
}

.cart-row small {
    color: var(--muted);
}

.quantity-controls {
    grid-template-columns: 34px 58px 34px 34px;
    align-items: center;
}

.quantity-controls button,
.quantity-controls input {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    text-align: center;
}

.quantity-controls button {
    cursor: pointer;
    font-weight: 900;
}

.quantity-controls input {
    width: 58px;
    padding: 4px;
}

.cart-panel {
    position: sticky;
    top: 16px;
}

.cart-total {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin: 18px 0;
    padding: 16px 0;
}

.cart-total strong {
    font-size: 34px;
    line-height: 1;
}

.cart-change {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(47, 191, 113, .28);
    border-radius: 8px;
    background: rgba(47, 191, 113, .08);
    color: var(--mint-dark);
    padding: 10px 12px;
    margin-bottom: 14px;
    font-weight: 900;
}

.quick-cash-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 14px;
}

.quick-cash-actions .ghost-button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 13px;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.form-error {
    color: var(--coral);
    font-weight: 800;
}

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.message {
    margin: 0;
    border: 1px solid rgba(255, 119, 92, .35);
    border-radius: 8px;
    padding: 12px 14px;
    background: rgba(255, 119, 92, .1);
    color: #9f2e1d;
    font-weight: 700;
}

.message.success {
    border-color: rgba(47, 191, 113, .35);
    background: rgba(47, 191, 113, .1);
    color: var(--mint-dark);
}

@media (max-width: 840px) {
    .auth-panel,
    .control-grid,
    .metric-grid,
    .inventory-shell,
    .reference-shell,
    .pos-shell {
        grid-template-columns: 1fr;
    }

    .inventory-row,
    .stock-row,
    .search-form,
    .product-filter,
    .stock-filter,
    .compact-form {
        grid-template-columns: 1fr;
    }

    .stock-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .form-layout .stack-form {
        grid-template-columns: 1fr;
    }

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

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        border-top: 1px solid var(--line);
        padding: 10px 0;
    }

    .data-table td {
        display: grid;
        grid-template-columns: 110px minmax(0, 1fr);
        gap: 10px;
        border-top: 0;
        padding: 5px 0;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 900;
        text-transform: uppercase;
    }

    .data-table td.empty,
    .data-table td.table-action {
        display: block;
    }

    .data-table td.empty::before,
    .data-table td.table-action::before {
        content: "";
        display: none;
    }

    .table-action .ghost-button,
    .table-action .row-actions {
        width: 100%;
    }

    .pos-shell {
        padding-bottom: 390px;
    }

    .cart-panel {
        position: fixed;
        right: 10px;
        bottom: 0;
        left: 10px;
        z-index: 20;
        max-height: 46vh;
        overflow-y: auto;
        border-radius: 8px 8px 0 0;
        padding: 14px;
    }

    .cart-total {
        margin: 12px 0;
        padding: 12px 0;
    }

    .cart-total strong {
        font-size: 28px;
    }

    .sale-row {
        align-items: stretch;
        padding: 10px 0;
    }

    .product-actions {
        justify-content: flex-end;
        min-width: 96px;
    }

    .compact-add-button {
        width: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .quantity-controls {
        grid-template-columns: 40px 62px 40px 40px;
    }

    .quantity-controls button,
    .quantity-controls input {
        width: 40px;
        height: 40px;
    }

    .quantity-controls input {
        width: 62px;
    }
}
