:root {
    color-scheme: light;
    --bg: #f4f7f8;
    --panel: #ffffff;
    --panel-soft: #eef6f5;
    --input-bg: #ffffff;
    --ink: #102027;
    --muted: #667780;
    --line: #d9e2e5;
    --teal: #00b7a8;
    --teal-dark: #008f84;
    --blue: #2878ff;
    --amber: #f2c94c;
    --coral: #ff7a59;
    --danger: #bd2b2b;
    --success: #087f5b;
    --on-accent: #ffffff;
    --primary-bg: #102027;
    --primary-ink: #ffffff;
    --success-bg: #ecf9f4;
    --error-bg: #fff2f0;
    --login-glow-a: rgba(0, 183, 168, 0.13);
    --login-glow-b: rgba(255, 122, 89, 0.13);
    --shadow: 0 18px 55px rgba(16, 32, 39, 0.12);
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1518;
    --panel: #172126;
    --panel-soft: #20333a;
    --input-bg: #101a1f;
    --ink: #eef7f7;
    --muted: #9aadb4;
    --line: #31444c;
    --teal: #24d4c5;
    --teal-dark: #62e3d8;
    --blue: #70a2ff;
    --amber: #f4d26a;
    --coral: #ff9276;
    --danger: #ff7d72;
    --success: #5bd4a4;
    --on-accent: #061817;
    --primary-bg: #24d4c5;
    --primary-ink: #061817;
    --success-bg: rgba(91, 212, 164, 0.12);
    --error-bg: rgba(255, 125, 114, 0.12);
    --login-glow-a: rgba(36, 212, 197, 0.16);
    --login-glow-b: rgba(255, 146, 118, 0.13);
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
}

button,
input,
select {
    font: inherit;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 750;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button.primary {
    color: var(--primary-ink);
    background: var(--primary-bg);
}

.button.secondary {
    color: var(--on-accent);
    background: var(--teal-dark);
}

.button.danger {
    color: var(--on-accent);
    background: var(--danger);
}

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

.button.small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.86rem;
}

.button.full {
    width: 100%;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--ink);
    font-weight: 650;
}

.flash-success {
    border-color: rgba(8, 127, 91, 0.25);
    color: var(--success);
    background: var(--success-bg);
}

.flash-error {
    border-color: rgba(189, 43, 43, 0.25);
    color: var(--danger);
    background: var(--error-bg);
}

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

.brand strong {
    display: block;
    line-height: 1.05;
}

.brand small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.76rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    color: var(--primary-ink);
    background: var(--primary-bg);
    font-weight: 900;
}

.login-page,
.setup-page {
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        linear-gradient(130deg, var(--login-glow-a), transparent 38%),
        linear-gradient(310deg, var(--login-glow-b), transparent 36%),
        var(--bg);
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(340px, 620px);
    width: min(1080px, 100%);
    min-height: 660px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(28px, 5vw, 56px);
}

.login-brand {
    margin-bottom: 34px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 14px;
}

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

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--input-bg);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(0, 183, 168, 0.13);
}

.hint {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.login-art {
    display: grid;
    place-items: center;
    padding: 48px;
    background:
        linear-gradient(150deg, #102027 0%, #16323d 58%, #23505a 100%);
}

.terminal-preview {
    display: grid;
    gap: 22px;
    width: min(430px, 100%);
    padding: 24px;
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 20px 65px rgba(0, 0, 0, 0.28);
}

.preview-header,
.preview-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-header span,
.preview-total span {
    color: var(--muted);
    font-weight: 700;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.preview-grid span {
    aspect-ratio: 1;
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.preview-grid span:nth-child(2n) {
    background: rgba(40, 120, 255, 0.13);
}

.preview-grid span:nth-child(3n) {
    background: rgba(242, 201, 76, 0.2);
}

.app-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 22px;
    border-right: 1px solid var(--line);
    background: var(--panel);
}

.sidebar nav {
    display: grid;
    gap: 7px;
    margin-top: 34px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 750;
}

.nav-item.is-active,
.nav-item:hover {
    color: var(--ink);
    background: var(--panel-soft);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: var(--on-accent);
    background: var(--teal-dark);
    font-size: 0.74rem;
}

.sidebar-footer {
    display: grid;
    gap: 8px;
    margin-top: auto;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.sidebar-footer span {
    font-weight: 800;
}

.sidebar-footer small {
    color: var(--muted);
}

.workspace {
    min-width: 0;
    padding: 26px;
}

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

.topbar h1,
.cart-head h2,
.panel h2,
.setup-card h1 {
    margin: 0;
    letter-spacing: 0;
}

.eyebrow,
.section-label {
    margin: 0 0 6px;
    color: var(--teal-dark);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar-meta {
    color: var(--muted);
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--panel);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.theme-switch input {
    position: relative;
    width: 36px;
    min-height: 20px;
    height: 20px;
    padding: 0;
    border-radius: 999px;
    background: var(--panel-soft);
    appearance: none;
    cursor: pointer;
}

.theme-switch input::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--muted);
    content: "";
    transition: transform 140ms ease, background 140ms ease;
}

.theme-switch input:checked {
    border-color: var(--teal);
    background: var(--teal);
}

.theme-switch input:checked::after {
    transform: translateX(16px);
    background: var(--on-accent);
}

.pos-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
    gap: 20px;
    align-items: start;
}

.catalog-panel,
.cart-panel,
.panel,
.table-wrap,
.empty-card,
.setup-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.catalog-panel {
    padding: 18px;
}

.tool-row {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: end;
}

.tab {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--panel);
    font-weight: 800;
    cursor: pointer;
}

.tab.is-active {
    color: var(--primary-ink);
    border-color: var(--primary-bg);
    background: var(--primary-bg);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

.product-tile {
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    gap: 8px;
    min-height: 166px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-align: left;
    color: var(--ink);
    background: var(--panel);
    cursor: pointer;
}

.product-tile:hover {
    border-color: var(--teal);
    box-shadow: 0 10px 28px rgba(16, 32, 39, 0.08);
}

.product-tile.is-disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.product-color {
    width: 34px;
    height: 8px;
    border-radius: 99px;
}

.product-name {
    min-height: 42px;
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.25;
}

.product-meta,
.product-bottom small,
table small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
}

.product-bottom {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

.cart-panel {
    position: sticky;
    top: 20px;
    overflow: hidden;
}

.checkout-form {
    display: grid;
}

.cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.cart-items {
    display: grid;
    gap: 10px;
    min-height: 150px;
    max-height: 320px;
    overflow: auto;
    padding: 14px 18px;
}

.empty-state,
.empty-table {
    color: var(--muted);
    text-align: center;
}

.cart-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.cart-line strong {
    display: block;
}

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

.quantity-control {
    display: grid;
    grid-template-columns: 30px 34px 30px;
    gap: 4px;
    align-items: center;
}

.quantity-control button {
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: var(--input-bg);
    cursor: pointer;
}

.quantity-control span {
    text-align: center;
    font-weight: 850;
}

.summary-box,
.payment-box,
.customer-box {
    display: grid;
    gap: 12px;
    padding: 16px 18px;
    border-top: 1px solid var(--line);
}

.summary-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
}

.summary-line strong {
    color: var(--ink);
}

.summary-line.total {
    padding-top: 10px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-size: 1.1rem;
}

.payment-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.payment-options label,
.check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--panel);
}

.payment-options input,
.check input {
    width: auto;
    min-height: auto;
}

.checkout-button {
    min-height: 58px;
    border-radius: 0;
    font-size: 1.03rem;
}

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

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

.metric {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.metric span {
    display: block;
    color: var(--muted);
    font-weight: 750;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.toolbar label {
    width: 220px;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    color: var(--ink);
    background: var(--panel-soft);
    font-weight: 800;
    font-size: 0.8rem;
}

.receipt-layout {
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(220px, 280px);
    gap: 18px;
    align-items: start;
}

.receipt,
.receipt-actions {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.receipt {
    padding: 24px;
}

.receipt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--ink);
}

.receipt-meta {
    display: grid;
    gap: 8px;
    margin: 16px 0;
}

.receipt-meta div,
.receipt-totals div,
.setup-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

dt {
    color: var(--muted);
    font-weight: 750;
}

dd {
    margin: 0;
    font-weight: 800;
}

.receipt-table th,
.receipt-table td {
    padding-left: 0;
    padding-right: 0;
}

.receipt-totals {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.receipt-totals .grand {
    padding-top: 10px;
    border-top: 2px solid var(--ink);
    font-size: 1.12rem;
}

.receipt-footer {
    margin: 22px 0 0;
    color: var(--muted);
    text-align: center;
}

.receipt-actions {
    display: grid;
    gap: 12px;
    padding: 16px;
}

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

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

.row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.inline-form {
    margin: 0;
}

.panel {
    padding: 18px;
}

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

.form-grid h2,
.form-grid .button,
.form-grid .check {
    grid-column: 1 / -1;
}

.empty-card {
    padding: 22px;
}

.setup-shell {
    width: min(760px, 100%);
}

.setup-card {
    padding: clamp(24px, 5vw, 42px);
    box-shadow: var(--shadow);
}

.setup-card h1 {
    margin-top: 24px;
}

pre {
    overflow: auto;
    padding: 16px;
    border-radius: var(--radius);
    background: #102027;
    color: #ffffff;
}

.setup-list {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1120px) {
    .pos-grid,
    .manage-grid,
    .receipt-layout {
        grid-template-columns: 1fr;
    }

    .cart-panel {
        position: static;
    }
}

@media (max-width: 860px) {
    .login-shell,
    .app-layout {
        grid-template-columns: 1fr;
    }

    .login-art {
        display: none;
    }

    .sidebar {
        position: static;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 20px;
    }

    .sidebar-footer {
        margin-top: 20px;
    }

    .workspace {
        padding: 18px;
    }

    .tool-row,
    .metrics,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .cart-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        align-items: flex-start;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 560px) {
    .login-page,
    .setup-page {
        padding: 12px;
    }

    .login-shell {
        min-height: auto;
    }

    .product-grid,
    .payment-options {
        grid-template-columns: 1fr;
    }

    .toolbar label {
        width: 100%;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .sidebar,
    .topbar,
    .flash,
    .no-print,
    .receipt-actions {
        display: none !important;
    }

    .app-layout {
        display: block;
    }

    .workspace {
        padding: 0;
    }

    .receipt-layout {
        display: block;
    }

    .receipt {
        width: 76mm;
        margin: 0 auto;
        border: 0;
        border-radius: 0;
        padding: 0;
    }
}
