@font-face { font-family: 'Roboto Local'; font-weight: 400; src: url('vendor/roboto-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Roboto Local'; font-weight: 500; src: url('vendor/roboto-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Roboto Local'; font-weight: 700; src: url('vendor/roboto-latin-700-normal.woff2') format('woff2'); }

/* Layout: navy sidebar + sticky filter header + scrolling content; orange marks what is active. */
:root {
  --font: 'Roboto Local', Roboto, 'Segoe UI', Arial, sans-serif;
  --navy: #002856; --navy-2: #0B3A70; --orange: #DC4E10; --orange-soft: #FCE9E0; --blue: #2A4EEF;
  --bg: #F4F5F7; --panel: #FFFFFF; --soft: #F0F2F5; --line: #DDE1E6; --field: #FFFFFF;
  --fg: #141A22; --muted: #5B6573; --head: #002856;
  --ok: #1E7A46; --bad: #C2410C; --warn: #B45309; --bad-soft: #FDECE4;
  --s0: #002856; --s1: #DC4E10; --s2: #2A4EEF; --s3: #8A98AB; --s4: #F2A27A; --s5: #14877A;
  --grid: #E8EBEF; --axis: #BCC3CC;
  --side-fg: #FFFFFF; --side-muted: #A9BAD3; --side-hover: rgba(255,255,255,.08);
  --shadow: 0 1px 2px rgba(0,20,50,.06), 0 4px 16px rgba(0,20,50,.06);
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1520; --panel: #151F2D; --soft: #1B2737; --line: #2A3850; --field: #101824;
    --fg: #E8EDF3; --muted: #9AA8BA; --head: #CFDDF0; --orange-soft: #3A2116;
    --ok: #5FD08E; --bad: #FF8A5B; --warn: #F2B35B; --bad-soft: #3A1E14;
    --s0: #6F96D3; --s1: #F06A2E; --s2: #7D93F7; --s3: #8D9BB0; --s4: #F6BB98; --s5: #3CC2AE;
    --grid: #223047; --axis: #44536B; --navy: #0A2447;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2 { text-wrap: balance; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* --- botones --- */
.btn { border: 1px solid transparent; border-radius: var(--r); padding: 8px 16px; font-weight: 500; cursor: pointer; background: none; line-height: 1.2; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: #C24410; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-secondary { border-color: var(--line); background: var(--panel); color: var(--head); }
.btn-secondary:hover { border-color: var(--head); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-link { color: var(--orange); padding: 4px 6px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-ghost-light { border-color: rgba(255,255,255,.5); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.1); }
.btn-side { width: 100%; border-color: rgba(255,255,255,.25); color: #fff; font-size: 13px; padding: 7px 10px; }
.btn-side:hover { background: var(--side-hover); }
.btn-side:disabled { opacity: .55; cursor: progress; }

/* --- bienvenida --- */
.onb { min-height: 100%; display: grid; place-items: center; padding: 32px; background: var(--bg); }
.onb-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); max-width: 980px; width: 100%; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); background: var(--panel); }
.onb-intro { background: var(--navy); color: #fff; padding: 40px 36px; display: flex; flex-direction: column; gap: 16px; }
.onb-intro h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.onb-intro p { margin: 0; color: #D5DEEA; line-height: 1.5; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--orange); }
.onb-points { list-style: none; margin: 8px 0 auto; padding: 0; display: grid; gap: 12px; color: #D5DEEA; line-height: 1.4; }
.onb-points li { padding-left: 14px; border-left: 3px solid var(--orange); }
.onb-points b { display: block; color: #fff; }
.onb-intro .btn { align-self: flex-start; margin-top: 16px; }
.onb-form { padding: 36px; display: grid; gap: 14px; align-content: start; }
.onb-form h2 { margin: 0; font-size: 20px; color: var(--head); }
.onb-form p { margin: 0; line-height: 1.45; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: var(--field); padding: 9px 11px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(42,78,239,.15); }
.field small { font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw { position: relative; display: block; }
.pw input { padding-right: 56px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px 6px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: var(--r); background: var(--bad-soft); color: var(--bad); font-size: 13px; line-height: 1.4; }
.form-hint { margin: 0; font-size: 12px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-actions.left { justify-content: flex-start; }
.saved { color: var(--ok); font-size: 13px; }

/* --- estructura --- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100%; }
.side { background: var(--navy); color: var(--side-fg); display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; min-height: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand div { display: grid; line-height: 1.2; }
.brand strong { font-size: 15px; }
.brand span { font-size: 11px; color: var(--side-muted); letter-spacing: .06em; text-transform: uppercase; }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: var(--r); background: none; color: var(--side-muted); cursor: pointer; text-align: left; font-weight: 500; position: relative; }
.nav-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--orange); }
.nav-sep { height: 1px; background: rgba(255,255,255,.12); margin: 8px 4px; }
.user { margin-top: auto; display: grid; gap: 2px; padding: 0 12px; font-size: 13px; }
.user span { color: #fff; overflow-wrap: anywhere; }
.user-out { color: var(--side-muted); font-size: 12px; text-decoration: none; }
.user-out:hover { color: #fff; text-decoration: underline; }
.user:not([hidden]) + .sync { margin-top: 0; }
.sync { margin-top: auto; display: grid; gap: 6px; padding: 12px; border-radius: var(--r); background: rgba(255,255,255,.06); font-size: 13px; }
.sync-row { display: flex; align-items: center; gap: 8px; }
.sync-sub { font-size: 12px; color: var(--side-muted); line-height: 1.35; overflow-wrap: anywhere; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s3); flex: none; }
.dot.ok { background: #4CC38A; }
.dot.run { background: var(--orange); animation: pulse 1.2s ease-in-out infinite; }
.dot.err { background: #FF6B4A; }
.dot.demo { background: #F2B35B; }
@keyframes pulse { 50% { opacity: .35; } }

.main { min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 20px 28px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.top-title { min-width: 0; }
.top h1 { margin: 0; font-size: 24px; color: var(--head); }
.takeaway { margin: 4px 0 0; color: var(--muted); }
.takeaway b { color: var(--fg); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--orange); color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .range input { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 7px 10px; max-width: 220px; min-width: 0; }
.filters select.on { border-color: var(--orange); background: var(--orange-soft); }
.range { display: flex; align-items: center; gap: 6px; }
.banner { margin: 16px 28px 0; padding: 10px 14px; border-radius: var(--r); background: var(--orange-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.banner-error { background: var(--bad-soft); color: var(--bad); }
.content { padding: 20px 28px 32px; display: grid; gap: 16px; }
.empty { margin: 0; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); }
.page { display: grid; gap: 16px; min-width: 0; }

/* --- indicadores --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
@media (min-width: 900px) { .kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 4px; align-content: start; box-shadow: var(--shadow); min-width: 0; }
.kpi-main { box-shadow: var(--shadow), inset 0 3px 0 var(--orange); }
.kl { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv { display: flex; align-items: baseline; gap: 5px; }
.kv b { font-size: 28px; font-weight: 700; color: var(--head); font-variant-numeric: tabular-nums; line-height: 1.15; }
.kv small { color: var(--muted); font-size: 13px; }
.kd { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.up { color: var(--ok); }
.down { color: var(--bad); }

/* --- tarjetas y gráficos --- */
.card { background: var(--panel); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px; align-content: start; box-shadow: var(--shadow); min-width: 0; }
.card-h h2 { margin: 0; font-size: 16px; color: var(--head); }
.card-h p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.chart { position: relative; min-height: 240px; }
.chart svg { display: block; overflow: visible; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridl { stroke: var(--grid); }
.axis { stroke: var(--axis); }
.nodata { min-height: inherit; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.hbars { display: grid; gap: 8px; min-height: 120px; align-content: start; }
.hb { display: grid; grid-template-columns: minmax(90px, 180px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; border-radius: 4px; padding: 2px 4px; margin: 0 -4px; }
.hbars.click .hb { cursor: pointer; }
.hbars.click .hb:hover { background: var(--soft); }
.hb.sel { background: var(--orange-soft); }
.hb-l { overflow-wrap: anywhere; }
.hb-t { height: 14px; background: var(--grid); border-radius: 3px; overflow: hidden; display: flex; }
.stack .hb-t { height: 24px; }
.hb-b { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 500; overflow: hidden; white-space: nowrap; }
.hb-v { font-variant-numeric: tabular-nums; text-align: right; min-width: 72px; font-weight: 500; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 6px 20px rgba(0,20,50,.18); padding: 8px 10px; font-size: 12px; display: grid; gap: 3px; white-space: nowrap; }
.tip-h { color: var(--muted); }
.tip-r { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }

/* --- tablas --- */
.tbox { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; background: var(--soft); text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--head); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th:hover { color: var(--orange); }
.tbl th[aria-sort]::after { content: " ↓"; color: var(--orange); }
.tbl th[aria-sort="ascending"]::after { content: " ↑"; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--soft); }
.tbl.click tbody tr { cursor: pointer; }
.tbl .r { text-align: right; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.share { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.share i { display: inline-block; height: 6px; border-radius: 3px; background: var(--s0); opacity: .8; }
.defs { margin: 0; font-size: 12px; color: var(--muted); max-width: 90ch; line-height: 1.5; }

/* --- configuración --- */
.settings { display: grid; gap: 16px; max-width: 760px; }
.kvlist { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 13px; }
.kvlist dt { color: var(--muted); }
.kvlist dd { margin: 0; overflow-wrap: anywhere; }
.confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--r); background: var(--bad-soft); color: var(--bad); font-size: 13px; }

[data-refresh] { transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) { .dot.run { animation: none; } }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 68px minmax(0, 1fr); }
  .brand div, .nav-item span, .sync-sub, #sync-text, #user-name { display: none; }
  .user { padding: 0; text-align: center; }
  .brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; }
  .sync { padding: 8px; justify-items: center; }
  .btn-side { font-size: 0; padding: 8px; }
  .btn-side::before { content: "↻"; font-size: 16px; }
  .hide-sm { display: none; }
}
@media (max-width: 760px) {
  .onb-card { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .banner { margin-left: 16px; margin-right: 16px; }
}
body.invitado [data-goto="ajustes"] { display: none; }

/* --- usuarios --- */
.settings.wide { max-width: 980px; }
.tbl.static th { cursor: default; }
.tbl.static th:hover { color: var(--head); }
.inline-form { display: grid; gap: 12px; padding-top: 4px; }
.inline-form h3 { margin: 4px 0 0; font-size: 14px; color: var(--head); }
.field-row.three { grid-template-columns: 1.2fr 1.2fr auto; align-items: end; }
.field.check { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; }
.field.check input { width: auto; }
.field.check span { font-size: 13px; color: var(--fg); }
.result { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--r); background: color-mix(in srgb, var(--ok) 10%, transparent); font-size: 13px; }
.result code { display: block; padding: 8px 10px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; overflow-wrap: anywhere; user-select: all; }
.result .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.acts { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.acts .btn { padding: 4px 8px; font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--soft); color: var(--muted); }
.tag.admin { background: var(--orange-soft); color: var(--orange); }
.tag.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.inline-confirm { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--bad); }
@media (max-width: 760px) { .field-row.three { grid-template-columns: 1fr; } }

/* --- clientes --- */
.notice { margin: 0; padding: 10px 14px; border-radius: var(--r); background: var(--orange-soft); font-size: 13px; }
.notice.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type=search] { flex: 1 1 220px; min-width: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 7px 10px; }
.toolbar select { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 7px 10px; max-width: 220px; }
.tbl tr.sel td { background: var(--orange-soft); }
.clase { display: inline-block; min-width: 26px; text-align: center; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.clase.A { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.clase.B { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.clase.C { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.clase.ins { color: var(--muted); background: var(--soft); font-weight: 500; white-space: nowrap; }
h3.sub { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field-row.three-eq { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filters.solo-periodo select, .filters.solo-periodo #btn-limpiar { display: none; }
@media (max-width: 760px) { .field-row.three-eq { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .seg { flex-wrap: wrap; max-width: 100%; }
  .seg button { padding: 6px 10px; }
  .kpis, .kpis.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv b { font-size: 24px; }
}
