/* ============================================================
   DyRcañada — estilos. Diseño de alto contraste y accesible.
   Pensado para PC, tablet y móvil. Fuentes grandes y legibles.
   ============================================================ */
:root {
    --primary: #4f46e5; --primary-dark: #3730a3; --primary-soft: #e8e7fb;
    --success: #059669; --success-soft: #d1fae5;
    --danger: #dc2626;  --danger-soft: #fee2e2;
    --warning: #d97706; --warning-soft: #fef3c7;
    --info: #2563eb;    --info-soft: #dbeafe;
    --whatsapp: #1fae55;
    --bg: #eef1f8; --card: #ffffff; --text: #0b1220; --text-muted: #475569;
    --border: #d3dae8; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 2px 8px rgba(15,23,42,.06);
    --shadow-lg: 0 12px 30px rgba(15,23,42,.14); --radius: 14px;
    --grad: linear-gradient(135deg, #4f46e5, #7c3aed);
    --fs-base: 16px;
}
:root[data-theme="dark"] {
    --primary: #7c78f0; --primary-dark: #6d69e6; --primary-soft: #262a48;
    --success: #34d399; --success-soft: #10331f;
    --danger: #f87171;  --danger-soft: #3a1717;
    --warning: #fbbf24; --warning-soft: #3a2c0c;
    --info: #60a5fa;    --info-soft: #14263f;
    --whatsapp: #25D366;
    --bg: #0b1120; --card: #161d31; --text: #f2f5fb; --text-muted: #a7b2c8;
    --border: #29324c; --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-lg: 0 12px 30px rgba(0,0,0,.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: var(--fs-base); }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.6;
    -webkit-font-smoothing: antialiased; transition: background .25s, color .25s;
    font-size: 1rem;
    background-image: radial-gradient(1100px 480px at 100% -5%, rgba(202,165,58,.06), transparent 60%);
    background-attachment: fixed;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* LAYOUT */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 258px; background: var(--card); border-right: 1px solid var(--border);
    padding: 22px 14px; position: fixed; height: 100vh; overflow-y: auto; z-index: 100;
}
.main-content { flex: 1; margin-left: 258px; padding: 32px; max-width: 100%; }

.logo { display: flex; align-items: center; gap: 12px; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
/* Cabecera de marca (negro + dorado) en el sidebar, igual en ambos temas */
.sidebar .logo {
    background: linear-gradient(135deg, #0b0b12 0%, #1b1526 100%);
    border: 1px solid #2b2742; border-bottom: 3px solid #caa53a;
    border-radius: 14px; padding: 14px 14px; margin: 0 0 22px;
    box-shadow: var(--shadow);
}
.sidebar .logo .logo-word b { color: #ffffff; }
.sidebar .logo .logo-word small { color: #c7b273; }
.logo-icon { width: 42px; height: 42px; background: var(--grad); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; flex-shrink: 0; }
.logo-mark { width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0; }
.logo-word { display: flex; flex-direction: column; line-height: 1.05; }
.logo-word b { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; }
.logo-word small { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.oro { background: linear-gradient(180deg, #fdeeb0, #e6c24c 55%, #a9791c);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }

.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 13px; color: var(--text-muted);
    text-decoration: none; border-radius: 10px; margin-bottom: 3px; font-size: 1rem; font-weight: 600;
    transition: background .15s, color .15s; position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: inset 3px 0 0 #caa53a, var(--shadow); }
.nav-item i { width: 22px; text-align: center; font-size: 1.05rem; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 800; min-width: 22px; height: 22px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.nav-item.active .nav-badge { background: #fff; color: var(--danger); }

/* HEADERS */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.page-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; }
.page-subtitle { color: var(--text-muted); font-size: .95rem; margin-top: 4px; }

/* CARDS */
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--border); }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 12px; font-size: 1.15rem; }
.stat-label { font-size: .9rem; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat-sub { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }

/* BUTTONS (touch-friendly) */
.btn { min-height: 44px; padding: 11px 18px; border: none; border-radius: 11px; font-weight: 700; cursor: pointer; font-size: .95rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, transform .1s, box-shadow .15s; font-family: inherit; text-decoration: none; line-height: 1; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-lg); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border: 2px solid var(--border); }
.btn-ghost:hover { background: var(--bg); border-color: var(--primary); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; }
.btn-sm.btn-icon { width: 34px; min-height: 34px; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .9rem; font-weight: 700; margin-bottom: 7px; color: var(--text); }
.form-control { width: 100%; min-height: 46px; padding: 11px 14px; border: 2px solid var(--border); border-radius: 10px; font-size: 1rem; font-family: inherit; background: var(--card); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
textarea.form-control { min-height: 100px; resize: vertical; }

/* TABLES */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 13px 16px; font-size: .8rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--border); }
td { padding: 15px 16px; border-bottom: 1px solid var(--border); font-size: .95rem; }
tbody tr:hover { background: var(--bg); }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px; font-size: .8rem; font-weight: 700; gap: 4px; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

/* CUOTAS */
.cuotas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.cuota-card { padding: 16px; border-radius: 12px; border: 2px solid var(--border); background: var(--card); cursor: pointer; transition: transform .12s, box-shadow .15s; position: relative; }
.cuota-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.cuota-card.pendiente { border-color: var(--danger); background: var(--danger-soft); }
.cuota-card.vencida { border-color: var(--danger); background: var(--danger-soft); }
.cuota-card.pagada { border-color: var(--success); background: var(--success-soft); }
.cuota-card.parcial { border-color: var(--warning); background: var(--warning-soft); }
.cuota-numero { font-size: .82rem; color: var(--text-muted); font-weight: 700; }
.cuota-monto { font-size: 1.25rem; font-weight: 800; margin: 4px 0; }
.cuota-fecha { font-size: .82rem; color: var(--text-muted); }
.pagadas-det { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.pagadas-det summary { cursor: pointer; font-weight: 800; font-size: 1rem; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--text-muted); padding: 6px 0; }
.pagadas-det summary::-webkit-details-marker { display: none; }
.pagadas-det .chev { transition: transform .2s; margin-left: auto; }
.pagadas-det[open] .chev { transform: rotate(90deg); }

/* ALERTAS */
.alerta-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 12px; margin-bottom: 8px; border-left: 5px solid; background: var(--card); gap: 12px; flex-wrap: wrap; }
.alerta-item.hoy { border-color: var(--warning); background: var(--warning-soft); }
.alerta-item.manana { border-color: var(--info); background: var(--info-soft); }
.alerta-item.vencida { border-color: var(--danger); background: var(--danger-soft); }
.alerta-info { flex: 1; min-width: 180px; }
.alerta-nombre { font-weight: 800; font-size: 1rem; }
.alerta-detalle { font-size: .9rem; color: var(--text-muted); margin-top: 2px; }
.alerta-actions { display: flex; gap: 8px; }

/* RECORDATORIOS (centro de mensajes) */
.reco-grupo { border-left: 6px solid var(--border); }
.reco-grupo.g-bad { border-left-color: var(--danger); }
.reco-grupo.g-hoy { border-left-color: var(--warning); }
.reco-grupo.g-man { border-left-color: var(--info); }
.reco-grupo.g-pas { border-left-color: var(--primary); }
.reco-item { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--bg); flex-wrap: wrap; }
.reco-item.reco-enviado { opacity: .55; }
.reco-info { flex: 1; min-width: 200px; }
.reco-nombre { font-weight: 800; font-size: 1.05rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reco-msg { margin-top: 6px; font-size: .9rem; color: var(--text-muted); }
.reco-msg summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.reco-msg p { margin-top: 6px; background: var(--card); border: 1px dashed var(--border); border-radius: 8px; padding: 10px; }
.reco-actions .btn { min-width: 120px; }
.ocultar-enviados .reco-item.reco-enviado { display: none; }
.ocultar-enviados .reco-grupo.grupo-todos-enviados { display: none; }

/* PROGRESO / RIESGO / RANKING */
.progress { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--success); border-radius: 999px; transition: width .3s; }
.riesgo-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.riesgo-ok { background: var(--success); } .riesgo-warn { background: var(--warning); } .riesgo-bad { background: var(--danger); }
.rank-list { list-style: none; }
.rank-list li { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: .95rem; }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(2,6,23,.6); z-index: 1000; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal { background: var(--card); border-radius: var(--radius); padding: 24px; max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 1.2rem; font-weight: 800; }

/* TOOLBAR / SEARCH */
.toolbar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: flex-end; }
.search-box { flex: 1; min-width: 240px; position: relative; }
.search-box input { width: 100%; min-height: 46px; padding: 11px 14px 11px 42px; border: 2px solid var(--border); border-radius: 11px; background: var(--card); color: var(--text); font-size: 1rem; }
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* CALENDARIO */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { margin-bottom: 6px; }
.cal-dow { text-align: center; font-size: .78rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; }
.cal-cell { min-height: 96px; border: 1px solid var(--border); border-radius: 10px; padding: 5px; background: var(--card); }
.cal-empty { border: none; background: transparent; }
.cal-hoy { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.cal-num { font-size: .8rem; font-weight: 800; color: var(--text-muted); margin-bottom: 4px; }
.cal-num-link { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer; color: var(--primary); font-family: inherit; font-size: .8rem; font-weight: 800; margin-bottom: 4px; padding: 0; }
.cal-num-link:hover { text-decoration: underline; }
.cal-ev { display: block; font-size: .68rem; font-weight: 700; padding: 3px 5px; border-radius: 5px; margin-bottom: 3px; text-decoration: none; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-pend { background: var(--info); } .ev-bad { background: var(--danger); } .ev-warn { background: var(--warning); } .ev-ok { background: var(--success); }
.ev-pend-dot { background: var(--info); }

/* ANIMACIONES / SKELETON */
.card, .stat-card { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.skeleton { position: relative; overflow: hidden; background: var(--border); border-radius: 8px; min-height: 16px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* LOGIN (fondo profesional negro + dorado) */
.login-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
    background:
        radial-gradient(900px 420px at 50% -8%, rgba(230,194,76,.16), transparent 62%),
        radial-gradient(700px 500px at 100% 110%, rgba(124,58,237,.10), transparent 60%),
        linear-gradient(160deg, #0a0a10 0%, #15111f 55%, #0a0a10 100%);
    background-attachment: fixed;
}
.login-card {
    background: #14141c; color: #f2f5fb;
    border: 1px solid #2a2740; border-top: 3px solid #caa53a;
    box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.login-card .form-label { color: #e7e9f2; }
.login-card .form-control { background: #0f0f17; color: #f2f5fb; border-color: #2a2740; }
.login-card .form-control:focus { border-color: #caa53a; box-shadow: 0 0 0 4px rgba(202,165,58,.18); }

/* BANNER DE MENSAJES PENDIENTES (imposible de no ver) */
.banner-pend {
    position: sticky; top: 0; z-index: 90;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin: -8px 0 20px; padding: 14px 18px; border-radius: 12px;
    background: linear-gradient(135deg, #dc2626, #ea580c); color: #fff;
    box-shadow: var(--shadow-lg); border: 2px solid #fff2;
    animation: bannerPulse 1.8s ease-in-out infinite;
}
.banner-pend .banner-ico { font-size: 1.4rem; }
.banner-pend .banner-txt { font-size: 1.1rem; font-weight: 700; flex: 1; min-width: 180px; }
.banner-pend .banner-txt b { font-size: 1.25rem; }
.banner-pend .btn-whatsapp { background: #fff; color: #128a3e; font-weight: 800; }
.banner-pend .banner-x { background: none; border: none; color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; opacity: .85; }
.banner-pend .banner-x:hover { opacity: 1; }
@keyframes bannerPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); } }
.fa-shake { animation: shake 1s ease-in-out infinite; display: inline-block; }
@keyframes shake { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(6deg); } }

/* TOAST */
.toast { position: fixed; bottom: 22px; right: 22px; padding: 14px 20px; border-radius: 12px; background: #0b1220; color: #fff; box-shadow: var(--shadow-lg); z-index: 2000; display: flex; align-items: center; gap: 10px; font-weight: 700; animation: slideIn .3s; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }

/* BARRA SUPERIOR MÓVIL + BOTÓN FLOTANTE */
.topbar { display: none; }
.fab-menu { display: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(2,6,23,.55); z-index: 140; }
.sidebar-backdrop.visible { display: block; }

/* RESPONSIVE: tablet */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; padding: 24px; }
    .page-title { font-size: 1.55rem; }
}
/* RESPONSIVE: móvil */
@media (max-width: 768px) {
    .topbar {
        display: flex; align-items: center; gap: 12px;
        position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 150;
        padding: 0 14px; background: linear-gradient(135deg, #0b0b12, #1b1526);
        border-bottom: 3px solid #caa53a; box-shadow: 0 4px 14px rgba(0,0,0,.35);
    }
    /* Hamburguesa GRANDE, dorada, con texto "Menú" */
    .topbar .menu-toggle {
        display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
        border-radius: 24px; border: none; cursor: pointer; font-family: inherit;
        background: linear-gradient(180deg, #f3d873, #c99a2e); color: #0b0b12;
        font-size: 1.05rem; font-weight: 800; box-shadow: 0 2px 8px rgba(0,0,0,.35);
    }
    .topbar .menu-toggle:active { transform: scale(.96); }
    .topbar-brand { color: #fff; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; margin-left: auto; }
    /* Botón flotante redondo (siempre a mano con el pulgar) */
    .fab-menu {
        display: flex; align-items: center; justify-content: center;
        position: fixed; bottom: 22px; left: 22px; width: 62px; height: 62px; border-radius: 50%;
        background: linear-gradient(135deg, #f3d873, #c99a2e); color: #0b0b12; font-size: 1.5rem;
        border: 3px solid #0b0b12; box-shadow: 0 8px 22px rgba(0,0,0,.45); cursor: pointer; z-index: 155;
        animation: fabPulse 2.2s ease-in-out infinite;
    }
    .fab-menu:active { transform: scale(.94); }
    @keyframes fabPulse { 0%,100% { box-shadow: 0 8px 22px rgba(0,0,0,.45), 0 0 0 0 rgba(202,165,58,.5); } 50% { box-shadow: 0 8px 22px rgba(0,0,0,.45), 0 0 0 10px rgba(202,165,58,0); } }
    .sidebar { top: 0; z-index: 160; transform: translateX(-100%); transition: transform .28s; box-shadow: var(--shadow-lg); width: 82%; max-width: 320px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar .nav-item { padding: 15px 14px; font-size: 1.05rem; }
    .main-content { margin-left: 0; padding: 16px; padding-top: 80px; }
    .cuotas-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .cal-cell { min-height: 62px; }
    .cal-ev { font-size: .6rem; }
    /* Tablas -> tarjetas */
    table.responsive thead { display: none; }
    table.responsive tr { display: block; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 4px; background: var(--card); }
    table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: none; padding: 9px 12px; text-align: right; }
    table.responsive td::before { content: attr(data-label); font-weight: 800; color: var(--text-muted); text-align: left; }
    table.responsive td:empty { display: none; }
}

/* Encabezado de marca solo al imprimir */
.print-header { display: none; }
.print-header img { width: 54px; height: 54px; }
.print-header .marca { font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }

/* IMPRESIÓN */
@media print {
    .sidebar, .topbar, .fab-menu, .sidebar-backdrop, .no-print, .btn, .banner-pend, .page-header a, form.toolbar { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .print-header { display: flex !important; align-items: center; gap: 12px; padding: 0 0 12px; margin-bottom: 12px; border-bottom: 2px solid #caa53a; }
}
