/* SEOBinmo · estilos — hoja de cálculo compacta: tablas por bloques, mínimo desplazamiento */
:root {
  /* Mismos tokens que el resto de aplicaciones SEOB (SEOBtopo, SEOBbc3): azul marino, acento azul, letra del sistema */
  --bg: #F6F8FA; --surface: #FFFFFF; --surface-2: #EEF2F6; --band: #E9EEF3; --line: #DCE2E8; --line-2: #C9D2DB;
  --ink: #1B2430; --ink-2: #3E4A57; --muted: #5A6570;
  --brand: #2E7DD2; --brand-2: #1F5FA6; --brand-ink: #FFFFFF; --brand-soft: #E3EEFA;
  --good: #2C7A4B; --good-soft: #DDF0E3; --warn: #9A6212; --warn-soft: #F7EBD2; --bad: #B3261E; --bad-soft: #F8DEDB;
  --accent: #9A6212; --accent-soft: #F7EBD2; --input: #FBFCFD;
  /* Cabecera: azul marino fijo, no sigue el tema claro/oscuro */
  --side-bg: #0F2030; --side-bg2: #16293B; --side-ink: #EAF0F5; --side-muted: #93A5B5; --side-line: rgba(255,255,255,.08); --side-active: rgba(46,125,210,.28);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Consolas, "Cascadia Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1420; --surface: #12202E; --surface-2: #182A3B; --band: #1B2D3F; --line: #223244; --line-2: #2E4257;
    --ink: #E7EDF3; --ink-2: #C2CFDA; --muted: #9FB0BE;
    --brand: #4DA3F0; --brand-2: #6DB5F3; --brand-ink: #0B1420; --brand-soft: #1B3550;
    --good: #6CC592; --good-soft: #173226; --warn: #E0A94B; --warn-soft: #3A2C12; --bad: #F08A80; --bad-soft: #3D1D1A;
    --accent: #E0A94B; --accent-soft: #3A2C12; --input: #0F1B28; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1420; --surface: #12202E; --surface-2: #182A3B; --band: #1B2D3F; --line: #223244; --line-2: #2E4257;
  --ink: #E7EDF3; --ink-2: #C2CFDA; --muted: #9FB0BE;
  --brand: #4DA3F0; --brand-2: #6DB5F3; --brand-ink: #0B1420; --brand-soft: #1B3550;
  --good: #6CC592; --good-soft: #173226; --warn: #E0A94B; --warn-soft: #3A2C12; --bad: #F08A80; --bad-soft: #3D1D1A;
  --accent: #E0A94B; --accent-soft: #3A2C12; --input: #0F1B28; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.muted { color: var(--muted); } .small { font-size: 11.5px; } .nowrap { white-space: nowrap; }
.pad { padding: 12px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.num, .n { font-variant-numeric: tabular-nums; }

/* Barra superior */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; align-items: center; gap: 20px; padding: 7px 16px; background: var(--side-bg); color: var(--side-ink); border-bottom: 1px solid var(--side-line); }
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--side-ink); }
.brand b { font: 700 15px var(--mono); letter-spacing: .3px; } .brand small { color: var(--side-muted); font-size: 11px; }
#nav { display: flex; gap: 2px; flex: 1; }
#nav a { padding: 5px 10px; border-radius: 6px; color: var(--side-muted); font-weight: 500; }
#nav a:hover { background: var(--side-bg2); color: var(--side-ink); } #nav a.on { background: var(--side-active); color: #fff; }
.user { display: flex; align-items: center; gap: 10px; color: var(--side-ink); }
.user a { color: var(--side-muted); } .user a:hover { color: var(--side-ink); }
.topbar .badge { background: rgba(255,255,255,.1); color: var(--side-ink); }
.badge { font-size: 10.5px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 500 12.5px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); } .btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); } .btn.small { padding: 3px 8px; font-size: 12px; } .btn.wide { width: 100%; justify-content: center; padding: 10px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); padding: 3px 6px; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.pulse { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }
.icon { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 3px 5px; border-radius: 5px; }
.icon:hover { background: var(--band); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Cabecera del estudio */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.head .title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.back { font-size: 12px; color: var(--muted); } .dirty { color: var(--warn); font-weight: 600; }

/* Pestañas */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-2); margin-bottom: 10px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 6px 12px; font: 500 12.5px var(--font); color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .tab-add { color: var(--muted); margin-left: auto; }

/* Paneles: un bloque = una tabla con cabecera de banda */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--band); border-bottom: 1px solid var(--line); }
.panel > header h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); font-weight: 600; }
.panel > header .tools { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.panel .body { padding: 8px 10px; }
.panel .scroll { overflow-x: auto; }
.cols { display: grid; gap: 10px; align-items: start; margin-bottom: 10px; }
.cols > * { min-width: 0; }
.c-solar { grid-template-columns: minmax(280px, 1fr) minmax(300px, 1fr) minmax(320px, 1.2fr); }
.c-esc { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.prog-panel { margin-bottom: 10px; }
.t.prog { width: max-content; min-width: 100%; }
.t.prog th, .t.prog td { padding: 2px 4px; }
.t.prog th:first-child, .t.prog td:first-child { padding-left: 8px; }
.t.prog select { padding: 0 1px; }
.t td.w40 > *, .t .w40 { width: 40px; } .t td.w48 > *, .t .w48 { width: 48px; } .t td.w52 > *, .t .w52 { width: 52px; } .t td.w56 > *, .t .w56 { width: 56px; } .t td.w64 > *, .t .w64 { width: 64px; } .t td.w72 > *, .t .w72 { width: 72px; }
.t td.w84 > *, .t .w84 { width: 84px; } .t td.w96 > *, .t .w96 { width: 96px; } .t td.w110 > *, .t .w110 { width: 110px; } .t td.w130 > *, .t .w130 { width: 130px; }
.fline.inl { padding: 6px 10px; border-bottom: 1px solid var(--line); gap: 14px; align-items: center; }
.fline.inl .f { display: flex; align-items: center; gap: 6px; }
.fline.inl .f > span { font-size: 11.5px; white-space: nowrap; }
.c-gastos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 10px; }

/* Tablas compactas tipo hoja */
table { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 3px 8px; border-bottom: 1px solid var(--line); height: 26px; vertical-align: middle; }
.t thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; text-align: left; background: var(--surface-2); white-space: nowrap; }
.t .r, .t th.r { text-align: right; } .t .c { text-align: center; }
.t td.n, .t th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tr.sec td { background: var(--surface-2); font-weight: 600; cursor: pointer; user-select: none; }
.t tr.sec td:first-child::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); transition: transform .12s; }
.t tr.sec.open td:first-child::before { transform: rotate(90deg); }
.t tr.det td:first-child { padding-left: 24px; color: var(--ink-2); }
.t tr.det td { font-size: 12.5px; }
.t tr.tot td { font-weight: 700; border-top: 1px solid var(--line-2); background: var(--surface-2); }
.t tr.big td { font-size: 14px; }
.t tr.sub td { color: var(--ink-2); font-weight: 600; }
.t tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-2); }
.t tr:last-child td { border-bottom: 0; }
.t .grp { text-align: center; border-left: 1px solid var(--line); }
.t .bl { border-left: 1px solid var(--line); }
.t.kv td:first-child { color: var(--ink-2); }
.t.kv td.n { font-weight: 500; }
.t .calc { background: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.t tr.base td { background: var(--brand-soft); font-weight: 600; }
.t.list tbody tr { cursor: pointer; } .t.list tbody tr:hover td { background: var(--surface-2); }
.pos { color: var(--good); } .neg { color: var(--bad); }
td.best { color: var(--good); font-weight: 700; background: var(--good-soft) !important; }

/* Entradas dentro de tablas: aspecto de celda editable */
.t input, .t select, .f input, .f select, .f textarea {
  width: 100%; min-width: 0; padding: 2px 6px; height: 22px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--input); color: var(--ink); font: 13px var(--font); font-variant-numeric: tabular-nums;
}
.t input.n, .f input.n { text-align: right; }
.t select { padding: 0 2px; cursor: pointer; }
.t input:hover, .t select:hover { border-color: var(--line-2); }
.t input:focus, .t select:focus, .f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.t input:disabled, .t select:disabled, .f input:disabled, .f select:disabled, .f textarea:disabled {
  border-color: transparent; background: transparent; color: var(--ink); opacity: 1; -webkit-text-fill-color: var(--ink); appearance: none; cursor: default;
}
.f textarea { height: auto; resize: vertical; padding: 4px 6px; }
.unit { display: flex; align-items: center; gap: 3px; } .unit span { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.w40 { width: 40px; } .w56 { width: 56px; } .w64 { width: 64px; } .w72 { width: 72px; } .w84 { width: 84px; } .w96 { width: 96px; } .w110 { width: 110px; } .w130 { width: 130px; }

/* Línea de datos horizontal */
.fline { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding: 8px 10px; }
.f { display: grid; gap: 2px; } .f > span { font-size: 11px; color: var(--muted); font-weight: 500; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.kpi { padding: 6px 10px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.kpi small { display: block; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.kpi.good { background: var(--good-soft); } .kpi.good b { color: var(--good); }
.kpi.warn { background: var(--warn-soft); } .kpi.warn b { color: var(--warn); }
.kpi.bad { background: var(--bad-soft); } .kpi.bad b { color: var(--bad); }
.chip { display: inline-block; padding: 0 7px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); }
.meter { display: inline-block; width: 60px; height: 6px; border-radius: 99px; background: var(--band); vertical-align: middle; overflow: hidden; margin-right: 6px; }
.meter i { display: block; height: 100%; background: var(--brand); }
.meter.over i { background: var(--bad); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.addbar { display: flex; gap: 2px; flex-wrap: wrap; padding: 4px 6px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* Mapa */
#map { height: 300px; background: var(--surface-2); }
.map-tools { display: flex; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.map-tools input { height: 24px; border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; background: var(--input); color: var(--ink); font: 12.5px var(--font); flex: 1; min-width: 120px; }
#p-mercado, #p-planea { margin-top: 10px; }
.mercado { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }
.merc-ideal { border-right: 1px solid var(--line); }
.pla-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }
.pla-grid > :first-child { border-right: 1px solid var(--line); }
.pla-grid details ul { margin: 2px 0 4px 16px; padding: 0; color: var(--muted); }
.pla-zonas details { margin-top: 2px; } .pla-zonas details p { margin: 2px 0; color: var(--muted); max-width: 70ch; }
.alert.warn { margin: 8px 10px; padding: 6px 10px; border-radius: 6px; font-size: 12px; background: color-mix(in srgb, #e0a100 14%, transparent); border: 1px solid color-mix(in srgb, #e0a100 45%, transparent); }
#planea-tools { display: flex; gap: 6px; }
.merc-ref { border-top: 1px solid var(--line); }
.merc-btns { display: flex; gap: 6px; } a.btn { text-decoration: none; }
.merc-test .t input[type=date] { width: 128px; }
#cat-info { justify-content: flex-start; align-items: center; color: var(--ink); }
.map-foot { padding: 4px 10px; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.leaflet-container { font: 12px var(--font); }
.seob-pin span { display: block; width: 24px; height: 24px; border-radius: 50% 50% 50% 0; background: #d2452f; border: 3px solid #fff; transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0,0,0,.35); }

/* Varios */
.empty { text-align: center; padding: 40px 20px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--muted); }
.alert { background: var(--bad-soft); color: var(--bad); padding: 8px 10px; border-radius: 6px; }
.note { font-size: 11.5px; color: var(--muted); padding: 5px 10px; border-top: 1px solid var(--line); }
.warnline { color: var(--bad); font-weight: 600; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px 10px; }
.levels div { background: var(--surface-2); padding: 6px 8px; border-radius: 6px; } .levels b { display: block; } .levels span { font-size: 11.5px; color: var(--muted); }
.inline-form { display: grid; grid-template-columns: 2fr 1.5fr 1fr auto; gap: 6px; padding: 8px 10px; }
#toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.ok { background: var(--good); color: #fff; } #toast.err { background: var(--bad); color: #fff; }
.modal { position: fixed; inset: 0; background: rgba(10, 15, 12, .45); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal > div { background: var(--surface); border-radius: 10px; padding: 16px; max-width: 380px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal p { margin: 0 0 14px; } .modal .actions { justify-content: flex-end; }

/* Login */

/* Responsive */
@media (max-width: 1280px) { .c-solar { grid-template-columns: 1fr 1fr; } .c-solar > :last-child { grid-column: 1 / -1; } .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } .kpi:nth-child(5) { border-left: 0; } .kpi:nth-child(n+5) { border-top: 1px solid var(--line); } }
@media (max-width: 1050px) { .c-esc, .c-gastos { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; } #nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .pla-grid { grid-template-columns: 1fr; } .pla-grid > :first-child { border-right: 0; }
  .mercado { grid-template-columns: 1fr; } .merc-ideal { border-right: 0; border-bottom: 1px solid var(--line); }
  .c-solar { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-left: 0; } .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .levels { grid-template-columns: 1fr 1fr; } .inline-form { grid-template-columns: 1fr; } .user > span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Impresión / PDF */
#print { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body.printing > :not(#print) { display: none !important; }
  body.printing #print { display: block; }
  body { background: #fff; color: #111; font-size: 10px; }
  #print .p-head { display: flex; justify-content: space-between; border-bottom: 2px solid #0F2030; padding-bottom: 4px; margin-bottom: 8px; color: #0F2030; }
  #print h1 { font-size: 16px; } #print h2 { font-size: 12px; margin: 10px 0 6px; color: #1F5FA6; }
  #print .p-esc { break-before: page; }
  #print .panel, #print .kpis { break-inside: avoid; border-color: #bbb; }
  #print .cols { grid-template-columns: 1.25fr .75fr; }
  #print .kpis { grid-template-columns: repeat(8, 1fr); }
  #print .t th, #print .t td { height: auto; padding: 2px 5px; }
  #print .t tr.sec td:first-child::before { content: ""; width: 0; }
}
.t .crit { font-size: 11px; color: var(--muted); line-height: 1.3; margin-top: 1px; white-space: normal; }
