:root {
  --ink: #0c1118;
  --ink-2: #141c27;
  --panel: #182230;
  --line: #2a3545;
  --brass: #c4a35a;
  --brass-2: #e4c57a;
  --paper: #e8dfc8;
  --mute: #8b97a8;
  --ok: #3cbf8f;
  --warn: #e0a24a;
  --stop: #d45b4a;
  --text: #edf1f6;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  display: flex;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(196, 163, 90, 0.08), transparent 50%),
    var(--ink);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.01em;
}

a { color: var(--brass-2); text-decoration: none; }
h1, h2 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}
h1 { font-size: 2rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.rail {
  width: 240px;
  flex: 0 0 240px;
  background: var(--ink-2);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.8rem;
  position: sticky;
  top: 0;
}
.brand { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 1.2rem; }
.brand .mark {
  width: 2.2rem; height: 2.2rem; border-radius: 6px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--brass-2), var(--brass));
  color: #1b1406; font-family: "Source Serif 4", serif; font-weight: 600;
}
.brand strong { display: block; font-size: 1rem; }
.brand em { font-style: normal; color: var(--mute); font-size: 1rem; }
.rail nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail nav a {
  color: var(--mute);
  padding: 0.42rem 0.65rem;
  border-radius: 6px;
  font-size: 1rem;
}
.rail nav a.on, .rail nav a:hover { background: var(--panel); color: var(--paper); }
.logout { margin-top: 1rem; }
.logout button, button, input, select {
  font: inherit;
}
.logout button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--mute);
  padding: 0.45rem;
  border-radius: 6px;
  cursor: pointer;
}

main { flex: 1; padding: 1.2rem 1.6rem 3rem; min-width: 0; }
main.bare { padding: 0; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.8rem;
}
.clocks { display: flex; gap: 1.4rem; }
.clocks .k { display: block; color: var(--mute); font-size: 1rem; text-transform: uppercase; }
.clocks strong { font-family: "IBM Plex Mono", monospace; font-size: 1.15rem; }
.banners { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.banner, .chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.banner.stop, .chip.stop { border-color: var(--stop); color: #ffb4aa; }
.banner.warn, .chip.warn { border-color: var(--warn); color: #f3d19a; }
.chip.green, .chip.GREEN { border-color: var(--ok); color: var(--ok); }
.chip.yellow, .chip.YELLOW { border-color: var(--warn); color: #f3d19a; }
.chip.red, .chip.RED { border-color: var(--stop); color: #ffb4aa; }
.session-reason { color: var(--mute); font-size: 1rem; margin: 0.6rem 0 1.2rem; }

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
}
.eyebrow { color: var(--brass); text-transform: uppercase; font-size: 1rem; letter-spacing: 0.12em; }
.lede { color: var(--mute); max-width: 62ch; line-height: 1.5; }
.stat-stack {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem;
}
.stat-stack div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
}
.stat-stack span { color: var(--mute); font-size: 1rem; display: block; }
.stat-stack strong { font-family: "IBM Plex Mono", monospace; font-size: 1.2rem; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; margin: 1rem 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.capital-card header { display: flex; justify-content: space-between; align-items: start; }
.figure { font-family: "IBM Plex Mono", monospace; font-size: 1.55rem; margin: 0.3rem 0; color: var(--brass-2); }
.muted { color: var(--mute); font-size: 1rem; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem 0.8rem; margin: 0.8rem 0 0; }
dt { color: var(--mute); font-size: 1rem; }
dd { margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 1rem; }
.stack { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.8rem; }
label { display: flex; flex-direction: column; gap: 0.28rem; font-size: 1rem; color: var(--mute); }
input {
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
button {
  background: var(--brass);
  color: #1b1406;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
button.danger { background: var(--stop); color: white; }
.login-card a.btn {
  display: inline-block;
  background: var(--brass);
  color: #1b1406;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
}
.flash { background: #3a1d1a; color: #ffc7bf; padding: 0.6rem 0.8rem; border-radius: 8px; }
.confirm { border-color: var(--brass); margin: 1rem 0; }

table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mute); font-weight: 500; }
.compare th { width: 30%; }

.health { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.28rem; }
.health li { display: grid; grid-template-columns: 12px 1fr auto; gap: 0.5rem; align-items: center; font-size: 1rem; }
.health em { color: var(--mute); font-style: normal; font-family: "IBM Plex Mono", monospace; font-size: 1rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); display: inline-block; }
.dot.GREEN { background: var(--ok); }
.dot.YELLOW { background: var(--warn); }
.dot.RED { background: var(--stop); }
.dot.UNKNOWN { background: #5c6a7c; }
.plain { color: var(--mute); }
.settings { display: grid; grid-template-columns: 220px 1fr; gap: 0.45rem 1rem; }
.settings dt { color: var(--mute); }
.settings dd { margin: 0; font-family: "IBM Plex Mono", monospace; }

.pipeline {
  display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; list-style: none; margin: 1rem 0 1.4rem;
}
.pipeline li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 1rem;
}

pre {
  background: var(--ink);
  border: 1px solid var(--line);
  padding: 0.9rem;
  border-radius: 8px;
  overflow: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  line-height: 1.45;
}

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.chip.ok { border-color: var(--ok); color: var(--ok); }

.owner-status {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin: 1rem 0;
}
.callback-box {
  font-family: "IBM Plex Mono", monospace;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  word-break: break-all;
  color: var(--brass-2);
}
a.connect-fyers {
  display: inline-block;
  background: var(--brass);
  color: #1b1406;
  font-size: 1.05rem;
  padding: 0.85rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.hint code { color: var(--paper); }

@media (max-width: 800px) {
  body { flex-direction: column; }
  .rail {
    width: 100%;
    flex: none;
    min-height: 0;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .hero, .grid-3, .split, .owner-status, .stat-stack { grid-template-columns: 1fr; }
  a.connect-fyers { width: 100%; text-align: center; }
}

.login-card h1 { margin-bottom: 0.4rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1rem; }
.hint { color: var(--mute); font-size: 1rem; }

.pred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.7rem; }
.causal-chain { margin: 0.3rem 0 1rem 1.1rem; color: var(--paper); }
.causal-chain li { margin: 0.25rem 0; }
.narrative { color: var(--paper); padding-left: 1.1rem; }
select {
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

/* Larger readable default, with user-controlled text scaling. */
html { font-size: 150%; }
.reading-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin-bottom: 1rem; color: var(--text); }
.reading-controls button { min-width: 2.4rem; min-height: 2.4rem; padding: .35rem .65rem;
  font: inherit; border: 1px solid var(--brass); border-radius: .4rem;
  background: var(--panel); color: var(--text); cursor: pointer; }
.reading-controls button:focus-visible { outline: 3px solid var(--brass-2); outline-offset: 3px; }
.reading-controls button:disabled { opacity: .45; cursor: default; }
.reading-controls output { min-width: 3.5rem; text-align: center; font-variant-numeric: tabular-nums; }
main { min-width: 0; }

body { line-height: 1.55; }
small, input, select, textarea, button { font-size: 1rem; }
.rail nav a, .brand strong, .brand em, .hint, .muted, .banner, .chip, .clocks .k,
.session-reason, label, dt, dd, table { font-size: 1rem; }
.rail { width: 14rem; flex-basis: 14rem; }
.top, .clocks, .banners { flex-wrap: wrap; }
@media (max-width: 1100px) {
 body { flex-direction: column; }
 .rail { width: 100%; flex: none; min-height: 0; position: static; }
 .rail nav { flex-direction: row; flex-wrap: wrap; }
 main { padding: 1rem; }
}
