:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #dde5f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --soft-blue: #e8f0ff;
    --success: #12805c;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(39, 52, 88, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
}

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

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background:
        linear-gradient(rgba(14, 26, 50, 0.72), rgba(14, 26, 50, 0.52)),
        url("https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 16px;
    padding: 34px;
    box-shadow: 0 24px 65px rgba(15, 23, 42, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h1 {
    margin: 0;
    font-size: 32px;
    color: #0f172a;
}

.login-header p {
    margin: 8px 0 0;
    color: #64748b;
}

.login-form label,
.stack-form label,
.order-ticket label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.login-form input[type="text"],
.login-form input[type="password"] {
    margin-bottom: 16px;
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 82px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 7px;
    width: auto;
    border: none;
    background: var(--soft-blue);
    color: var(--primary-dark);
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    font-size: 14px;
}

.remember-option {
    display: flex !important;
    align-items: center;
    gap: 7px;
    margin: 0 !important;
    font-weight: 400 !important;
    color: #475569;
}

.remember-option input {
    width: auto;
    margin: 0;
}

.forgot-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.btn-login,
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.btn-login,
.btn-primary {
    width: 100%;
    background: var(--primary);
    color: white;
}

.btn-login:hover,
.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    width: auto;
    border: 1px solid var(--line);
    background: white;
    color: var(--primary-dark);
}

.btn-danger {
    width: 100%;
    background: #fee4e2;
    color: var(--danger);
}

.btn-danger:hover {
    background: #fecdca;
}

.alert {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

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

.alert-success {
    background: #dcfae6;
    color: var(--success);
}

.alert-warning {
    background: #fef0c7;
    color: var(--warning);
}

.app-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #0f172a;
    color: white;
    padding: 22px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 10px;
    background: var(--primary);
    font-weight: 800;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: #cbd5e1;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    padding: 12px 14px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.main {
    min-width: 0;
    padding: 28px;
}

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

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
}

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

.user-pill small {
    color: var(--muted);
}

.user-pill a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.refresh-pill {
    width: auto;
    min-height: 32px;
    border: 1px solid rgba(31, 94, 255, 0.22);
    border-radius: var(--radius);
    background: var(--soft-blue);
    color: var(--primary-dark);
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.refresh-pill.is-paused {
    border-color: #fef0c7;
    background: #fffbeb;
    color: var(--warning);
}

.messages {
    margin-bottom: 18px;
}

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

.stat-card,
.panel,
.product-card,
.kitchen-card,
.billing-card,
.order-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 18px;
}

.stat-card span,
.product-card span,
.product-picker span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin: 8px 0;
    font-size: 30px;
}

.stat-card small {
    color: var(--muted);
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

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

.panel-header h2 {
    margin: 0;
    font-size: 20px;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

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

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

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 13px;
}

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

.status {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2f7;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
    text-transform: capitalize;
}

.status-en_cocina {
    background: #e8f0ff;
    color: var(--primary-dark);
}

.status-preparando {
    background: #fef0c7;
    color: var(--warning);
}

.status-listo {
    background: #dcfae6;
    color: var(--success);
}

.status-entregado {
    background: #f4ebff;
    color: #6941c6;
}

.status-anulado {
    background: #fee4e2;
    color: var(--danger);
}

.status-facturado {
    background: #e0f2fe;
    color: #075985;
}

.status-entrada {
    background: #dcfae6;
    color: var(--success);
}

.status-salida {
    background: #fee4e2;
    color: var(--danger);
}

.status-ingreso {
    background: #dcfae6;
    color: var(--success);
}

.status-egreso {
    background: #fee4e2;
    color: var(--danger);
}

.status-ajuste {
    background: #fef0c7;
    color: var(--warning);
}

.status-warning {
    background: #fef0c7;
    color: var(--warning);
}

.two-column,
.order-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 18px;
    align-items: start;
}

.two-column.wide-left {
    grid-template-columns: minmax(0, 1fr) 340px;
}

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

.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
}

.category-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.category-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.category-list small {
    color: var(--muted);
}

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

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

.product-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    box-shadow: none;
}

.product-card h3 {
    margin: 6px 0;
    font-size: 17px;
}

.product-card p {
    min-height: 38px;
    margin: 0;
    color: var(--muted);
}

.product-card footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.product-card.muted {
    opacity: 0.55;
}

.link-button {
    width: auto;
    border: none;
    background: transparent;
    color: var(--primary);
    font-weight: 800;
    cursor: pointer;
}

.table-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

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

.order-menu-tools {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.order-menu-tools input[type="search"] {
    min-width: 0;
}

.menu-result-count {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.product-empty-state {
    margin: 16px 0 0;
}

.tab-button {
    width: auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: var(--muted);
    padding: 9px 12px;
    cursor: pointer;
}

.tab-button.active {
    border-color: var(--primary);
    background: var(--soft-blue);
    color: var(--primary-dark);
    font-weight: 800;
}

.product-picker {
    min-height: 118px;
    width: 100%;
    display: grid;
    gap: 7px;
    align-content: start;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 14px;
    cursor: pointer;
}

.product-picker:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 25px rgba(37, 99, 235, 0.13);
}

.product-picker.is-disabled,
.product-picker:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    transform: none;
}

.stock-chip {
    display: inline-flex;
    width: fit-content;
    margin-top: 10px;
    padding: 5px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #344054;
    font-weight: 800;
}

.stock-chip-alert {
    background: #fee4e2;
    color: var(--danger);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.fiscal-box {
    display: grid;
    gap: 10px;
    margin: 14px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.fiscal-box h3 {
    margin: 0;
    font-size: 15px;
}

.billing-fiscal {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.billing-fiscal label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.billing-fiscal .span-2 {
    grid-column: span 2;
}

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

.check-item {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f8fafc;
}

.check-item strong {
    font-size: 12px;
    text-transform: uppercase;
}

.check-item.is-blocking {
    border-color: #fecdca;
    background: #fff5f5;
}

.check-item.is-blocking strong {
    color: var(--danger);
}

.check-item.is-info {
    border-color: #fedf89;
    background: #fffbeb;
}

.check-item.is-info strong {
    color: var(--warning);
}

button:disabled,
input[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.cart-items {
    display: grid;
    gap: 10px;
    min-height: 86px;
    margin: 14px 0;
}

.cart-items.empty {
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
}

.cart-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.cart-line-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.ticket-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.ticket-total strong {
    font-size: 24px;
}

.order-list,
.kitchen-board {
    display: grid;
    gap: 14px;
}

.order-row,
.billing-card {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    box-shadow: none;
}

.order-row div,
.billing-card div {
    display: grid;
    gap: 6px;
}

.billing-card {
    grid-template-columns: 1fr auto;
}

.billing-form {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
}

.billing-form .billing-fiscal {
    grid-column: 1 / -1;
}

.cash-open-panel {
    border-color: rgba(247, 144, 9, 0.24);
    background: #fffcf5;
}

.cash-open-form {
    grid-template-columns: minmax(160px, 220px) 1fr auto;
}

.cash-method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.cash-method-grid div {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.cash-method-grid span,
.cash-history small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.cash-method-grid strong {
    font-size: 18px;
}

.cash-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.cash-form h3 {
    margin: 0;
    font-size: 16px;
}

.cash-close-form {
    border-top-style: dashed;
}

.cash-history {
    display: grid;
    gap: 10px;
}

.cash-history article {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.cash-history article > small {
    grid-column: 1 / -1;
}

.kitchen-board {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.kitchen-card {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.kitchen-card header,
.kitchen-card footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.kitchen-card small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.kitchen-items {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.kitchen-items li {
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.note {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
}

.empty-panel {
    grid-column: 1 / -1;
    text-align: center;
}

.user-list,
.table-card-grid,
.permission-grid {
    display: grid;
    gap: 12px;
}

.editable-row {
    display: grid;
    grid-template-columns: 1.1fr 140px 1fr auto auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.editable-row label,
.table-card label {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.switch-line {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    color: var(--text) !important;
    font-size: 14px !important;
}

.switch-line input {
    width: auto;
}

.permission-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.permission-grid article {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.permission-grid span,
.table-meta {
    color: var(--muted);
}

.table-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.table-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.table-card header,
.table-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.table-card.muted {
    opacity: 0.55;
}

.receipt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 16px;
}

.receipt-actions form {
    margin: 0;
}

.print-button {
    width: auto;
}

.receipt {
    max-width: 820px;
    margin: 0 auto 24px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow);
}

.receipt-header,
.receipt-meta,
.receipt-totals {
    display: grid;
    gap: 14px;
}

.receipt-header {
    grid-template-columns: 1fr auto;
    align-items: start;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.receipt-header h2 {
    margin: 12px 0 4px;
}

.receipt-header p,
.receipt-header span,
.receipt-meta span,
.receipt-footer {
    color: var(--muted);
}

.receipt-header > div:last-child {
    text-align: right;
}

.receipt-header > div:last-child strong {
    display: block;
    font-size: 22px;
}

.receipt-meta {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin: 18px 0;
}

.receipt-meta div,
.receipt-totals div {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.receipt-totals {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}

.receipt-totals strong {
    font-size: 20px;
}

.receipt-footer {
    margin-top: 24px;
    text-align: center;
}

.filter-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

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

.rank-list article {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.rank-list div {
    display: grid;
    gap: 5px;
}

.rank-list small {
    color: var(--muted);
}

.detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 16px;
}

.detail-actions form {
    margin: 0;
}

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

.summary-list div {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.summary-list span,
.table-note {
    color: var(--muted);
}

.table-note {
    display: block;
    margin-top: 5px;
}

.detail-note {
    margin: 14px 0 0;
    white-space: pre-line;
}

.danger-zone {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

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

.inventory-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) 150px auto 120px 110px auto;
    gap: 10px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: white;
    box-shadow: var(--shadow-soft);
}

.inventory-row.stock-alert {
    border-color: #fecdca;
    background: #fffafa;
}

.inventory-product {
    display: grid;
    gap: 4px;
}

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

.inventory-stock {
    display: block;
    font-weight: 900;
}

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

.settings-layout > .panel:nth-child(2) {
    grid-column: 1;
}

.settings-layout > .panel:not(.settings-preview) {
    grid-column: 1;
}

.settings-preview {
    grid-column: 2;
    grid-row: 1 / span 3;
    position: sticky;
    top: 24px;
}

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

.settings-grid label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.settings-grid .span-2 {
    grid-column: 1 / -1;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.receipt-mini {
    display: grid;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fafc;
}

.receipt-mini .brand-mark {
    margin-bottom: 6px;
}

.receipt-mini strong {
    font-size: 22px;
}

.receipt-mini small,
.receipt-business {
    color: var(--muted);
}

.receipt-business {
    display: grid;
    gap: 3px;
    margin-top: 8px;
}

.receipt-header small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

@media (max-width: 980px) {
    .app-body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .nav {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .nav a {
        text-align: center;
    }

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

    .two-column,
    .two-column.wide-left,
    .order-layout {
        grid-template-columns: 1fr;
    }

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

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

@media (max-width: 640px) {
    .main,
    .sidebar {
        padding: 18px;
    }

    .topbar,
    .panel-header,
    .login-options {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-pill,
    .inline-form,
    .form-grid,
    .billing-form,
    .order-row,
    .billing-card,
    .editable-row,
    .permission-grid,
    .filter-form,
    .receipt-header,
    .receipt-meta,
    .receipt-totals,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .receipt-header > div:last-child {
        text-align: left;
    }

    .receipt-actions {
        flex-direction: column;
    }

    .detail-actions {
        flex-direction: column;
    }

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

    .login-card {
        padding: 26px 22px;
    }
}

@media print {
    body {
        background: white;
    }

    .sidebar,
    .topbar,
    .messages,
    .no-print {
        display: none !important;
    }

    .app-body,
    .main {
        display: block;
        padding: 0;
    }

    .receipt {
        max-width: none;
        margin: 0;
        border: none;
        box-shadow: none;
        padding: 0;
    }

    th,
    td {
        white-space: normal;
    }
}

/* Presentation overhaul */
:root {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --text: #111827;
    --muted: #667085;
    --line: #d9e2ef;
    --primary: #1f5eff;
    --primary-dark: #1746c8;
    --soft-blue: #edf4ff;
    --success: #087443;
    --warning: #a15c07;
    --danger: #b42318;
    --sidebar: #101828;
    --sidebar-soft: #182230;
    --radius: 8px;
    --shadow: 0 14px 38px rgba(16, 24, 40, 0.08);
    --shadow-soft: 0 8px 20px rgba(16, 24, 40, 0.06);
}

html {
    min-width: 320px;
    text-size-adjust: 100%;
}

body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    line-height: 1.45;
    background:
        linear-gradient(180deg, rgba(237, 244, 255, 0.8), rgba(246, 248, 251, 0) 280px),
        var(--bg);
}

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

button,
a,
input,
select,
textarea {
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(31, 94, 255, 0.22);
    outline-offset: 2px;
}

input,
select,
textarea {
    min-height: 44px;
    border-color: #d0d7e2;
    border-radius: var(--radius);
}

textarea {
    resize: vertical;
}

form[data-submitting="true"] button[type="submit"],
form[data-submitting="true"] input[type="submit"],
button.is-loading {
    cursor: wait;
    opacity: 0.72;
}

.app-body {
    grid-template-columns: 280px minmax(0, 1fr);
}

.mobile-topbar,
.sidebar-backdrop,
.sidebar-close {
    display: none;
}

.sidebar {
    background:
        linear-gradient(180deg, rgba(31, 94, 255, 0.12), rgba(16, 24, 40, 0) 180px),
        var(--sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 24px 18px;
    transition: transform 0.22s ease;
}

.brand {
    min-height: 52px;
    margin-bottom: 30px;
}

.brand-mark {
    flex: 0 0 auto;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.nav {
    gap: 6px;
}

.nav a {
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    color: #d6dce8;
    font-weight: 700;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav a.active {
    background: #ffffff;
    color: var(--sidebar);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.main {
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: clamp(18px, 2.5vw, 34px);
}

.topbar {
    min-height: 72px;
    padding: 18px;
    border: 1px solid rgba(217, 226, 239, 0.82);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

.topbar h1 {
    max-width: 100%;
    font-size: clamp(24px, 2vw, 34px);
    line-height: 1.15;
}

.eyebrow {
    letter-spacing: 0;
}

.user-pill {
    flex-wrap: wrap;
    justify-content: flex-end;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.panel,
.stat-card,
.product-card,
.kitchen-card,
.billing-card,
.order-row,
.editable-row,
.table-card,
.permission-grid article,
.summary-list div,
.receipt,
.rank-list article {
    border-color: rgba(217, 226, 239, 0.95);
    border-radius: var(--radius);
}

.panel,
.stat-card {
    box-shadow: var(--shadow);
}

.panel {
    padding: clamp(16px, 1.7vw, 24px);
}

.panel-header {
    align-items: flex-start;
}

.panel-header h2 {
    font-size: clamp(18px, 1.4vw, 22px);
}

.panel-header p {
    max-width: 720px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stat-card {
    min-height: 132px;
    display: grid;
    align-content: space-between;
}

.stat-card strong {
    font-size: clamp(26px, 2.4vw, 36px);
}

.btn-login,
.btn-primary,
.btn-secondary,
.btn-danger,
.tab-button,
.qty-button,
.link-button {
    border-radius: var(--radius);
}

.btn-primary:hover,
.btn-login:hover,
.btn-secondary:hover,
.product-picker:hover,
.tab-button:hover {
    transform: translateY(-1px);
}

.btn-secondary:hover {
    border-color: rgba(31, 94, 255, 0.35);
    background: var(--soft-blue);
}

.btn-primary,
.btn-login {
    box-shadow: 0 9px 18px rgba(31, 94, 255, 0.2);
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: white;
}

.table-wrap table {
    min-width: 680px;
}

th {
    background: #f8fafc;
    font-weight: 800;
}

td {
    vertical-align: middle;
}

tbody tr:hover {
    background: #fbfdff;
}

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

.product-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
}

.product-picker,
.product-card,
.cart-line,
.kitchen-items li,
.category-list div,
.table-card,
.editable-row,
.billing-card,
.order-row {
    box-shadow: var(--shadow-soft);
}

.product-picker {
    min-height: 126px;
}

.order-layout {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
}

.order-ticket {
    position: sticky;
    top: 24px;
}

.kitchen-board {
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

.status {
    min-height: 26px;
    align-items: center;
}

.login-card {
    border-radius: var(--radius);
}

.login-body {
    padding: clamp(18px, 4vw, 36px);
}

.login-header h1 {
    font-size: clamp(28px, 8vw, 34px);
}

.receipt {
    width: min(100%, 880px);
}

@media (max-width: 1180px) {
    .two-column,
    .two-column.wide-left {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

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

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

@media (max-width: 900px) {
    .app-body {
        display: block;
        padding-top: 68px;
    }

    .mobile-topbar {
        position: fixed;
        z-index: 60;
        top: 0;
        left: 0;
        right: 0;
        min-height: 68px;
        display: grid;
        grid-template-columns: 44px 1fr auto;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        border-bottom: 1px solid rgba(217, 226, 239, 0.9);
        background: rgba(255, 255, 255, 0.94);
        box-shadow: var(--shadow-soft);
        backdrop-filter: blur(14px);
    }

    .mobile-menu-button {
        width: 44px;
        height: 44px;
        display: grid;
        place-items: center;
        gap: 4px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: white;
        cursor: pointer;
    }

    .mobile-menu-button span {
        width: 18px;
        height: 2px;
        display: block;
        border-radius: 2px;
        background: var(--text);
    }

    .mobile-brand {
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 10px;
        font-weight: 800;
    }

    .mobile-brand .brand-mark {
        width: 36px;
        height: 36px;
    }

    .mobile-logout {
        color: var(--primary);
        font-weight: 800;
        text-decoration: none;
    }

    .sidebar {
        position: fixed;
        z-index: 80;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(86vw, 320px);
        height: auto;
        overflow-y: auto;
        transform: translateX(-104%);
        box-shadow: 24px 0 48px rgba(16, 24, 40, 0.24);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 70;
        inset: 0;
        display: block;
        pointer-events: none;
        background: rgba(16, 24, 40, 0);
        transition: background-color 0.22s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        pointer-events: auto;
        background: rgba(16, 24, 40, 0.46);
    }

    .sidebar-close {
        width: 36px;
        height: 36px;
        display: grid;
        place-items: center;
        margin-left: auto;
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: var(--radius);
        background: rgba(255, 255, 255, 0.08);
        color: white;
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
    }

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

    .nav a {
        text-align: left;
    }

    .main {
        padding: 16px;
    }

    .topbar {
        margin-bottom: 16px;
    }

    .two-column,
    .two-column.wide-left,
    .order-layout,
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .order-ticket {
        position: static;
    }

    .settings-layout > .panel:nth-child(2),
    .settings-preview {
        grid-column: auto;
        grid-row: auto;
    }

    .settings-preview {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar {
        display: grid;
        gap: 14px;
    }

    .user-pill {
        width: 100%;
        justify-content: space-between;
    }

    .panel,
    .stat-card {
        padding: 15px;
    }

    .panel-header {
        display: grid;
        gap: 12px;
    }

    .table-wrap {
        border: none;
        background: transparent;
        overflow: visible;
    }

    .table-wrap table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .table-wrap thead {
        display: none;
    }

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

    .table-wrap tr {
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: white;
        box-shadow: var(--shadow-soft);
    }

    .table-wrap td {
        min-height: 36px;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 8px 0;
        border-bottom: 1px solid #eef2f7;
        text-align: right;
        white-space: normal;
    }

    .table-wrap td:last-child {
        border-bottom: none;
    }

    .table-wrap td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        text-align: left;
    }

    .empty-cell {
        display: block !important;
        text-align: center !important;
    }

    .empty-cell::before {
        content: "";
        display: none;
    }

    .inline-form,
    .form-grid,
    .order-menu-tools,
    .billing-form,
    .filter-form,
    .receipt-header,
    .receipt-meta,
    .receipt-totals,
    .permission-grid,
    .editable-row,
    .inventory-row,
    .settings-grid,
    .order-row,
    .billing-card {
        grid-template-columns: 1fr;
    }

    .settings-grid .span-2,
    .billing-fiscal .span-2 {
        grid-column: auto;
    }

    .billing-fiscal,
    .checklist-grid,
    .cash-method-grid {
        grid-template-columns: 1fr;
    }

    .order-row,
    .billing-card {
        align-items: stretch;
    }

    .order-row .btn-secondary,
    .order-row form,
    .order-row button,
    .billing-card button,
    .billing-card .btn-primary {
        width: 100%;
    }

    .product-grid,
    .product-grid.compact,
    .kitchen-board,
    .table-card-grid {
        grid-template-columns: 1fr;
    }

    .receipt-header > div:last-child {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .app-body {
        padding-top: 64px;
    }

    .mobile-topbar {
        min-height: 64px;
    }

    .mobile-logout {
        font-size: 13px;
    }

    .main {
        padding: 12px;
    }

    .topbar h1 {
        font-size: 23px;
    }

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

    .cart-line {
        grid-template-columns: 1fr;
    }

    .cart-line-controls {
        justify-content: space-between;
    }

    .receipt,
    .login-card {
        padding: 18px;
    }
}
