/* ============================================================
   Sistema de diseño "Trasteros y ·" — tema oscuro.
   Sin recursos remotos (fuentes de sistema). Reescrito (rediseño Fable).
   ============================================================ */
:root{
  --bg:#14171c; --bg-elev:#1c2128; --bg-row:#1a1f26; --bg-hover:#232a33; --bg-inset:#101317;
  --border:#2b323c; --border-strong:#3d4653;
  --text:#e6e8eb; --muted:#8b949e; --faint:#6e7681;
  --accent:#4a90d9; --accent-hover:#5da0e6; --accent-text:#0d1117;
  --ok:#2ea043; --ok-fg:#3fb950; --ok-bg:rgba(46,160,67,.14);
  --warn:#d29922; --warn-fg:#d9a62e; --warn-bg:rgba(210,153,34,.14);
  --danger:#b83b32; --danger-fg:#e5534b; --danger-bg:rgba(184,59,50,.14);
  --info:#3b82c4; --info-fg:#58a6ff; --info-bg:rgba(59,130,196,.14);
  --neutral-bg:rgba(139,148,158,.12);
  --s-ing:#3987e5; --s-gas:#d95926; --s-inv:#199e70; --s-pas:#8b949e;
  --grid:#242b34;
}
*{ box-sizing:border-box; }
html,body{ margin:0; }
body{
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-size:14px; line-height:1.45; color:var(--text); background:var(--bg);
}
a{ color:var(--accent); text-decoration:none; }
a:hover{ color:var(--accent-hover); }
.mono{ font-family: ui-monospace,"Cascadia Mono","SF Mono",Consolas,monospace;
  font-variant-numeric:tabular-nums; }
.muted{ color:var(--muted); }
.faint{ color:var(--faint); }
.num{ text-align:right; font-variant-numeric:tabular-nums; }
h1{ font-size:20px; font-weight:600; margin:0; }
h2{ font-size:16px; font-weight:600; margin:0; }

/* ---------- Navegación 2 niveles ---------- */
.topbar{ position:sticky; top:0; z-index:50; height:56px; display:flex; align-items:center;
  gap:24px; padding:0 24px; background:var(--bg-elev); border-bottom:1px solid var(--border); }
.brand{ font-size:18px; font-weight:700; color:var(--text); text-decoration:none; }
.brand .dot{ color:var(--accent); font-size:1.3em; line-height:0; }
.nav1{ display:flex; gap:4px; }
.nav1 a{ padding:7px 14px; border-radius:6px; color:var(--muted); text-decoration:none; font-size:14px; }
.nav1 a:hover{ background:var(--bg-hover); color:var(--text); }
.nav1 a.active{ background:var(--bg-hover); color:var(--text); font-weight:600; }
.verifactu{ margin-left:auto; display:inline-flex; align-items:center; gap:6px; font-size:12px;
  color:var(--muted); background:var(--neutral-bg); padding:4px 10px; border-radius:999px; }
.verifactu::before{ content:""; width:7px; height:7px; border-radius:50%; background:var(--ok-fg); }
.subnav{ display:flex; gap:4px; height:42px; padding:0 24px; align-items:stretch;
  background:var(--bg); border-bottom:1px solid var(--border); position:sticky; top:56px; z-index:40; }
.subnav a{ display:flex; align-items:center; padding:0 12px; color:var(--muted); text-decoration:none;
  font-size:13.5px; border-bottom:2px solid transparent; margin-bottom:-1px; }
.subnav a:hover{ color:var(--text); }
.subnav a.active{ color:var(--text); font-weight:600; border-bottom-color:var(--accent); }

/* ---------- Layout ---------- */
main{ max-width:1180px; margin:0 auto; padding:24px 24px 48px; }
.page-head{ display:flex; align-items:center; gap:12px; margin-bottom:16px; }
.page-head .title{ display:flex; align-items:baseline; gap:10px; }
.page-head .count{ color:var(--muted); font-size:12.5px; }
.page-head .spacer{ margin-left:auto; }
.nota{ color:var(--muted); font-size:12.5px; margin:8px 0; }
.hint{ color:var(--faint); font-size:12px; margin:4px 0 0; }
code{ background:var(--bg-inset); padding:.1em .35em; border-radius:4px; font-size:.9em; }

/* ---------- Botones ---------- */
.btn{ display:inline-flex; align-items:center; gap:6px; height:32px; padding:0 14px; font-size:14px;
  font-weight:500; border-radius:6px; border:1px solid transparent; background:transparent;
  color:var(--text); cursor:pointer; white-space:nowrap; text-decoration:none; }
.btn-sm{ height:26px; padding:0 10px; font-size:13px; }
.btn-primary{ background:var(--accent); color:var(--accent-text); font-weight:600; }
.btn-primary:hover{ background:var(--accent-hover); }
.btn-secondary{ background:var(--bg-elev); border-color:var(--border-strong); }
.btn-secondary:hover{ background:var(--bg-hover); }
.btn-ghost{ color:var(--muted); }
.btn-ghost:hover{ background:var(--bg-hover); color:var(--text); }
.btn-ghost-danger{ color:var(--danger-fg); }
.btn-ghost-danger:hover{ background:var(--danger-bg); }
.btn:focus-visible{ outline:2px solid rgba(74,144,217,.5); outline-offset:1px; }
.btn[disabled]{ opacity:.45; pointer-events:none; }

/* Grupo segmentado (− | + y Particular|Empresa) */
.btn-group{ display:inline-flex; }
.btn-group .btn{ border-radius:0; border:1px solid var(--border-strong); margin-left:-1px; }
.btn-group .btn:first-child{ border-radius:6px 0 0 6px; margin-left:0; }
.btn-group .btn:last-child{ border-radius:0 6px 6px 0; }
.btn-group .btn.active{ background:var(--accent); color:var(--accent-text); border-color:var(--accent); font-weight:600; }

/* ---------- Barra de filtros / mini-barra ---------- */
.filter-bar{ display:flex; gap:8px; margin-bottom:12px; align-items:center; flex-wrap:wrap; }
.filter-bar input[type="search"], .filter-bar input.search{ width:260px; }
.toggle-inline{ display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); cursor:pointer; }

/* ---------- Tablas ---------- */
.table{ width:100%; border-collapse:collapse; background:var(--bg-elev); border:1px solid var(--border);
  border-radius:8px; overflow:hidden; }
.table thead th{ font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.06em;
  color:var(--muted); text-align:left; padding:10px 12px; border-bottom:1px solid var(--border-strong); }
.table tbody td{ padding:10px 12px; border-bottom:1px solid var(--border); vertical-align:middle; }
.table tbody tr:last-child td{ border-bottom:none; }
.table tbody tr:hover{ background:var(--bg-hover); }
.table.zebra tbody tr:nth-child(even){ background:var(--bg-row); }
.table td.num, .table th.num{ text-align:right; }
.table td.center, .table th.center{ text-align:center; }
.table tfoot td{ padding:10px 12px; border-top:2px solid var(--border-strong); font-weight:600; }
.cell-l1{ font-weight:500; }
.cell-l2{ font-size:12.5px; color:var(--muted); }
.doc-prefix{ color:var(--muted); }
.empty-row td{ text-align:center; color:var(--muted); padding:24px 12px; }

/* ---------- Card ---------- */
.card{ background:var(--bg-elev); border:1px solid var(--border); border-radius:8px; padding:24px; }
.card-narrow{ max-width:640px; margin:0 auto; }

/* ---------- Badges (semáforo §4.2) ---------- */
.badge{ display:inline-flex; align-items:center; gap:6px; height:22px; padding:0 10px;
  border-radius:999px; font-size:12px; font-weight:500;
  background:var(--badge-bg,var(--neutral-bg)); color:var(--badge-fg,var(--muted)); }
.badge::before{ content:""; width:8px; height:8px; border-radius:50%; background:var(--badge-fg,var(--muted)); }
.badge-debe{ --badge-bg:var(--danger-bg); --badge-fg:var(--danger-fg); }
.badge-aldia{ --badge-bg:var(--ok-bg); --badge-fg:var(--ok-fg); }
.badge-adelantado{ --badge-bg:var(--info-bg); --badge-fg:var(--info-fg); }
.badge-sindato{ --badge-bg:var(--neutral-bg); --badge-fg:var(--muted); }
.badge-baja{ --badge-bg:var(--neutral-bg); --badge-fg:var(--faint); }
.badge-neutral{ --badge-bg:var(--neutral-bg); --badge-fg:var(--muted); }

/* ---------- Franja de estado + baja ---------- */
tr.estado{ box-shadow: inset 3px 0 0 var(--estado-color); }
tr.estado-debe{ --estado-color:var(--danger-fg); }
tr.estado-aldia{ --estado-color:var(--ok-fg); }
tr.estado-adelantado{ --estado-color:var(--info-fg); }
tr.estado-sindato{ --estado-color:var(--muted); }
tr.baja{ --estado-color:var(--faint); opacity:.55; box-shadow: inset 3px 0 0 var(--faint); }

/* ---------- Chips (resumen = filtros) ---------- */
.chips{ display:flex; gap:8px; margin-bottom:16px; flex-wrap:wrap; }
.chip{ display:flex; flex-direction:column; gap:2px; min-width:110px; padding:10px 14px;
  background:var(--bg-elev); border:1px solid var(--border); border-radius:8px; cursor:pointer; text-decoration:none; }
.chip:hover{ background:var(--bg-hover); }
.chip.active{ border-color:var(--border-strong); background:var(--bg-hover); }
.chip .num{ font-size:20px; font-weight:600; color:var(--text); display:flex; align-items:center; gap:8px; text-align:left; }
.chip .num::before{ content:""; width:8px; height:8px; border-radius:50%; background:var(--chip-dot,var(--muted)); }
.chip .lbl{ font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
.chip-deben{ --chip-dot:var(--danger-fg); }
.chip-aldia{ --chip-dot:var(--ok-fg); }
.chip-adelantado{ --chip-dot:var(--info-fg); }
.chip-sindato{ --chip-dot:var(--muted); }
.chip-todos{ --chip-dot:var(--accent); }

/* ---------- Cabecera ordenable ---------- */
th.sortable a{ color:inherit; text-decoration:none; display:inline-flex; align-items:center; }
th.sortable a:hover{ color:var(--text); }
th.sortable .dir{ margin-left:4px; color:var(--accent); }

/* ---------- Acciones de fila (cobros) ---------- */
.row-actions{ display:flex; gap:6px; justify-content:flex-end; align-items:center; }
.row-actions .cobrar-slot{ min-width:96px; display:flex; justify-content:flex-end; }
details.menu{ position:relative; }
details.menu > summary{ list-style:none; cursor:pointer; }
details.menu > summary::-webkit-details-marker{ display:none; }
details.menu[open] > .menu-body{ position:absolute; right:0; top:calc(100% + 4px); z-index:20;
  min-width:200px; background:var(--bg-elev); border:1px solid var(--border-strong);
  border-radius:6px; padding:4px; }
.menu-body button{ display:block; width:100%; text-align:left; padding:7px 10px; font-size:13px;
  color:var(--text); background:none; border:0; border-radius:4px; cursor:pointer; }
.menu-body button:hover{ background:var(--bg-hover); }
.menu-body button.danger{ color:var(--danger-fg); }
.menu-body button.danger:hover{ background:var(--danger-bg); }
.menu-body .fijar-row{ display:flex; gap:6px; align-items:center; padding:6px 8px; }
.menu-body .fijar-row input[type="month"]{ flex:1; min-width:0; }

/* ---------- Formularios ---------- */
label{ display:block; }
.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.field > .label, .form-label{ font-size:12px; font-weight:600; text-transform:uppercase;
  letter-spacing:.06em; color:var(--muted); }
input, select, textarea{ height:34px; background:var(--bg-inset); color:var(--text);
  border:1px solid var(--border); border-radius:6px; padding:0 10px; font-size:14px; font-family:inherit; width:100%; }
textarea{ height:auto; padding:8px 10px; }
select{ appearance:auto; }
input:focus, select:focus, textarea:focus{ outline:none; border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(74,144,217,.25); }
input[type="checkbox"]{ width:auto; height:auto; }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
fieldset{ border:none; border-top:1px solid var(--border); padding:16px 0 0; margin:20px 0 0; }
fieldset:first-of-type{ border-top:none; padding-top:0; margin-top:0; }
fieldset > legend{ font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.06em;
  color:var(--muted); padding:0; margin-bottom:4px; }
.check-inline{ display:flex; align-items:center; gap:8px; }
.check-inline.locked{ opacity:.6; pointer-events:none; }
.check-inline .label{ text-transform:none; letter-spacing:normal; font-size:13px; font-weight:400; color:var(--text); }
.form-actions{ display:flex; justify-content:flex-end; gap:8px; margin-top:20px; }
.field-error{ color:var(--danger-fg); font-size:12px; margin-top:4px; }
input.err, select.err{ border-color:var(--danger-fg); }

/* ---------- Mensajes ---------- */
.alert{ padding:10px 14px; border-radius:6px; font-size:13px; margin-bottom:16px; }
.alert-danger{ background:var(--danger-bg); border:1px solid var(--danger-fg); color:var(--danger-fg); }
.alert-ok{ background:var(--ok-bg); border:1px solid var(--ok-fg); color:var(--ok-fg); }
.alert-warn{ background:var(--warn-bg); border:1px solid var(--warn-fg); color:var(--warn-fg); }
.envio.ok{ color:var(--ok-fg); font-size:12.5px; }
.envio.error{ color:var(--danger-fg); font-size:12.5px; }
.enviada-tag{ color:var(--muted); font-size:12.5px; }

/* ---------- Dropzone (DNIs) ---------- */
.dropzone{ height:140px; width:100%; border:2px dashed var(--border); border-radius:8px;
  background:var(--bg-inset); display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:6px; color:var(--muted); cursor:pointer; text-align:center; padding:12px; }
.dropzone.drag{ border-color:var(--accent); background:var(--info-bg); color:var(--text); }
.dropzone .dz-files{ list-style:none; padding:0; margin:6px 0 0; font-size:12.5px; color:var(--text); }

/* ---------- Generar factura (bloque inline) ---------- */
.inline-panel{ background:var(--bg-elev); border:1px solid var(--border-strong); border-radius:8px;
  padding:16px; margin-bottom:16px; }
details.gen{ position:relative; }
details.gen > summary{ list-style:none; }
details.gen > summary::-webkit-details-marker{ display:none; }
details.gen[open] > .inline-panel{ position:absolute; right:0; top:calc(100% + 8px);
  width:min(820px,88vw); z-index:30; }

/* ---------- Indicador HTMX ---------- */
.htmx-request{ opacity:.6; pointer-events:none; }

footer{ color:var(--faint); font-size:11.5px; padding:32px 24px; text-align:center; }

/* ============================================================
   Bloque finanzas (rediseño dashboard + extracto) — prefijo .fx-
   ============================================================ */
.tblwrap{ overflow-x:auto; }
.htmx-indicator{ opacity:0; transition:opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator{ opacity:1; }

.fx-scope{ display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--muted); }
.fx-scope .btn-ghost{ padding:0 8px; }
.fx-scope .period{ min-width:120px; text-align:center; font-weight:600; color:var(--text); font-size:14px; }
.fx-lbl{ font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
.fx-sub{ font-size:12.5px; color:var(--muted); }

.fx-hero{ display:grid; grid-template-columns:minmax(0,5fr) minmax(0,7fr); gap:12px; margin-bottom:12px; }
.fx-hero .card{ padding:20px 24px; display:flex; flex-direction:column; gap:10px; min-width:0; }
.fx-big{ font-size:48px; line-height:1.05; font-weight:600; letter-spacing:-.01em; }
.fx-delta{ display:inline-flex; align-items:center; gap:6px; font-size:13px; font-weight:600; padding:2px 8px; border-radius:999px; }
.fx-delta.up{ color:var(--ok-fg); background:var(--ok-bg); }
.fx-delta.down{ color:var(--danger-fg); background:var(--danger-bg); }
.fx-spark{ width:100%; height:56px; display:block; margin-top:auto; }
.fx-spark .all{ fill:none; stroke:var(--faint); stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.fx-spark .sel{ fill:none; stroke:var(--s-ing); stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.fx-spark .dot{ fill:var(--s-ing); stroke:var(--bg-elev); stroke-width:2; }
.fx-legend{ display:flex; gap:14px; flex-wrap:wrap; font-size:12.5px; color:var(--muted); }
.fx-legend span{ display:inline-flex; align-items:center; gap:6px; }
.fx-legend i{ width:10px; height:10px; border-radius:3px; display:inline-block; }
.fx-cols{ width:100%; max-width:100%; height:auto; display:block; }
.fx-spark{ max-width:100%; }
.fx-cols .s-ing{ fill:var(--s-ing); } .fx-cols .s-gas{ fill:var(--s-gas); }
.fx-cols .dim{ opacity:.32; }
.fx-cols .grid{ stroke:var(--grid); stroke-width:1; } .fx-cols .base{ stroke:var(--border-strong); stroke-width:1; }
.fx-cols .ax{ fill:var(--faint); font-size:10.5px; font-family:inherit; font-variant-numeric:tabular-nums; }
.fx-cols .val{ fill:var(--text); font-size:11px; font-weight:600; font-family:inherit; }
.fx-cols rect:hover{ filter:brightness(1.18); }

.fx-tiles{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:28px; }
.fx-tile{ background:var(--bg-elev); border:1px solid var(--border); border-radius:8px; padding:16px 18px; display:flex; flex-direction:column; gap:8px; min-height:150px; min-width:0; }
.fx-tile .v{ font-size:26px; font-weight:600; line-height:1.1; }
.fx-tile .foot{ margin-top:auto; font-size:12px; color:var(--faint); }
.fx-bars{ display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--muted); }
.fx-bars .row{ display:grid; grid-template-columns:86px minmax(0,1fr) auto; align-items:center; gap:8px; }
.fx-bars .track{ height:8px; border-radius:4px; background:var(--bg-inset); overflow:hidden; }
.fx-bars .fill{ height:100%; border-radius:0 4px 4px 0; min-width:2px; }
.fx-bars .val{ color:var(--text); font-variant-numeric:tabular-nums; }
.fx-meter{ height:10px; border-radius:5px; background:rgba(25,158,112,.18); overflow:hidden; }
.fx-meter .fill{ height:100%; background:var(--s-inv); border-radius:0 5px 5px 0; }

.fx-sec{ display:flex; align-items:baseline; gap:10px; margin:0 0 10px; }
.fx-sec .count{ color:var(--muted); font-size:12.5px; }
.fx-two{ display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; margin:12px 0; }
.fx-two .card{ padding:18px 20px; min-width:0; }
.fx-two h2{ margin-bottom:12px; }
.fx-hbars{ display:flex; flex-direction:column; gap:8px; }
.fx-hbars .row{ display:grid; grid-template-columns:96px minmax(0,1fr) 70px; align-items:center; gap:10px; font-size:13px; }
.fx-hbars .track{ height:14px; position:relative; }
.fx-hbars .fill{ height:100%; background:var(--s-gas); border-radius:0 4px 4px 0; min-width:2px; }
.fx-hbars .num{ font-variant-numeric:tabular-nums; }
.fx-dl{ display:grid; grid-template-columns:minmax(0,1fr) auto; row-gap:8px; column-gap:16px; font-size:13.5px; }
.fx-dl dt{ color:var(--muted); margin:0; } .fx-dl dd{ margin:0; text-align:right; font-variant-numeric:tabular-nums; }
.fx-dl .total{ border-top:1px solid var(--border-strong); padding-top:8px; font-weight:600; color:var(--text); }
.fx-dl .total dd{ font-weight:700; }
.fx-inv-list{ display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:6px 14px; font-size:13px; }
.fx-inv-list .h{ font-size:11.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-weight:600; }
.fx-inv-list .n{ text-align:right; font-variant-numeric:tabular-nums; }
.fx-stack{ display:flex; height:10px; border-radius:5px; overflow:hidden; gap:2px; margin-top:12px; }
.fx-stack .a{ background:var(--s-inv); } .fx-stack .b{ background:var(--bg-inset); flex:1; }

@media (max-width:900px){ .fx-hero{ grid-template-columns:minmax(0,1fr); } .fx-tiles{ grid-template-columns:repeat(2,minmax(0,1fr)); } .fx-two{ grid-template-columns:minmax(0,1fr); } }
@media (max-width:520px){ .fx-tiles{ grid-template-columns:minmax(0,1fr); } .fx-big{ font-size:40px; } }

/* ---------- Auth (login / recuperar / reset / cambiar contraseña) ---------- */
.usermenu{ margin-left:16px; display:flex; align-items:center; gap:14px; }
.usermenu a{ color:var(--muted); font-size:14px; text-decoration:none; }
.usermenu a:hover, .usermenu a.active{ color:var(--text); }
.usermenu a.salir{ color:var(--danger-fg); }
.usermenu a.salir:hover{ color:#f08a82; }
.auth-card{ max-width:400px; margin:56px auto; }
.auth-card h1{ margin:0 0 6px; }
.auth-form{ display:flex; flex-direction:column; gap:14px; margin-top:18px; }
.auth-form label{ font-size:13px; color:var(--muted); }
.auth-form input{ width:100%; margin-top:5px; }
.auth-form .btn{ margin-top:6px; width:100%; justify-content:center; height:36px; }
.auth-alt{ margin-top:16px; font-size:14px; }
.auth-alt a{ color:var(--accent); text-decoration:none; }
.auth-alt a:hover{ text-decoration:underline; }
.auth-error{ background:var(--danger-bg); color:var(--danger-fg); border:1px solid var(--danger); border-radius:6px; padding:10px 12px; font-size:14px; margin-top:12px; }
.auth-ok{ background:var(--ok-bg); color:var(--ok-fg); border:1px solid var(--ok); border-radius:6px; padding:10px 12px; font-size:14px; margin-top:12px; }
