* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #d85a30;
    --primary-dark: #993c1d;
    --bg: #f7f5f0;
    --surface: #ffffff;
    --border: #e2ded4;
    --text: #2c2c2a;
    --text-secondary: #6b6a63;
    --success: #3b6d11;
    --success-bg: #eaf3de;
    --warning: #854f0b;
    --warning-bg: #faeeda;
    --danger: #a32d2d;
    --morado: #7a1fa2;
    --danger-bg: #fcebeb;
    --radius: 10px;

    /* Tipografia */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;

    /* Escala de espaciado (para ir migrando los numeros sueltos con el tiempo) */
    --espacio-xs: 4px;
    --espacio-sm: 8px;
    --espacio-md: 16px;
    --espacio-lg: 24px;
    --espacio-xl: 32px;

    /* Radios */
    --radius-sm: 6px;
    --radius-lg: 14px;

    /* Sombras */
    --sombra-sm: 0 1px 3px rgba(0,0,0,0.06);
    --sombra-md: 0 4px 16px rgba(0,0,0,0.08);
    --sombra-lg: 0 8px 30px rgba(0,0,0,0.12);

    /* Movimiento (para el paso de motion design mas adelante) */
    --transicion: 180ms ease;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Iconos SVG inline (Lucide) — heredan el color de texto del elemento
   padre, igual que hacia el emoji, pero consistentes entre pantallas. */
.icono {
    display: inline-block;
    vertical-align: -3px;
    flex-shrink: 0;
}
.icono-logo {
    vertical-align: -5px;
    margin-right: 6px;
    color: var(--primary);
}

.contenedor {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.barra-superior {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 200;
}

.barra-superior h1 { font-size: 18px; font-weight: 600; }
.barra-superior-izq { display: flex; align-items: center; gap: 10px; }
.barra-superior-izq h1 { margin: 0; }

.nav-links { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
/* Cada opcion del menu se ve como una pestaña. La seleccionada lleva fondo del color de marca y
   texto blanco, para que de un vistazo se sepa en cual pantalla se esta (antes solo cambiaba de
   color, igual que al pasar el raton por encima, y costaba distinguirla). */
.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    position: relative;
    padding: 7px 13px;
    border-radius: 999px;
    line-height: 1.2;
    white-space: nowrap;
    transition: background var(--transicion), color var(--transicion);
}
.nav-links a:hover { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.nav-links a.activo {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 6px color-mix(in srgb, var(--primary) 35%, transparent);
}
.nav-links a.activo:hover { color: #fff; background: var(--primary); }
/* El badge rojo de avisos se corre un poco para no chocar con el borde redondeado de la pestaña. */
.nav-links a .badge-notif { top: -2px; right: -2px; }

.badge-notif {
    position: absolute;
    top: -8px;
    right: -14px;
    background: var(--danger, #c0392b);
    color: white;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 999px;
    min-width: 16px;
    text-align: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transicion), border-color var(--transicion);
}
.btn:hover { background: var(--primary-dark); }
.btn-secundario {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secundario:hover { background: var(--bg); }
.btn-peligro { background: var(--danger); }
.btn-peligro:hover { background: #791f1f; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-accion-azul { background: #e2eef8; color: #235a86; border: 1px solid #b9d5ec; }
.btn-accion-azul:hover { background: #d0e4f5; }
.btn-accion-morada { background: #efe4f5; color: #5a2f82; border: 1px solid #d9c3ea; }
.btn-accion-morada:hover { background: #e4d3f0; }
.btn-accion-verde { background: #e3f3e6; color: #2c6b3c; border: 1px solid #c3e5ca; }
.btn-accion-verde:hover { background: #d3ecd8; }
.btn-accion-roja { background: #fbe5e4; color: #a02f2e; border: 1px solid #f2c4c2; }
.btn-accion-roja:hover { background: #f7d5d3; }

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transicion);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.campo { margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
}
.badge-exito { background: var(--success-bg); color: var(--success); }
.badge-alerta { background: var(--warning-bg); color: var(--warning); }
.badge-peligro { background: var(--danger-bg); color: var(--danger); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }

.metrica { background: var(--bg); border-radius: 8px; padding: 1rem; }
.metrica .etiqueta { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.metrica .valor { font-size: 24px; font-weight: 700; }

.pantalla-pin {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.pin-caja {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.pin-input {
    text-align: center;
    font-size: 28px;
    letter-spacing: 12px;
    padding: 14px;
    margin: 1.25rem 0;
}
.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 0.5rem;
}

.modal-fondo {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transicion), visibility var(--transicion);
}
.modal-fondo.abierto { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-caja {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.96) translateY(6px);
    transition: transform var(--transicion);
}
.modal-fondo.abierto .modal-caja { transform: scale(1) translateY(0); }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.cerrar-modal {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    width: auto;
}

.acciones-fila { display: flex; gap: 8px; }

/* ==========================================================
   AJUSTES PARA CELULAR Y TABLET
   ========================================================== */
@media (max-width: 780px) {
    .contenedor { padding: 1rem; overflow-x: hidden; }
    body { overflow-x: hidden; }

    .barra-superior {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    .barra-superior h1 { font-size: 15px; }
    .nav-links {
        gap: 0.3rem;
        flex-wrap: wrap;
        width: 100%;
        font-size: 13px;
    }
    .nav-links a { padding: 6px 11px; }

    .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; gap: 0.6rem; }

    .modal-caja {
        width: 94%;
        padding: 1.1rem;
        max-height: 90vh;
    }

    table { font-size: 13px; }
    th, td { padding: 8px; }

    .btn { padding: 9px 14px; font-size: 13.5px; }
    .btn-sm { padding: 6px 10px; font-size: 12.5px; }

    input, select, textarea { font-size: 16px; } /* evita zoom automatico en iPhone al escribir */
}

@media (max-width: 480px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .barra-superior h1 { font-size: 14px; }
    .contenedor { padding: 0.65rem; }
}

/* Envuelve tablas anchas en un contenedor con scroll horizontal, en vez de
   aplastar las columnas hasta que no se entienda nada */
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ==========================================================
   MENU LATERAL DE OPCIONES AVANZADAS (reemplaza el viejo desplegable)
   Ver includes/sidebar_avanzado.php
   ========================================================== */
.btn-abrir-sidebar {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 0;
    flex-shrink: 0;
    transition: background var(--transicion), color var(--transicion);
}
.btn-abrir-sidebar:hover, .btn-abrir-sidebar.activo { background: var(--bg); color: var(--primary); }

.sidebar-fondo {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transicion), visibility var(--transicion);
}
.sidebar-fondo.abierto { opacity: 1; visibility: visible; pointer-events: auto; }

.sidebar-panel {
    background: var(--primary);
    color: white;
    width: 270px;
    max-width: 85vw;
    height: 100%;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transicion);
    box-shadow: var(--sombra-lg);
}
.sidebar-fondo.abierto .sidebar-panel { transform: translateX(0); }

.sidebar-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.18);
    flex-shrink: 0;
}
.sidebar-panel-header span { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.sidebar-panel-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    display: flex;
    transition: opacity var(--transicion);
}
.sidebar-panel-header button:hover { opacity: 1; }

.sidebar-panel nav {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    gap: 2px;
    overflow-y: auto;
}
.sidebar-panel nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    transition: background var(--transicion), color var(--transicion);
}
.sidebar-panel nav a:hover { background: rgba(255,255,255,0.1); color: white; }
.sidebar-panel nav a.activo { background: rgba(255,255,255,0.18); color: white; font-weight: 700; }

/* ==========================================================
   TOAST (reemplazo de alert() nativo del navegador)
   Ver mostrarToast() en assets/js/utils.js
   ========================================================== */
#toast-contenedor {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: 100%;
    padding: 0 16px;
}
.toast {
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--sombra-lg);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transicion), transform var(--transicion);
    max-width: 420px;
    text-align: center;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--danger); }
.toast-exito { background: var(--success); }
.toast-info { background: var(--text); }

/* ==========================================================
   UTILIDADES REUTILIZABLES (paso 2 del rediseno visual)
   Reemplazan los style="" sueltos mas repetidos del proyecto, para que
   un boton o un texto secundario se vea igual en Mesa, Caja y Reportes.
   ========================================================== */

/* Texto secundario: el patron mas repetido de todo el proyecto */
.texto-secundario { color: var(--text-secondary); }
.texto-sm { font-size: 13px; }
.texto-danger { color: var(--danger); }
.texto-success { color: var(--success); }

/* El patron "descripcion debajo de un h2/h3": texto secundario + tamaño +
   espacio abajo, antes escrito suelto en cada pantalla */
.subtitulo { color: var(--text-secondary); font-size: 13px; margin-bottom: 1.25rem; }

/* Botones que ocupan todo el ancho del contenedor (formularios, modales) */
.btn-ancho { width: 100%; justify-content: center; }
/* Boton que reparte el espacio disponible con sus hermanos (pares de acciones) */
.btn-flex { flex: 1; justify-content: center; }

/* Fila con icono + texto alineados (el patron que mas se repite desde que
   reemplazamos los emojis por iconos SVG) */
.fila-icono { display: flex; align-items: center; gap: 5px; }
.fila-icono-sm { display: flex; align-items: center; gap: 4px; }
.fila-icono-centrada { display: flex; align-items: center; justify-content: center; gap: 5px; }

/* Espaciados sueltos mas comunes, usando la escala de tokens ya definida */
.mb-xs { margin-bottom: var(--espacio-xs); }
.mb-sm { margin-bottom: var(--espacio-sm); }
.mb-md { margin-bottom: var(--espacio-md); }
.mb-lg { margin-bottom: var(--espacio-lg); }
.mb-xl { margin-bottom: var(--espacio-xl); }
.mt-xs { margin-top: var(--espacio-xs); }
.mt-sm { margin-top: var(--espacio-sm); }
.mt-md { margin-top: var(--espacio-md); }
.mt-lg { margin-top: var(--espacio-lg); }

/* Tarjeta sin relleno propio (para listas/tablas que manejan su propio padding) */
.card-plano { padding: 0; }
