*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* Every number in the interface is monospaced and column-aligned. Reading a
   dashboard means comparing figures, and proportional digits make that harder
   than it needs to be. */
.num, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.caps {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-low);
  font-weight: 500;
}

.muted { color: var(--text-mid); }
.dim { color: var(--text-low); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---- App shell ----------------------------------------------------------- */

#app { height: 100%; }

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--topbar-h) var(--ticker-h) 1fr var(--actionbar-h);
  grid-template-areas:
    "brand  topbar"
    "rail   ticker"
    "rail   main"
    "rail   actionbar";
  height: 100%;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}

.brand-mark {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.14em;
  color: var(--text-hi);
}

.rail {
  grid-area: rail;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  padding-top: var(--sp-3);
  overflow-y: auto;
}

.main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--sp-4);
  background: var(--bg-0);
}

.actionbar {
  grid-area: actionbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--bg-1);
  border-top: 1px solid var(--line);
}

/* ---- Layout primitives --------------------------------------------------- */

.grid { display: grid; gap: var(--sp-3); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-tight { display: flex; align-items: center; gap: var(--sp-2); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.fill { flex: 1 1 auto; min-width: 0; }
.scroll-x { overflow-x: auto; }

@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .cols-4, .cols-3, .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: 0 1fr; }
  .rail, .brand { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
