/* ============================================================
   Clickie — Sistema visual (Plataforma UBM · Autoplanet)
   Estricto a la Guía de Estilo Clickie:
   blanco · violeta #2B2E6F · amarillo #FDC400 (solo CTA) · navy #1F2A44 títulos
   Raleway (títulos) + Open Sans (cuerpo) · SIN degradados · sombras suaves
   ============================================================ */
:root {
  --ink:        #1F2A44;   /* azul oscuro — títulos / estructura */
  --primary:    #2B2E6F;   /* violeta Clickie — acentos */
  --primary-soft:#ECEDF5;
  --accent:     #FDC400;   /* amarillo Clickie — SOLO CTAs/énfasis puntual */
  --accent-deep:#B98A00;

  --white:      #FFFFFF;
  --canvas:     #FFFFFF;   /* fondo principal */
  --surface:    #FFFFFF;
  --gray-soft:  #F4F4F4;   /* fondos secundarios / tarjetas suaves */
  --gray-100:   #F4F4F4;
  --gray-200:   #ECECEF;
  --gray-mid:   #6F7380;   /* texto secundario / bordes */
  --border:     #E6E7EC;
  --border-2:   #F0F0F3;

  --green:      #7B8D20;   /* éxito / sostenibilidad / ahorro */
  --green-soft: #EEF2DC;
  --orange:     #DB6A00;   /* alerta / crítico (lógica semáforo) */
  --orange-soft:#FBEADA;
  --blue:       #2B2E6F;   /* en data-viz, usamos violeta como "neutro fuerte" */

  --text:       #2A2E3A;
  --text-muted: #6F7380;
  --text-faint: #9AA0AD;

  --shadow-sm: 0 1px 2px rgba(31,42,68,.04);
  --shadow:    0 1px 3px rgba(31,42,68,.05), 0 6px 18px rgba(31,42,68,.05);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --space-1: 8px; --space-2: 16px; --space-3: 24px; --space-4: 32px;

  --font: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Raleway", "Open Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  color: var(--ink); margin: 0 0 .4em; font-family: var(--font-display);
  font-weight: 800; letter-spacing: -.01em;
}
h3, h4 { font-weight: 700; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hl { color: var(--primary); }        /* destaque violeta en títulos (1-2 palabras) */
.muted { color: var(--text-muted); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6d8e0; border-radius: 20px; border: 2px solid #fff; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; transition: .15s ease;
}
/* CTA principal = amarillo Clickie (acento puntual), texto navy */
.btn-primary { background: var(--accent); color: var(--ink); }
.btn-primary:hover { background: #ffce26; }
/* Acción secundaria = violeta */
.btn-secondary { background: var(--primary); color: #fff; }
.btn-secondary:hover { background: #34388a; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Tarjetas ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 20px;
}
.card.pad-lg { padding: 24px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2,1fr); }
.g3 { grid-template-columns: repeat(3,1fr); }
.g4 { grid-template-columns: repeat(4,1fr); }
.g5 { grid-template-columns: repeat(5,1fr); }

/* ---- Inputs ---- */
.input {
  width: 100%; font-family: inherit; font-size: 14px;
  padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select.input { cursor: pointer; }

/* ---- Eyebrow / encabezados de sección ---- */
.eyebrow { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--primary); font-weight: 800; margin-bottom: 5px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin: 30px 0 14px; }
.section-head:first-child { margin-top: 2px; }
.section-head h2 { font-size: 18px; }
.section-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 12.5px; max-width: 640px; }

/* ---- KPI ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; }
.kpi .lab { font-size: 11.5px; color: var(--text-muted); font-weight: 600;
  display: flex; align-items: center; gap: 8px; }
.kpi .ic-chip { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  flex: none; color: var(--primary); background: var(--primary-soft); }
.kpi .num { font-family: var(--font-display); font-size: 28px; font-weight: 800;
  color: var(--ink); letter-spacing: -.02em; margin: 12px 0 2px; line-height: 1; }
.kpi .sub { font-size: 11.5px; color: var(--text-faint); }
.kpi .chip { margin-left: auto; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.chip.up { background: var(--orange-soft); color: var(--orange); }
.chip.down { background: var(--green-soft); color: var(--green); }
.tint-violet { background: var(--primary-soft); color: var(--primary); }
.tint-green  { background: var(--green-soft);  color: var(--green); }
.tint-orange { background: var(--orange-soft); color: var(--orange); }
.tint-ink    { background: #EAECF1; color: var(--ink); }

/* ---- Hero (Clickie: tarjeta blanca, acentos violeta/navy) ---- */
.hero { background: #fff; color: var(--ink); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius-lg); padding: 28px 30px; margin-top: 16px; }
/* Tarjetas apiladas directamente (p.ej. vistas admin) no deben quedar pegadas */
#section-root > .card + .card { margin-top: 16px; }
.hero .eyebrow { color: var(--primary); }
.hero h2 { color: var(--ink); font-size: 25px; margin: 6px 0 8px; }
.hero p { color: var(--text-muted); max-width: 640px; margin: 0 0 18px; font-size: 13px; }
.stat-strip { display: flex; gap: 30px; flex-wrap: wrap; }
.stat-strip .s b { font-family: var(--font-display); font-size: 22px; font-weight: 800; display: block; color: var(--ink); }
.hero .stat-strip .s b.accent { color: var(--green); }
.stat-strip .s span { font-size: 11.5px; color: var(--text-muted); }

/* ---- Alertas ---- */
.alert { display: flex; gap: 14px; border-radius: var(--radius-md); padding: 16px 18px;
  font-size: 12.5px; align-items: flex-start; }
.alert .a-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  flex: none; font-weight: 800; }
.alert.warn { background: var(--orange-soft); border: 1px solid #F0CBA3; }
.alert.warn .a-ic { background: var(--orange); color: #fff; }
.alert.alert-info { background: var(--primary-soft); border: 1px solid #CFD1E8; }
.alert.alert-info .a-ic { background: var(--primary); color: #fff; }
.alert h4 { margin: 0 0 8px; font-size: 13px; }
.alert .cols { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.alert .cols h5 { margin: 0 0 5px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.alert ul { margin: 0; padding-left: 16px; } .alert li { margin-bottom: 3px; }

/* ---- Donut + leyenda ---- */
.donut-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.dwrap { position: relative; width: 178px; height: 178px; flex: none; }
.donut { width: 178px; height: 178px; transform: rotate(-90deg); }
/* pointer-events:none → el hover atraviesa el texto y llega a los segmentos del SVG */
.dwrap .ctr { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.dwrap .ctr b { font-family: var(--font-display); font-size: 17px; font-weight: 800; color: var(--ink); line-height: 1.05; }
.dwrap .ctr span { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.legend { flex: 1; min-width: 220px; }
.legend .row { display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 1px dashed var(--border-2); font-size: 13px; }
.legend .row:last-child { border: 0; }
.legend .k { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.legend .k i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.legend .v { margin-left: auto; font-weight: 700; font-family: var(--font-display); color: var(--ink); }

/* ---- Barras horizontales (monto a la derecha, fuera de la barra → siempre legible) ---- */
.hb { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.hb .hb-l { width: 190px; flex: none; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb .hb-track { flex: 1; min-width: 80px; height: 22px; background: var(--gray-soft); border-radius: 7px; overflow: hidden; }
.hb .hb-fill { height: 100%; border-radius: 7px; min-width: 6px;
  transition: width .6s cubic-bezier(.2,.7,.2,1); }
.hb .hb-v { width: 96px; flex: none; text-align: right; font-family: var(--font-display);
  font-weight: 800; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink); white-space: nowrap; }

/* ---- Tablas ---- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.data-table thead th { text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700; padding: 13px 16px; background: var(--gray-soft);
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.data-table thead th:hover { color: var(--primary); }
.data-table th .sort-ind { font-size: 10px; margin-left: 4px; color: var(--primary); }
.data-table tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--gray-soft); }
td.num, th.num { text-align: right; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font-display); }

/* ---- Badges / tags / confianza ---- */
.tag { display: inline-block; font-size: 10px; font-weight: 800; padding: 2px 9px; border-radius: 20px; letter-spacing: .03em; }
.tag.crit { background: var(--orange-soft); color: var(--orange); }
.tag.alta { background: #FBEEDA; color: var(--accent-deep); }
.tag.media { background: var(--primary-soft); color: var(--primary); }
.conf { font-size: 9.5px; font-weight: 800; padding: 2px 9px; border-radius: 20px; letter-spacing: .05em;
  text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.conf::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.conf.alta { background: var(--green-soft); color: var(--green); } .conf.alta::before { background: var(--green); }
.conf.media { background: #FBEEDA; color: var(--accent-deep); } .conf.media::before { background: var(--accent); }
.conf.baja { background: var(--gray-soft); color: var(--text-muted); } .conf.baja::before { background: var(--text-faint); }
.score-bar { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); }
.score-bar .mini { width: 52px; height: 6px; border-radius: 10px; background: var(--gray-soft); overflow: hidden; }
.score-bar .mini i { display: block; height: 100%; border-radius: 10px; }

/* ---- Pillar cards ---- */
.pillar { cursor: pointer; transition: .18s; border-left: 3px solid transparent; }
.pillar:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(31,42,68,.10); }
.pillar .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pillar .name { font-weight: 700; font-size: 13px; color: var(--ink); }
.pillar .amt { font-family: var(--font-display); font-size: 22px; font-weight: 800; margin: 10px 0 1px; }
.pillar .meta { font-size: 11px; color: var(--text-muted); }
.pillar .bar { height: 6px; border-radius: 10px; background: var(--gray-soft); margin-top: 11px; overflow: hidden; }
.pillar .bar i { display: block; height: 100%; border-radius: 10px; }
.pillar .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; }
.arrow { color: var(--text-faint); font-size: 16px; transition: .18s; }
.pillar:hover .arrow { color: var(--ink); transform: translateX(3px); }

/* ---- Opportunity hero (3 paneles) ---- */
.ohero { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr; border-radius: var(--radius-md);
  overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.ohero .op { padding: 22px; }
.ohero .op:not(:last-child) { border-right: 1px solid var(--border); }
.ohero .op .lab { font-size: 11px; color: var(--text-muted); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.ohero .op .big { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 10px 0 3px; line-height: 1; color: var(--ink); }
.ohero .op.q { background: var(--green-soft); } .ohero .op.q .big { color: var(--green); }
.ohero .op.d { background: var(--orange-soft); } .ohero .op.d .big { color: var(--orange); font-size: 24px; }
.ohero .op .sm { font-size: 11.5px; color: var(--text-muted); }

/* ---- Discover / nota ---- */
.disc { border: 1px dashed var(--orange); background: var(--orange-soft); }
.disc .dt { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--ink); }
.disc .dt::before { content: "◌"; color: var(--orange); font-size: 16px; }
.disc p { margin: 0 0 10px; color: var(--text-muted); font-size: 12px; }
.disc .need { font-size: 11.5px; color: var(--text); } .disc .need b { color: var(--orange); }
.disc .ref { margin-top: 10px; font-family: var(--font-display); font-size: 14px; font-weight: 800; color: var(--orange); }
.note { display: flex; gap: 12px; background: var(--gray-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 12.5px; color: var(--text-muted); align-items: flex-start; }
.note svg { flex: none; margin-top: 1px; color: var(--primary); }
.note b { color: var(--ink); font-weight: 700; }

/* ---- Timeline ---- */
.timeline { display: grid; grid-template-columns: repeat(4,1fr); position: relative; margin-top: 10px; }
.tl-step { padding: 0 16px; position: relative; }
.tl-step:not(:last-child)::after { content: ""; position: absolute; top: 13px; left: 50%; right: -50%;
  height: 2px; background: var(--border); z-index: 0; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid var(--primary);
  color: var(--primary); display: grid; place-items: center; font-family: var(--font-display);
  font-weight: 800; font-size: 12px; position: relative; z-index: 1; }
.tl-when { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); font-weight: 800; margin: 14px 0 4px; }
.tl-step h4 { margin: 0 0 6px; font-size: 13.5px; }
.tl-step ul { margin: 0; padding-left: 16px; color: var(--text-muted); font-size: 12px; }

/* ---- Acciones (plan) ---- */
.act-card { border: 1px solid var(--border); border-left: 4px solid var(--text-faint);
  border-radius: var(--radius-md); background: var(--surface); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.act-card.pri-alta { border-left-color: var(--orange); }
.act-card.pri-media { border-left-color: var(--accent); }
.act-card.pri-baja { border-left-color: var(--green); }
.act-card + .act-card { margin-top: 10px; }
.act-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.act-head .ttl { font-weight: 700; font-size: 14px; flex: 1; min-width: 200px; color: var(--ink); }
.act-head .amt { font-family: var(--font-display); font-weight: 800; font-size: 15px; }
.act-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 9px; font-size: 11.5px; color: var(--text-muted); }
.act-meta b { color: var(--text); font-weight: 700; }
.pr, .ty { font-size: 10px; font-weight: 800; padding: 2px 9px; border-radius: 6px; letter-spacing: .04em; }
.pr.alta { background: var(--orange-soft); color: var(--orange); }
.pr.media { background: #FBEEDA; color: var(--accent-deep); }
.pr.baja { background: var(--green-soft); color: var(--green); }
.ty.con { background: var(--green-soft); color: var(--green); }
.ty.des { background: var(--orange-soft); color: var(--orange); }

/* ---- Fee ---- */
.fee-row { display: flex; justify-content: space-between; align-items: baseline; padding: 11px 0;
  border-bottom: 1px dashed var(--border-2); font-size: 13px; }
.fee-row b { font-family: var(--font-display); }
.fee-total { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px;
  background: var(--ink); color: #fff; border-radius: var(--radius-sm); margin-top: 14px; }
.fee-total b { font-family: var(--font-display); font-size: 22px; color: var(--accent); }

/* ---- Factor de carga: tarjetas de banda ---- */
.fc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.fc-band { background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--text-faint);
  border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.fc-band .cat { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--text-secondary); }
.fc-band .rng { font-size: 11px; color: var(--text-muted); font-style: italic; margin-top: 2px; }
.fc-band .big { font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1.1; margin: 6px 0 2px; }
.fc-band .sub { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }
.fc-band .desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
@media (max-width: 980px) { .fc-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---- Glosario ---- */
.gloss { display: grid; grid-template-columns: repeat(2,1fr); gap: 0 28px; }
.gloss .gi { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border-2);
  font-size: 12.5px; align-items: baseline; }
.gloss .gi b { font-family: var(--font-display); color: var(--ink); flex: none; width: 96px; }
.gloss .gi span { color: var(--text-muted); }

/* ---- Tooltip ⓘ ---- */
.info { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--text-faint); color: var(--text-muted); font-size: 9px; font-style: normal;
  cursor: help; position: relative; font-weight: 700; flex: none; }
.info:hover { border-color: var(--primary); color: var(--primary); }
.info:hover .tip { opacity: 1; visibility: visible; }
.tip { position: absolute; bottom: 150%; left: 50%; transform: translateX(-50%); width: 220px;
  background: var(--ink); color: #E7ECF5; font-size: 11px; font-weight: 400; line-height: 1.45;
  padding: 9px 11px; border-radius: 9px; opacity: 0; visibility: hidden; transition: .16s; z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); text-align: left; letter-spacing: 0; }
.tip b { color: var(--accent); }

/* ---- Estados ---- */
.error { color: var(--orange); } .ok { color: var(--green); }
.loading { display: grid; gap: 14px; }
.loading::before, .loading::after { content: ""; display: block; height: 120px; border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--gray-soft) 25%, #ececf2 50%, var(--gray-soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.loading::after { height: 240px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
