:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --border: #E2E5EA;
  --input-border: #C9CED6;
  --text: #111827;
  --text-2: #5B6472;
  --primary: #1D4ED8;
  --fineza: #0B3F86;
  --proj: #BFD0F7;
  --ideal: #B45309;
  --header: #E4E7EC;
  --header-border: #CDD2DA;
  --track: #EEF0F3;
  --r-card: 12px;
  --r-ctl: 8px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

.muted { color: var(--text-2); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Controles ---------- */

label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }

input, select {
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-ctl);
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
input.num { text-align: right; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; }

.btn {
  font: inherit;
  font-weight: 600;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--input-border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #F7F8FA; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1A45C2; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-danger { color: #B91C1C; border-color: #F3B4B4; }
.btn-danger:hover { background: #FEF2F2; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; }
.btn-link { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.ok { background: #E3EBFC; color: #1E3A8A; }
.chip.warn { background: #FDF0DC; color: #92400E; }
.chip.risk { background: #FBE4E8; color: #9F1239; }
.chip.off { background: #EEF0F3; color: var(--text-2); }

.alert { padding: 12px 14px; border-radius: var(--r-ctl); font-size: 14px; }
.alert-error { background: #FBE4E8; color: #9F1239; }
.alert-ok { background: #E3EBFC; color: #1E3A8A; }

/* ---------- Login ---------- */

.login-page { background: #fff; min-height: 100vh; }
.login {
  max-width: 420px;
  margin: 0 auto;
  padding: 48px 16px 32px;
  text-align: center;
}
.login-logo { width: 200px; max-width: 70%; height: auto; }
.login-sub { margin: 8px 0 28px; color: var(--text-2); }
.login-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px;
  display: grid;
  gap: 16px;
}
.login-card .btn { width: 100%; height: 46px; }
.unidades-title {
  margin: 36px 0 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-2);
}
.unidades-logos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 20px 28px;
}

/* ---------- Encabezado ---------- */

.header { background: var(--header); border-bottom: 1px solid var(--header-border); }
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.header-logo { height: 42px; width: auto; display: block; }
.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tab {
  height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-ctl);
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, .5); }
.tab.active { background: var(--fineza); color: #fff; }
.tab-badge {
  margin-left: 6px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: #DC2626; color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.pend-card { border: 1px solid #F5C77E; }
.conexion-vieja { color: #92400E; }
.user-box { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-weight: 500; }
.chip-rol { background: #fff; color: var(--fineza); }
.btn-salir { background: #fff; border-color: #B4BBC6; height: 38px; }

.notice-wrap { max-width: 1280px; margin: 16px auto 0; padding: 0 24px; }
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #E3EBFC;
  color: #1E3A8A;
  border-radius: var(--r-ctl);
  padding: 12px 14px;
  font-size: 14px;
}
.notice.error { background: #FDF0DC; color: #92400E; }
.notice span { flex: 1; }
.notice button { border: 0; background: none; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }

/* ---------- Layout ---------- */

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px;
  min-width: 0;
}
.layout-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.side { display: grid; gap: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.card-head p { margin: 4px 0 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.r, th.r { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 2px solid var(--border); border-bottom: 0; font-weight: 600; }

.form-row { display: grid; gap: 6px; max-width: 220px; margin-bottom: 18px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }
.actions .spacer { flex: 1; }
.form-msg { margin-top: 14px; }

.kv { display: grid; gap: 10px; margin: 14px 0 16px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv dt, .kv span:first-child { color: var(--text-2); }
.formula {
  background: var(--bg);
  border-radius: var(--r-ctl);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  margin: 12px 0;
}

/* Ventas */
.ventas-table input { min-width: 150px; }
.unidad-nombre { font-weight: 600; }
.unidad-meta { font-size: 13px; color: var(--text-2); }
.grupo-row td { background: #F7F8FA; font-weight: 600; }
.sub-row td:first-child { padding-left: 28px; }
.sub-row .unidad-nombre { font-weight: 500; }

/* Usuarios */
.alta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}
.alta-grid .btn { width: 100%; }

/* ---------- Dashboard ---------- */

.dash-head { margin-bottom: 20px; }
.dash-head p { margin: 4px 0 0; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kpi { display: grid; gap: 6px; align-content: start; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.15; }
.kpi-sub { font-size: 14px; color: var(--text-2); }
.kpi.dark { background: #111827; border-color: #111827; color: #fff; }
.kpi.dark .kpi-label, .kpi.dark .kpi-sub { color: #D1D5DB; }

.unidades {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}
.u-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.u-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.u-big { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 10px; flex-wrap: wrap; }
.u-big strong { font-size: 34px; font-weight: 600; line-height: 1; }
.u-big span { color: var(--text-2); font-size: 14px; }

.bar { position: relative; height: 14px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar.thin { height: 8px; }
.bar .proj, .bar .real { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.bar .proj { background: var(--proj); }
.bar .real { background: var(--primary); }
.bar .target { position: absolute; top: 0; bottom: 0; left: 83.333%; width: 2px; margin-left: -1px; background: #111827; }

.u-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.u-stats div { display: grid; gap: 2px; min-width: 0; }
.u-stats span { font-size: 12px; color: var(--text-2); }
.u-stats strong { font-size: 15px; font-weight: 600; }

.canales { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 12px; }
.canal-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.canal-head strong { font-weight: 600; }
.canal-head span { color: var(--text-2); font-size: 13px; }

.leyenda { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 14px 0 20px; font-size: 13px; color: var(--text-2); }
.leyenda span { display: inline-flex; align-items: center; gap: 8px; }
.sw { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.real { background: var(--primary); }
.sw.proj { background: var(--proj); }
.sw.target { width: 2px; height: 14px; background: #111827; border-radius: 0; }
.sw.ideal { width: 14px; height: 2px; background: var(--ideal); border-radius: 0; }

.dash-bottom {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}
.chart { margin-top: 16px; }
.chart-cols {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.col { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; min-width: 0; }
.col-bar { width: 100%; max-width: 48px; background: #93A9E8; border-radius: 6px 6px 0 0; position: relative; }
.col.last .col-bar { background: var(--primary); }
.col-pct { position: absolute; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; white-space: nowrap; }
.ritmo td:first-child { white-space: nowrap; }
.ritmo th, .ritmo td { padding-left: 6px; padding-right: 6px; }
.col-ideal { position: absolute; left: 50%; transform: translateX(-50%); width: 100%; max-width: 60px; height: 2px; background: var(--ideal); }
.chart-labels { display: flex; gap: 10px; margin-top: 6px; }
.chart-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--text-2); min-width: 0; }

/* Proyección al cierre (sección destacada) */
.proy-hero {
  background: #111827;
  color: #fff;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
}
.proy-top {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}
.proy-label { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #9CA3AF; }
.proy-amount { font-size: 52px; font-weight: 700; line-height: 1.05; margin: 6px 0 12px; letter-spacing: -.01em; }
.proy-state { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: #D1D5DB; font-size: 14px; }
.proy-brecha { margin: 14px 0 4px; font-size: 16px; color: #E5E7EB; }
.proy-ritmo { margin: 0; font-size: 14px; color: #9CA3AF; }
.proy-ritmo b { color: #E5E7EB; font-weight: 600; }
.hl-ok { color: #4ADE80; }
.hl-risk { color: #F87171; }

.gauge { position: relative; width: 240px; height: 132px; margin: 0 auto; overflow: hidden; }
.gauge-arc { position: absolute; left: 0; top: 0; width: 240px; height: 240px; border-radius: 50%; }
.gauge-hole { position: absolute; left: 28px; top: 28px; width: 184px; height: 184px; border-radius: 50%; background: #111827; }
.gauge-target { position: absolute; left: 119px; top: 0; width: 2px; height: 120px; transform-origin: 1px 120px; transform: rotate(60deg); }
.gauge-target::before { content: ''; position: absolute; left: 0; top: -4px; width: 2px; height: 36px; background: #fff; }
.gauge-text { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; display: grid; }
.gauge-text strong { font-size: 34px; font-weight: 700; line-height: 1; }
.gauge-text span { font-size: 12px; color: #9CA3AF; margin-top: 4px; }

.proy-cmps { display: grid; gap: 12px; }
.proy-cmp { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.proy-cmp span { font-size: 12px; color: #9CA3AF; }
.proy-cmp b { font-size: 26px; font-weight: 700; line-height: 1.15; }
.proy-cmp small { font-size: 12px; color: #9CA3AF; }
.proy-cmp .var-na { font-size: 18px; color: #6B7280; }

.proy-units {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}
.proy-unit { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; min-width: 0; }
.pu-name { font-size: 13px; font-weight: 600; color: #E5E7EB; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pu-name small { color: #9CA3AF; font-weight: 500; font-size: 12px; }
.pu-value { font-size: 20px; font-weight: 700; }
.pu-bar { position: relative; height: 6px; background: rgba(255, 255, 255, .14); border-radius: 999px; overflow: hidden; }
.pu-bar div { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.pu-bar i { position: absolute; top: 0; bottom: 0; left: 83.333%; width: 2px; background: #fff; }
.pu-pct { font-size: 12px; color: #9CA3AF; }
.proy-nota { margin: 14px 0 0; font-size: 12px; color: #9CA3AF; }
.tag-ref {
  display: inline-block; vertical-align: 2px; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; border: 1px dashed currentColor;
  font-size: 11px; font-weight: 600; color: #6B7280; letter-spacing: .02em;
}
.proy-hero .tag-ref { color: #9CA3AF; }
.pu-ok { color: #60A5FA; }
.pu-warn { color: #FBBF24; }
.pu-risk { color: #F87171; }

@media (max-width: 1100px) {
  .proy-top { grid-template-columns: minmax(0, 1fr) auto; }
  .proy-cmps { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .proy-hero { padding: 20px 16px; }
  .proy-top { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .proy-amount { font-size: 38px; }
  .proy-cmp b { font-size: 20px; }
  .proy-units { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pu-name small { display: none; }
}

/* Ventas por sucursal */
.suc-mes { display: grid; gap: 4px; min-width: 180px; }
.suc-mes label { margin: 0; }
.suc-carga-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.suc-carga-grid input[type="file"] { height: auto; padding: 10px; }
textarea {
  font: inherit; font-size: 13px; font-family: ui-monospace, 'IBM Plex Mono', monospace;
  width: 100%; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: var(--r-ctl);
  resize: vertical; background: #fff; color: var(--text);
}
.suc-errores { margin: 12px 0 0; padding: 12px 14px 12px 30px; background: #FDF0DC; color: #92400E; border-radius: var(--r-ctl); font-size: 13px; }
.suc-errores li:first-child { list-style: none; margin-left: -16px; margin-bottom: 4px; }
.sd-chart { height: 180px; display: flex; align-items: flex-end; gap: 3px; margin-top: 16px; border-bottom: 1px solid var(--border); }
.sd-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.sd-col > div { width: 100%; border-radius: 3px 3px 0 0; }
.sd-labels { display: flex; gap: 3px; margin-top: 4px; }
.sd-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--text-2); min-width: 0; }
.sd-labels .finde, .sdd .finde { color: #B45309; font-weight: 700; }
.sp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 16px; }
.sp-dia { background: var(--bg); border-radius: var(--r-ctl); padding: 10px 4px; display: grid; justify-items: center; gap: 2px; }
.sp-dia.finde { background: #FEF3C7; }
.sp-dia span { font-size: 12px; color: var(--text-2); }
.sp-dia strong { font-size: 15px; }
.sp-dia small { font-size: 11px; color: var(--text-2); }
.suc-buscar { width: 220px; height: 40px; }
.suc-row { cursor: pointer; }
.suc-row:hover td, .suc-row.abierta td { background: #F7F8FA; }
.suc-detalle td { background: #F7F8FA; }
.rank-bar { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; }
.rank-bar div { height: 100%; background: #F59E0B; border-radius: 999px; }
.sdd { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.sdd-dia { flex: 1 0 34px; display: grid; justify-items: center; gap: 2px; font-size: 11px; }
.sdd-bar { width: 100%; height: 70px; display: flex; align-items: flex-end; }
.sdd-bar div { width: 100%; border-radius: 3px 3px 0 0; }
.sdd-dia small { font-size: 10px; color: var(--text-2); }
@media (max-width: 760px) {
  .suc-buscar { width: 100%; }
  .sp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sd-chart, .sd-labels { gap: 1px; }
}

/* Clima */
.clima-card { margin-bottom: 16px; }
.clima-cmp { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.clima-cmp > div { background: var(--bg); border-radius: var(--r-ctl); padding: 12px 14px; display: grid; gap: 2px; }
.clima-cmp > div.ajustada { background: #EFF6FF; border: 1px solid #BFD0F7; }
.clima-cmp span { font-size: 12px; color: var(--text-2); }
.clima-cmp strong { font-size: 22px; font-weight: 700; }
.clima-cmp small { font-size: 12px; color: var(--text-2); }
.clima-dias { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.clima-dia {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px;
  display: grid; justify-items: center; gap: 2px; text-align: center; background: var(--surface);
}
.clima-dia.fuerte { border: 2px solid #F59E0B; padding: 9px 5px; }
.clima-dia.llueve { background: #EFF6FF; }
.cd-fecha { font-size: 13px; font-weight: 600; }
.clima-ico { width: 30px; height: 32px; }
.clima-ico.sin { display: grid; place-items: center; color: var(--text-2); }
.cd-temp { font-size: 16px; font-weight: 600; }
.cd-lluvia { font-size: 12px; color: #1D4ED8; min-height: 16px; }
.cd-peso { font-size: 11px; color: var(--text-2); }

/* Cargar ventas: días y comparativa */
.main-col { display: grid; gap: 20px; min-width: 0; }
.dias-input { width: 80px; min-width: 0; }
.dias-table input:disabled { background: #F7F8FA; color: var(--text-2); border-color: var(--border); }
.seg { display: inline-flex; border: 1px solid var(--input-border); border-radius: var(--r-ctl); overflow: hidden; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; font-weight: 500; color: #374151; }
.seg input:checked + span { background: var(--fineza); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }

.pesos-box { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.pesos-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.peso { margin: 0; display: grid; gap: 4px; font-size: 13px; }
.peso-input { position: relative; }
.peso-input input { padding-right: 24px; }
.peso-input i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--text-2); font-size: 13px; }
@media (max-width: 760px) { .pesos-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Colores de unidad */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin-right: 8px; vertical-align: 0; }
.col-stack { width: 100%; max-width: 48px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0; overflow: hidden; }
.col-stack > div { width: 100%; }
.col:not(.last) .col-stack { opacity: .72; }

/* Torta */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-top: 16px; }
.donut { width: 180px; height: 180px; border-radius: 50%; position: relative; flex: none; margin: 0 auto; }
.donut-hole {
  position: absolute; inset: 30px; background: var(--surface); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.donut-hole strong { font-size: 18px; font-weight: 600; }
.donut-hole span { font-size: 12px; color: var(--text-2); }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 220px; display: grid; gap: 10px; }
.donut-legend li { display: grid; grid-template-columns: 1fr auto 56px; gap: 10px; align-items: center; font-size: 14px; white-space: nowrap; }
.sw.pair { width: 7px; border-radius: 3px 0 0 3px; margin-right: -8px; }
.sw.pair + .sw { width: 7px; border-radius: 0 3px 3px 0; }
.donut-legend li.sub { padding-left: 22px; font-size: 13px; color: var(--text-2); }
.donut-legend li > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.donut-legend strong { text-align: right; }

/* Comparativa */
.cmp-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
.cmp-kpis div { background: var(--bg); border-radius: var(--r-ctl); padding: 10px 12px; display: grid; gap: 2px; }
.cmp-kpis span { font-size: 12px; color: var(--text-2); }
.cmp-kpis b { font-size: 22px; }
.cmp-list { display: grid; gap: 14px; }
.cmp-row { display: grid; gap: 5px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.cmp-row:last-child { border-bottom: 0; padding-bottom: 0; }
.cmp-row.sub { padding-left: 18px; }
.cmp-row.total { border-top: 2px solid var(--border); padding-top: 12px; }
.cmp-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; margin-bottom: 2px; }
.cmp-head span { font-size: 13px; color: var(--text-2); }
.cmp-bar { display: grid; grid-template-columns: 76px 1fr 96px; gap: 8px; align-items: center; font-size: 12px; }
.cmp-bar .lbl { color: var(--text-2); }
.cmp-bar .val { text-align: right; font-weight: 500; }
.cmp-bar .track { height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; }
.cmp-bar .track div { height: 100%; border-radius: 999px; }
.var-pos { color: #15803D; }
.var-neg { color: #B91C1C; }
.var-na { color: var(--text-2); }

.necesario-alto { color: #92400E; font-weight: 600; }
.necesario-ok { color: #1E3A8A; font-weight: 600; }
.nota { font-size: 13px; color: var(--text-2); margin: 12px 0 0; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .layout-side { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .header-inner { padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; }
  .tab { padding: 0 12px; }
  .user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .container { padding: 16px; }
  .notice-wrap { padding: 0 16px; }
  .card { padding: 16px; }
  .unidades, .dash-bottom { grid-template-columns: minmax(0, 1fr); }
  .kpi-value { font-size: 24px; }
  .chart-cols, .chart-labels { gap: 4px; }
  .cmp-bar { grid-template-columns: 64px 1fr 84px; }
  .cmp-kpis b { font-size: 18px; }
  .seg span { padding: 0 12px; }
}
