/* Panel ABSA — estilos base */
:root {
  color-scheme: light;
  --brand: #0a5aa8;
  --brand-strong: #074581;
  --brand-soft: #e6f0fa;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --chart-surface: #fcfcfb;
  --ink: #0b1620;
  --ink-2: #4a5662;
  --muted: #7b8691;
  --line: #e2e6ea;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 22, 32, .10);
  --s1: #2a78d6;   /* serie 1 (azul) */
  --s2: #eb6834;   /* serie 2 (naranja) */
  --s3: #1baf7a;   /* serie 3 (aqua) */
  --good: #0ca30c; --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b; --critical-ink: #b42323;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 22, 32, .06), 0 1px 1px rgba(11, 22, 32, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #5aa2ec; --brand-strong: #8cc0f4; --brand-soft: #14273b;
    --page: #0f1215; --surface: #171b1f; --surface-2: #1c2126; --chart-surface: #1a1a19;
    --ink: #f3f5f7; --ink-2: #c3c9cf; --muted: #8a949e; --line: #2a3138;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, .10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --good-ink: #0ca30c; --critical-ink: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #5aa2ec; --brand-strong: #8cc0f4; --brand-soft: #14273b;
  --page: #0f1215; --surface: #171b1f; --surface-2: #1c2126; --chart-surface: #1a1a19;
  --ink: #f3f5f7; --ink-2: #c3c9cf; --muted: #8a949e; --line: #2a3138;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, .10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --good-ink: #0ca30c; --critical-ink: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--page); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--critical-ink); }
.pos { color: var(--good-ink); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(to right, #0b2b4a 248px, transparent 248px); }
.sidebar { background: #0b2b4a; color: #d6e3f0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 650; }
.sidebar .brand .logo { width: 34px; height: 34px; border-radius: 9px; background: #2a78d6; display: grid; place-items: center; font-size: 13px; letter-spacing: .5px; }
.sidebar .brand small { display: block; font-weight: 400; color: #9fb6cc; font-size: 11px; }
.nav-group { padding: 10px 10px 4px; }
.nav-group .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8aa3bb; padding: 6px 10px; }
.nav-group a { display: flex; align-items: center; gap: 10px; color: #d6e3f0; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.nav-group a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-group a.active { background: #2a78d6; color: #fff; }
.nav-group svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.sidebar .foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: #8aa3bb; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .who .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 650; font-size: 12px; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--ink); cursor: pointer; }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.mt { margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px 0; flex-wrap: wrap; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-b { padding: 14px 16px 16px; }
.card-b.flush { padding: 8px 0 0; }

.kpi { padding: 16px; }
.kpi .label { color: var(--ink-2); font-size: 12.5px; display: flex; gap: 6px; align-items: center; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.01em; white-space: nowrap; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.hero { background: linear-gradient(135deg, #0b2b4a, #0a5aa8); color: #fff; border: 0; }
.kpi.hero .label, .kpi.hero .foot { color: #cfe0f1; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 14%, transparent); }
.st-warn { color: #8a5a00; background: color-mix(in srgb, var(--warning) 22%, transparent); }
.st-crit { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 13%, transparent); }
.st-info { color: var(--brand); background: var(--brand-soft); }
.st-mute { color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-warn { color: var(--warning); } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tfoot td { font-weight: 650; border-top: 2px solid var(--line); border-bottom: 0; }
table.t tr.group td { background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.t .wrap { white-space: normal; min-width: 220px; }

/* ---------- Forms ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .lbl { font-size: 12px; color: var(--ink-2); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 36px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 0; border-color: var(--brand); }
input.amount { text-align: right; font-variant-numeric: tabular-nums; width: 200px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; border-radius: 8px; padding: 8px 14px; min-height: 36px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--critical-ink); }
.btn.sm { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; font-size: 13px; }
.alert-ok { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good-ink); }
.alert-error { background: color-mix(in srgb, var(--critical) 9%, var(--surface)); border-color: color-mix(in srgb, var(--critical) 35%, transparent); color: var(--critical-ink); }
.alert-info { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 16px; font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 600; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-color: var(--brand); text-decoration: none; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .dlabel { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; }
.chart .mark { stroke: var(--surface); stroke-width: 2px; paint-order: stroke; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .hl, .chart .hl.on { opacity: 1; }
.chart .hl { fill: var(--ink); opacity: 0; pointer-events: none; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); padding: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.12); border-radius: 8px; padding: 8px 10px; font-size: 12px; z-index: 10; min-width: 150px; opacity: 0; transition: opacity .08s; }
.tooltip.on { opacity: 1; }
.tooltip .tt-h { font-weight: 650; margin-bottom: 4px; }
.tooltip .tt-r { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tooltip .tt-r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > div { height: 100%; background: var(--s1); border-radius: 999px; }

/* ---------- Guest (login) ---------- */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #0b2b4a 0%, #0a5aa8 55%, #2a78d6 100%); }
.guest .box { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.guest .box h1 { font-size: 20px; margin: 10px 0 4px; }
.guest .box form { display: grid; gap: 14px; margin-top: 18px; }
.guest .logo { width: 44px; height: 44px; border-radius: 11px; background: #0a5aa8; color: #fff; display: grid; place-items: center; font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 40px; }
  .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi .value { font-size: 22px; }
  .topbar .who .name { display: none; }
}
@media print {
  .sidebar, .topbar, .filters, .actions, .no-print { display: none !important; }
  .app { display: block; }
  .card { break-inside: avoid; box-shadow: none; }
}
