:root {
  --bg: #0a1120; --panel: #101a2c; --panel2: #16223a; --border: #22314f;
  --text: #e7eef9; --muted: #8b9cba; --accent: #1f7aec; --accentText: #fff;
  --red: #ef4444; --green: #22c55e; --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); display: flex; font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
svg { fill: currentColor; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; }
[hidden] { display: none !important; }

/* ---------- Panel lateral ---------- */
.side {
  width: 248px; flex: none; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 7px; padding: 10px 12px; height: 100vh; position: sticky; top: 0;
  overflow-y: auto; scrollbar-width: none;
}
.side::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px 6px; border-bottom: 1px solid var(--border); }
.side .logo { max-width: 176px; }
/* Logo en dos capas: el azul de la marca (imagen) y "Info / RED RURAL" como máscara pintada con el color de texto del tema */
.logo { position: relative; display: block; width: 100%; max-width: 212px; aspect-ratio: 600 / 142; }
.logo img, .logo i { position: absolute; inset: 0; width: 100%; height: 100%; }
.logo i { background: var(--text); -webkit-mask: url(../img/logo-ink.png) center / 100% 100% no-repeat; mask: url(../img/logo-ink.png) center / 100% 100% no-repeat; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); font-weight: 700; padding: 2px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: 8px; border: 0; background: transparent;
  cursor: pointer; text-align: left; font-weight: 600; text-transform: uppercase; font-size: 13px;
}
.nav-item svg { width: 18px; height: 18px; opacity: .85; }
.nav-item:hover { background: var(--panel2); }
.nav-item.active { background: var(--accent); color: var(--accentText); }
.cfg-btn { border: 1px solid var(--border); }
.side-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; }
.side-card-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); font-weight: 700; }
.cot-value { font-size: 20px; font-weight: 800; margin: 1px 0 0; }
.upd-value { font-size: 13.5px; font-weight: 700; margin: 1px 0; }
.side-meta { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.dot.off { background: var(--red); }

/* ---------- Principal ---------- */
/* El panel lateral queda fijo: sólo scrollea el contenido principal */
body { height: 100vh; overflow: hidden; }
.main { flex: 1; min-width: 0; padding: 0 22px 40px; height: 100vh; overflow-y: auto; }
.view { padding-top: 18px; }
.pin {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; flex-direction: column; gap: 12px; margin-top: -18px; padding: 18px 0 10px;
  box-shadow: 0 10px 12px -10px rgba(0, 0, 0, .45);
}
.pin .totals-note { margin-top: -4px; }
.view { display: flex; flex-direction: column; gap: 16px; }
.head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
}
h1 { margin: 0; font-size: 22px; text-transform: uppercase; letter-spacing: .3px; }
.sub { color: var(--muted); margin-top: 2px; }
/* El encabezado del dashboard no cambia de alto: un título largo se corta con "…" en vez de bajar los filtros */
.pin .head { flex-wrap: nowrap; }
.pin .head > div:first-child { flex: 1; min-width: 0; }
.pin .head h1, .pin .head .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin .head .filters { flex: none; flex-wrap: nowrap; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fld input, .fld select {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 180px; color: var(--text);
}
.fld.wide input { min-width: 300px; }
.clr-wrap { position: relative; display: flex; }
.clr-wrap input, .clr-wrap select { width: 100%; padding-right: 34px; }
.clr-wrap select { padding-right: 52px; }
.clr {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer; color: var(--muted);
}
.clr-wrap select + .clr { right: 22px; }
.clr::before {
  content: ""; position: absolute; inset: 5px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3h6l1 2h4v2H4V5h4zm-3 6h12l-1 12H7zm3 2v8h2v-8zm4 0v8h2v-8z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3h6l1 2h4v2H4V5h4zm-3 6h12l-1 12H7zm3 2v8h2v-8zm4 0v8h2v-8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.clr:hover { color: var(--red); background: var(--panel); }
.fld.grow { flex: 1; } .fld.grow input { width: 100%; }
.fld.inline { flex-direction: row; align-items: center; gap: 8px; }
.fld.inline select { min-width: 0; padding: 5px 8px; }
.fld input:focus, .fld select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.btn {
  background: var(--accent); color: var(--accentText); border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 700; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn:hover { filter: brightness(1.1); }
.alert { background: color-mix(in srgb, #f59e0b 14%, var(--panel)); border: 1px solid color-mix(in srgb, #f59e0b 45%, transparent); border-radius: var(--radius); padding: 10px 14px; font-size: 12px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert summary { cursor: pointer; font-weight: 700; }

/* Ingreso */
body.locked .side, body.locked .main { display: none; }
.login-screen { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 16px; z-index: 50; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .fld input { width: 100%; min-width: 0; }
.login-brand { justify-content: center; margin-bottom: 18px; padding-bottom: 14px; }
.wide-btn { width: 100%; padding: 11px; }

/* Usuario en el panel lateral */
.who { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 6px 8px 6px 12px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; }
.who-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.who-txt b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-txt span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.who-out { background: transparent; border: 0; border-radius: 7px; width: 30px; height: 30px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.who-out svg { width: 18px; height: 18px; }
.who-out:hover { color: var(--red); background: var(--panel); }
.who + .cfg-btn { margin-top: 0; }

/* Configuración */
.cfg-sect { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: .4px; }
#cfgBody > .cfg-sect:first-child { border-top: 0; padding-top: 4px; }
/* Bloques plegables de configuración (acordeón): el cuerpo se abre/cierra animando la altura */
.cfg-blk { border-bottom: 1px solid var(--border); }
.cfg-blk-h { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 2px; background: none; border: 0; color: var(--text); font: inherit; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: .4px; text-align: left; cursor: pointer; }
.cfg-blk-h .small { text-transform: none; letter-spacing: 0; font-weight: 600; }
.cfg-blk-h:hover { color: var(--accent); }
.cfg-blk-h .pm { position: relative; flex: none; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 6px; }
.cfg-blk-h .pm::before, .cfg-blk-h .pm::after { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 2px; margin: -1px 0 0 -5px; background: currentColor; border-radius: 1px; transition: transform .3s ease; }
.cfg-blk-h .pm::after { transform: rotate(90deg); }
.cfg-blk.open .cfg-blk-h .pm::after { transform: rotate(0deg); }
.cfg-blk.open .cfg-blk-h { color: var(--accent); }
.cfg-blk-b { display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden; transition: grid-template-rows .35s ease, opacity .3s ease, visibility 0s .35s; }
.cfg-blk.open .cfg-blk-b { grid-template-rows: 1fr; opacity: 1; visibility: visible; transition-delay: 0s; }
.cfg-blk-in { min-height: 0; overflow: hidden; }
.cfg-blk-in > h3:first-child { margin-top: 2px; }
.cfg-blk-in::after { content: ''; display: block; height: 14px; }
#cfgBody.no-anim .cfg-blk-b, #cfgBody.no-anim .pm::after { transition: none; }
.dl-busy { align-self: flex-end; padding: 10px 0; min-width: 13ch; font-weight: 700; color: var(--accent); white-space: nowrap; animation: dl-blink 1s ease-in-out infinite; }
.side-busy { align-self: auto; padding: 0 6px; margin: -2px 0; font-size: 13px; }
@keyframes dl-blink { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
/* Botón del reloj con flecha: descarga cada 30 min. Apagado = ícono en el color del tema; prendido = botón lleno */
.btn.auto-btn { padding: 5px 7px; line-height: 0; color: var(--accent); }
.auto-btn svg { width: 25px; height: 25px; fill: currentColor; }
.auto-btn .ab-arc, .auto-btn .ab-hands { fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.btn.auto-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accentText); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.auto-btn:disabled { opacity: .5; cursor: wait; }
#dlTime:disabled, #dlSet:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(1); }
.dl-sched {margin-top: 6px; font-weight: 600; }
.dl-sched.ok { color: var(--ok, #34b77a); }
.dl-sched.pend { color: #e0a63b; }
#pwDialog { width: min(400px, 92vw); }
#pwDialog h2 { font-size: 16px; margin: 10px 0 6px; }
#pwDialog p { margin: 0 0 12px; line-height: 1.4; }
#pwDialog .dlg-foot { margin-top: 14px; }
/* Un solo scroll (el del cuerpo): la ventana no se desplaza entera */
#cfgDialog[open] { display: flex; flex-direction: column; overflow: hidden; }
#cfgDialog .dlg-body { flex: 1; min-height: 0; max-height: none; }
.users td { vertical-align: middle; }
.users select { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; color: var(--text); }
.u-act { display: flex; gap: 6px; align-items: center; }
.u-pw { width: 120px; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.danger:hover { color: var(--red); border-color: var(--red); }
.new-user { margin-top: 10px; }
.new-user .fld input, .new-user .fld select { min-width: 0; width: 150px; }

/* Totales */
.totals-wrap { position: relative; display: flex; flex-direction: column; gap: 12px; }
.tw-toggle {
  position: absolute; top: -9px; right: -9px; z-index: 2; width: 20px; height: 20px; border-radius: 50%; padding: 0;
  border: 1px solid var(--border); background: var(--panel2); color: var(--muted); cursor: pointer; font-weight: 800; font-size: 14px; line-height: 1;
}
.tw-toggle:hover { color: var(--text); border-color: var(--accent); }
.totals-line { display: none; }
.totals-wrap.collapsed .totals, .totals-wrap.collapsed .totals-note { display: none; }
.totals-wrap.collapsed .totals-line {
  display: flex; flex-wrap: wrap; gap: 4px 22px; align-items: baseline; padding: 6px 34px 6px 14px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px; font-variant-numeric: tabular-nums;
}
.totals-line small { color: var(--muted); text-transform: uppercase; font-size: 10.5px; letter-spacing: .5px; }
.totals-wrap.collapsed .tw-toggle { top: 50%; right: 8px; transform: translateY(-50%); }
.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2fr); gap: 12px; }
.total-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 14px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.total-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.t-red { --c: var(--red); } .t-blue { --c: #3b82f6; } .t-green { --c: var(--green); } .t-grain { --c: #eab308; }
.t-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.t-value { font-size: clamp(16px, 1.4vw, 23px); font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grain-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; margin-top: 2px; font-size: 11px; line-height: 1.35; }
.grain-mini span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grain-mini div { display: flex; justify-content: space-between; gap: 6px; }
.grain-mini b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals-note { font-size: 11px; color: var(--muted); margin-top: -8px; }

/* Cuadros */
.boxes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.box-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.box-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; flex: none; }
.box-ico.usd { background: #2563eb; } .box-ico.ars { background: #16a34a; } .box-ico.conv { background: #7c3aed; font-size: 10px; } .box-ico.grain { background: #ca8a04; } .box-ico.val { background: #0d9488; }
.box-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.box-total { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.buckets { display: flex; flex-direction: column; gap: 6px; }
.bk { display: grid; grid-template-columns: 50px 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.bk .lb { font-weight: 700; }
.bk .lb small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk .bar { height: 8px; background: var(--panel2); border-radius: 4px; position: relative; overflow: hidden; }
.bk .bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; }
.bk .bar i.neg { opacity: .45; }
.bk .v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.neg-v { color: var(--muted); }
.grain-list { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow-y: auto; overflow-x: hidden; }
.grain-list .bk { grid-template-columns: 110px 1fr auto; }
.grain-list .bk .lb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grain-list .bk .v { text-align: right; }
/* Disponibilidad valorizada (Pizarra Rosario): nombres cortos para que entren los U$S; fecha de los precios al pie */
#bVal .bk { grid-template-columns: 62px minmax(24px, 1fr) 14ch; }
.gran-note { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
/* El resaltado se agranda con sombra (no con márgenes) para no ensanchar la lista ni generar scroll */
.bk[data-tip] {border-radius: 4px; }
.bk[data-tip]:hover { background: var(--panel2); box-shadow: 0 0 0 3px var(--panel2); }
/* Ventana con los clientes de un renglón */
.bk-tip {
  position: fixed; z-index: 50; pointer-events: none; width: 380px; max-height: calc(100vh - 16px); overflow: hidden;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 12px; display: flex; flex-direction: column;
}
/* El listado se desplaza con la rueda del mouse, sin barra visible */
.bk-tip .tip-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.bk-tip .tip-list::-webkit-scrollbar { display: none; }
.bk-tip .tip-wheel { font-style: italic; }
.bk-tip .tip-h { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
.bk-tip .tip-h small { display: block; text-transform: none; color: var(--muted); font-size: 11px; letter-spacing: 0; }
.bk-tip .tip-s { color: var(--muted); margin: 3px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.bk-tip table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.bk-tip td { padding: 2px 0; white-space: nowrap; }
.bk-tip td:first-child { overflow: hidden; text-overflow: ellipsis; max-width: 240px; padding-right: 10px; }
.bk-tip td.r { font-weight: 600; }

/* Paneles */
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.grid2.tight { gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .3px; }
h2 small { font-weight: 400; text-transform: none; color: var(--muted); font-size: 13px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin: 18px 0 8px; }
.mini-h { margin-top: 0; }
.chip { font-size: 11px; background: var(--panel2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; color: var(--muted); }
.chart-wrap { position: relative; height: 290px; }
.chart-wrap.tall { height: 360px; }
.pie3d { position: absolute; inset: 0; display: grid; place-items: center; }
.pie3d-svg { width: 100%; height: 100%; }
.pie3d-pct { font-size: 12px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.35); stroke-width: 2px; }
.pie3d-leg { font-size: 12px; font-weight: 700; fill: var(--text); }
.pie3d-leg-v { font-size: 11px; fill: var(--muted); }
.pie3d-empty { fill: var(--muted); font-size: 14px; }

/* Tablas */
.table-scroll { max-height: 520px; overflow: auto; }
.table-scroll.short { max-height: 290px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px; background: var(--panel2); position: sticky; top: 0; z-index: 1; }
.tbl th.r { text-align: right; }
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover { color: var(--text); }
.tbl th.sorted { color: var(--accent); }
.tbl th.sorted::after { content: " ▼"; font-size: 9px; }
.tbl th.sorted.asc::after { content: " ▲"; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody tr:hover { background: var(--panel2); }
.tbl tr.click { cursor: pointer; }
.tbl tr.sel { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tbl tfoot td { font-weight: 800; border-top: 2px solid var(--border); }
#semaforo td:first-child { white-space: normal; }
#semaforo .pctbar { width: 40px; }
.sem { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.sem i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
.pctbar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--panel2); vertical-align: middle; margin-right: 6px; position: relative; overflow: hidden; }
.pctbar i { position: absolute; left: 0; top: 0; bottom: 0; }
.up { color: var(--red); } .down { color: var(--green); }
.more { margin: 10px auto 0; display: block; }
.movs summary { cursor: pointer; color: var(--accent); margin-top: 12px; font-weight: 600; }

/* Diálogo de configuración */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(720px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); margin: 0; }
.dlg-head h2 { font-size: 17px; }
.x { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
.dlg-body { padding: 6px 20px 20px; overflow-y: auto; max-height: calc(90vh - 60px); }
.dlg-body > .fld { margin: 12px 0; }
.dlg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.err { color: var(--red); font-size: 12px; min-height: 16px; margin: 6px 0; }
.ok { color: var(--green); font-size: 12px; }
.theme-row { align-items: center; }
.theme-cur { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 6px 12px; }
.theme-cur .sw { display: flex; width: 84px; height: 18px; border-radius: 4px; overflow: hidden; }
.theme-cur .sw span { flex: 1; }
.theme-cur .tn { font-size: 13px; font-weight: 600; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin-top: 8px; padding: 8px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; }
.themes { max-height: 300px; overflow-y: auto; }
.theme-group { grid-column: 1 / -1; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; padding: 4px 2px 0; }
.theme .tn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme { border: 2px solid transparent; border-radius: 8px; padding: 5px; cursor: pointer; background: var(--panel); text-align: left; }
.theme.active { border-color: var(--accent); }
.theme .sw { display: flex; height: 14px; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.theme .sw span { flex: 1; }
.theme .tn { font-size: 11px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 9px 16px; cursor: pointer; font-weight: 600; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: var(--accentText); }
.seg.sm button { padding: 4px 12px; font-size: 12px; }
.rank-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-item .ext { width: 13px; height: 13px; margin-left: auto; opacity: .55; }
.months { display: flex; flex-wrap: wrap; gap: 6px; }
.months button { background: var(--panel2); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 12px; font-weight: 600; min-width: 52px; }
.months button.on { background: var(--accent); color: var(--accentText); border-color: var(--accent); }
.months button sup { font-size: 9px; margin-left: 2px; }

/* ---------- Ventana Comparativa ---------- */
/* Compacta: entra entera en la ventana (1040x720) sin barras de scroll */
body.comp-page { display: block; height: auto; overflow: auto; }
/* La ventana se ajusta al contenido: nunca se muestra barra de scroll */
html:has(body.comp-page) { scrollbar-width: none; }
html:has(body.comp-page)::-webkit-scrollbar, body.comp-page::-webkit-scrollbar { display: none; }
.comp { padding: 8px 14px; display: flex; flex-direction: column; gap: 8px; max-width: 1400px; margin: 0 auto; }
.comp .head { padding: 8px 14px; gap: 12px; flex-wrap: nowrap; align-items: flex-end; }
.comp .head > div:first-child { min-width: 0; flex: 1; }
.comp h1 { font-size: 17px; }
.comp .sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp .filters { flex-wrap: nowrap; gap: 8px; }
.comp-leg { display: flex; gap: 14px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.comp .vs { font-weight: 800; font-size: 13px; color: var(--muted); padding-bottom: 8px; }
.comp .fld select { min-width: 0; width: 170px; padding-top: 6px; padding-bottom: 6px; }
/* A y B toman dos colores contrastantes del tema elegido (los fija comparativa.js) */
.vs-a::before, .vs-b::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; background: var(--ca); }
.vs-b::before { background: var(--cb); }
.comp .panel { padding: 10px 14px; }
.comp .panel-head { margin-bottom: 4px; }
.comp h2 { font-size: 13px; }
.comp h2 small { font-size: 12px; }
.comp .grid2 { gap: 10px; }
.comp .tbl { font-size: 11.5px; }
.comp .tbl th { padding: 3px 8px; font-size: 10.5px; }
.comp .tbl td { padding: 2px 8px; }
.comp .tbl tfoot td { padding-top: 3px; }
/* Posición (F.F. y SALDO F.F.): columnas alineadas con los grupos de barras del gráfico */
.pos { display: grid; max-width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; border-top: 1px solid var(--border); padding-top: 4px; }
.pos > div { padding: 3px 4px; white-space: nowrap; }
.pos-h { grid-column: 1 / -1; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: .3px; padding-bottom: 2px !important; }
.pos-l { font-weight: 800; font-size: 11.5px; color: var(--muted); }
.pos-v { text-align: center; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.comp-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.comp .t-label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp .t-value { font-size: 18px; line-height: 1.2; }
.comp-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 12px; border-left: 4px solid var(--c); min-width: 0; }
.comp-card.a { --c: var(--ca); } .comp-card.b { --c: var(--cb); } .comp-card.d { --c: var(--accent); }
.comp-split { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; }
.comp-split b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar3d { width: 100%; overflow: hidden; }
.bar3d-svg { display: block; max-width: 100%; height: auto; }
.bar3d-grid { stroke: var(--border); stroke-width: 1; fill: none; }
.bar3d-zero { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.bar3d-axis { font-size: 11px; fill: var(--muted); }
.bar3d-cat { font-size: 12.5px; font-weight: 800; fill: var(--text); }
.bar3d-sub { font-size: 10px; fill: var(--muted); }
.bar3d-val { font-size: 11px; font-weight: 700; fill: var(--text); }
.bar3d-leg { font-size: 12px; font-weight: 600; fill: var(--text); }
.bar3d-bar:hover { filter: brightness(1.15); }
@media (max-width: 800px) { .comp-cards { grid-template-columns: 1fr; } }

@media (max-width: 1180px) {
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .totals .t-grain { grid-column: span 2; }
  .pin .head { flex-wrap: wrap; }
  .pin .head .filters { flex-wrap: wrap; }
  .boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  body { flex-direction: column; height: auto; overflow: visible; }
  .side { width: auto; height: auto; position: static; }
  .main { height: auto; overflow: visible; }
  .pin { position: static; box-shadow: none; }
  .grid2 { grid-template-columns: 1fr; }
  .main { padding: 12px 16px 30px; }
}
@media (max-width: 600px) {
  .totals, .boxes { grid-template-columns: 1fr; }
  .totals .t-grain { grid-column: auto; }
  .fld input, .fld select, .fld.wide input { min-width: 0; width: 100%; }
  .filters, .filters .fld { width: 100%; }
}
