/* ============================================================
   GeoCenso · Análisis de Vencimiento
   Cuentas por cobrar por empresa · estilo vanguardista/corporativo
   ============================================================ */

:root {
    --mv-bg: #080c16;
    --mv-bg-card: rgba(255,255,255,.03);
    --mv-border: rgba(255,255,255,.08);
    --mv-chip-bg: rgba(255,255,255,.04);
    --mv-hover: rgba(255,255,255,.05);
    --mv-text: #e5e9f0;
    --mv-text-soft: #94a3b8;
    --mv-text-faint: #64748b;
    --mv-accent: #7dd3fc;
    --mv-shadow: 0 18px 40px -22px rgba(0,0,0,.7);
    --mv-scroll: rgba(255,255,255,.14);
    --mv-verde: #22c55e;
    --mv-amber: #f1c40f;
    --mv-aldia: #f1c40f;
}

body.light-mode {
    --mv-bg: #eef2f7;
    --mv-bg-card: #ffffff;
    --mv-border: #e2e8f0;
    --mv-chip-bg: #f1f5f9;
    --mv-hover: #eef2f7;
    --mv-text: #0f172a;
    --mv-text-soft: #475569;
    --mv-text-faint: #64748b;
    --mv-accent: #0369a1;
    --mv-shadow: 0 18px 40px -26px rgba(15,23,42,.35);
    --mv-scroll: rgba(100,116,139,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(1100px 500px at 15% -10%, rgba(241,196,15,.10), transparent 60%),
        radial-gradient(900px 400px at 100% 0%, rgba(79,70,229,.12), transparent 55%),
        var(--mv-bg);
    color: var(--mv-text);
    overflow: hidden;
    transition: background .3s, color .3s;
}
body.light-mode {
    background:
        radial-gradient(1100px 500px at 15% -10%, rgba(241,196,15,.08), transparent 60%),
        radial-gradient(900px 400px at 100% 0%, rgba(79,70,229,.08), transparent 55%),
        var(--mv-bg);
}

.mv-board { height: 100vh; width: 100%; display: flex; flex-direction: column; padding: 12px 18px 12px; }

/* ---------- Barra superior ---------- */
.mv-topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
    padding-bottom: 12px; border-bottom: 1px solid var(--mv-border); margin-bottom: 14px;
}
.mv-brand { display: flex; align-items: center; gap: 11px; }
.mv-logo {
    width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 19px; background: linear-gradient(135deg, #b45309, #f59e0b 55%, #4F46E5);
    box-shadow: 0 0 20px -4px rgba(245,158,11,.7);
}
.mv-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.mv-subtitle { font-size: 11px; color: var(--mv-text-soft); margin-top: 1px; }

.mv-update-badge {
    display: flex; align-items: center; gap: 9px; padding: 6px 12px; border-radius: 12px;
    background: var(--mv-chip-bg); border: 1px solid var(--mv-border);
}
.mv-update-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mv-verde); box-shadow: 0 0 10px 1px rgba(34,197,94,.7); animation: pulseV 2s infinite; }
@keyframes pulseV { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.55);} 50% { box-shadow: 0 0 0 6px rgba(34,197,94,0);} }
.mv-update-lbl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--mv-text-faint); }
.mv-update-val { font-size: 13px; font-weight: 800; color: var(--mv-accent); }

.mv-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.mv-chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px; background: var(--mv-chip-bg); border: 1px solid var(--mv-border);
}
.mv-chip b { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mv-chip.deuda b { color: var(--mv-verde); }
.mv-chip.aldia b { color: #b45309; }

.mv-controls { display: flex; align-items: center; gap: 10px; }
.mv-clock {
    font-family: 'SF Mono', ui-monospace, monospace; font-size: 20px; font-weight: 700;
    letter-spacing: .02em; color: #c7d2fe; text-shadow: 0 0 16px rgba(129,140,248,.45);
}
.mv-auto { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--mv-text-soft); cursor: pointer; user-select: none; }
.mv-auto input { accent-color: #f59e0b; }
.mv-btn-ico {
    width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: var(--mv-text); text-decoration: none; background: var(--mv-chip-bg);
    border: 1px solid var(--mv-border); cursor: pointer; transition: background .15s, transform .15s;
}
.mv-btn-ico:hover { background: var(--mv-hover); transform: translateY(-1px); }

/* ---------- Tarjetas por empresa ---------- */
.mv-cards {
    flex: 1; min-height: 0; overflow: auto;
    display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start;
    gap: 14px;
}
.mv-card {
    flex: 0 0 calc((100% - 28px) / 3);
    min-height: min(calc((100% - 14px) / 2), 540px);
    display: flex; flex-direction: column;
    background: var(--mv-bg-card); border: 1px solid var(--mv-border); border-radius: 16px;
    box-shadow: var(--mv-shadow); overflow: hidden; position: relative;
}
.mv-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
    background: linear-gradient(180deg, #f59e0b, #b45309);
}
.mv-card-head {
    display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 14px; border-bottom: 1px solid var(--mv-border);
    background: linear-gradient(135deg, rgba(245,158,11,.12), rgba(79,70,229,.05));
}
.mv-card-name { font-size: 14px; font-weight: 800; color: var(--mv-text); letter-spacing: 0; }
.mv-upd {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
    padding: 4px 10px; border-radius: 999px;
    color: var(--mv-accent); background: var(--mv-chip-bg); border: 1px solid var(--mv-border);
}
.mv-aldia-chip {
    font-size: 10.5px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
    color: #b45309; background: rgba(241,196,15,.16); border: 1px solid rgba(241,196,15,.4);
}

.mv-total { padding: 12px 14px 6px; }
.mv-total span { display: block; font-size: 10px; color: var(--mv-text-faint); text-transform: uppercase; letter-spacing: .06em; }
.mv-total b { font-size: 28px; font-weight: 800; color: var(--mv-verde); font-variant-numeric: tabular-nums; }
.mv-total small { font-size: 11px; color: var(--mv-text-soft); margin-left: 8px; }

/* Barra apilada de envejecimiento */
.mv-aging { padding: 6px 14px 8px; }
.mv-aging-bar { display: flex; height: 20px; width: 100%; border-radius: 6px; overflow: hidden; background: rgba(100,116,139,.15); }
.mv-aging-bar div { height: 100%; transition: width .6s ease; }
.mv-aging-bar div:hover { filter: brightness(1.2); }

/* Detalle Al día / Mora temprana */
.mv-destacado {
    margin: 0 14px 10px; padding: 10px 12px; border-radius: 12px;
    background: linear-gradient(135deg, rgba(241,196,15,.16), rgba(245,158,11,.05));
    border: 1px solid rgba(241,196,15,.35);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px;
}
.mv-destacado .lbl { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--mv-text-soft); }
.mv-destacado b { font-size: 20px; color: #b45309; font-variant-numeric: tabular-nums; }
.mv-destacado .pct { font-size: 11.5px; color: var(--mv-text-soft); font-weight: 700; }
.mv-destacado .pct b { font-size: 14px; }

/* Rangos */
.mv-rangos {
    flex: 1; min-height: 0;
    padding: 2px 14px 12px;
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
}
.mv-rango { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 6px; border-radius: 6px; min-width: 0; }
.mv-rango:hover { background: var(--mv-hover); }
.mv-rango-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.mv-rango-nombre { flex: 1; color: var(--mv-text-soft); min-width: 0; }
.mv-rango-fac { font-size: 10.5px; color: var(--mv-text-faint); }
.mv-rango-monto { font-family: 'SF Mono', ui-monospace, monospace; font-weight: 700; color: var(--mv-text); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.mv-rango-pct { width: 48px; text-align: right; font-weight: 800; color: var(--mv-accent); font-variant-numeric: tabular-nums; }

/* Flash al actualizar */
.mv-flash { animation: mvFlash .6s ease; }
@keyframes mvFlash { 0% { filter: brightness(1.35); } 100% { filter: brightness(1); } }

.mv-footer { text-align: center; font-size: 10px; color: var(--mv-text-faint); margin-top: 10px; }

.mv-cards::-webkit-scrollbar { width: 8px; }
.mv-cards::-webkit-scrollbar-thumb { background: var(--mv-scroll); border-radius: 999px; }
.mv-cards::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .mv-cards { overflow: auto; }
    .mv-card { flex-basis: calc((100% - 14px) / 2); height: auto; min-height: 0; }
}
@media (max-width: 900px) {
    body { overflow: auto; }
    .mv-board { height: auto; min-height: 100vh; }
    .mv-clock { font-size: 16px; }
    .mv-cards { overflow: visible; align-content: flex-start; }
    .mv-card { flex-basis: calc((100% - 14px) / 2); height: auto; min-height: 0; }
}
@media (max-width: 560px) {
    .mv-card { flex-basis: 100%; }
    .mv-rango { flex-wrap: wrap; gap: 4px 8px; }
    .mv-rango-fac { width: 100%; margin-left: 18px; }
    .mv-destacado b { font-size: 17px; }
}
@media (min-width: 2000px) {
    .mv-card { min-height: min(calc((100% - 14px) / 2), 620px); }
}
