/* Dashboard styles — dark-first, minimalist, self-hosted (no CDN/fonts). */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1d212b;
  --line: #262b36;
  --fg: #e6e8ec;
  --muted: #8b93a1;
  --accent: #6ea8fe;
  --pos: #4ade80;
  --neg: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9; --surface: #fff; --surface-2: #f0f2f5; --line: #e2e6ec;
    --fg: #1a1d23; --muted: #5b6472; --accent: #2b6cff;
    --pos: #15803d; --neg: #b91c1c; --warn: #b45309; color-scheme: light;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { body { animation: none } }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  max-width: 1600px; margin: 0 auto; padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.topbar nav { display: flex; gap: 1.25rem; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a.active { color: var(--fg); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .85rem; }
.stamp { color: var(--muted); font-size: .8rem; font-family: var(--mono); }

main { max-width: 1600px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }
.stamp-line { font-family: var(--mono); font-size: .82rem; color: var(--muted); margin: -.25rem 0 1rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 2rem 0 .75rem; }
h2:first-child { margin-top: .5rem; }
.muted { color: var(--muted); }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}

/* banners */
.banner { border-radius: var(--radius); padding: .85rem 1.1rem; margin-bottom: 1.25rem; font-weight: 500; }
.banner.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); border: 1px solid var(--warn); color: var(--warn); }
.banner.neg  { background: color-mix(in srgb, var(--neg) 15%, transparent);  border: 1px solid var(--neg);  color: var(--neg); }
.banner.ok   { background: color-mix(in srgb, var(--pos) 12%, transparent);  border: 1px solid var(--pos);  color: var(--pos); }
/* Blue = informative (a run is happening). Amber/red stay for "act on this". */
.banner.info { background: color-mix(in srgb, var(--accent) 13%, transparent); border: 1px solid var(--accent); color: var(--accent); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  position: sticky; top: 0; background: var(--surface);
  text-align: left; font-weight: 600; color: var(--muted);
  padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em;
}
tbody td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.row-attention { box-shadow: inset 3px 0 0 var(--warn); }
.row-bad { box-shadow: inset 3px 0 0 var(--neg); }
.row-ok { box-shadow: inset 3px 0 0 transparent; }

/* expandable rows */
tr.expandable { cursor: pointer; }
tr.expandable:focus { outline: 1px solid var(--accent); outline-offset: -1px; }
.twisty {
  display: inline-block; width: 1em; margin-right: .35rem;
  color: var(--muted); font-size: 1.1em; line-height: 1;
  text-align: center; vertical-align: baseline;
  transition: transform .12s ease; transform-origin: 45% 55%;
}
@media (prefers-reduced-motion: reduce) { .twisty { transition: none; } }
tr.expanded .twisty { transform: rotate(90deg); color: var(--accent); }
tr.detail { display: none; }
tr.detail.open { display: table-row; }
tr.detail > td { background: var(--bg); padding: .3rem .7rem .7rem; }
.legtable { width: auto; min-width: 60%; margin: .2rem 0 .4rem; font-size: .82rem; }
.legtable thead th { background: transparent; border-bottom: 1px solid var(--line); font-size: .7rem; padding: .3rem .6rem; }
.legtable td { padding: .35rem .6rem; border-bottom: 1px dashed var(--line); }
.legtable tr:last-child td { border-bottom: none; }

.pill { font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.pos { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 50%, var(--line)); }
.pill.neg { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 50%, var(--line)); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }

form.inline { display: inline; }
button.act {
  font: inherit; font-size: .8rem; cursor: pointer; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .3rem .7rem;
}
button.act:hover { border-color: var(--accent); }
button.act[disabled] { opacity: .5; cursor: not-allowed; }

/* run grid */
.grid { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 4px; }
.grid .cell { padding: .5rem .6rem; border-radius: 8px; font-size: .82rem; text-align: center; }
.grid .head { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; background: none; }
.grid .day { color: var(--muted); font-family: var(--mono); text-align: left; }
.cell.ran { background: color-mix(in srgb, var(--pos) 18%, var(--surface)); color: var(--pos); }
.cell.pending { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--warn); }
.cell.failed { background: color-mix(in srgb, var(--neg) 18%, var(--surface)); color: var(--neg); }
.cell.none { background: var(--surface-2); color: var(--muted); }

/* intraday: one collapsible section per day, EU | US side by side */
details.day { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .85rem; background: var(--surface); }
details.day > summary {
  cursor: pointer; list-style: none; padding: .85rem 1.1rem;
  font-weight: 600; display: flex; align-items: center; gap: .6rem;
}
details.day > summary::-webkit-details-marker { display: none; }
details.day > summary:hover { background: var(--surface-2); border-radius: var(--radius); }
details.day[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
details.day[open] > summary .twisty { transform: rotate(90deg); color: var(--accent); }
.day-meta { margin-left: auto; color: var(--muted); font-weight: 400; font-size: .82rem; font-family: var(--mono); }
/* Markets stacked inside a day (EU first, then US) — the side-by-side split
   halved every table's width for no benefit once the columns grew. */
.split { display: flex; flex-direction: column; gap: 1.25rem; padding: 1rem; }
.split .panel { min-width: 0; }
.split .card { margin-bottom: 0; padding: .5rem .6rem; overflow-x: auto; }
.panel h3 { font-size: .9rem; font-weight: 600; margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.panel .banner { font-size: .85rem; font-weight: 400; }
.panel table { font-size: .82rem; }
.panel thead th { font-size: .68rem; padding: .4rem .5rem; }
.panel tbody td { padding: .45rem .5rem; }

/* login (anonymous) */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 2.75rem 3rem; text-align: center; max-width: 380px; width: 100%; }
.btn { display: inline-block; background: var(--accent); color: #08101f; font-weight: 600; padding: .7rem 1.4rem; border-radius: 10px; }
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.err { color: var(--neg); }

/* mobile: tables collapse to stacked cards */
@media (max-width: 720px) {
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem; padding: .3rem 0; }
  tbody td { display: flex; justify-content: space-between; border: none; padding: .35rem 1rem; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; }
  .num { text-align: right; }
  .grid { grid-template-columns: 1fr; }
  .split { padding: .6rem; }
  .day-meta { display: none; }
}

/* amber rail: this row moved today (leg opened/cleared, new to the ledger) */
.row-changed { box-shadow: inset 3px 0 0 var(--warn); }

/* exit-model health card + shadow strips + weekly sections */
.modelcard { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; padding: .8rem 1.1rem; }
.shadow-strip { font-size: .82rem; margin: .5rem 0 0; font-family: var(--mono); }
.quality-line { font-size: .78rem; margin: .2rem 0 0; font-family: var(--mono); }
.weekly-body { padding: .5rem 1.1rem 1rem; }
.weekly-body .card { margin-bottom: 0; }
