:root {
    --color-bg: #fff7ed;
    --color-bg-strong: #fef3c7;
    --color-surface: #fffaf3;
    --color-panel: #ffffff;
    --color-primary: #f97316;
    --color-primary-dark: #ea580c;
    --color-secondary: #fb923c;
    --color-text: #1f2937;
    --color-muted: #64748b;
    --color-border: #ffe4c7;
    --color-success: #16a34a;
    --color-warning: #facc15;
    --color-danger: #dc2626;
    --shadow-soft: 0 14px 45px rgba(249, 115, 22, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

img {
    max-width: 100%;
    display: block;
}

button {
    font: inherit;
    cursor: pointer;
    border: none;
    border-radius: 14px;
    padding: 10px 16px;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

button:active {
    transform: scale(0.98);
}

button.primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-soft);
}

button.ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

button.ghost.active {
    background: rgba(255, 102, 0, 0.12);
    border-color: var(--color-primary);
}

button.text {
    background: transparent;
    color: var(--color-text);
    border: none;
    padding-inline: 4px;
}

button.text-danger {
    color: var(--color-danger);
}

.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 5;
}

body.sidebar-open .scrim {
    opacity: 1;
    pointer-events: auto;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #431407;
    color: #fff7ed;
    padding: 28px 20px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 6;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--color-primary);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    font-weight: 700;
}

.brand small {
    color: rgba(255, 247, 237, 0.7);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    border: none;
    background: transparent;
    color: inherit;
    padding: 12px 14px;
    text-align: left;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}

.nav-item span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.nav-item.active,
.nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-footer {
    margin-top: auto;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
    font-weight: 700;
}

.main {
    flex: 1;
    padding: 32px clamp(20px, 6vw, 48px) 48px;
    background: linear-gradient(180deg, rgba(255, 247, 237, 0.6), #fff);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
}

.topbar-titles {
    flex: 1;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.75rem;
    margin: 0;
    color: var(--color-muted);
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

.icon-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--color-border);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 16px;
}
.catalog-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}
.catalog-product {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 10px 12px;
    background: #fff;
}
.catalog-product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}
.catalog-empty,
.product-meta {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-muted);
}
.form-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
.form-switch input {
    width: auto;
}
    padding: 0;
}

.icon-button span {
    width: 20px;
    height: 2px;
    background: var(--color-text);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 18px;
.detail-field textarea {
    resize: vertical;
    min-height: 90px;
.catalog-product-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.catalog-product-actions .ghost {
    padding-inline: 10px;
    font-size: 0.85rem;
}
}
}

.card {
    background: var(--color-panel);
    border-radius: 18px;
    padding: 20px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.card h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--color-muted);
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 8px 0 4px;
}

.status-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.chip-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-muted);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 16px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: var(--color-panel);
    padding: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--color-surface);
}

.actions-inline {
    display: flex;
    gap: 8px;
}

.status {
    margin: 16px 0 0;
    color: var(--color-muted);
}

.detail-drawer {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 20;
}

.detail-drawer.open {
    display: flex;
}

.detail-card {
    width: min(720px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: #fffdf9;
    border-radius: 24px;
    box-shadow: 0 40px 120px rgba(15, 23, 42, 0.25);
    border: 1px solid var(--color-border);
    padding: 24px;
}

.detail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin: 20px 0 10px;
}

.detail-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.detail-time {
    margin: 0 0 12px;
    color: var(--color-muted);
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.detail-plates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.detail-plate-card {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 12px;
    background: var(--color-surface);
}

.detail-plate-card h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

.detail-plate-card strong {
    font-size: 1.1rem;
}

.detail-items {
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}

.detail-items table {
    margin: 0;
}
    .card-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 12px;
    }
    .card-actions .ghost,
    .card-actions a.ghost {
        text-decoration: none;
        padding-inline: 16px;
    }

    .card-actions a.ghost {
        border: 1px solid var(--color-border);
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        color: var(--color-primary);
        font-weight: 600;
        padding-block: 8px;
    }

.detail-summary {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding-top: 12px;
}
    .product-search-results {
        margin: 8px 0;
        border: 1px solid var(--color-border);
        border-radius: 16px;
        background: #fff;
        padding: 6px;
        max-height: 240px;
        overflow-y: auto;
        box-shadow: 0 18px 35px rgba(67, 20, 7, 0.08);
    }
    .product-result {
        width: 100%;
        border: none;
        background: transparent;
        border-radius: 12px;
        padding: 10px 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: left;
        color: var(--color-text);
    }
    .product-result:not(:last-child) {
        margin-bottom: 4px;
    }
    .product-result:hover,
    .product-result.active {
        background: rgba(249, 115, 22, 0.09);
    }
    .product-result-prices {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        font-weight: 600;
    }
    .product-result-prices .price-alt {
        font-size: 0.85rem;
        color: var(--color-muted);
    }
    .detail-price-hint {
        font-size: 0.9rem;
        color: var(--color-muted);
        margin: 4px 0 8px;
    }
    .checkbox-inline {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-weight: 600;
        cursor: pointer;
    }
    .checkbox-inline input[type='checkbox'] {
        width: 18px;
        height: 18px;
        accent-color: var(--color-primary);
    }

.detail-summary div {
    min-width: 160px;
}

.detail-summary strong {
    font-size: 1.2rem;
}

.detail-actions {
    margin-top: 20px;
    display: grid;
    gap: 20px;
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
}

body.page-admin .detail-actions {
    display: none;
}

body.page-historial .detail-actions {
    display: none;
}

.detail-actions section {
    border: 1px dashed var(--color-border);
    border-radius: 16px;
    padding: 16px;
    background: var(--color-panel);
}

.detail-actions h3 {
    margin-top: 0;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.detail-field.compact {
    margin-bottom: 0;
    min-width: 140px;
}

.detail-field input,
.detail-field select,
.detail-field textarea {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px;
    font-size: 1rem;
    background: #fff;
}

.detail-field.compact input,
.detail-field.compact select {
    padding: 8px 10px;
    font-size: 0.95rem;
}

.detail-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

button.full {
    width: 100%;
}

button.icon-only {
    padding-inline: 12px;
}

/* Auth page */
body.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #ffe7ba, #fff7ed);
    padding: 32px 16px;
}

.auth-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: 0 30px 80px rgba(249, 115, 22, 0.18);
}

.auth-card h1 {
    margin: 0 0 6px;
    font-size: 1.8rem;
}

.auth-card p {
    margin: 0 0 24px;
    color: var(--color-muted);
}

.auth-card label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.auth-card input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    margin-bottom: 16px;
    font-size: 1rem;
}

.alert {
    background: #fee2e2;
    color: var(--color-danger);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
    display: none;
}

/* Mesero specific */
.mesas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.mesa-card {
    border-radius: 18px;
    border: 1px solid var(--color-border);
    padding: 18px;
    background: var(--color-panel);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mesa-card h3 {
    margin: 0;
}

.mesa-meta {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.mesa-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-panel);
    padding: 14px 16px;
}

.metric-card h4 {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.metric-card strong {
    font-size: 1.4rem;
}

.badge.status-LIBRE { background: #dcfce7; color: var(--color-success); }
.badge.status-OCUPADA { background: #fee2e2; color: var(--color-danger); }
.badge.status-CUENTA { background: #fef9c3; color: #a16207; }
.badge.status-INACTIVA { background: #e5e7eb; color: #374151; }
.badge.status-ABIERTA { background: #dbeafe; color: #1d4ed8; }
.badge.status-EN_CUENTA { background: #fef3c7; color: #b45309; }

.delivery-section {
    margin-top: 32px;
    background: var(--color-panel);
    border-radius: 20px;
    border: 1px solid var(--color-border);
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

.history-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    gap: 12px;
}

.pagination-controls {
    display: flex;
    gap: 8px;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.report-range {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.report-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 18px;
}

.report-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.report-list li {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
}

.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.progress-line {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--color-border);
    overflow: hidden;
    margin-top: 6px;
}

.progress-line span {
    display: block;
    height: 100%;
    background: var(--color-primary);
}

.report-hours {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hour-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.hour-bar span {
    font-weight: 600;
    display: inline-block;
    min-width: 60px;
}

.hour-bar .progress-line {
    flex: 1 1 140px;
    margin-top: 0;
}

.hour-bar small {
    color: var(--color-muted);
}

.orders-toolbar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 12px 0 8px;
    padding: 16px;
    border-radius: 24px;
    border: 1px solid var(--color-border);
    background: var(--color-panel);
}

.orders-range {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.orders-range .chip-group {
    flex: 1 1 220px;
}

.orders-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.orders-filters .detail-field {
    flex: 1 1 150px;
}

.orders-search {
    flex: 2 1 240px;
}

.orders-search input {
    width: 100%;
}

.mesa-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    align-items: flex-end;
}

.mesa-form .form-group {
    flex: 1 1 200px;
}

.mesa-form input {
    width: 100%;
}

.mesa-input,
.mesa-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: #fff;
    font: inherit;
}

.delivery-toolbar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.delivery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.delivery-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.delivery-card {
    border: 1px solid var(--color-border);
    border-radius: 18px;
    padding: 16px;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delivery-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.delivery-meta {
    font-size: 0.85rem;
    color: var(--color-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.delivery-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.delivery-empty {
    margin: 0;
    color: var(--color-muted);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 30;
}

.modal.open {
    display: flex;
}

.modal-card {
    width: min(520px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: #fffdf9;
    border-radius: 20px;
    border: 1px solid var(--color-border);
    box-shadow: 0 40px 120px rgba(15, 23, 42, 0.25);
    padding: 24px;
}

.modal-section {
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 16px;
    margin: 0 0 16px;
    background: var(--color-panel);
}

.modal-section legend {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-muted);
    padding: 0 6px;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.delivery-modal-card textarea {
    min-height: 80px;
}

.modal-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px 16px;
    border: 1px dashed var(--color-border);
    border-radius: 14px;
    background: var(--color-panel);
}

.modal-summary div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 30;
}

.toast {
    min-width: 240px;
    padding: 12px 16px;
    border-radius: 12px;
    color: #fff;
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-success { background: #16a34a; }
.toast.toast-error { background: #dc2626; }
.toast.toast-warning { background: #ca8a04; }
.toast.toast-info { background: rgba(15, 23, 42, 0.9); }

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -280px;
        transition: left 0.2s ease;
    }
    body.sidebar-open .sidebar {
        left: 0;
    }
    .icon-button {
        display: flex;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-wrap: wrap;
    }
    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .auth-card {
        padding: 32px 24px;
    }
}
