:root {
  --bg: #eef1f4; --surface: #ffffff; --ink: #18222c; --muted: #5d6873; --line: #d3dae1;
  --paper: #a66a12; --live: #1f7a4d; --danger: #b3362e; --link: #23559f; --buy: #1f7a4d; --sell: #b3362e;
  --rail: 196px; --strip: 44px;
  font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.45; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
[hidden] { display: none !important; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; }
.login form { background: var(--surface); padding: 32px; width: min(360px, 92vw); border-top: 4px solid var(--paper); }
.login p { color: var(--muted); margin: 0 0 20px; }
.login label { display: block; margin-bottom: 14px; }
.login input { display: block; width: 100%; margin-top: 4px; }
.error { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; }

/* ---- estado: la franja superior es el único elemento con color de fondo ---- */
.strip { position: fixed; top: 0; left: 0; right: 0; height: var(--strip); display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--paper); color: #fff; z-index: 10; }
.strip[data-mode="live"] { background: var(--live); }
.strip[data-kill="1"] { background: var(--danger); }
.mode { font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; padding: 2px 8px; border: 1px solid rgba(255,255,255,.6); }
.strip .kill { margin-left: auto; background: #fff; color: var(--danger); border: 0; padding: 6px 12px; font-weight: 600; cursor: pointer; }
.strip[data-kill="1"] .kill { color: var(--live); }
.strip .quiet { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); padding: 5px 10px; cursor: pointer; }

.rail { position: fixed; top: var(--strip); left: 0; bottom: 0; width: var(--rail); padding: 20px 0; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.rail a { padding: 9px 20px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.rail a.active { border-left-color: var(--ink); font-weight: 600; }
.rail a:hover { background: var(--bg); }
main { margin: var(--strip) 0 0 var(--rail); padding: 28px 32px 60px; max-width: 1400px; }

/* ---- tablas ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 13px; border-bottom: 2px solid var(--ink); }
td.num, th.num { text-align: right; }
tr.off td { color: var(--muted); }
.text { max-width: 520px; }
.small { font-size: 13px; color: var(--muted); }
.buy { color: var(--buy); font-weight: 600; } .sell { color: var(--sell); font-weight: 600; }
.stage { font-size: 12px; padding: 1px 6px; border: 1px solid var(--line); }
.stage.signal { border-color: var(--buy); color: var(--buy); font-weight: 600; }
.stage.triaged { border-color: var(--paper); color: var(--paper); }

/* ---- resumen de Inicio: cifras en línea, sin tarjetas ---- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 24px; margin: 16px 0 28px; border-top: 2px solid var(--ink); }
.facts div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts b { display: block; font-size: 24px; font-weight: 600; }
.facts span { color: var(--muted); font-size: 13px; }
.bar { height: 6px; background: var(--line); position: relative; margin-top: 4px; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); }
.empty { padding: 20px 0; color: var(--muted); }

/* ---- controles ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.toolbar .grow { flex: 1; }
input, select, textarea { padding: 6px 8px; border: 1px solid var(--line); background: var(--surface); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
button { padding: 6px 12px; border: 1px solid var(--ink); background: var(--surface); cursor: pointer; }
button.primary { background: var(--ink); color: #fff; }
button.link { border: 0; background: none; color: var(--link); padding: 2px 4px; }
dialog { border: 0; padding: 0; width: min(640px, 94vw); }
dialog::backdrop { background: rgba(24,34,44,.45); }
dialog form { padding: 24px 28px; display: grid; gap: 12px; }
dialog label { display: grid; gap: 4px; font-size: 14px; }
dialog label.row { grid-template-columns: auto 1fr; align-items: center; }
dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
textarea { min-height: 90px; resize: vertical; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; z-index: 20; }
.toast.err { background: var(--danger); }

@media (max-width: 860px) {
  :root { --rail: 0px; }
  .rail { position: static; width: auto; flex-direction: row; flex-wrap: wrap; padding: 6px 8px; margin-top: var(--strip); border-right: 0; border-bottom: 1px solid var(--line); }
  .rail a { padding: 6px 10px; border-left: 0; border-bottom: 2px solid transparent; }
  .rail a.active { border-bottom-color: var(--ink); }
  main { margin: 0; padding: 16px; }
  .text { max-width: none; }
  th:nth-child(n+5), td:nth-child(n+5) { display: none; }
}
@media (prefers-reduced-motion: no-preference) { .bar i { transition: width .3s; } }
