:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --ink: #0f1b2d;
  --ink2: #4a5568;
  --muted: #8a94a6;
  --line: #e6e8ee;
  --brand: #0f1b2d;
  --accent: #f2a516;
  --up: #12805c;
  --down: #c8372d;
  --warn: #b7791f;
  --chip: #eceef3;
  --r: 16px;
  --safe-b: env(safe-area-inset-bottom);
  --safe-t: env(safe-area-inset-top);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #141d2e; --ink: #eef1f6; --ink2: #b4bccb; --muted: #7d889c;
    --line: #233049; --chip: #1d2840; --up: #3ccf91; --down: #ff6b5e; --warn: #f0b44c;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
body { overscroll-behavior-y: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--down); min-height: 1.2em; font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, #0f1b2d 0%, #1c2f4d 100%); }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 22px; padding: 28px 22px; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-logo { width: 64px; height: 64px; border-radius: 15px; }
.login h1 { margin: 10px 0 0; font-size: 26px; }
.login input { width: 100%; padding: 14px; margin: 6px 0; border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; background: var(--bg); color: var(--ink); }
.btn { border: 0; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 600; width: 100%; margin-top: 8px; }
.btn.primary { background: var(--accent); color: #1a1205; }
.btn.ghost { background: var(--chip); color: var(--ink); }

/* Header */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-t) + 10px) 18px 10px; background: var(--brand); color: #fff; }
.top-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.top-sub { font-size: 12px; opacity: .7; }
.icon-btn { background: rgba(255,255,255,.12); border: 0; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Vista */
.view { padding: 14px 14px calc(90px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(15,27,45,.06); }
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.hero { background: var(--brand); color: #fff; }
.hero h3 { color: rgba(255,255,255,.6); }
.big { font-size: 34px; font-weight: 750; letter-spacing: -1px; }
.mid { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 0; }
.kpi .lbl { font-size: 12px; color: var(--muted); }
.kpi .val { font-size: 20px; font-weight: 700; margin-top: 2px; }
.kpi .cmp { font-size: 12px; margin-top: 2px; }
.hero .muted { color: rgba(255,255,255,.6); }
.pill { white-space: nowrap; display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--chip); }
.pill.up { background: rgba(18,128,92,.12); } .pill.down { background: rgba(200,55,45,.12); } .pill.warn { background: rgba(183,121,31,.14); }
.hero .pill { background: rgba(255,255,255,.14); }
.bar { height: 8px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.light { background: var(--chip); }

/* Chips / segment */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--chip); color: var(--ink); padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 500; }
.chip.on { background: var(--ink); color: var(--card); }
.seg { display: flex; background: var(--chip); border-radius: 11px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.dates { display: flex; gap: 8px; margin-bottom: 12px; }
.dates input { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 15px; }

/* Listas */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.list h3 { margin: 0; padding: 14px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.list h3 + .item { border-top: 0; }
.item.tap:active { background: var(--chip); }
.item .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.item .r { text-align: right; flex: none; }
.item .l { min-width: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.more { display: block; width: 100%; border: 0; background: transparent; color: var(--accent); font-weight: 600; padding: 12px; border-top: 1px solid var(--line); font-size: 14px; }
.hbar { height: 6px; background: var(--chip); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.hbar > i { display: block; height: 100%; background: var(--accent); }

/* Gráfico */
.chart { width: 100%; height: 140px; display: block; }
.chart .b { fill: var(--accent); }
.chart .b.dim { fill: var(--line); }
.chart text { fill: var(--muted); font-size: 9px; }
.hero .chart .b.dim { fill: rgba(255,255,255,.18); }

/* Tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
.tabs button { position: relative; flex: 1; border: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--ink); }
.tabs button.on svg { stroke: var(--accent); stroke-width: 2.2; }
.badge { position: absolute; top: 0; left: calc(50% + 6px); background: var(--down); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 99px; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column;
  animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(100%); } to { transform: none; } }
.sheet-top { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; padding: calc(var(--safe-t) + 10px) 10px 10px;
  background: var(--brand); color: #fff; }
.sheet-title { text-align: center; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link { border: 0; background: none; color: var(--accent); font-size: 16px; font-weight: 600; text-align: left; padding: 6px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(30px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sheet-body > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-weight: 500; }

.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 16px; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--card);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90%; }
.skel { height: 90px; border-radius: var(--r); margin-bottom: 12px;
  background: linear-gradient(90deg, var(--card) 0%, var(--chip) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.btn-sm { border: 0; background: var(--chip); color: var(--ink); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
