/* =====================================================================
   Sistema de diseño - Sistema Hermandad
   Se carga DESPUÉS de styles.css. Define tokens de color/espaciado y
   re-estiliza el marco (cabecera, menú lateral) y los componentes base
   (botones, tablas, tarjetas, formularios, modales).
   Base neutra; morado y negro solo como detalle (acentos).
   Tema claro por defecto; tema oscuro con body.dark-mode.
   ===================================================================== */

:root {
    /* Superficies y texto (tema claro) */
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f1f3f6;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-muted: #667085;
    --text-faint: #98a2b3;

    /* Acentos: morado (principal) y negro (detalle) */
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: rgba(124, 58, 237, 0.10);
    --accent-contrast: #ffffff;
    --ink: #0b0b10;

    /* Estados */
    --success: #12b76a;
    --warning: #f79009;
    --danger: #d92d20;

    /* Forma y sombra */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.14);

    /* Espaciado */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --input-bg: #ffffff;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

body.dark-mode {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1b1f27;
    --surface-3: #222732;
    --border: #2a2f3b;
    --border-strong: #3a4150;
    --text: #e8eaf0;
    --text-muted: #9aa3b2;
    --text-faint: #6b7385;

    --accent: #a78bfa;
    --accent-hover: #b9a1fb;
    --accent-soft: rgba(167, 139, 250, 0.14);
    --accent-contrast: #12091f;
    --ink: #000000;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 14px 32px rgba(0, 0, 0, 0.55);

    --input-bg: #11141a;
}

/* ---------- Base ---------- */
body,
body.dark-mode {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

.app-container { background: var(--bg); }

/* ---------- Cabecera ---------- */
body header,
body.dark-mode header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 -2px 0 var(--accent);
    padding: 10px 24px;
    backdrop-filter: none;
    gap: var(--space-4);
}

body header h1,
body.dark-mode header h1 {
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

body .header-subtitle,
body.dark-mode .header-subtitle {
    color: var(--text-muted) !important;
    font-size: 12px !important;
}

.header-brand { gap: 12px !important; }
.header-brand img { width: 44px !important; height: 44px !important; }

.menu-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.user-info { gap: var(--space-2); }

body .user-info span,
body.dark-mode .user-info span {
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
}

body .user-info button,
body.dark-mode .user-info button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-right: 0 !important;
    transform: none;
}

body .user-info button:hover,
body.dark-mode .user-info button:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
    transform: none;
}

.ico {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Selector de tema */
.theme-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 28px 7px 10px;
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}
.theme-select:hover { background-color: var(--surface-3); }
.theme-select option { background: var(--surface); color: var(--text); }

/* ---------- Menú lateral ---------- */
body .sidebar,
body.dark-mode .sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: none;
    width: 252px;
    padding: 12px 0;
}

.sidebar-nav { gap: 2px; padding: 0 var(--space-2) var(--space-5); }
/* Evita que los grupos con overflow (submenús) se colapsen cuando el menú es largo */
.sidebar-nav > * { flex-shrink: 0; }

.sidebar-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 16px 12px 6px;
}
.sidebar-group-label:first-child { padding-top: 6px; }
.sidebar-group-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

body .sidebar-btn,
body.dark-mode .sidebar-btn {
    width: 100%;
    padding: 9px 12px;
    margin: 0;
    border: none;
    border-left: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    line-height: 1.35;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}

body .sidebar-btn:hover,
body.dark-mode .sidebar-btn:hover {
    background: var(--surface-3);
    color: var(--text);
    border-left-color: transparent;
}

body .sidebar-btn.active,
body.dark-mode .sidebar-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    border-left-color: transparent;
}

body .sidebar-btn.active::before,
body.dark-mode .sidebar-btn.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.sidebar-btn .ico,
.sidebar-btn .nav-ico {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    vertical-align: -4px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body .sidebar-category,
body.dark-mode .sidebar-category {
    color: var(--text);
    font-weight: 600;
}

body .sidebar-submenu,
body.dark-mode .sidebar-submenu {
    background: transparent;
    padding-left: 14px;
    border-left: 1px solid var(--border);
    margin: 2px 0 2px 18px;
}

body .sidebar-subbtn,
body.dark-mode .sidebar-subbtn {
    padding-left: 12px;
    font-size: 14px;
}

body .sidebar-header h2,
body.dark-mode .sidebar-header h2 {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 12px 20px 6px;
    border-bottom: none;
}

body .sidebar > .sidebar-btn,
body.dark-mode .sidebar > .sidebar-btn {
    width: calc(100% - 16px);
    margin: 2px 8px;
}

.sidebar-credit { color: var(--text-faint); }

/* ---------- Contenido ---------- */
body .main-content,
body.dark-mode .main-content {
    background: var(--bg);
    color: var(--text);
    padding: 28px 32px;
}

body .content-section h2,
body.dark-mode .content-section h2 {
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 20px;
}

body .content-section p,
body.dark-mode .content-section p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Botones ---------- */
.btn-primary, .btn-secondary, .btn-danger, .btn-edit {
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    box-shadow: none;
    transform: none;
}

body .btn-primary,
body.dark-mode .btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
    border: 1px solid var(--accent);
}
body .btn-primary:hover,
body.dark-mode .btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: none;
    box-shadow: var(--shadow-sm);
}

body .btn-secondary,
body.dark-mode .btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
body .btn-secondary:hover,
body.dark-mode .btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
    transform: none;
}

body .btn-danger,
body.dark-mode .btn-danger {
    background: var(--danger);
    color: #fff;
    border: 1px solid var(--danger);
}
body .btn-danger:hover,
body.dark-mode .btn-danger:hover {
    background: #b42318;
    border-color: #b42318;
    transform: none;
}

/* ---------- Tarjetas de sección (panel de Inscripciones) ---------- */
/* El emoji decorativo de las tarjetas se oculta; el contenido queda como título + descripción. */
.seccion-card > div[style*="font-size: 48px"] { display: none; }

.secciones-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-3);
}

body .seccion-card,
body.dark-mode .seccion-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    text-align: left;
    min-height: 0;
    display: block;
}

body .seccion-card.clickeable:hover,
body.dark-mode .seccion-card.clickeable:hover {
    transform: none;
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

body .seccion-card h3,
body.dark-mode .seccion-card h3 {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 4px;
}

body .seccion-card .seccion-descripcion,
body.dark-mode .seccion-card .seccion-descripcion {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

body .stat-card,
body.dark-mode .stat-card,
body .chart-card,
body.dark-mode .chart-card,
body .form-section,
body.dark-mode .form-section,
body .detalles-section,
body.dark-mode .detalles-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

body .stat-card:hover,
body.dark-mode .stat-card:hover { transform: none; box-shadow: var(--shadow); }

/* ---------- Tablas ---------- */
body .table-container,
body.dark-mode .table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

body .data-table,
body.dark-mode .data-table { background: var(--surface); }

body .data-table thead,
body.dark-mode .data-table thead { background: var(--surface-2); }

body .data-table th,
body.dark-mode .data-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

body .data-table td,
body.dark-mode .data-table td {
    color: var(--text);
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

body .data-table tbody tr:hover,
body.dark-mode .data-table tbody tr:hover { background: var(--surface-2); }

/* ---------- Formularios ---------- */
body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body select,
body textarea,
body.dark-mode input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.dark-mode select,
body.dark-mode textarea {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-sm);
    font-family: var(--font);
}

body input:focus,
body select:focus,
body textarea:focus,
body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

body input::placeholder,
body.dark-mode input::placeholder,
body textarea::placeholder,
body.dark-mode textarea::placeholder { color: var(--text-faint); }

/* ---------- Modales ---------- */
body .modal-content,
body.dark-mode .modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

body .modal-header,
body.dark-mode .modal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

body .modal-header h2,
body.dark-mode .modal-header h2 {
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
}

body .modal-body,
body.dark-mode .modal-body {
    background: var(--surface);
    color: var(--text);
}

body .modal-body label,
body.dark-mode .modal-body label { color: var(--text-muted); }

/* ---------- Scrollbars ---------- */
.main-content::-webkit-scrollbar-thumb { background: var(--border-strong); }
.main-content::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- Móvil ---------- */
@media (max-width: 768px) {
    body header, body.dark-mode header { padding: 8px 12px; }
    .header-brand img { width: 36px !important; height: 36px !important; }
    body header h1 { font-size: 15px; }
    .header-subtitle { display: none; }
    body .main-content, body.dark-mode .main-content { padding: 16px; }
}

/* ---------- Jornada de venta ---------- */
.jornada-badge {
    display: inline-block;
    margin-left: auto;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: none;
    vertical-align: 1px;
}
.jornada-badge.jornada-abierta { background: rgba(18, 183, 106, 0.14); color: var(--success); }
.jornada-badge.jornada-cerrada { background: rgba(217, 45, 32, 0.12); color: var(--danger); }

.jornada-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left-width: 4px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
}
.jornada-card-abierta { border-left-color: var(--success); }
.jornada-card-cerrada { border-left-color: var(--danger); }
.jornada-card-titulo { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.jornada-card-detalle { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }

.config-subtitulo {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 var(--space-2);
}
.config-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.config-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.config-ayuda { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); }

.zona-peligro {
    border: 1px solid rgba(217, 45, 32, 0.4);
    border-radius: var(--radius);
    padding: var(--space-5);
    margin-top: var(--space-6);
    background: rgba(217, 45, 32, 0.05);
}
.zona-peligro h3 { margin: 0 0 var(--space-2); font-size: 15px; color: var(--danger); }
.zona-peligro p { margin: 0 0 var(--space-3); font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.zona-peligro .zona-peligro-nota { margin: var(--space-2) 0 0; font-size: 12px; }
.zona-peligro button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Páginas, pestañas y métricas ---------- */
.pagina-encabezado {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.pagina-encabezado h2 { margin-bottom: 4px !important; }
.pagina-sub { margin: 0 0 var(--space-4); font-size: 13px; color: var(--text-muted); }
.table-container + .pagina-sub { margin-top: var(--space-3); }
.texto-vacio { text-align: center; color: var(--text-muted); padding: 32px 0; font-size: 14px; }
.texto-error { color: var(--danger); font-size: 14px; }
.celda-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.data-table .num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fila-click { cursor: pointer; }

.breadcrumb { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-muted); margin-bottom: var(--space-2); }
.breadcrumb a { color: var(--accent); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

.pestanas {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
    overflow-x: auto;
    scrollbar-width: none;
}
.pestanas::-webkit-scrollbar { display: none; }
.pestana {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: -1px;
}
.pestana:hover { color: var(--text); }
.pestana.active { color: var(--accent); border-bottom-color: var(--accent); }

.barra-acciones { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-4); }

.metricas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.metrica {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.metrica-valor { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.metrica-valor small { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.metrica-etq { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.datos-lista { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 0 0 var(--space-4); font-size: 14px; }
.datos-lista dt { color: var(--text-muted); font-weight: 600; }
.datos-lista dd { margin: 0; color: var(--text); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: rgba(18, 183, 106, 0.14); color: var(--success); }
.badge-warn { background: rgba(247, 144, 9, 0.16); color: var(--warning); }
.badge-neutral { background: var(--surface-3); color: var(--text-muted); }

.zona-aviso {
    border: 1px solid rgba(247, 144, 9, 0.45);
    background: rgba(247, 144, 9, 0.07);
    border-radius: var(--radius);
    padding: var(--space-5);
}
.zona-aviso h3 { margin: 0 0 var(--space-2); font-size: 15px; color: var(--warning); }
.zona-aviso p { margin: 0 0 var(--space-3); font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Etapa 3: controles de listas ---------- */
.segmentado {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.segmentado button {
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
}
.segmentado button:last-child { border-right: none; }
.segmentado button:hover { background: var(--surface-3); color: var(--text); }
.segmentado button.active { background: var(--accent-soft); color: var(--accent); }

.badge-err { background: rgba(217, 45, 32, 0.12); color: var(--danger); }
.acciones-fila { display: flex; gap: 6px; flex-wrap: wrap; }

/* Íconos dentro de recuadros de color de los modales (antes eran emojis) */
.modal-header div[style*="border-radius:8px"] > .ico,
.modal-header div[style*="border-radius: 8px"] > .ico { color: #fff; width: 20px; height: 20px; }
div[style*="border-radius:50%"] > .ico { width: 22px; height: 22px; color: currentColor; }

/* ---------- Etapa 4: contraste y compatibilidad de variables ---------- */
/* Variables que ya usaba el código anterior: se conectan al tema */
:root, body.dark-mode {
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --card-bg: var(--surface);
}

/* Etiquetas de formularios y modales: color de texto normal (no morado) */
body .modal label, body.dark-mode .modal label,
body .modal-body label, body.dark-mode .modal-body label,
body .form-group label, body.dark-mode .form-group label,
body #modal-perfil label, body.dark-mode #modal-perfil label {
    color: var(--text) !important;
    font-weight: 600;
}
body .modal-body .section-title, body.dark-mode .modal-body .section-title { color: var(--text) !important; }

/* Respaldo en modo oscuro: cualquier morado oscuro o gris oscuro fijo que quede en el código
   se aclara para que siempre sea legible sobre fondo oscuro. */
body.dark-mode [style*="color:#7c3aed"]:not(#modal-recibo *), body.dark-mode [style*="color: #7c3aed"]:not(#modal-recibo *),
body.dark-mode [style*="color:#6d28d9"]:not(#modal-recibo *), body.dark-mode [style*="color: #6d28d9"]:not(#modal-recibo *),
body.dark-mode [style*="color:#5b21b6"]:not(#modal-recibo *), body.dark-mode [style*="color: #5b21b6"]:not(#modal-recibo *),
body.dark-mode [style*="color:#4c1d95"]:not(#modal-recibo *), body.dark-mode [style*="color: #4c1d95"]:not(#modal-recibo *),
body.dark-mode [style*="color:#8b5cf6"]:not(#modal-recibo *), body.dark-mode [style*="color: #8b5cf6"]:not(#modal-recibo *) { color: var(--accent) !important; }
body.dark-mode [style*="color:#3b0764"]:not(#modal-recibo *), body.dark-mode [style*="color: #3b0764"]:not(#modal-recibo *),
body.dark-mode [style*="color:#1f2937"]:not(#modal-recibo *), body.dark-mode [style*="color: #1f2937"]:not(#modal-recibo *),
body.dark-mode [style*="color:#374151"]:not(#modal-recibo *), body.dark-mode [style*="color: #374151"]:not(#modal-recibo *),
body.dark-mode [style*="color:#111827"]:not(#modal-recibo *), body.dark-mode [style*="color: #111827"]:not(#modal-recibo *) { color: var(--text) !important; }
body.dark-mode [style*="color:#6b7280"]:not(#modal-recibo *), body.dark-mode [style*="color: #6b7280"]:not(#modal-recibo *),
body.dark-mode [style*="color:#4b5563"]:not(#modal-recibo *), body.dark-mode [style*="color: #4b5563"]:not(#modal-recibo *) { color: var(--text-muted) !important; }
/* Fondos claros fijos en modo oscuro (el recibo se excluye: se ve como el papel impreso) */
body.dark-mode [style*="background:#ffffff"]:not(#modal-recibo *), body.dark-mode [style*="background: #ffffff"]:not(#modal-recibo *),
body.dark-mode [style*="background:#fff;"]:not(#modal-recibo *), body.dark-mode [style*="background: #fff;"]:not(#modal-recibo *),
body.dark-mode [style*="background:white"]:not(#modal-recibo *), body.dark-mode [style*="background: white"]:not(#modal-recibo *) { background: var(--surface) !important; }
body.dark-mode [style*="background:#f9fafb"]:not(#modal-recibo *), body.dark-mode [style*="background:#f5f3ff"]:not(#modal-recibo *),
body.dark-mode [style*="background:#f9f7ff"]:not(#modal-recibo *), body.dark-mode [style*="background:#f3f4f6"]:not(#modal-recibo *),
body.dark-mode [style*="background:#f0fdf4"]:not(#modal-recibo *) { background: var(--surface-2) !important; }

/* Reproductor de música del devoto: íconos SVG */
#reproductor-devoto button .ico { width: 18px; height: 18px; }
#player-play-btn .ico { width: 16px; height: 16px; stroke: none; }

/* ---------- Detalle de cartulinas de un turno ---------- */
:root { --info: #2e90fa; }
.badge-info { background: rgba(46, 144, 250, 0.14); color: var(--info); }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }
.punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.punto-ok { background: var(--success); }
.punto-warn { background: var(--warning); }
.punto-info { background: var(--info); }
.punto-muted { background: var(--text-faint); }
.punto-neutral { background: var(--accent); }

.grupo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
    overflow: hidden;
    flex-shrink: 0; /* la sección es flex en columna: sin esto el grupo se recorta */
}
/* Ningún bloque directo de una sección debe encogerse y recortar su contenido */
.content-section > * { flex-shrink: 0; }
.grupo-ok { border-left-color: var(--success); }
.grupo-warn { border-left-color: var(--warning); }
.grupo-info { border-left-color: var(--info); }
.grupo-muted { border-left-color: var(--text-faint); }
.grupo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.grupo-header h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.grupo-header p { margin: 2px 0 0 !important; font-size: 12px !important; color: var(--text-muted); }
.grupo-body { padding: 12px 16px; }
.grupo-vacio { margin: 0 !important; color: var(--text-faint) !important; font-size: 13px !important; }
/* La tabla dentro del grupo no lleva su propio borde ni sombra */
.grupo-body:has(.grupo-tabla) { padding: 0; }
.grupo-body .grupo-tabla { border: none; box-shadow: none; border-radius: 0; margin: 0; flex: none; overflow-x: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Botón Editar antiguo (.btn-edit) alineado al estilo secundario */
body .btn-edit, body.dark-mode .btn-edit {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
body .btn-edit:hover, body.dark-mode .btn-edit:hover { background: var(--surface-3); transform: none; }

/* ---------- Login con el sistema de diseño (claro y oscuro) ---------- */
html { background: #f5f6f8; }
html:has(body.dark-mode) { background: #0e1014; }
body #login-section, body.dark-mode #login-section {
    background: var(--bg);
    align-items: center;
    padding: 24px 16px;
    box-sizing: border-box;
}
body .login-container, body.dark-mode .login-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin: 0 auto;
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
}
body .login-container h1, body.dark-mode .login-container h1 { color: var(--text); font-size: 24px; }
body .login-container h2, body.dark-mode .login-container h2 { color: var(--text-muted); font-size: 13px; }
body .login-form-group label, body.dark-mode .login-form-group label { color: var(--text); font-weight: 600; font-size: 13px; }
body #login-form input, body.dark-mode #login-form input {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 15px;
}
body #login-form input::placeholder, body.dark-mode #login-form input::placeholder { color: var(--text-faint); }
body #login-form button[type="submit"], body.dark-mode #login-form button[type="submit"] {
    background: var(--accent);
    color: var(--accent-contrast);
    box-shadow: none;
    border-radius: var(--radius-sm);
    transform: none;
}
body #login-form button[type="submit"]:hover, body.dark-mode #login-form button[type="submit"]:hover {
    background: var(--accent-hover);
    transform: none;
    box-shadow: var(--shadow-sm);
}
#btn-crear-cuenta {
    background: transparent !important;
    border: 1px solid var(--border-strong) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 600;
}
#btn-crear-cuenta:hover { background: var(--surface-3) !important; }
/* El logo tiene texto rojo oscuro: en modo oscuro se coloca sobre una placa clara para que se lea */
body.dark-mode .login-logo img {
    background: #ffffff;
    border-radius: 12px;
    padding: 8px;
    box-sizing: border-box;
}
body .error { background: rgba(217, 45, 32, 0.08); border-color: rgba(217, 45, 32, 0.3); color: var(--danger); }

/* ---------- Revisión final: filtros, acciones y estados ---------- */
.filtro-etq { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
/* Filtros de Personal dentro de un control segmentado (antes eran píldoras con degradado) */
body .segmentado .btn-filtro-orden, body .segmentado .btn-filtro-tipo,
body.dark-mode .segmentado .btn-filtro-orden, body.dark-mode .segmentado .btn-filtro-tipo {
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: none;
}
body .segmentado .btn-filtro-orden:last-child, body .segmentado .btn-filtro-tipo:last-child { border-right: none; }
body .segmentado .btn-filtro-orden:hover, body .segmentado .btn-filtro-tipo:hover { background: var(--surface-3); color: var(--text); }
body .segmentado .btn-filtro-orden.active, body .segmentado .btn-filtro-tipo.active,
body.dark-mode .segmentado .btn-filtro-orden.active, body.dark-mode .segmentado .btn-filtro-tipo.active {
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: none;
}
/* Botón de eliminar dentro de tablas: discreto (el rojo intenso queda para la confirmación) */
.btn-texto-peligro {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(217, 45, 32, 0.35);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
}
.btn-texto-peligro:hover { background: rgba(217, 45, 32, 0.08); border-color: var(--danger); }
.badge-neutral { background: var(--accent-soft); color: var(--accent); }
/* Listas sin scroll interno (la página ya hace scroll) */
body .list-container { max-height: none; overflow: visible; }
/* Botón flotante "Marcar Asistencia": acento del tema, sin degradado ni brillo */
body .btn-flotante-asistencia, body.dark-mode .btn-flotante-asistencia {
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 22px;
    animation: none;
}
body .btn-flotante-asistencia:hover, body.dark-mode .btn-flotante-asistencia:hover {
    background: var(--accent-hover);
    transform: none;
}
/* Login: el contenedor del logo medía 80px y la imagen 160px (se encimaba con el título) */
body .login-logo { width: auto !important; height: auto !important; margin: 0 auto 16px !important; background: transparent !important; box-shadow: none !important; }
body .login-logo img { display: block; width: 140px !important; height: 140px !important; }
/* Acciones y estados en tablas: en una sola línea */
.data-table td .acciones-fila { flex-wrap: nowrap; }
.data-table td .badge { white-space: nowrap; }

/* ---------- Ventana de confirmación (mostrarConfirmacion) ----------
   Antes: encabezado amarillo con degradado y título café (estilos de styles.css).
   Ahora: igual que el resto de ventanas del tema, en claro y oscuro. */
body .modal-content.modal-confirmacion,
body.dark-mode .modal-content.modal-confirmacion {
    background: var(--surface);
    max-width: 460px;
}
body .modal-content.modal-confirmacion .modal-header,
body.dark-mode .modal-content.modal-confirmacion .modal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
body .modal-content.modal-confirmacion .modal-header h2,
body.dark-mode .modal-content.modal-confirmacion .modal-header h2 {
    color: var(--text);
}
body .modal-content.modal-confirmacion .modal-body,
body.dark-mode .modal-content.modal-confirmacion .modal-body {
    background: var(--surface);
}
body #confirmacion-mensaje,
body.dark-mode #confirmacion-mensaje {
    color: var(--text) !important;
    font-size: 15px;
    margin-bottom: 12px;
}
body .confirmacion-detalles,
body.dark-mode .confirmacion-detalles {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 14px 0;
    color: var(--text);
    line-height: 1.6;
}
body .confirmacion-detalles p,
body.dark-mode .confirmacion-detalles p { color: var(--text); margin: 4px 0; }
body .confirmacion-detalles strong,
body.dark-mode .confirmacion-detalles strong { color: var(--text-muted); font-weight: 600; }
body .confirmacion-detalles hr,
body.dark-mode .confirmacion-detalles hr { border-top: 1px solid var(--border); margin: 10px 0; }
/* Botones de ventanas: siempre [Cancelar] [Acción principal] a la derecha,
   sin importar el orden en el HTML (la acción principal o de peligro va al final). */
body .modal .form-actions,
body .modal .modal-pie {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
body .modal .form-actions > .btn-primary,
body .modal .form-actions > .btn-danger,
body .modal .modal-pie > .btn-primary,
body .modal .modal-pie > .btn-danger { order: 2; }

/* ---------- Ventanas de recibo / abono: quitar fondos y colores fijos ---------- */
body #modal-recibo .modal-content,
body #modal-recibo .modal-header,
body.dark-mode #modal-recibo .modal-content,
body.dark-mode #modal-recibo .modal-header { background: var(--surface) !important; }
body #modal-recibo .modal-header h2,
body.dark-mode #modal-recibo .modal-header h2 { color: var(--text) !important; }
body #modal-abono .modal-body,
body.dark-mode #modal-abono .modal-body { color: var(--text); }

/* ---------- Utilidades para ventanas (modales) ---------- */
/* Pie de botones alineado a la derecha */
.modal-pie { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
/* Avisos con color suave según el tema */
.aviso {
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}
.aviso p { margin: 0; }
.aviso b, .aviso strong { color: inherit; }
.aviso-peligro { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.aviso-peligro .aviso-titulo { color: var(--danger); }
.aviso-info { border-color: color-mix(in srgb, var(--info) 35%, transparent); background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.aviso-ok { border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.aviso-warn { border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.aviso-titulo { font-weight: 700; display: block; margin-bottom: 4px; }
/* Campo de formulario dentro de ventanas */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.campo input, .campo select, .campo textarea { width: 100%; box-sizing: border-box; }
/* Tarjeta plana para datos dentro de ventanas */
.tarjeta-plana { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
/* Título de ventana con tono de peligro (acciones irreversibles) */
body .modal-header h2.titulo-peligro, body.dark-mode .modal-header h2.titulo-peligro { color: var(--danger); }
/* Título de ventanas armadas sin .modal-header */
body .modal-titulo, body.dark-mode .modal-titulo { margin: 0; color: var(--text); font-size: 17px; font-weight: 700; }
body .campo input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body .campo select,
body .campo textarea {
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
}
/* Barra de desplazamiento de ventanas largas: discreta, con los tonos del tema */
body .modal-content::-webkit-scrollbar { width: 8px; }
body .modal-content::-webkit-scrollbar-track { background: transparent; }
body .modal-content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
body .modal-content::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
body .modal-content { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* =====================================================================
   VISTA DEL DEVOTO (respeta el tema claro / oscuro / automático)
   ===================================================================== */
body.devoto-mode, body.devoto-mode .app-container, body.devoto-mode .main-content,
body.devoto-mode #devoto-content { background: var(--bg) !important; }
.devoto-pagina { min-height: 100vh; color: var(--text); }
/* Barra superior fija */
.devoto-topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.devoto-topbar-inner {
    max-width: 760px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.devoto-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.devoto-id img { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.devoto-id-nombre { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.devoto-id-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.devoto-acciones { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.devoto-acciones select { padding: 7px 10px; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); }
.devoto-acciones .btn-secondary { padding: 7px 12px; font-size: 13px; }
/* Columna única de contenido */
.devoto-columna { max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; }
/* Banner: imagen completa, sin recortes ni elementos encima */
.devoto-banner {
    position: relative; border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 18px;
}
.devoto-banner img { display: block; width: 100%; height: auto; transition: opacity 1.2s ease; }
.devoto-banner img.carrusel-img + img.carrusel-img,
.devoto-banner img.carrusel-img ~ img.carrusel-img { position: absolute; inset: 0; height: 100%; object-fit: contain; }
/* Métricas */
.devoto-metricas-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.devoto-metrica { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.devoto-metrica-valor { display: block; font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.2; }
.devoto-metrica-etq { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.devoto-metrica .badge { margin-top: 8px; }
/* Tarjetas */
.devoto-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 18px; }
.devoto-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.devoto-card h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.devoto-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.devoto-dato-etq { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.devoto-dato-val { margin: 3px 0 0; font-size: 15px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
/* Turnos */
.devoto-cortejo-titulo { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; margin: 18px 0 2px; padding-bottom: 8px; border-bottom: 1px solid var(--border-strong); }
.devoto-cortejo-titulo:first-child { margin-top: 0; }
.devoto-cortejo-titulo b { font-size: 13px; color: var(--accent); }
.devoto-cortejo-titulo span { font-size: 12px; color: var(--text-muted); }
.devoto-turno { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.devoto-turno:last-child { border-bottom: none; }
.devoto-turno-nombre { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.devoto-turno-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-muted); }
.devoto-turno-corr { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: var(--accent); }
.devoto-turno-der { text-align: right; flex-shrink: 0; }
.devoto-turno-monto { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.devoto-turno-estado { margin-top: 6px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.devoto-turno-estado .btn-secondary { padding: 4px 10px; font-size: 12px; }
.devoto-total { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.devoto-total span:last-child { font-size: 18px; }
/* Aviso de procesión en vivo */
.devoto-envivo {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer;
    background: color-mix(in srgb, var(--success) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--success) 40%, transparent);
    border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 18px;
}
.devoto-envivo b { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.devoto-envivo b::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 25%, transparent); }
.devoto-envivo p { margin: 3px 0 0; font-size: 13px; color: var(--text-muted); }
.devoto-envivo .flecha { font-size: 26px; color: var(--success); line-height: 1; }
/* Reproductor */
body #reproductor-devoto {
    background: var(--surface) !important; border-top: 1px solid var(--border) !important;
    box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.08) !important;
}
#reproductor-devoto .player-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; display: flex; }
#reproductor-devoto .player-btn:hover { color: var(--text); }
#reproductor-devoto #player-titulo { color: var(--text) !important; }
#reproductor-devoto #player-artista { color: var(--text-muted) !important; }
#reproductor-devoto input[type="range"] { accent-color: var(--accent); }
body #player-lista { background: var(--surface) !important; border: 1px solid var(--border) !important; box-shadow: var(--shadow-lg) !important; }
#player-lista .player-item p:first-child { color: var(--text) !important; }
#player-lista .player-item p:last-child { color: var(--text-muted) !important; }
#player-lista .player-item.activo { background: var(--accent-soft) !important; }
/* Barra de desplazamiento de la página del devoto */
body.devoto-mode .main-content::-webkit-scrollbar,
body.devoto-mode::-webkit-scrollbar { width: 8px; }
body.devoto-mode .main-content::-webkit-scrollbar-thumb,
body.devoto-mode::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
body.devoto-mode .main-content::-webkit-scrollbar-track,
body.devoto-mode::-webkit-scrollbar-track { background: transparent; }
body.devoto-mode .main-content { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
/* Celular */
@media (max-width: 640px) {
    .devoto-topbar-inner { flex-wrap: wrap; }
    .devoto-id img { width: 34px; height: 34px; }
    .devoto-acciones { width: 100%; justify-content: flex-end; }
    .devoto-metricas-grid { gap: 8px; }
    .devoto-metrica { padding: 12px; }
    .devoto-metrica-valor { font-size: 19px; }
    .devoto-datos { grid-template-columns: 1fr; }
    .devoto-card { padding: 16px; }
    .devoto-turno { flex-direction: column; gap: 8px; }
    .devoto-turno-der { text-align: left; }
    .devoto-turno-estado { justify-content: flex-start; }
}
/* Prioridad sobre ".content-section p" de styles.css (que pintaba los textos en gris) */
#devoto-content .devoto-id-nombre, #devoto-content .devoto-turno-nombre, #devoto-content .devoto-turno-monto,
#devoto-content .devoto-dato-val, #devoto-content .devoto-card h3 { color: var(--text); }
#devoto-content .devoto-id-sub, #devoto-content .devoto-turno-sub, #devoto-content .devoto-dato-etq,
#devoto-content .devoto-envivo p { color: var(--text-muted); }
#devoto-content .devoto-turno-corr { color: var(--accent); }
#devoto-content p { margin-bottom: 0; }
/* Banner: altura máxima para imágenes altas, sin recortar */
.devoto-banner img { max-height: 62vh; object-fit: contain; }
/* Sin doble línea entre el último turno y el total */
.devoto-turno:has(+ .devoto-total) { border-bottom: none; }
/* Tarjetas del resumen del devoto: detalle y "Próxima fecha" */
#devoto-content .devoto-metrica-sub { display: block; margin-top: 6px; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.devoto-metrica-fecha { cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.devoto-metrica-fecha:hover, .devoto-metrica-fecha:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
#devoto-content .devoto-fecha-nombre { display: block; font-size: 16px; font-weight: 800; color: var(--text); line-height: 1.25; }
#devoto-content .devoto-fecha-link { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--accent); }
/* Calendario de Cuaresma y Semana Santa */
.cal-lista { list-style: none; margin: 0; padding: 0; }
.cal-item { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
.cal-item.pasada { opacity: .5; }
.cal-item.proxima { border-color: var(--accent); background: var(--accent-soft); }
.cal-fecha { width: 48px; flex-shrink: 0; text-align: center; border-right: 1px solid var(--border); padding-right: 12px; }
.cal-fecha b { display: block; font-size: 20px; line-height: 1; color: var(--text); }
.cal-fecha span { display: block; margin-top: 3px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.cal-info { flex: 1; min-width: 0; }
.modal .cal-nombre { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.modal .cal-desc { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); text-transform: none; }
.cal-desc::first-letter { text-transform: uppercase; }
@media (max-width: 640px) {
    #devoto-content .devoto-fecha-nombre { font-size: 14px; }
}
#devoto-content .devoto-fecha-faltan { display: block; margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--text); }

/* =====================================================================
   CELULAR (≤ 640 px): tablas reducidas con menú ⋮, encabezado compacto,
   filtros ordenados y márgenes parejos. En computadora no cambia nada.
   ===================================================================== */
/* Menú ⋮ (lo arma tabla-movil.js); fuera del celular no existe */
.kebab-celda { width: 44px; text-align: right; }
.kebab-btn {
    width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent; border-radius: 8px;
    color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0;
}
.kebab-btn:hover, .kebab-btn[aria-expanded="true"] { background: var(--surface-3); border-color: var(--border); color: var(--text); }
.kebab-lista {
    display: none; position: fixed; z-index: 3000; min-width: 190px; max-width: 80vw;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 6px; flex-direction: column;
}
.kebab-lista.abierta { display: flex; }
body .kebab-lista .kebab-item,
body.dark-mode .kebab-lista .kebab-item {
    display: block !important; width: 100% !important; text-align: left !important;
    background: transparent !important; border: none !important; box-shadow: none !important;
    color: var(--text) !important; font-size: 14px !important; font-weight: 500 !important;
    padding: 11px 12px !important; margin: 0 !important; border-radius: 6px !important;
    min-height: 0 !important; white-space: nowrap; transform: none !important;
}
body .kebab-lista .kebab-item:hover { background: var(--surface-2) !important; }
body .kebab-lista .kebab-peligro { color: var(--danger) !important; order: 99; border-top: 1px solid var(--border) !important; border-radius: 0 0 6px 6px !important; }

/* Selector de tema dentro del menú lateral (solo celular) */
.sidebar-tema { display: none; }

@media (max-width: 640px) {
    /* --- Tablas --- */
    body .data-table th, body .data-table td,
    body.dark-mode .data-table th, body.dark-mode .data-table td {
        max-width: none !important; font-size: 13px !important; padding: 10px 8px !important;
        white-space: normal; overflow-wrap: anywhere;
    }
    body .data-table.tabla-movil { width: 100%; min-width: 0 !important; }
    body .data-table .col-oculta-movil { display: none !important; }
    body .data-table th.kebab-celda, body .data-table td.kebab-celda { width: 44px; padding: 4px !important; vertical-align: middle; }
    body .data-table:not(.tabla-movil-con-menu) .kebab-celda { display: none !important; }
    body .table-container { overflow-x: hidden; }
    body .data-table td .badge { white-space: nowrap; }
    body .data-table td .btn-primary, body .data-table td .btn-secondary { white-space: nowrap; }

    /* --- Márgenes parejos del contenido --- */
    body .main-content, body.dark-mode .main-content { padding: 14px 12px 80px !important; }

    /* --- Encabezado en una sola fila --- */
    body header, body.dark-mode header {
        flex-wrap: nowrap !important; gap: 8px; padding: 8px 10px !important;
    }
    body header .menu-toggle { flex-shrink: 0; order: 0; margin: 0; }
    body header .header-brand { flex: 1 1 auto !important; min-width: 0; margin: 0 !important; order: 1; gap: 8px !important; }
    body header .header-brand img { width: 32px !important; height: 32px !important; }
    body header h1 { font-size: 14px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
    body header .user-info { order: 2; flex-shrink: 0; gap: 4px !important; flex-wrap: nowrap; }
    body header .user-info .theme-select, body header .user-info #user-name { display: none !important; }
    body header .user-info button {
        font-size: 0 !important; width: 38px; height: 38px; min-height: 38px !important;
        padding: 0 !important; display: inline-flex; align-items: center; justify-content: center;
    }
    body header .user-info button .ico { width: 18px; height: 18px; margin: 0; }
    body header .user-info button[style*="display: none"] { display: none !important; }

    /* Selector de tema en el menú lateral */
    .sidebar-tema { display: block; padding: 10px 12px 4px; }
    .sidebar-tema select { width: 100%; padding: 9px 10px; font-size: 14px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); }

    /* --- Filtros: cada grupo en su línea, buscador a todo el ancho --- */
    body .barra-acciones { flex-wrap: wrap; gap: 8px; }
    body .barra-acciones > input[type="text"], body .barra-acciones > input[type="search"] {
        flex: 1 1 100% !important; max-width: none !important; min-width: 0 !important;
    }
    body .barra-acciones > select, body .barra-acciones > input[type="date"] { flex: 1 1 45%; min-width: 0; }
    body .barra-acciones > .filtro-etq { flex: 1 1 100%; margin: 6px 0 0; }
    body .barra-acciones > .segmentado { flex: 1 1 100%; display: flex; flex-wrap: wrap; }
    body .barra-acciones > .segmentado > button { flex: 1 1 auto; }
    body .barra-acciones > button[style*="margin-left:auto"], body .barra-acciones > button[style*="margin-left: auto"] { margin-left: 0 !important; }
    body .pagina-encabezado { flex-wrap: wrap; gap: 10px; }
    body .pagina-encabezado .barra-acciones { width: 100%; }
}
@media (max-width: 640px) {
    /* Logo y título visibles en el encabezado (styles.css los ocultaba) */
    body header .header-brand img { display: block !important; }
    body header .header-brand h1 { display: block !important; }
    /* Encabezados de tabla: no partir palabras letra por letra */
    body .data-table th, body.dark-mode .data-table th {
        font-size: 11px !important; word-break: normal !important; overflow-wrap: normal !important; white-space: nowrap;
    }
    body .data-table td { word-break: normal !important; overflow-wrap: anywhere !important; }
    /* La tabla crece con su contenido: sin barra de desplazamiento interna */
    body .table-container, body.dark-mode .table-container {
        flex: none !important; max-height: none !important; overflow: hidden !important;
    }
    /* El menú lateral abierto no queda debajo del botón ☰ */
    body .sidebar.active { padding-top: 58px !important; }
    /* Filtros segmentados más compactos */
    body .barra-acciones > .segmentado > button { padding: 8px 10px; font-size: 13px; }
}
@media (max-width: 640px) {
    /* Montos y números completos en una línea */
    body .data-table td.num, body .data-table th.num { white-space: nowrap; overflow-wrap: normal !important; }
}
/* Lista de cortejos: más compacta para que quepan las tres acciones sin desplazar */
body .data-table.tabla-cortejos th, body .data-table.tabla-cortejos td { padding: 11px 8px; }
body .data-table.tabla-cortejos th { white-space: normal; line-height: 1.3; font-size: 11px; letter-spacing: 0.02em; }
body .data-table.tabla-cortejos td:first-child { min-width: 150px; }
body .data-table.tabla-cortejos td:last-child { width: 1%; }
body .data-table.tabla-cortejos td:last-child .acciones-fila { flex-wrap: nowrap; gap: 4px; }
body .data-table.tabla-cortejos td:last-child .acciones-fila button { padding: 4px 8px !important; }
@media (min-width: 641px) and (max-width: 1280px) {
    body .data-table.tabla-cortejos th, body .data-table.tabla-cortejos td { padding: 9px 6px; font-size: 13px; }
    body .data-table.tabla-cortejos th { font-size: 10.5px; letter-spacing: 0; }
}
