/* =======================================================
   VARIABLES BASE
======================================================= */
:root {
    --color-bg: #eef1f5;
    --color-text: #1a1a1a;

    --sidebar-bg1: #1d2939;
    --sidebar-bg2: #111a24;

    --primary: #1e88e5;
    --primary-dark: #0d6cd1;

    --table-head: #1e88e5;

    --card-bg: #ffffff;
    --modal-bg: #ffffff;
    --input-bg: #fafafa;

    --smooth: 0.3s ease;
}

/* =======================================================
   DARK MODE
======================================================= */
html.dark {
    --color-bg: #0e1217;
    --color-text: #e5e5e5;

    --sidebar-bg1: #0a0f14;
    --sidebar-bg2: #05080a;

    --primary: #7cb8ff;
    --primary-dark: #5c9de8;

    --table-head: #3d5979;

    --card-bg: #141a22;
    --modal-bg: #1b232e;
    --input-bg: #0f141a;
}

/* =======================================================
   TEMAS EXTRA
======================================================= */
html.theme-rosa   { --primary: #ff4fa3; --primary-dark: #cc2f80; --table-head: #ff4fa3; }
html.theme-dorado { --primary: #e4b34d; --primary-dark: #b4852c; --table-head: #e4b34d; }
html.theme-celeste{ --primary: #11c2ff; --primary-dark: #0096cc; --table-head: #11c2ff; }

/* =======================================================
   BASE GLOBAL
======================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Inter", sans-serif;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    transition: background var(--smooth), color var(--smooth);
}

#app { display: flex; height: 100vh; }

/* =======================================================
   BOTÓN FLOTANTE – MÓVIL
======================================================= */
#mobile-menu-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 16px 18px;
    border-radius: 50%;
    font-size: 24px;
    box-shadow: 0 4px 14px #0006;
    cursor: pointer;
    z-index: 300;
    display: none;
}
#mobile-menu-btn:hover { transform: scale(1.08); }

@media (max-width: 900px) {
    #mobile-menu-btn { display: block; }
}

/* =======================================================
   SIDEBAR MEJORADO 🔥
======================================================= */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, var(--sidebar-bg1), var(--sidebar-bg2));
    color: white;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px #0002;
    border-right: 1px solid #0004;
    transition: left 0.35s ease;
    overflow-y: auto; /* Evita que el menú se salga del fondo en pantallas pequeñas */
}
.sidebar h2 { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 10px; }

.sidebar ul { 
    list-style: none; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    margin-top: 15px;
    flex-grow: 1; /* Esto es la magia que empuja elementos al fondo */
}

.sidebar li {
    padding: 12px 14px;
    background: #253445d0;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.25s;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}
.sidebar li:hover { background: var(--primary); transform: translateX(6px) scale(1.04); }

/* Clases para botones especiales del menú */
.menu-btn-crm { background: rgba(46, 204, 113, 0.1) !important; font-weight: bold; border-left: 4px solid #2ecc71; }
.menu-btn-caja { background: rgba(255,255,255,0.1) !important; font-weight: bold; border-left: 4px solid #f1c40f; }
.menu-btn-reporte { font-weight: bold; border-left: 4px solid var(--primary); }
.menu-btn-backup { background: rgba(52, 152, 219, 0.2) !important; font-weight: bold; border-left: 4px solid #3498db; }

/* Botón de cerrar sesión anclado al fondo del marco */
.menu-btn-logout {
    margin-top: auto !important; 
    margin-bottom: 10px;
    background: #e74c3c !important; 
    color: white !important; 
    font-weight: bold !important; 
    border: none !important; 
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}
.menu-btn-logout:hover { background: #c0392b !important; }

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        width: 240px;
        padding-top: 40px;
        z-index: 250;
    }
    .sidebar.sidebar-open { left: 0; }
}

/* =======================================================
   CONTENIDO
======================================================= */
.content {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
}
@media (max-width: 900px) { .content { padding: 20px; } }

.section { display: none; }
.section.visible { display: block; }
.section h1 { font-size: 28px; margin-bottom: 18px; font-weight: 700; }

/* =======================================================
   FORMULARIOS
======================================================= */
.form-box {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 14px;
    box-shadow: 0 4px 14px #0001;
    margin-bottom: 30px;
    border: 1px solid #e3e3e3;
}
html.dark .form-box { border-color: #2c3e50; }

.form-row-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}
@media (max-width: 900px) { .form-row-grid { grid-template-columns: 1fr; } }

label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    background: var(--input-bg);
    border: 1px solid #ccc;
    font-size: 14px;
    transition: 0.2s;
}
html.dark input, html.dark select, html.dark textarea { border-color: #334155; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.2); }

/* CLASES NUEVAS PARA IMGBB */
.file-input { padding: 10px; background: #e0f2fe; border: 1px dashed var(--primary); color: var(--primary-dark); cursor: pointer; width: 100%; border-radius: 8px;}
html.dark .file-input { background: #1a2c3f; border-color: var(--primary); color: var(--primary); }

.btn-foto { background: #e0f2fe; color: #0284c7; padding: 6px 12px; border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: bold; border: 1px solid #bae6fd; display: inline-block;}
.btn-foto:hover { background: #bae6fd; }
html.dark .btn-foto { background: #0c4a6e; color: #38bdf8; border-color: #0284c7; }
html.dark .btn-foto:hover { background: #075985; }

/* Botones */
.btn-primary, .btn-secondary {
    padding: 12px 20px;
    border: none;
    min-width: 150px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.25s;
    box-shadow: 0 4px 10px #0003;
}
.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.btn-primary:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.1); }

.btn-secondary { background: #ddd; color: #333; }
.btn-secondary:hover { background: #ccc; }
html.dark .btn-secondary { background: #334155; color: #cbd5e1; }
html.dark .btn-secondary:hover { background: #475569; }

/* =======================================================
   TABLAS
======================================================= */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    margin-top: 15px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px #0002;
}

.data-table thead { background: var(--table-head); color: white; }
.data-table th { padding: 14px 10px; font-size: 14px; font-weight: 600; }
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
html.dark .data-table td { border-bottom-color: #2c3e50; }
.data-table tr:hover { background: #f1f7ff50; }
html.dark .data-table tr:hover { background: #1e293b; }

/* Botones dentro de tablas */
.data-table button {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: white;
}

.btn-historial { background: #8b5cf6; }
.btn-historial:hover { background: #6d3de9; }

.btn-add { background: #1e88e5; }
.btn-add:hover { background: #0d6cd1; }

.btn-eliminar { background: #e63946; }
.btn-eliminar:hover { background: #c62828; }

.btn-abonar { background: #2ecc71; }
.btn-abonar:hover { background: #27ae60; }

.btn-editar { background: #ff9800; }
.btn-editar:hover { background: #e68900; }

/* =======================================================
   MODALES
======================================================= */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    z-index: 90;
}
.modal-overlay.hidden { display: none; }

.modal {
    position: fixed; inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal.hidden { display: none; }

.modal-content {
    background: var(--modal-bg);
    padding: 25px;
    border-radius: 14px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 6px 18px #0004;
    position: relative;
}

.modal-content.small { max-width: 480px; }
.modal-content.large { max-width: 1000px; }

/* Botón cerrar modal */
.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
}
.modal-close:hover { background: #c0392b; transform: scale(1.1); }

/* =======================================================
   AUTOCOMPLETAR PACIENTE
======================================================= */
.paciente-sugerencias {
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    max-height: 160px;
    overflow-y: auto;
    padding: 5px;
    margin-top: 4px;
    position: absolute;
    width: calc(100% - 2px);
    z-index: 50;
}
html.dark .paciente-sugerencias { background: var(--input-bg); border-color: #334155; }
.paciente-sugerencias div { padding: 8px; cursor: pointer; }
.paciente-sugerencias div:hover { background: #dce9ff; }
html.dark .paciente-sugerencias div:hover { background: #1e293b; }

.hidden { display: none !important; }

/* =======================================================
   FIX BOTONES OPERA
======================================================= */
#medidas-resumen-tbody button:nth-child(1) { background: #8b5cf6 !important; }
#medidas-resumen-tbody button:nth-child(2) { background: #1e88e5 !important; }
#medidas-resumen-tbody button:nth-child(3) { background: #e63946 !important; }

#modal-medidas-tbody button {
    background: #ff9800 !important;
}
#modal-medidas-tbody button:hover {
    background: #e68900 !important;
}

/* =======================================================
   DASHBOARD
======================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 12px #0001;
    border: 1px solid #e3e3e3;
}
html.dark .card { border-color: #2c3e50; }

.entregas-list { list-style: none; margin-top: 10px; padding-left: 0; }

.entregas-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 6px;
    border-bottom: 1px solid #eee;
}
html.dark .entregas-list li { border-bottom-color: #2c3e50; }

.entrega-nombre { flex: 1; font-weight: 600; }
.entrega-fecha { color: #888; margin-left: 10px; }
.entrega-total { font-weight: 600; color: var(--primary-dark); }

/* =======================================================
   REPORTE CLIENTE
======================================================= */
.reporte-cliente-header {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.reporte-cliente-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.data-table.mini th,
.data-table.mini td {
    padding: 6px 8px;
    font-size: 12px;
}

.data-table.mini { border-radius: 10px; }

/* =======================================================
   SELECT DE LUGAR
======================================================= */
.cuenta-lugar-select {
    padding: 6px 10px;
    border-radius: 6px !important;
    border: none !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

/* =======================================================
   RESPONSIVE
======================================================= */
@media (max-width: 900px) {
    .content { padding: 15px !important; }
    .form-box { padding: 15px; }

    .data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    #mobile-menu-btn {
        padding: 18px;
        font-size: 26px;
    }

    .sidebar {
        width: 210px !important;
        left: -215px;
    }
}

@media (max-width: 600px) {
    .data-table th, .data-table td {
        padding: 8px 10px;
        font-size: 13px;
    }

    .btn-editar,
    .btn-abonar,
    .btn-eliminar,
    .btn-historial {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
}

/* =======================================================
   HISTORIAL MEDIDAS
======================================================= */

.item-medida {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 18px;
    background: #fff;
}
html.dark .item-medida { background: var(--input-bg); border-color: #334155; }

.tabla-medidas {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: #fff;
}
html.dark .tabla-medidas { background: var(--input-bg); }

.tabla-medidas th,
.tabla-medidas td {
    border: 1px solid #ccc;
    padding: 6px;
    text-align: center;
}
html.dark .tabla-medidas th, html.dark .tabla-medidas td { border-color: #334155; }

.label-grupo {
    background: #f2f2f2;
    font-weight: bold;
}
html.dark .label-grupo { background: #1e293b; }

.label-ojo {
    font-weight: bold;
}

.extras p {
    margin: 4px 0;
}

/* =======================================================
   ESTILOS LOGIN
======================================================= */
.login-box {
    background: var(--card-bg);
    width: 100%;
    max-width: 380px;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    text-align: center;
    border: 1px solid rgba(0,0,0,0.05);
}
html.dark .login-box { border-color: #2c3e50; }

.login-box h2 {
    color: var(--primary);
    font-size: 26px;
    margin-bottom: 20px;
    font-weight: 800;
}

.login-box input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: var(--input-bg);
    font-size: 15px;
    transition: 0.3s;
}

.login-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 136, 229, 0.1);
}

.login-box button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 10px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
}

.login-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 136, 229, 0.3);
}

.error-msg {
    background: #fff5f5;
    color: #e53e3e;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid #feb2b2;
    text-align: left;
    display: flex;
    align-items: center;
}
html.dark .error-msg { background: #451a1a; color: #fca5a5; border-color: #7f1d1d; }
.error-msg::before {
    content: "⚠️";
    margin-right: 8px;
}
/* =======================================================
   IMPRESIÓN TÉRMICA Y A4 (CORRECCIÓN IPAD VISIONX)
======================================================= */
@media print {
    /* Desaparecemos toda la app y modales de raíz */
    body.imprimiendo-ticket #app,
    body.imprimiendo-certificado #app,
    body.imprimiendo-ticket .modal-overlay,
    body.imprimiendo-certificado .modal-overlay,
    body.imprimiendo-ticket .modal,
    body.imprimiendo-certificado .modal,
    body.imprimiendo-ticket #mobile-menu-btn,
    body.imprimiendo-certificado #mobile-menu-btn {
        display: none !important;
    }

    /* Formato para la ticketera (58mm) */
    body.imprimiendo-ticket {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    body.imprimiendo-ticket #print-area {
        position: absolute; left: 0; top: 0;
        width: 58mm; 
        padding: 0; margin: 0;
        font-family: 'Helvetica', 'Arial', sans-serif;
        color: black; background: white; font-size: 11px;
    }
    body.imprimiendo-ticket table.tabla-ticket { width: 100%; border-collapse: collapse; margin-bottom: 5px; }
    body.imprimiendo-ticket table.tabla-ticket th,
    body.imprimiendo-ticket table.tabla-ticket td {
        border: 1px solid black; padding: 2px; text-align: center; font-size: 10px;
    }

    /* Formato para el Certificado A4 */
    body.imprimiendo-certificado {
        background: white !important;
    }
    body.imprimiendo-certificado #print-area {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* =======================================================
   BUSCADOR DE PRODUCTOS (Cuentas y Venta Rápida)
======================================================= */
.producto-sugerencias {
    position: absolute;
    left: 0; right: 0; top: 100%;
    margin-top: 2px;
    background: var(--card-bg);
    border: 1px solid #ccc;
    border-radius: 8px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 80;
    box-shadow: 0 8px 20px #0003;
}
html.dark .producto-sugerencias { border-color: #334155; }
.producto-sugerencias .ps-item {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 8px 12px; cursor: pointer; font-size: 13px;
    border-bottom: 1px solid #eee;
}
html.dark .producto-sugerencias .ps-item { border-bottom-color: #2c3e50; }
.producto-sugerencias .ps-item:hover,
.producto-sugerencias .ps-item.activo { background: #dce9ff; }
html.dark .producto-sugerencias .ps-item:hover,
html.dark .producto-sugerencias .ps-item.activo { background: #1e293b; }
.producto-sugerencias .ps-codigo { font-weight: bold; color: var(--primary-dark); margin-right: 6px; }
.producto-sugerencias .ps-detalle { color: #777; font-size: 12px; }
.producto-sugerencias .ps-precio { font-weight: bold; white-space: nowrap; }
.producto-sugerencias .ps-agotado { color: #c62828; font-weight: bold; }
.producto-sugerencias .ps-vacio { padding: 10px 12px; color: #888; font-size: 13px; }

/* =======================================================
   AGENDA DE CITAS (menú "Citas")
======================================================= */
.agenda-hero {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 22px 26px; margin-bottom: 18px; border-radius: 16px; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.agenda-hero::after {
    content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px;
    border-radius: 50%; background: rgba(255, 255, 255, 0.12); pointer-events: none;
}
.agenda-hero h1 { margin: 0 0 6px; color: #fff; font-size: 26px; }
.agenda-hero p { margin: 0; max-width: 640px; opacity: 0.93; font-size: 14px; line-height: 1.45; }
.agenda-hero-btn {
    position: relative; z-index: 1; background: #fff; color: var(--primary-dark);
    border: none; border-radius: 12px; padding: 12px 22px; font-weight: 700; font-size: 15px;
    cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22); transition: 0.2s;
}
.agenda-hero-btn:hover { transform: translateY(-2px) scale(1.03); }

/* Tarjetas de resumen */
.agenda-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.agenda-kpi {
    --c: #1e88e5; --c-rgb: 30, 136, 229;
    display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer;
    background: var(--card-bg); border-radius: 14px;
    border: 1px solid rgba(var(--c-rgb), 0.25); border-left: 6px solid var(--c);
    box-shadow: 0 4px 14px #0001; transition: 0.2s;
}
.agenda-kpi:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(var(--c-rgb), 0.28); }
.agenda-kpi-icono {
    width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px; font-size: 22px;
    display: flex; align-items: center; justify-content: center; background: rgba(var(--c-rgb), 0.16);
}
.agenda-kpi-num { font-size: 28px; font-weight: 800; line-height: 1; color: var(--c); }
.agenda-kpi-txt { font-size: 13px; font-weight: 600; opacity: 0.75; margin-top: 4px; }
.kpi-hoy       { --c: #22c55e; --c-rgb: 34, 197, 94; }
.kpi-manana    { --c: #1e88e5; --c-rgb: 30, 136, 229; }
.kpi-confirmar { --c: #fb8c00; --c-rgb: 251, 140, 0; }
.kpi-cerrar    { --c: #e53935; --c-rgb: 229, 57, 53; }
@media (max-width: 900px) { .agenda-kpis { grid-template-columns: repeat(2, 1fr); } }

/* Barra de filtros */
.agenda-toolbar {
    background: var(--card-bg); border: 1px solid #e3e3e3; border-radius: 14px;
    padding: 16px 18px; box-shadow: 0 4px 14px #0001; margin-bottom: 14px;
}
html.dark .agenda-toolbar { border-color: #2c3e50; }
.agenda-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.agenda-chip {
    --c: #64748b; --c-rgb: 100, 116, 139;
    padding: 8px 16px; border-radius: 999px; border: 2px solid var(--c); background: transparent;
    color: var(--c); font-weight: 700; font-size: 13px; cursor: pointer; transition: 0.2s;
}
.agenda-chip:hover { background: rgba(var(--c-rgb), 0.14); transform: translateY(-1px); }
.agenda-chip.activo { background: var(--c); color: #fff; box-shadow: 0 4px 10px rgba(var(--c-rgb), 0.45); }
.chip-hoy       { --c: #22c55e; --c-rgb: 34, 197, 94; }
.chip-manana    { --c: #1e88e5; --c-rgb: 30, 136, 229; }
.chip-semana    { --c: #8b5cf6; --c-rgb: 139, 92, 246; }
.chip-proximas  { --c: #14b8a6; --c-rgb: 20, 184, 166; }
.chip-anteriores{ --c: #64748b; --c-rgb: 100, 116, 139; }

.agenda-filtros { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.agenda-campo { display: flex; flex-direction: column; }
.agenda-campo input, .agenda-campo select { width: auto; min-width: 160px; }
.agenda-campo-buscar { flex: 1; min-width: 220px; }
.agenda-campo-buscar input { width: 100%; }
@media (max-width: 600px) {
    .agenda-campo { flex: 1 1 100%; }
    .agenda-campo input, .agenda-campo select { width: 100%; }
}
.agenda-resumen {
    display: inline-block; margin: 4px 2px 0; padding: 4px 14px; border-radius: 999px; font-weight: 700;
    font-size: 13px; color: var(--primary-dark); background: rgba(30, 136, 229, 0.12);
}
.agenda-resumen:empty { display: none; }

/* Tabla */
.agenda-tabla { margin-top: 10px; }
.agenda-tabla td { vertical-align: middle; }
.agenda-fila { --c: #fb8c00; --c-rgb: 251, 140, 0; background: rgba(var(--c-rgb), 0.07); }
.agenda-fila td:first-child { border-left: 5px solid var(--c); }
.agenda-fila.agenda-hoy { background: rgba(var(--c-rgb), 0.15); }
.agenda-est-pendiente  { --c: #fb8c00; --c-rgb: 251, 140, 0; }
.agenda-est-confirmada { --c: #1e88e5; --c-rgb: 30, 136, 229; }
.agenda-est-atendida   { --c: #2e9e4f; --c-rgb: 46, 158, 79; }
.agenda-est-noasistio  { --c: #e53935; --c-rgb: 229, 57, 53; }
.agenda-est-cancelada  { --c: #757575; --c-rgb: 117, 117, 117; }
.agenda-est-cancelada .agenda-cliente-nombre,
.agenda-est-cancelada .agenda-motivo { text-decoration: line-through; opacity: 0.6; }

.agenda-fecha-txt { font-weight: 700; white-space: nowrap; }
.agenda-badge {
    display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 800; color: #fff; letter-spacing: 0.3px;
}
.agenda-badge-hoy    { background: #22c55e; }
.agenda-badge-manana { background: #1e88e5; }
.agenda-badge-cerrar { background: #e53935; }
.agenda-hora {
    display: inline-block; padding: 5px 11px; border-radius: 9px; font-weight: 800; white-space: nowrap;
    background: rgba(30, 136, 229, 0.14); color: var(--primary-dark);
}
.agenda-cliente { display: flex; align-items: center; gap: 10px; }
.agenda-avatar {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: #1e88e5; color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
.agenda-cliente-nombre { font-weight: 600; }
.agenda-tel { white-space: nowrap; opacity: 0.9; }
.agenda-motivo {
    display: inline-block; padding: 3px 10px; border-radius: 8px; font-weight: 600; font-size: 13px;
    background: rgba(139, 92, 246, 0.14); color: #7c3aed;
}
html.dark .agenda-motivo { color: #c4b5fd; }
.agenda-obs { color: #777; font-size: 12px; margin-top: 4px; }
.agenda-tabla .agenda-estado-select {
    width: auto; padding: 7px 12px; border-radius: 999px; border: 2px solid var(--c); color: var(--c);
    background: rgba(var(--c-rgb), 0.13); font-weight: 800; font-size: 13px; cursor: pointer;
}
.agenda-acciones { display: flex; gap: 6px; align-items: center; }
.agenda-icono-btn, .data-table .agenda-icono-btn {
    width: 36px; height: 36px; min-width: 0; padding: 0; display: inline-flex; align-items: center;
    justify-content: center; border: none; border-radius: 10px; color: #fff; font-size: 16px;
    cursor: pointer; text-decoration: none; transition: 0.2s; box-shadow: 0 3px 8px #0002;
}
.agenda-icono-btn:hover { transform: translateY(-2px) scale(1.06); filter: brightness(1.08); }
.agenda-btn-wa   { background: #25d366; }
.agenda-btn-edit { background: #ff9800; }
.agenda-btn-del  { background: #e63946; }

/* Modal de cita */
.agenda-modal { max-width: 520px; }
.agenda-modal-head {
    margin: -25px -25px 20px; padding: 20px 60px 20px 25px; display: flex; align-items: center; gap: 12px;
    border-radius: 14px 14px 0 0; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.agenda-modal-head h3 { margin: 0; font-size: 19px; color: #fff; }
.agenda-modal-ico { font-size: 26px; }
#modal-agenda-cita .modal-close { background: rgba(255, 255, 255, 0.25); }
#modal-agenda-cita .modal-close:hover { background: rgba(255, 255, 255, 0.45); }
.agenda-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.agenda-f-full { grid-column: 1 / -1; }
.agenda-form label { color: var(--primary-dark); font-size: 13px; }
html.dark .agenda-form label { color: var(--primary); }
.agenda-form input, .agenda-form select, .agenda-form textarea { border-width: 2px; }
@media (max-width: 480px) { .agenda-form { grid-template-columns: 1fr; } }
.agenda-guardar {
    width: 100%; margin-top: 18px; padding: 14px; font-size: 16px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

/* -------------------------------------------------------
   AGENDA: alarmas de recordatorio (Dashboard + menú)
------------------------------------------------------- */
.agenda-menu-badge {
    display: inline-block; min-width: 22px; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
    background: #ef4444; color: #fff; font-size: 12px; font-weight: 800; text-align: center; line-height: 1.5;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); animation: agendaPulso 2s infinite;
}
@keyframes agendaPulso {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.agenda-rec-list { list-style: none; padding: 0; margin: 0; max-height: 340px; overflow-y: auto; }
.agenda-rec-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #eee;
}
html.dark .agenda-rec-item { border-bottom-color: #2c3e50; }
.agenda-rec-item.agenda-rec-hecho { opacity: 0.6; }
.agenda-rec-dia {
    flex-shrink: 0; min-width: 74px; padding: 5px 8px; border-radius: 10px; text-align: center;
    font-size: 11px; font-weight: 800; color: #fff; letter-spacing: 0.3px;
}
.agenda-rec-dia-0 { background: #22c55e; }
.agenda-rec-dia-1 { background: #1e88e5; }
.agenda-rec-dia-2 { background: #8b5cf6; }
.agenda-rec-dia-3 { background: #14b8a6; }
.agenda-rec-info { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.agenda-rec-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-rec-info small { color: #777; }
.agenda-rec-est { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.agenda-rec-est-ok   { background: rgba(30, 136, 229, 0.15); color: #1e88e5; }
.agenda-rec-est-pend { background: rgba(251, 140, 0, 0.18); color: #e67e00; }
.agenda-rec-ok { color: #2e9e4f !important; font-weight: 700; margin-left: 4px; }
.agenda-rec-acc { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.agenda-rec-sintel { font-size: 18px; opacity: 0.6; padding: 0 6px; }
.agenda-btn-check { background: #64748b; }
.agenda-btn-hecho { background: #94a3b8; }
.agenda-recordado {
    display: inline-block; margin-top: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
    background: rgba(46, 158, 79, 0.16); color: #2e9e4f;
}

/* -------------------------------------------------------
   AGENDA: crear cliente nuevo desde la cita
------------------------------------------------------- */
.agenda-seg { display: flex; gap: 6px; padding: 5px; border-radius: 12px; background: rgba(100, 116, 139, 0.14); }
.agenda-seg-btn {
    flex: 1; padding: 9px 10px; border: none; border-radius: 9px; background: transparent; color: inherit;
    font-weight: 700; font-size: 13px; cursor: pointer; transition: 0.2s;
}
.agenda-seg-btn:hover { background: rgba(100, 116, 139, 0.18); }
.agenda-seg-btn.activo { background: var(--primary); color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25); }
.agenda-nuevo-box {
    padding: 14px; border-radius: 12px; border: 2px dashed #22c55e; background: rgba(34, 197, 94, 0.08);
}
.agenda-nuevo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .agenda-nuevo-grid { grid-template-columns: 1fr; } }
.agenda-nuevo-nota { display: block; margin-top: 10px; font-size: 12px; line-height: 1.4; opacity: 0.85; }

/* Aviso flotante */
.agenda-toast {
    position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); z-index: 300;
    padding: 12px 22px; border-radius: 12px; background: #16a34a; color: #fff; font-weight: 700; font-size: 14px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3); opacity: 0; pointer-events: none; transition: 0.3s;
}
.agenda-toast.visible { opacity: 1; transform: translate(-50%, 0); }
