:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --secondary: #2c3e50;
    --accent: #f39c12;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --sidebar-width: 260px;
    --header-height: 60px;
    --border-radius: 8px;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 5px 25px rgba(0,0,0,0.12);
    --sidebar-bg: #2c3e50;
    --page-bg: #f5f6fa;
    --text-color: #333333;
    --topbar-bg: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--page-bg, var(--gray-100));
    color: var(--text-color, var(--gray-800));
    line-height: 1.6;
}

/* ===== LOGIN ===== */
.login-page {
    --login-bg: none;
    margin: 0;
    background: var(--secondary);
}

.login-layout {
    min-height: 100vh;
    display: flex;
    width: 100%;
}

/* Panel izquierdo: marca + imagen de fondo (configurable) */
.login-brand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--secondary);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

/* Capa oscura opcional para legibilidad sobre la imagen */
.login-brand::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(44, 62, 80, 0.25);
}

/* Panel derecho: tarjeta de login */
.login-panel {
    width: 420px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: var(--white);
}

.login-card {
    background: transparent;
    border-radius: 12px;
    padding: 10px 20px;
    width: 100%;
    max-width: 360px;
    box-shadow: none;
}

.login-card h1 {
    text-align: center;
    color: var(--secondary);
    margin-bottom: 8px;
    font-size: 1.6rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.login-card .logo-icon {
    text-align: center;
    font-size: 3rem;
    margin-bottom: 15px;
}

/* Responsive login */
@media (max-width: 900px) {
    .login-layout { flex-direction: column; }
    .login-brand {
        min-height: 32vh;
        order: 1;
    }
    .login-panel {
        width: 100%;
        order: 2;
        padding: 30px 20px;
        flex: 1;
    }
}

/* ===== LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg, var(--secondary));
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--white);
}

.sidebar-brand small {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 15px 0;
}

.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: var(--white);
    border-left-color: var(--primary);
}

.sidebar-nav a .icon {
    width: 22px;
    margin-right: 12px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.sidebar-footer .user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-role {
    font-size: 0.7rem;
    color: var(--gray-500);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow-x: hidden;
}

.topbar {
    height: var(--header-height);
    background: var(--topbar-bg, var(--white));
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar .menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px 10px;
    margin-right: 10px;
    color: var(--gray-700);
}

.topbar .page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.topbar .topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-area {
    flex: 1;
    padding: 24px;
    min-width: 0;
    max-width: 100%;
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-100);
}

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-icon.primary { background: rgba(231,76,60,0.1); color: var(--primary); }
.stat-card .stat-icon.success { background: rgba(39,174,96,0.1); color: var(--success); }
.stat-card .stat-icon.warning { background: rgba(243,156,18,0.1); color: var(--warning); }
.stat-card .stat-icon.info { background: rgba(52,152,219,0.1); color: var(--info); }

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-info { background: var(--info); color: var(--white); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* ===== TABLES ===== */
.table-responsive {
    overflow-x: auto;
}

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

table th, table td {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-200);
}

table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}

table tbody tr:hover {
    background: rgba(231,76,60,0.02);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(39,174,96,0.1); color: var(--success); }
.badge-warning { background: rgba(243,156,18,0.1); color: var(--warning); }
.badge-danger { background: rgba(231,76,60,0.1); color: var(--danger); }
.badge-info { background: rgba(52,152,219,0.1); color: var(--info); }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* ===== MESA MAP ===== */
.mesa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
    padding: 10px 0;
}

.mesa-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.mesa-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.mesa-card.libre { border-color: var(--success); }
.mesa-card.ocupada { border-color: var(--danger); background: rgba(231,76,60,0.03); }
.mesa-card.cuenta_pedida { border-color: var(--warning); background: rgba(243,156,18,0.03); }

.mesa-card .mesa-numero {
    font-size: 1.6rem;
    font-weight: 700;
}

.mesa-card .mesa-cap {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.mesa-card .mesa-status {
    margin-top: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mesa-card.libre .mesa-status { color: var(--success); }
.mesa-card.ocupada .mesa-status { color: var(--danger); }
.mesa-card.cuenta_pedida .mesa-status { color: var(--warning); }

/* ===== PEDIDO PANEL ===== */
.pedido-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
    width: 100%;
    min-width: 0;
}

.pedido-layout > * {
    min-width: 0;
}

.menu-categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.menu-categories::-webkit-scrollbar {
    height: 4px;
}

.menu-categories::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.menu-categories .cat-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex: 0 0 auto;
}

.menu-categories .cat-btn.active,
.menu-categories .cat-btn:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.menu-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    min-width: 0;
}

.menu-item-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 0;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.menu-item-card .item-img {
    width: 100%;
    height: 150px;
    overflow: hidden;
    background: var(--gray-100);
}

.menu-item-card .item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.menu-item-card .item-img.item-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
}

.menu-item-card .item-name,
.menu-item-card .item-desc,
.menu-item-card .item-price {
    padding-left: 14px;
    padding-right: 14px;
}

.menu-item-card .item-name {
    margin-top: 12px;
}

.menu-item-card .item-price {
    padding-bottom: 12px;
    margin-top: auto;
}

.menu-item-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(231,76,60,0.12);
}

.menu-item-card.inactive {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-item-card .item-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.menu-item-card .item-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

.menu-item-card .item-price {
    font-weight: 700;
    color: var(--primary);
}

.pedido-resumen {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: sticky;
    top: calc(var(--header-height) + 24px);
}

.pedido-resumen .resumen-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.pedido-resumen .resumen-items {
    max-height: 350px;
    overflow-y: auto;
    padding: 10px 20px;
}

.resumen-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.resumen-item .item-qty {
    background: var(--primary);
    color: var(--white);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.resumen-item .item-info {
    flex: 1;
}

.resumen-item .item-info .name {
    font-size: 0.85rem;
    font-weight: 500;
}

.resumen-item .item-info .vars {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.resumen-item .item-subtotal {
    font-weight: 600;
    font-size: 0.85rem;
}

.resumen-item .item-remove {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
}

.resumen-item .item-remove:hover {
    color: var(--danger);
}

.resumen-totals {
    padding: 16px 20px;
    border-top: 2px solid var(--gray-200);
}

.resumen-totals .total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.resumen-totals .total-row.grand {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}

.resumen-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== MODALS ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0 5px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== COCINA ===== */
.cocina-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.cocina-pedido-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border-top: 4px solid var(--primary);
}

.cocina-pedido-card.listo {
    border-top-color: var(--success);
}

.cocina-pedido-card .pedido-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-100);
}

.cocina-pedido-card .pedido-items {
    padding: 12px 16px;
}

.cocina-pedido-card .pedido-items li {
    padding: 6px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-100);
    list-style: none;
}

.cocina-pedido-card .pedido-items li:last-child {
    border-bottom: none;
}

.cocina-pedido-card .pedido-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
}

/* ===== WHATSAPP PANEL ===== */
.whatsapp-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - var(--header-height) - 48px);
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.whatsapp-list {
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
}

.whatsapp-list .chat-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    transition: background 0.2s;
}

.whatsapp-list .chat-item:hover,
.whatsapp-list .chat-item.active {
    background: rgba(231,76,60,0.05);
}

.whatsapp-list .chat-item .chat-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.whatsapp-list .chat-item .chat-phone {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.whatsapp-list .chat-item .chat-preview {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.whatsapp-chat {
    display: flex;
    flex-direction: column;
}

.whatsapp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--gray-100);
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-bubble.incoming {
    background: var(--white);
    border: 1px solid var(--gray-200);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-bubble.outgoing {
    background: #DCF8C6;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-bubble .bubble-time {
    font-size: 0.65rem;
    color: var(--gray-500);
    text-align: right;
    margin-top: 4px;
}

.whatsapp-input {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .pedido-layout {
        grid-template-columns: 1fr;
    }
    /* En pantallas intermedias se mantiene flujo normal (no flotar sobre el menu) */
    .pedido-resumen {
        position: static;
        width: 100%;
        box-shadow: none;
        border: 1px solid var(--gray-200);
    }
    .resumen-collapse {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .pedido-resumen .resumen-header {
        padding: 10px 16px;
        cursor: pointer;
    }
    .resumen-collapse {
        max-height: none;
    }
    .resumen-collapse.collapsed {
        display: none;
    }
    .resumen-collapse .resumen-items {
        max-height: 260px;
        overflow-y: auto;
    }
    .pedido-resumen .resumen-totals,
    .pedido-resumen .resumen-actions {
        padding: 10px 16px;
        border-top: 1px solid var(--gray-200);
    }
    .pedido-resumen #btnPagar,
    .pedido-resumen #btnCuenta {
        font-size: 0.9rem;
        padding: 10px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .topbar .menu-toggle {
        display: block;
    }
    .content-area {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .whatsapp-layout {
        grid-template-columns: 1fr;
    }
    .mesa-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

@media (max-width: 600px) {
    .menu-items-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .menu-item-card .item-img {
        height: 110px;
    }
}

@media (max-width: 400px) {
    .menu-items-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .menu-item-card .item-img {
        height: 100px;
    }
    .menu-item-card .item-desc {
        display: none;
    }
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== LOADING ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: rgba(39,174,96,0.1); color: var(--success); border: 1px solid rgba(39,174,96,0.2); }
.alert-danger { background: rgba(231,76,60,0.1); color: var(--danger); border: 1px solid rgba(231,76,60,0.2); }
.alert-warning { background: rgba(243,156,18,0.1); color: var(--warning); border: 1px solid rgba(243,156,18,0.2); }
.alert-info { background: rgba(52,152,219,0.1); color: var(--info); border: 1px solid rgba(52,152,219,0.2); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    margin-top: 8px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-bar .filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
}

.filter-bar .filter-group .form-control {
    min-width: 150px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ---------- Watermark EMM Soluciones ---------- */
.watermark {
    position: fixed;
    bottom: 12px;
    right: 16px;
    opacity: 0.10;
    pointer-events: none;
    z-index: 0;
}
.watermark img {
    height: 60px;
    width: auto;
    filter: grayscale(100%);
}

/* ===== NUEVOS GRIDS RESPONSIVE ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.detalle-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

.reportes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .reportes-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== DEMO COUNTDOWN ===== */
.demo-countdown {
    margin: 12px 16px 16px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 10px;
    color: var(--white);
    text-align: center;
}

.demo-countdown .demo-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.demo-countdown .demo-time {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.demo-countdown .demo-hint {
    font-size: 0.65rem;
    opacity: 0.85;
    margin-top: 2px;
}

/* ===== DELIVERY ===== */
.delivery-direction {
    padding: 10px 16px;
    background: rgba(243,156,18,0.08);
    font-size: 0.85rem;
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .detalle-grid {
        grid-template-columns: 1fr;
    }
    .delivery-direction {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stat-card {
        padding: 14px;
        gap: 10px;
    }
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    .stat-card .stat-value {
        font-size: 1.15rem;
    }
    .d-flex.justify-between.align-center.mb-3,
    .topbar {
        padding: 0 12px;
    }
    .content-area {
        padding: 12px;
    }
    .filter-bar .filter-group .form-control {
        min-width: 100%;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    /* Tablas horribles en movil -> scroll horizontal */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    th, td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    /* Tablas -> tarjetas apiladas en movil */
    .table-responsive table thead {
        display: none;
    }
    .table-responsive table tbody {
        display: block;
    }
    .table-responsive table tr {
        display: block;
        border: 1px solid var(--gray-200);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 6px 4px;
        background: var(--white);
    }
    .table-responsive table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        border-bottom: 1px solid var(--gray-100);
        padding: 8px 12px;
        text-align: right;
        flex-wrap: wrap;
    }
    .table-responsive table td[colspan] {
        display: block;
        text-align: center;
        justify-content: center;
        padding: 20px;
    }
    .table-responsive table td[colspan]::before {
        content: none;
    }
    .table-responsive table td:last-child {
        border-bottom: none;
    }
    .table-responsive table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        text-align: left;
        flex: 0 0 auto;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
    .table-responsive table td:empty::before {
        content: '\00a0';
    }
    .table-responsive table td .d-flex {
        justify-content: flex-end;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== ENCABEZADOS FLEX RESPONSIVE ===== */
@media (max-width: 768px) {
    .content-area > .d-flex.justify-between {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .content-area > .d-flex.justify-between > .d-flex {
        flex-wrap: wrap;
    }
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Menu toggle button en pantallas muy chicas */
@media (max-width: 768px) {
    .topbar .menu-toggle {
        display: inline-flex;
    }
}

/* Divider "o" en login */
.divider-or {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 18px 0;
    color: var(--gray-500);
    font-size: 0.8rem;
}

.divider-or::before,
.divider-or::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--gray-200);
}

.divider-or span {
    padding: 0 12px;
}

/* ===== LOGO SIDEBAR ===== */
.sidebar-logo {
    max-width: 140px;
    max-height: 70px;
    object-fit: contain;
    display: block;
    margin: 0 auto 8px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.sidebar-logo-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 6px;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    margin: 0 0 8px;
    background: rgba(255,255,255,0.08);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.15);
}

.theme-toggle .theme-icon {
    font-size: 1rem;
}

/* ===== MODO OSCURO ===== */
body.dark {
    --page-bg: #1e2227;
    --text-color: #e4e6eb;
    --topbar-bg: #2a2f36;
    --white: #2a2f36;
    --gray-100: #23282e;
    --gray-200: #313741;
    --gray-300: #3a414c;
    --gray-400: #4a535f;
    --gray-500: #8a939e;
    --gray-600: #a8b0ba;
    --gray-700: #c3cad3;
    --gray-800: #e4e6eb;
    background: var(--page-bg);
    color: var(--text-color);
}

body.dark .card {
    background: var(--gray-200);
    border-color: var(--gray-300);
}

body.dark .topbar {
    background: var(--topbar-bg);
    border-bottom-color: var(--gray-300);
}

body.dark .card-header {
    border-bottom-color: var(--gray-300);
}

body.dark .form-control,
body.dark .form-control:focus {
    background: var(--gray-100);
    color: var(--text-color);
    border-color: var(--gray-400);
}

body.dark .table {
    --bs-table-bg: transparent;
    color: var(--text-color);
}

body.dark .login-page {
    background: #1e2227;
}

body.dark .login-panel {
    background: var(--gray-200);
}

body.dark .divider-or span {
    color: var(--gray-500);
}

body.dark .theme-toggle {
    color: #ffffff;
}

/* El sidebar siempre usa fondo oscuro propio: forzamos texto claro en modo oscuro */
body.dark .sidebar-brand h2,
body.dark .sidebar-nav a:hover,
body.dark .sidebar-nav a.active,
body.dark .sidebar-nav a .badge,
body.dark .user-info .user-name,
body.dark .user-info .user-role {
    color: #ffffff;
}

body.dark .sidebar-brand small {
    color: var(--gray-500);
}
