/* ============================================================
   Panel Encuesta 9009 — estilos
   Estética: consola de telemetría / sala de control, sobria y legible.
   ============================================================ */

:root {
    --ink:        #0f1b2d;
    --ink-2:      #16263d;
    --surface:    #f4f6f9;
    --card:       #ffffff;
    --border:     #e3e7ee;
    --border-2:   #eef1f6;
    --text:       #16263d;
    --text-soft:  #5b6675;
    --muted:      #8a94a3;

    --brand:      #0891b2;
    --brand-deep: #155e75;
    --good:       #16a34a;
    --warn:       #d97706;
    --danger:     #dc2626;

    --radius:     14px;
    --radius-sm:  9px;
    --shadow:     0 1px 2px rgba(15,27,45,.05), 0 8px 24px -16px rgba(15,27,45,.25);
    --shadow-sm:  0 1px 2px rgba(15,27,45,.06);

    --font-display: 'Space Grotesk', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --font-body:    'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    --font-mono:    'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    line-height: 1.45;
    font-size: 15px;
}

code { font-family: var(--font-mono); font-size: .9em; }

/* ----------------------------- Top bar ----------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
    color: #eaf0f7;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar__brand { display: flex; align-items: center; gap: 14px; }
.topbar__title { display: block; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.topbar__subtitle { display: block; font-size: 12px; color: #9fb0c4; margin-top: 1px; }
.topbar__meta { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #b9c6d6; }
.topbar__host { font-family: var(--font-mono); color: #d6e0ec; }
.topbar__clock { font-variant-numeric: tabular-nums; }

/* Glifo de señal animado */
.topbar__signal { display: inline-flex; align-items: flex-end; gap: 3px; height: 24px; }
.topbar__signal i {
    width: 4px; border-radius: 2px; background: var(--brand);
    animation: pulse 1.8s ease-in-out infinite;
}
.topbar__signal i:nth-child(1) { height: 8px;  animation-delay: 0s; }
.topbar__signal i:nth-child(2) { height: 14px; animation-delay: .15s; }
.topbar__signal i:nth-child(3) { height: 20px; animation-delay: .3s; }
.topbar__signal i:nth-child(4) { height: 24px; animation-delay: .45s; background: #22d3ee; }
@keyframes pulse { 0%,100% { opacity:.45; } 50% { opacity:1; } }

.badge {
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: rgba(8,145,178,.18); color: #67e8f9; border: 1px solid rgba(34,211,238,.3);
}

/* ----------------------------- Layout ----------------------------- */
.page { max-width: 1280px; margin: 0 auto; padding: 22px 24px 40px; }

.footer {
    max-width: 1280px; margin: 0 auto; padding: 0 24px 28px;
    color: var(--muted); font-size: 12.5px;
}

/* ----------------------------- Filtro ----------------------------- */
.filterbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}
.filterbar__dates { display: flex; align-items: flex-end; gap: 10px; }
.filterbar__presets { display: flex; gap: 6px; }
.filterbar__right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.filterbar__range {
    font-family: var(--font-display); font-weight: 600; font-size: 14px;
    color: var(--brand-deep); background: #ecfdff; border: 1px solid #cffafe;
    padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field input[type="date"] {
    font: inherit; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: #fff; color: var(--text); min-width: 150px;
}
.field input[type="date"]:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 600; cursor: pointer;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-deep); }
.btn--ghost { background: #fff; color: var(--brand-deep); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--brand); background: #f0fdff; }

.chip {
    font-size: 13px; font-weight: 500; color: var(--text-soft);
    padding: 7px 12px; border-radius: 999px; text-decoration: none;
    border: 1px solid var(--border); background: #fff;
}
.chip:hover { border-color: var(--brand); color: var(--brand-deep); }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ----------------------------- Banner ----------------------------- */
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner--warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ----------------------------- KPIs ----------------------------- */
.kpis {
    display: grid; gap: 14px; margin-bottom: 18px;
    grid-template-columns: repeat(6, 1fr);
}
.kpi {
    position: relative; overflow: hidden;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 16px 14px; box-shadow: var(--shadow-sm);
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--muted); }
.kpi--accent::before { background: var(--brand); }
.kpi--good::before   { background: var(--good); }
.kpi--warn::before   { background: var(--warn); }
.kpi__label { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; }
.kpi__value {
    display: block; font-family: var(--font-display); font-weight: 700;
    font-size: 30px; line-height: 1.1; margin: 8px 0 6px; color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.kpi__foot { display: block; font-size: 12.5px; color: var(--muted); }
.kpi__foot strong { color: var(--text); font-weight: 600; }

/* ----------------------------- Paneles ----------------------------- */
.panel {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.panel__head { margin-bottom: 14px; }
.panel__title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--ink); }
.panel__hint { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

/* ----------------------------- Embudo ----------------------------- */
.funnel__stages { display: flex; flex-direction: column; gap: 12px; }
.stage__top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.stage__index {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 7px;
    background: var(--ink); color: #fff; font-size: 12px; font-weight: 600;
    font-family: var(--font-display); flex: 0 0 auto;
}
.stage__label { font-weight: 600; color: var(--text); }
.stage__value {
    margin-left: auto; font-family: var(--font-display); font-weight: 700;
    font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.stage__bar { height: 12px; background: var(--border-2); border-radius: 999px; overflow: hidden; }
.stage__fill {
    display: block; height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-deep), var(--brand));
    transition: width .6s cubic-bezier(.2,.7,.2,1);
}
.stage__foot { display: flex; gap: 14px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.stage__conv { color: var(--text-soft); }

/* ----------------------------- Grillas ----------------------------- */
.grid { display: grid; gap: 18px; margin-bottom: 0; }
.grid--charts { grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; }
.grid--two { grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
.panel--wide { grid-column: span 3; }

.chartbox { position: relative; height: 240px; }
.chartbox--donut { height: 250px; }
.chartbox--tall { height: 300px; }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }

/* ----------------------------- Tablas ----------------------------- */
.tablewrap { overflow-x: auto; }
.ltable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ltable th {
    text-align: left; font-weight: 600; color: var(--text-soft);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
    padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.ltable td { padding: 9px 10px; border-bottom: 1px solid var(--border-2); }
.ltable tbody tr:last-child td { border-bottom: 0; }
.ltable tbody tr:hover { background: #f8fafc; }
.ltable .num { text-align: right; font-variant-numeric: tabular-nums; }
.ltable .muted { color: var(--muted); }
.ltable--calls td { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

.pill {
    display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
    color: var(--c, #475569);
    background: color-mix(in srgb, var(--c, #94a3b8) 14%, white);
    border: 1px solid color-mix(in srgb, var(--c, #94a3b8) 35%, white);
}

/* ----------------------------- CDR ----------------------------- */
.cdr { display: grid; grid-template-columns: 1fr 1.1fr; gap: 18px; align-items: start; }
.cdr__cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ministat { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.ministat__label { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.ministat__value { display: block; font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ----------------------------- Error ----------------------------- */
.errorbox {
    max-width: 560px; margin: 60px auto; text-align: center;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 34px; box-shadow: var(--shadow);
}
.errorbox__icon {
    width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%;
    background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
    display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700;
}
.errorbox__title { font-family: var(--font-display); margin: 0 0 8px; color: var(--ink); }
.errorbox__msg { color: var(--text-soft); font-size: 14px; }
.errorbox__hints { text-align: left; margin: 18px auto; max-width: 460px; color: var(--text-soft); font-size: 13.5px; }
.errorbox__hints li { margin: 6px 0; }

/* ----------------------------- Responsive ----------------------------- */
@media (max-width: 1080px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .grid--charts { grid-template-columns: 1fr 1fr; }
    .panel--wide { grid-column: span 2; }
}
@media (max-width: 760px) {
    .page { padding: 16px 14px 32px; }
    .topbar { padding: 12px 14px; }
    .topbar__subtitle { display: none; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .grid--charts, .grid--two, .cdr, .cdr__cards { grid-template-columns: 1fr; }
    .panel--wide { grid-column: span 1; }
    .filterbar__right { margin-left: 0; width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
