:root {
  --ink: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --border: rgba(11,11,11,0.10);
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --accent: #2a78d6;
  --accent-soft: #eaf1fb;
  --slot2: #eb6834;
  --good: #0ca30c;
  --good-soft: #e7f7e7;
  --warning: #fab219;
  --warning-soft: #fff6e1;
  --critical: #d03b3b;
  --critical-soft: #fbe9e9;
  --critical-mid: #eeb3b3;
  --warning-mid: #f2d493;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--page); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #184f95; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 24px 16px; gap: 28px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.sidebar-brand img { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-brand .title { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.sidebar-brand .subtitle { font-size: 11px; color: var(--ink-muted); line-height: 1.2; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: var(--ink-secondary); font-size: 14px; font-weight: 500; cursor: pointer;
}
.sidebar-link:hover { background: var(--page); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-link svg { flex-shrink: 0; }

.main { flex: 1; padding: 32px 40px 56px 40px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 14px; color: var(--ink-secondary); margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.card-pad { padding: 18px 20px; }

.field-label {
  font-size: 11.5px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase;
  letter-spacing: 0.03em; display: block; margin-bottom: 6px;
}
input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; font-family: var(--font); font-size: 13.5px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 8px; font-size: 14px; font-weight: 700;
  cursor: pointer; border: 1px solid transparent; font-family: var(--font);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #184f95; }
.btn-secondary { background: #fff; color: var(--ink-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--page); }
.btn-danger { background: #fff; color: var(--critical); border-color: #f3c6c6; }
.btn-danger:hover { background: var(--critical-soft); }
.btn-block { width: 100%; }

.pill {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-critical { background: var(--critical-soft); color: var(--critical); }

.back-btn {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 16px;
  padding: 5px 10px 5px 8px; border-radius: 20px; border: 1px solid var(--border);
  background: #fff; color: var(--ink-secondary); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s ease; width: fit-content;
}
.back-btn:hover { background: var(--page); }

.flash { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.flash-ok { background: var(--good-soft); color: var(--good); }
.flash-error { background: var(--critical-soft); color: var(--critical); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--ink-muted);
     text-transform: uppercase; letter-spacing: 0.03em; padding: 12px 0; border-bottom: 1px solid var(--gridline); }
td { padding: 13px 0; border-bottom: 1px solid var(--gridline); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-tile { flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
             border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.stat-tile .label { font-size: 12px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-tile .value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

.block-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.block-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px;
                background: var(--page); border-bottom: 1px solid var(--gridline); }
.block-header .name { font-size: 14.5px; font-weight: 700; }
.block-header .note { font-size: 12px; color: var(--ink-muted); margin-top: 1px; }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px;
            border-bottom: 1px solid var(--gridline); }
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--page); }
.item-q { font-size: 13.5px; font-weight: 500; }
.item-hint { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }
.item-peso { color: #b7b5ae; font-weight: 400; }

.seg { display: flex; gap: 6px; flex-shrink: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.seg span {
  display: block; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--ink-secondary); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.seg input:checked + span.v-si { background: var(--good); border-color: var(--good); color: #fff; }
.seg input:checked + span.v-regular { background: var(--warning); border-color: var(--warning); color: #fff; }
.seg input:checked + span.v-no { background: var(--critical); border-color: var(--critical); color: #fff; }
.seg input:checked + span.v-na { background: var(--ink-muted); border-color: var(--ink-muted); color: #fff; }

.critical-card { background: var(--critical-soft); border: 1px solid rgba(208,59,59,0.25); border-radius: 10px; overflow: hidden; }
.critical-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid rgba(208,59,59,0.2); }
.critical-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid rgba(208,59,59,0.2); }
.critical-row:last-child { border-bottom: none; }
.critical-row input { width: 20px; height: 20px; }

.summary-panel { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 32px; align-self: flex-start; }
.summary-total { display: flex; align-items: baseline; gap: 6px; margin-top: 14px; }
.summary-total .n { font-size: 44px; font-weight: 800; }
.summary-total .of { font-size: 16px; color: var(--ink-muted); }
.summary-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 8px 12px; border-radius: 8px; }
.progress-row { padding: 10px 0; border-bottom: 1px solid var(--gridline); }
.progress-row:last-child { border-bottom: none; }
.progress-track { height: 6px; border-radius: 3px; background: var(--gridline); overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--accent); }

.form-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.form-grid > div { flex: 1; min-width: 200px; }

.type-toggle { display: flex; gap: 6px; }
.type-toggle label { flex: 1; }
.type-toggle input { position: absolute; opacity: 0; }
.type-toggle span { display: block; text-align: center; padding: 10px; border-radius: 7px; border: 1px solid var(--border);
                     background: #fff; color: var(--ink-secondary); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.type-toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Agrupa los badges de tipo de llamada en dos bloques (comerciales / soporte),
   cada uno con su propia etiqueta encima, para poder distinguirlos de un
   vistazo ahora que hay más de dos tipos. */
.type-groups { display: flex; gap: 28px; flex-wrap: wrap; }
.type-group { min-width: 220px; }
.type-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
                     color: var(--ink-muted); margin-bottom: 6px; }

.registrar-layout { display: flex; gap: 24px; align-items: flex-start; }
.registrar-checklist { flex: 1; min-width: 0; }

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

/* ---- Tabs (histórico: Resumen / Puntos de mejora) ---- */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--gridline); margin-top: -4px; }
.tab-btn {
  padding: 11px 6px; margin-bottom: -1px; font-size: 14px; font-weight: 700; color: var(--ink-muted);
  border-bottom: 2.5px solid transparent;
}
.tab-btn:hover { color: var(--ink-secondary); }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- Filtros (chips de meses, tipo) ---- */
.filtros { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.filtros .campo { display: flex; flex-direction: column; }

/* ---- Desplegable de meses (multi-selección) ---- */
.mes-dropdown { position: relative; }
.mes-dropdown-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none;
  min-width: 260px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
  font-size: 13.5px; color: var(--ink); cursor: pointer;
}
.mes-dropdown-btn::-webkit-details-marker { display: none; }
.mes-dropdown-btn svg { flex-shrink: 0; color: var(--ink-muted); transition: transform 0.15s ease; }
.mes-dropdown[open] .mes-dropdown-btn svg { transform: rotate(180deg); }
.mes-dropdown-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 260px; max-height: 280px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(11,11,11,0.14);
  padding: 6px; display: flex; flex-direction: column; gap: 1px;
}
.mes-opt { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 6px; font-size: 13.5px; cursor: pointer; }
.mes-opt:hover { background: var(--page); }
.mes-opt input { width: 16px; height: 16px; flex-shrink: 0; margin: 0; cursor: pointer; }
.mes-opt .n { color: var(--ink-muted); font-size: 12px; margin-left: auto; }

.type-toggle-real { display: inline-flex; gap: 6px; background: var(--page); padding: 4px; border-radius: 9px; border: 1px solid var(--border); }
.type-toggle-real label { position: relative; }
.type-toggle-real input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.type-toggle-real span {
  display: block; padding: 8px 20px; border-radius: 6px; color: var(--ink-secondary);
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.type-toggle-real input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(11,11,11,0.08); }
.type-toggle-real .count { color: var(--ink-muted); font-weight: 400; }

.section-note { font-size: 12.5px; color: var(--ink-muted); }

/* ---- Ranking general de bloques (resumen rápido, arriba del detalle) ---- */
.ranking-card { padding: 6px 20px 16px 20px; max-width: 460px; }
.ranking-title { font-size: 13px; font-weight: 700; color: var(--ink-secondary); padding: 14px 0 8px 0; }
.ranking-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--gridline); }
.ranking-row:last-child { border-bottom: none; }
.ranking-rank {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; font-size: 11.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 1px solid transparent;
}
.ranking-name { width: 130px; flex-shrink: 0; font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-track { flex: 1; max-width: 120px; height: 9px; border-radius: 4px; background: var(--gridline); overflow: hidden; display: flex; min-width: 0; }
.ranking-fill-no { height: 100%; background: var(--critical-mid); }
.ranking-fill-regular { height: 100%; background: var(--warning-mid); }
.ranking-n { width: 24px; flex-shrink: 0; text-align: right; font-size: 13.5px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-secondary); }

/* ---- Bloques (desplegables <details>, ordenados de mas a menos fallos) ---- */
.bloque-list { display: flex; flex-direction: column; gap: 12px; }
.bloque-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.bloque-card[open] { box-shadow: 0 1px 3px rgba(11,11,11,0.06); }

.bloque-head {
  display: flex; align-items: center; gap: 18px; padding: 18px 22px; cursor: pointer; list-style: none;
}
.bloque-head::-webkit-details-marker { display: none; }
.bloque-head:hover { background: var(--page); }

.bloque-rank {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
.bloque-rank.sev-alta { background: var(--critical-soft); color: var(--critical); border-color: rgba(208,59,59,0.25); }
.bloque-rank.sev-media { background: var(--warning-soft); color: var(--warning); border-color: rgba(217,154,27,0.3); }
.bloque-rank.sev-baja { background: var(--page); color: var(--ink-muted); border-color: var(--border); }

.bloque-main { flex: 1; min-width: 0; }
.bloque-name { font-size: 16px; font-weight: 800; color: var(--ink); }
.bloque-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 3px; }
.bloque-bar-track { height: 9px; border-radius: 5px; background: var(--gridline); overflow: hidden; margin-top: 10px; display: flex; }
.bloque-bar-no { height: 100%; background: var(--critical-mid); }
.bloque-bar-regular { height: 100%; background: var(--warning-mid); }

.bloque-count { flex-shrink: 0; text-align: center; width: 76px; }
.bloque-count .n { font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.bloque-count .label { font-size: 10.5px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 4px; }

.bloque-chevron { flex-shrink: 0; color: var(--ink-muted); transition: transform 0.15s ease; }
.bloque-card[open] .bloque-chevron { transform: rotate(180deg); color: var(--ink); }

.bloque-body { border-top: 1px solid var(--gridline); background: var(--page); padding: 6px 22px 16px 22px; }

.pregunta-row { padding: 14px 0; border-bottom: 1px solid var(--gridline); }
.pregunta-row:last-child { border-bottom: none; }
.pregunta-top { display: flex; align-items: center; gap: 18px; }
.pregunta-info { flex: 1; min-width: 0; }
.pregunta-q { font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.pregunta-hint { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }
.pregunta-mini-track { height: 5px; border-radius: 3px; background: var(--gridline); overflow: hidden; margin-top: 9px; max-width: 280px; }
.pregunta-mini-fill { height: 100%; border-radius: 3px; background: var(--critical-mid); }

.pregunta-side { flex-shrink: 0; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pregunta-frac { font-size: 12px; color: var(--ink-secondary); font-weight: 600; }
.count-pills { display: flex; gap: 6px; }
.cpill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.cpill-no { background: var(--critical-soft); color: var(--critical); }
.cpill-regular { background: var(--warning-soft); color: var(--warning); }

/* ---- Instancias individuales (fecha + auditoría) ---- */
.instancias { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--gridline); }
.instancia-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-secondary); }
.instancia-valor {
  display: inline-flex; align-items: center; justify-content: center; width: 58px; flex-shrink: 0;
  padding: 2px 0; border-radius: 20px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em;
}
.instancia-valor.no { background: var(--critical-soft); color: var(--critical); }
.instancia-valor.regular { background: var(--warning-soft); color: var(--warning); }
.instancia-fecha { width: 80px; flex-shrink: 0; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.instancia-cod { font-weight: 700; }

.criticos-nota {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 8px;
  background: var(--critical-soft); border: 1px solid rgba(208,59,59,0.15); font-size: 13px; color: var(--ink-secondary);
}
.criticos-nota b { color: var(--critical); }
.criticos-nota ul { margin: 4px 0 0 0; padding-left: 18px; }

/* ---- Enviar por email ---- */
.email-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; }
.email-card .titulo { font-size: 14.5px; font-weight: 700; }
.email-card .sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 3px; }
.carpetas-email { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.carpeta-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-secondary); }
.carpeta-row svg { flex-shrink: 0; color: var(--ink-muted); }
.carpeta-row .n { color: var(--ink-muted); }
.carpeta-row a { font-weight: 600; }

/* ---- Dashboard del auditor: hechas / requeridas ---- */
.cuota-cell { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cuota-cell .n { color: var(--ink); font-weight: 800; }
.cuota-cell .n.zero { font-weight: 400; color: #b0afa5; }
.cuota-cell .n.na { color: var(--critical); }
.cuota-cell .req { color: #c3c2b7; font-weight: 600; }
.cuota-cell.no-aplica { color: #c3c2b7; }
.tabla-cuota tfoot td { border-top: 2px solid var(--gridline); background: #f4f3ef; font-weight: 700; }
.cuota-leyenda { display: flex; gap: 22px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-secondary); margin-top: 12px; align-items: center; }
.cuota-leyenda b { font-weight: 800; }
.dd-wrap { position: relative; }
.dd-btn { font-family: inherit; font-size: 13.5px; padding: 8px 12px; border: 1px solid var(--gridline); border-radius: 8px;
  background: #fff; color: var(--ink); cursor: pointer; min-width: 210px; text-align: left; display: flex; justify-content: space-between; gap: 10px; }
.dd-panel { display: none; position: absolute; right: 0; top: 42px; z-index: 20; background: #fff; border: 1px solid var(--gridline);
  border-radius: 10px; padding: 8px; min-width: 300px; box-shadow: 0 8px 24px rgba(0,0,0,.10); }
.dd-panel.open { display: block; }
.dd-panel label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; cursor: pointer; }
.dd-panel label:hover { background: var(--page); }
.dd-panel .sub { color: var(--ink-muted); font-size: 12px; }
.dd-panel hr { border: 0; border-top: 1px solid var(--gridline); margin: 6px 0; }
.dd-panel .dd-apply { margin: 8px 6px 4px; }
