/* XITE viewer — shared shell. Dark-first trading UI.
   Tokens from the validated reference palette (dataviz skill):
   surfaces #0d0d0d/#1a1a19, ink #fff/#c3c2b7/#898781, grid #2c2c2a,
   status good #0ca30c warning #fab219 serious #ec835a critical #d03b3b,
   series-1 blue #3987e5. */

:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --blue: #3987e5;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up: #0ca30c;
  --down: #d03b3b;
  --radius: 14px;
  --nav-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: var(--blue); text-decoration: none; }

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100dvh; }

main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Mobile: fixed bottom tab bar, app-like */
nav.tabs {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(26, 26, 25, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
}
nav.tabs a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
nav.tabs a svg { width: 22px; height: 22px; }
nav.tabs a.active { color: var(--ink); }
nav.tabs .brand { display: none; }

/* Desktop: left sidebar, app-like */
@media (min-width: 900px) {
  main { padding: 28px 32px; }
  nav.tabs {
    position: sticky;
    top: 0;
    inset: auto;
    height: 100dvh;
    width: 216px;
    flex-direction: column;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    gap: 4px;
  }
  nav.tabs .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 22px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--ink);
  }
  nav.tabs .brand .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 12px var(--blue);
  }
  nav.tabs a {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    font-size: 14px;
  }
  nav.tabs a.active { background: var(--surface-2); }
  nav.tabs a:hover:not(.active) { background: rgba(255, 255, 255, 0.04); }
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-title { margin: 2px 0 14px; font-size: 22px; font-weight: 800; }
.page-title small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.tile .v { font-size: 22px; font-weight: 800; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--ink-2); margin-top: 1px; }

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good); background: rgba(12, 163, 12, 0.12); }
.pill.warning { color: var(--warning); background: rgba(250, 178, 25, 0.12); }
.pill.critical { color: var(--critical); background: rgba(208, 59, 59, 0.14); }
.pill.muted { color: var(--muted); }
.pill.blue { color: var(--blue); background: rgba(57, 135, 229, 0.14); }

/* ---------------------------------------------------------------- tables */

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.dim td { color: var(--muted); }
.pos { color: var(--good); font-weight: 700; }
.neg { color: var(--critical); font-weight: 700; }

/* --------------------------------------------------------------- switches */

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background 0.18s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--muted); transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .track { background: rgba(12, 163, 12, 0.35); }
.switch input:checked + .track::after { transform: translateX(19px); background: var(--good); }
.switch input:disabled + .track { opacity: 0.4; }

/* rows in strategy list */
.strat { display: flex; align-items: flex-start; gap: 14px; padding: 14px 2px; border-bottom: 1px solid var(--grid); }
.strat:last-child { border-bottom: none; }
.strat .info { flex: 1; min-width: 0; }
.strat .name { font-weight: 700; font-size: 15px; }
.strat .desc { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.strat .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* trades list (mobile card style) */
.trade { padding: 14px 2px; border-bottom: 1px solid var(--grid); }
.trade:last-child { border-bottom: none; }
.trade .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trade .when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.trade .reason { color: var(--ink-2); font-size: 13px; margin-top: 7px; line-height: 1.55; }

/* chart bits */
#chart { width: 100%; height: 62dvh; min-height: 380px; }
@media (max-width: 899px) { #chart { height: 48dvh; min-height: 320px; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.legend i.dash { border-top-style: dashed; }

.note { color: var(--muted); font-size: 12.5px; }
.updated { color: var(--muted); font-size: 11.5px; margin-top: 6px; }
button.linkish {
  background: none; border: none; color: var(--blue);
  font: inherit; font-size: 12.5px; cursor: pointer; padding: 0;
}
