:root {
  --bg: #0b0e14; --surface: #121722; --surface2: #182031; --border: #222b3b;
  --text: #e6e9ef; --muted: #8b93a7; --accent: #6b9cff;
  --green: #34c27a; --red: #f06464; --amber: #f0b429; --violet: #a78bfa;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
body { min-height: 100vh; }
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

/* cabecera */
header.top { position: sticky; top: 0; z-index: 5; background: rgba(11,14,20,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); }
.top-row { display: flex; align-items: center; gap: 10px; padding: 12px 0 8px; }
.brand { font-weight: 700; letter-spacing: .2px; font-size: 17px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: .5px;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.badge.paper { color: var(--amber); border-color: rgba(240,180,41,.35); background: rgba(240,180,41,.08); }
.badge.real { color: var(--red); border-color: rgba(240,100,100,.35); background: rgba(240,100,100,.08); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(52,194,122,.15); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(240,100,100,.15); }
.spacer { flex: 1; }
button, .btn { font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #33405a; }
button.primary { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }
button.ghost { background: transparent; }

nav.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { white-space: nowrap; text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; }
nav.tabs a.active { color: var(--text); background: var(--surface2); }

/* tarjetas */
section.page { display: none; padding-top: 18px; }
section.page.active { display: block; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 22px 0 10px;
  font-weight: 600; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card .label { color: var(--muted); font-size: 13px; }
.card .big { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }
.bar { height: 8px; background: var(--surface2); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.bar.warn > i { background: var(--amber); } .bar.bad > i { background: var(--red); }

/* posiciones */
.two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; text-align: right; font-weight: 500; }
.card h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.side { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.side.long { background: rgba(52,194,122,.12); color: var(--green); }
.side.short { background: rgba(240,100,100,.12); color: var(--red); }
.side.flat { background: var(--surface2); color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* gráficos */
.chart-card { padding: 12px 12px 6px; }
.chart-card .title { display: flex; align-items: baseline; gap: 10px; padding: 2px 4px 8px; }
.chart-card .title b { font-size: 14px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 8px; color: var(--muted); }
.seg button.on { background: var(--surface2); color: var(--text); }
.uplot { font-family: inherit; }
.u-legend { display: none; }

/* tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 720px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

/* eventos */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chips button { font-size: 13px; padding: 5px 11px; border-radius: 99px; color: var(--muted); }
.chips button.on { color: var(--text); border-color: var(--accent); }
.event { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.event .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.event .text { white-space: pre-line; font-size: 14px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface2); color: var(--muted); }
.tag.silenciada { color: var(--amber); } .tag.no-enviada { color: var(--muted); }

/* preferencias */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); }
.toggle:last-child { border-bottom: 0; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: rgba(107,156,255,.25); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--accent); }
select { font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; }
.save-row { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.toast { color: var(--green); font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.login input { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; }
.login input:focus { outline: 2px solid rgba(107,156,255,.4); border-color: var(--accent); }
.login button { width: 100%; margin-top: 20px; padding: 11px; }
.error { color: var(--red); font-size: 14px; margin-top: 12px; min-height: 20px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.i-me { background: #6b9cff; } .i-his { background: #a78bfa; } .i-in { background: #34c27a; }
.i-add { background: #f0b429; } .i-red { background: #8b93a7; } .i-out { background: #f06464; }
header.top .wrap { padding-bottom: 0; }
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 13px; }
  .card .big { font-size: 20px; }
  .card .sub { font-size: 12px; }
}
