/* UBM 2.0 — diseño estilo "diagnóstico UBM" (portado de UBM 1.0). Identidad Clickie. */
:root {
  --ink: #1F2A44;
  --primary: #2B2E6F;
  --primary-soft: #ECEDF5;
  --accent: #FDC400;
  --accent-deep: #B98A00;
  --white: #fff;
  --gray-soft: #F4F4F4;
  --gray-200: #ECECEF;
  --border: #E6E7EC;
  --border-2: #F0F0F3;
  --green: #7B8D20;
  --green-soft: #EEF2DC;
  --orange: #DB6A00;
  --orange-soft: #FBEADA;
  --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;
  /* Escala de espaciado (recetario único de separaciones) */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 18px; --space-6: 24px; --space-8: 32px;
  /* Elevación (sombras con nombre) */
  --elev-1: var(--shadow-sm); --elev-2: var(--shadow);
  /* Colores semánticos de estado (un solo origen para ok/alerta/crítico/info) */
  --danger: #C62828; --danger-soft: #FDECEC;
  --warn: var(--orange); --warn-soft: var(--orange-soft);
  --ok: var(--green); --ok-soft: var(--green-soft);
  --info: var(--primary); --info-soft: var(--primary-soft);
  --font: "Open Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-display: "Raleway", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--gray-soft); -webkit-font-smoothing: antialiased; }
h1,h2,h3,h4,.display,.eyebrow { font-family: var(--font-display); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Campos (formularios admin) --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; font-family: inherit; }
.field input:focus, .field select:focus { border-color: var(--primary); }

/* --- Login (limpio, fondo claro, compacto) --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--gray-soft); }
.login-card { width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: 16px; box-shadow: 0 10px 40px rgba(31,42,68,.10); padding: 30px 32px 26px; }
.login-card .brand { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.login-card .brand img { width: 38px; height: 38px; border-radius: 9px; }
.login-card .brand .bt { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--ink); line-height: 1; }
.login-card .brand .bs { font-size: 10px; letter-spacing: .1em; color: var(--text-faint); text-transform: uppercase; margin-top: 3px; }
.login-card h1 { font-family: var(--font-display); font-size: 22px; font-weight: 800; margin: 0 0 5px; color: var(--ink); line-height: 1.2; }
.login-card h1 span { color: var(--primary); }
.login-card p.sub { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field label { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.login-card .field input { padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14.5px; transition: border-color .15s; }
.login-card .btn-primary { padding: 12px; font-size: 15px; border-radius: 10px; margin-top: 8px; }
.login-error { background: #FDECEC; color: #C62828; border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--text-faint); }

/* --- Botones --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 700; font-size: 14px; border: none; cursor: pointer; font-family: inherit; }
.btn-primary { width: 100%; background: var(--accent); color: var(--ink); }
.btn-primary:hover { background: #ffce26; }
.btn-ghost { border: 1px solid var(--border); background: var(--white); color: var(--ink); }
.btn-ghost:hover { background: var(--gray-soft); }

/* --- Shell (paneles flotantes sobre lienzo gris, estilo plataforma) --- */
.app { display: none; }
.app.show { display: grid; grid-template-columns: 264px 1fr; gap: var(--space-5); padding: var(--space-5); min-height: 100vh; background: var(--gray-soft); }
.sidebar { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); position: sticky; top: 18px; height: calc(100vh - 36px); display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; }
.sidebar .brand img { width: 36px; height: 36px; border-radius: 9px; }
.sidebar .brand .t { font-family: var(--font-display); font-weight: 800; color: var(--ink); font-size: 17px; line-height: 1.05; }
.sidebar .brand .s { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav .group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding: 16px 12px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav a:hover { background: var(--gray-soft); }
.nav a.active { background: var(--primary); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a .ico { width: 18px; text-align: center; opacity: .85; font-size: 14px; }
.sidebar .who { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; font-size: 13px; }
.sidebar .who-id { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.sidebar .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 13px; flex: none; }
.sidebar .who-txt { min-width: 0; }
.sidebar .who .name { font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .who .mail { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { display: flex; flex-direction: column; min-width: 0; gap: var(--space-5); }
.topbar { position: sticky; top: 18px; z-index: 20; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; align-items: center; flex-wrap: wrap; gap: 12px 14px; padding: 14px 22px; }
.topbar > div:first-of-type { min-width: 0; }
.topbar h2 { margin: 0; font-size: 19px; }
.topbar .crumb { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.topbar .spacer { flex: 1; }
.pill { border: 1px solid var(--border); background: var(--white); border-radius: 999px; padding: 7px 14px; font-size: 12.5px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 7px; }
.pill b { color: var(--ink); font-family: var(--font-display); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.acc-select { border: 1px solid var(--border); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 700; color: var(--ink); background: var(--white); font-family: var(--font-display); }
.svc-switch { display: inline-flex; gap: 4px; background: var(--gray-soft); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.svc-btn { border: none; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer; font-family: inherit; }
.svc-btn:hover { color: var(--ink); }
.svc-btn.active { background: var(--primary); color: #fff; }
.content { padding: 0 0 40px; }

/* Sub-pestañas de hub (2º nivel de navegación, dentro de la página; estilo subrayado) */
.subtabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab { border: none; background: transparent; padding: 10px 14px; font-family: inherit; font-weight: 700; font-size: 13.5px; color: var(--text-muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Controles de análisis: toggle de medida + barra de filtros */
.fila-controles { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.mini-seg { display: inline-flex; gap: 3px; background: var(--gray-soft); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.mini-btn { border: none; background: transparent; padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); cursor: pointer; font-family: inherit; white-space: nowrap; }
.mini-btn:hover { color: var(--ink); }
.mini-btn.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow-sm); }
.fbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.fbar label { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.fbar select { border: 1px solid var(--border); border-radius: 9px; padding: 6px 9px; font-size: 12.5px; font-weight: 600; color: var(--ink); background: var(--white); font-family: inherit; max-width: 230px; }
.fbar select:focus { outline: none; border-color: var(--primary); }
.legend-inline { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.legend-inline .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* --- Cards / grid --- */
.grid { display: grid; gap: var(--space-4); }
.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); }
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 20px; }
.card.pad-lg { padding: 24px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; }
.section-block { margin-bottom: var(--space-5); }
.hero h2 { font-size: 30px; margin: 6px 0 8px; color: var(--ink); }
.hero p { color: var(--text-muted); max-width: 70ch; margin: 0; font-size: 14.5px; }
.stat-strip { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-top: 20px; }
.stat-strip .s .v { font-family: var(--font-display); font-weight: 800; font-size: 23px; color: var(--ink); }
.stat-strip .s .l { font-size: 12px; color: var(--text-muted); }
.stat-strip .s .v.green { color: var(--green); }

/* KPI */
.kpi { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 18px; }
.kpi .top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.kpi .ic-chip { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 15px; }
.kpi .label { font-size: 12.5px; color: var(--text-muted); font-weight: 700; }
.kpi .value { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--ink); line-height: 1.05; }
.kpi .subv { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi .chip { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; margin-left: auto; }
.chip.up { background: var(--orange-soft); color: var(--orange); }
.chip.down { background: var(--green-soft); color: var(--green); }
.kpi-link { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
.kpi-link:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: 0 8px 22px rgba(43,46,111,.14); }
.kpi .more { font-size: 12px; color: var(--primary); font-weight: 700; margin-top: 8px; }

/* Tablas */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 13.5px; background: var(--white); }
table.data-table thead th { text-transform: uppercase; font-size: 11px; letter-spacing: .04em; color: var(--text-muted); background: var(--gray-soft); padding: 11px 12px; text-align: left; cursor: pointer; white-space: nowrap; }
table.data-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
table.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 { color: var(--text-faint); font-weight: 700; }

/* Donut + hbars (SVG/HTML) */
.donut-wrap { display: flex; gap: var(--space-6); align-items: center; flex-wrap: wrap; }
.dwrap { position: relative; width: 190px; height: 190px; flex: none; }
/* La capa del centro NO debe capturar el mouse: así el hover llega a los segmentos del donut.
   flex column centrado: el bloque (valor + label) queda al medio vertical y horizontal del donut. */
.dwrap .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.dwrap .center .v { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--ink); }
.dwrap .center .l { font-size: 10px; color: var(--text-muted); }
.legend { flex: 1; min-width: 180px; }
.legend .row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border-2); font-size: 13px; }
.legend .row .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend .row .v { margin-left: auto; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.hb { display: flex; align-items: center; gap: 12px; margin: 9px 0; }
.hb .hb-l { width: 200px; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .hb-track { flex: 1; height: 22px; background: var(--gray-soft); border-radius: 7px; overflow: hidden; min-width: 80px; }
.hb .hb-fill { height: 100%; border-radius: 7px; }
.hb .hb-v { width: 104px; text-align: right; font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 13px; }

/* Alert / scope box */
.alert { display: flex; gap: 14px; padding: 16px 18px; border-radius: var(--radius-md); margin-bottom: 18px; }
.alert .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; font-weight: 800; }
.alert-info { background: var(--primary-soft); border: 1px solid #D9DCF7; }
.alert-info .ic { background: var(--primary); color: #fff; }
.alert.warn { background: var(--orange-soft); border: 1px solid #F3D6B5; }
.alert.warn .ic { background: var(--orange); color: #fff; }
.scope { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--space-6); }
.scope h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.scope ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.scope li { margin-bottom: 5px; }

/* tags / badges */
.tag { display: inline-block; font-weight: 800; font-size: 11px; padding: 2px 9px; border-radius: 20px; }
.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); }
.tag.ok { background: var(--green-soft); color: var(--green); }

/* score bar / fc bands / ohero / disc / note / timeline */
.score-bar { display: inline-flex; align-items: center; gap: 8px; }
.score-bar .track { width: 56px; height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.score-bar .fill { height: 100%; }
.ohero { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; }
.ohero .op { padding: 22px; border-right: 1px solid var(--border); }
.ohero .op:last-child { border-right: none; }
.ohero .op.q { background: var(--green-soft); }
.ohero .op.d { background: var(--orange-soft); }
.ohero .op .v { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--ink); }
.ohero .op .l { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.fc-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }
.fc-band { background: var(--white); border: 1px solid var(--border); border-left: 5px solid var(--gray-200); border-radius: var(--radius-sm); padding: 14px; }
.fc-band .n { font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.fc-band .lbl { font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.fc-band .rng { font-size: 11px; color: var(--text-muted); }
.fc-band .desc { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.note { display: flex; gap: 10px; background: var(--gray-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text-muted); }
.disc { border: 1px dashed var(--orange); background: var(--orange-soft); border-radius: var(--radius-md); padding: 16px 18px; }
.disc .t { font-weight: 800; color: var(--accent-deep); font-size: 13px; }
.timeline { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; position: relative; }
.tl-step { position: relative; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--primary); display: grid; place-items: center; font-weight: 800; color: var(--primary); font-size: 13px; background: #fff; }
.tl-when { font-size: 11px; color: var(--text-muted); margin-top: 8px; text-transform: uppercase; letter-spacing: .04em; }
.tl-step h4 { margin: 3px 0 6px; font-size: 14px; }
.tl-step ul { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--text-muted); }
.act-card { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 16px; background: #fff; }
.act-head { display: flex; align-items: center; gap: 10px; }
.act-head .ttl { font-weight: 700; }
.act-head .amt { margin-left: auto; font-family: var(--font-display); font-weight: 800; color: var(--green); }
.act-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }

/* Tooltip interactivo de gráficos + hover de segmentos */
.chart-tip { position: fixed; z-index: 60; background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.22); white-space: nowrap; }
.seg { cursor: pointer; transition: opacity .12s; }
.seg:hover { opacity: .82; }
.hb:hover .hb-fill { filter: brightness(1.08); }

/* Carga: esqueletos con shimmer (en vez de "Cargando…") */
.sk-wrap { display: flex; flex-direction: column; gap: 16px; }
.sk { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 20px; }
.sk-bar { border-radius: 8px; background: var(--gray-200); position: relative; overflow: hidden; }
.sk-bar::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: sk-shimmer 1.4s infinite; }
@keyframes sk-shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .sk-bar::after { animation: none; } #section-root > * { animation: none; } }

/* Transición sobria al montar contenido de una sección */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
#section-root > * { animation: fade-in .24s ease both; }

.error-box { display: flex; gap: 12px; align-items: flex-start; background: #FDECEC; color: #C62828; border: 1px solid #F5C6C6; border-radius: var(--radius-md); padding: 16px 18px; font-size: 14px; }
.error-box::before { content: "!"; flex: none; width: 24px; height: 24px; border-radius: 7px; background: #C62828; color: #fff; display: grid; place-items: center; font-weight: 800; }
.empty { display: flex; gap: 10px; align-items: center; justify-content: center; background: var(--gray-soft); border: 1px dashed var(--border); border-radius: var(--radius-md); padding: 28px 18px; color: var(--text-muted); font-size: 14px; text-align: center; }

/* --- Chat (asesor virtual) --- */
.chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--accent); color: var(--ink); font-size: 24px; box-shadow: 0 6px 20px rgba(253,196,0,.5); display: none; align-items: center; justify-content: center; cursor: pointer; }
.chat-panel { position: fixed; right: 22px; bottom: 90px; z-index: 41; width: 380px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 130px); background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 40px rgba(31,42,68,.22); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { background: var(--primary); color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }
.chat-head strong { font-family: var(--font-display); font-size: 15px; }
.chat-sub { font-size: 11px; color: #C7CAEC; margin-top: 2px; }
.chat-x { background: transparent; border: none; color: #fff; font-size: 16px; cursor: pointer; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--gray-soft); }
.chat-msg { max-width: 85%; padding: 10px 13px; border-radius: 13px; font-size: 14px; line-height: 1.5; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.typing { color: var(--text-muted); font-style: italic; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 14px; outline: none; max-height: 120px; }
.chat-send { width: auto; padding: 0 16px; border-radius: 10px; font-size: 16px; }

/* --- Gestión UBM (gestiones documentarias) --- */
/* Buscador de sucursales (combobox) */
.gpick { position: relative; }
.gpick input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; font-family: inherit; }
.gpick input:focus { border-color: var(--primary); }
.gpick-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(31,42,68,.16); max-height: 260px; overflow-y: auto; }
.gpick-item { padding: 9px 13px; font-size: 13.5px; cursor: pointer; border-bottom: 1px solid var(--border-2); }
.gpick-item:last-child { border-bottom: none; }
.gpick-item:hover { background: var(--primary-soft); }
.gpick-empty { color: var(--text-faint); cursor: default; }
.gpick-empty:hover { background: transparent; }

/* Campana de notificaciones */
.notif-wrap { position: relative; }
.notif-bell { position: relative; border: 1px solid var(--border); background: var(--white); border-radius: 999px; width: 38px; height: 38px; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.notif-bell:hover { background: var(--gray-soft); }
.notif-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 999px; background: #C62828; color: #fff; font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; font-family: var(--font-display); }
.notif-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: 380px; max-width: calc(100vw - 40px); background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 44px rgba(31,42,68,.20); overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-family: var(--font-display); }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border-2); cursor: pointer; align-items: flex-start; }
.notif-item:hover { background: var(--gray-soft); }
.notif-item.unread { background: var(--primary-soft); }
.notif-item.unread:hover { background: #E2E4F2; }
.notif-ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.notif-rech { background: #FDECEC; color: #C62828; }
.notif-ok { background: var(--green-soft); color: var(--green); }
.notif-info { background: var(--primary-soft); color: var(--primary); }
.notif-txt { font-size: 13px; min-width: 0; }
.notif-txt > div { color: var(--text-muted); margin-top: 2px; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; margin-top: 6px; margin-left: auto; }

.gtabs { display: inline-flex; gap: 4px; background: var(--white); border: 1px solid var(--border); border-radius: 999px; padding: 4px; box-shadow: var(--shadow-sm); }
.gtabs button { border: none; background: transparent; padding: 8px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--text-muted); cursor: pointer; font-family: var(--font-display); }
.gtabs button:hover { color: var(--ink); }
.gtabs button.active { background: var(--primary); color: #fff; }
.gbadge { display: inline-block; font-weight: 800; font-size: 11px; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.gb-pend { background: var(--orange-soft); color: var(--orange); }
.gb-carg { background: var(--primary-soft); color: var(--primary); }
.gb-ok { background: var(--green-soft); color: var(--green); }
.gb-rech { background: #FDECEC; color: #C62828; }
.gb-na { background: var(--gray-soft); color: var(--text-faint); }
.gb-envi { background: #FBEEDA; color: var(--accent-deep); }
.gb-clickie { background: var(--primary); color: #fff; font-size: 10px; padding: 2px 8px; }
.gb-cliente { background: var(--accent); color: var(--ink); font-size: 10px; padding: 2px 8px; }
.g-row { cursor: pointer; }
.gprog { display: inline-flex; align-items: center; margin-right: 8px; vertical-align: middle; }
.gprog .track { width: 64px; height: 7px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; display: inline-block; }
.gprog .fill { height: 100%; background: var(--green); border-radius: 99px; display: block; }
.gprog-lg .track { width: 100%; height: 9px; }
.gsteps { display: flex; gap: 0; overflow-x: auto; }
.gstep { flex: 1; min-width: 96px; text-align: center; position: relative; padding-top: 4px; }
.gstep::before { content: ""; position: absolute; top: 19px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.gstep:first-child::before { display: none; }
.gstep.done::before, .gstep.cur::before { background: var(--primary); }
.gstep .dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); background: #fff; color: var(--text-faint); display: grid; place-items: center; font-weight: 800; font-size: 13px; margin: 0 auto; position: relative; z-index: 1; }
.gstep.done .dot { border-color: var(--primary); background: var(--primary); color: #fff; }
.gstep.cur .dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.gstep .lbl { font-size: 11px; color: var(--text-faint); margin-top: 7px; font-weight: 700; padding: 0 4px; }
.gstep.done .lbl, .gstep.cur .lbl { color: var(--primary); }
.gdoc { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 10px; background: #fff; }
.gdoc-na { opacity: .55; }
.gdoc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; font-size: 14px; }
.gdoc-vig { font-size: 11.5px; color: var(--accent-deep); background: #FBEEDA; border-radius: 20px; padding: 2px 9px; font-weight: 700; white-space: nowrap; }
.gdoc-motivo { background: #FDECEC; color: #C62828; border-radius: 8px; padding: 8px 11px; font-size: 12.5px; margin-top: 9px; }
.gfiles { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.gfile { display: flex; align-items: center; gap: 10px; background: var(--gray-soft); border: 1px solid var(--border-2); border-radius: 8px; padding: 7px 11px; font-size: 13px; }
.gfile a { color: var(--primary); font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gfile a:hover { text-decoration: underline; }
.gfile .faint { font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.gfile-dl { flex: none; }
.gfile-x { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 13px; flex: none; }
.gfile-x:hover { color: #C62828; }
.gdoc-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gbtn { padding: 6px 12px; font-size: 12.5px; width: auto; }
.gbtn-ok { border-color: var(--green); color: var(--green); }
.gbtn-ok:hover { background: var(--green-soft); }
.gbtn-no { border-color: #E3A0A0; color: #C62828; }
.gbtn-no:hover { background: #FDECEC; }
.gcoms, .gacts { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.gcom { background: var(--gray-soft); border: 1px solid var(--border-2); border-radius: 10px; padding: 10px 13px; }
.gcom-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.gcom-head .faint { margin-left: auto; font-size: 11.5px; }
.gcom-body { font-size: 13.5px; white-space: pre-wrap; }
.gact { display: flex; gap: 10px; align-items: flex-start; padding: 2px 0; }
.gact-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: none; }
.gact-desc { font-size: 13px; }
@media (max-width: 980px) { .gstep { min-width: 84px; } .gfile .faint { display: none; } }

.menu-btn { display: none; }
.scrim { display: none; }
@media (max-width: 980px) {
  .app.show { grid-template-columns: 1fr; gap: var(--space-4); padding: var(--space-4); }
  .sidebar { position: fixed; top: 0; z-index: 30; width: 250px; height: 100vh; border-radius: 0; box-shadow: 0 0 40px rgba(31,42,68,.18); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(31,42,68,.42); animation: fade-in .2s ease; }
  .topbar { top: 14px; }
  .g5,.g4 { grid-template-columns: repeat(2,1fr); }
  .g3,.scope,.fc-grid,.stat-strip { grid-template-columns: 1fr; }
  .ohero { grid-template-columns: 1fr; }
  .ohero .op { border-right: none; border-bottom: 1px solid var(--border); }
  .timeline { grid-template-columns: 1fr 1fr; }
  .menu-btn { display: inline-flex; }
}
@media (max-width: 620px) { .g2,.g4,.g5 { grid-template-columns: 1fr; } .app.show { padding: 12px; gap: 12px; } .content { padding: 0 0 24px; } }

/* --- Agua: control de facturación --- */
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.wflag { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; margin: 1px 4px 1px 0; }
.wflag.warn { background: var(--orange-soft); color: var(--orange); }
.wflag.crit { background: var(--danger-soft); color: var(--danger); }
.wfilters { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }
.wpu { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff; }
.wpu .l { font-size: 11.5px; font-weight: 700; color: var(--text-muted); }
.wpu .v { font-family: var(--font-display); font-weight: 800; font-size: 21px; color: var(--ink); margin-top: 3px; }
.wpu .f { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; }
.wleg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wleg button, .wleg .wleg-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 700; color: var(--text); font-family: inherit; }
.wleg button { cursor: pointer; }
.wleg button:hover { background: var(--gray-soft); }
.wleg button.off { opacity: .35; }
.wleg .wleg-item { border: none; padding: 2px 6px; color: var(--text-muted); }
.wleg .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
@media (max-width: 980px) { .wfilters { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 620px) { .wfilters { grid-template-columns: 1fr; } }

/* --- Plan de acción: vista de proyecto por frentes ------------------------------ */
.pg-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; cursor: pointer; user-select: none; }
.pg-head:hover h3 { color: var(--primary); }
.pg-stats { display: flex; gap: 22px; align-items: center; }
.pg-stat .v { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--ink); }
.pg-stat .l { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.pg-caret { color: var(--text-faint); font-size: 13px; width: 16px; text-align: center; }
.pg-body.hidden { display: none; }
@media (max-width: 980px) { .pg-stats { gap: 14px; } .pg-stat .v { font-size: 14px; } }

/* --- Plan de acción: camino de madurez por etapas -------------------------------- */
.et-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.et-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 16px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s, transform .15s, border-color .15s; }
.et-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--primary); }
.et-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.et-foco { border: 2px solid var(--accent); box-shadow: var(--shadow-sm); }
.et-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.et-num { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: var(--text-faint); }
.et-title { display: flex; align-items: center; gap: 9px; }
.et-title h3 { margin: 0; font-size: 14.5px; line-height: 1.25; }
.et-desc { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.et-prog { display: flex; align-items: center; gap: 9px; margin-top: auto; }
.et-prog .gprog { flex: 1; }
.et-nums { display: flex; gap: 18px; }
.et-nums .v { font-family: var(--font-display); font-weight: 800; font-size: 14.5px; color: var(--ink); }
.et-nums .l { font-size: 10.5px; color: var(--text-faint); }
.et-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.et-abrir { font-size: 12px; font-weight: 700; color: var(--primary); }
.lib-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 11px 0; border-bottom: 1px solid var(--border-2); }
.lib-row:last-child { border-bottom: none; }

/* --- Plan de acción: checklist estructurado de etapa (secciones/tareas) ---------- */
.sec-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.tk-row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 2px; border-bottom: 1px solid var(--border-2); }
.tk-row:last-child { border-bottom: none; }
.tk-check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border); background: #fff;
  color: #fff; font-size: 13px; font-weight: 800; display: grid; place-items: center; cursor: pointer;
  flex: none; margin-top: 1px; transition: background .12s, border-color .12s; padding: 0; }
.tk-check:hover { border-color: var(--green); }
.tk-check.on { background: var(--green); border-color: var(--green); }
.tk-check.ro { cursor: default; }
.tk-check.ro:hover { border-color: var(--border); }
.tk-check.ro.on:hover { border-color: var(--green); }
.tk-x { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 13px;
  padding: 3px 6px; border-radius: 6px; }
.tk-x:hover { background: #FDECEC; color: #C62828; }
.tk-panel { background: var(--gray-soft); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 10px 12px; margin-top: 8px; }
.tk-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tk-inline input, .tk-inline select { border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px;
  font-size: 12.5px; font-family: inherit; outline: none; }
.tk-inline input:focus { border-color: var(--primary); }
.tk-sub { margin-top: 12px; padding: 4px 0 0 12px; border-left: 2px solid var(--border); }
.tk-sub-head { font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--text-muted);
  text-transform: uppercase; margin-bottom: 2px; }

/* --- Sidebar colapsable (riel de íconos, solo escritorio) ------------------------ */
.side-toggle { border: 1px solid var(--border); background: var(--white); color: var(--text-muted);
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer; display: grid; place-items: center;
  font-size: 13px; font-family: inherit; margin-left: auto; flex: none; padding: 0; line-height: 1; }
.side-toggle:hover { color: var(--primary); border-color: var(--primary); }
@media (min-width: 981px) {
  .app.show.side-mini { grid-template-columns: 78px 1fr; }
  .side-mini .sidebar { padding: 16px 10px; }
  .side-mini .sidebar .brand { flex-direction: column; gap: 10px; padding: 2px 0 14px; }
  .side-mini .sidebar .brand > div { display: none; }
  .side-mini .side-toggle { margin-left: 0; }
  .side-mini .nav a { justify-content: center; padding: 10px 0; }
  .side-mini .nav a span:not(.ico) { display: none; }
  .side-mini .nav a .ico { width: auto; font-size: 16px; }
  .side-mini .nav a.active { box-shadow: none; }
  .side-mini .nav .group-label { font-size: 0; padding: 0; border-top: 1px solid var(--border); margin: 12px 8px 6px; }
  .side-mini .who { padding-top: 10px; }
  .side-mini .who-id { justify-content: center; margin-bottom: 9px; }
  .side-mini .who-txt { display: none; }
  .side-mini #logout-btn { font-size: 0; padding: 8px 0; }
  .side-mini #logout-btn::before { content: "⏻"; font-size: 15px; }
}
@media (max-width: 980px) { .side-toggle { display: none; } }

/* --- Selector de distribuidoras por región --------------------------------------- */
.dx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.dx-region { background: var(--white); border: 1px solid var(--border-2); border-radius: 10px; padding: 10px 12px; }
.dx-region-name { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dx-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; cursor: pointer; color: var(--text); }
.dx-item input { accent-color: var(--primary); width: 15px; height: 15px; flex: none; cursor: pointer; }
.dx-item:hover span { color: var(--primary); }
