/* JMDT Simulator Console — theme.
 *
 * The tokens below are the ones jmdt.io defines on :root, copied verbatim so the
 * console reads as the same product rather than as an internal tool that happens to
 * be dark. Two substitutions, both deliberate:
 *
 *   * Body text uses the same font stack jmdt.io declares, headed by Iosevka Charon
 *     Mono. That face is self-hosted on jmdt.io and is not redistributed here, so an
 *     operator who has it sees the site's exact typography and everyone else falls
 *     through to the same ui-monospace tail the site itself specifies.
 *   * Headings use Jersey 25, the face the site uses for h1–h3. It is NOT fetched
 *     from a font CDN: this console loads nothing from a third party, because a
 *     render-blocking <link> to a host that stalls rather than fails stops the page’s
 *     script from ever executing, and the console then shows "connecting…" forever.
 *     Drop a woff2 at static/fonts/jersey25.woff2 to get the exact face; without it
 *     the @font-face below simply never matches and headings fall through to the mono
 *     stack, which is why font-display is swap and nothing waits on it.
 */

@font-face {
  font-family: "Jersey 25";
  src: url("/fonts/jersey25.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
  font-style: normal;
}

:root {
  --background: #000000;
  --surface: #0a0a0a;
  --surface-2: #111111;
  --border: #1f1f1f;
  --border-bright: #2a2a2a;
  --text: #ffffff;
  --text-dim: #a0a0a0;
  --text-muted: #6b6b6b;
  --accent-orange: #c97032;
  --accent-orange-dim: #5a3416;
  --accent-green: #4ade80;
  --accent-pink: #ff3b8a;

  --mono: "Iosevka Charon Mono", Iosevka, ui-monospace, Menlo, monospace;
  --pixel: "Jersey 25", var(--mono);
  --radius: 4px;
  --gap: 16px;
  --maxw: 1440px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* The user-agent's [hidden] rule is a bare `display: none`, which ANY class rule
 * setting display beats on specificity — so `.drawer { display: flex }` kept the job
 * drawer on screen even while its hidden attribute was set. Restoring the intent
 * globally is the fix: an element marked hidden is hidden, whatever else styles it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--pixel); font-weight: 400; letter-spacing: .01em; margin: 0; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

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

.mono-caps, .label {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 300;
  color: var(--text-muted);
}

.gradient-text {
  background: linear-gradient(360deg, rgb(255, 81, 47), rgb(240, 152, 25));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dotted {
  background-image: linear-gradient(to right, var(--border-bright) 0, var(--border-bright) 4px, transparent 4px, transparent 8px);
  background-size: 8px 1px;
  background-repeat: repeat-x;
  background-position: center;
  height: 1px;
  border: 0;
  margin: 20px 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: rgba(0, 0, 0, .86);
  backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: 10px; flex: 0 0 auto; }
.wordmark { font-family: var(--pixel); font-size: 26px; line-height: 1; letter-spacing: .02em; }
.wordmark-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--text-muted); }

.envswitch { display: flex; gap: 8px; flex: 1 1 auto; flex-wrap: wrap; }
.topbar-right { display: flex; gap: 8px; align-items: center; }

/* Nav chips reproduce jmdt.io's glass chip: a faint white gradient, a hairline
 * border, an inset highlight. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text);
  background: linear-gradient(rgba(255,255,255,.10), rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.1), inset 0 -1px rgba(0,0,0,.2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: rgba(255,255,255,.16); text-decoration: none; }
.chip-ghost { background: transparent; box-shadow: none; color: var(--text-dim); }
.chip-user { cursor: default; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
.chip-user .linkout { font-size: 11px; color: var(--text-muted); }

.chip.active { background: linear-gradient(rgba(132,132,132,.20), rgba(255,148,9,.20)); color: #fff; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.chip .dot.production { background: var(--accent-orange); box-shadow: 0 0 8px var(--accent-orange); }
.chip .dot.testnet { background: var(--accent-green); box-shadow: 0 0 8px rgba(74,222,128,.6); }
.chip .dot.busy { background: var(--accent-pink); animation: pulse 1.4s ease-in-out infinite; }
.chip .dot.broken { background: var(--accent-pink); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- ticker ---------- */

.ticker {
  padding: 8px 20px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-orange);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(90,52,22,.35), rgba(0,0,0,0));
}

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

.view { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 120px; }
.loading { color: var(--text-muted); padding: 60px 0; text-align: center; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 18px 0 22px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  background: none;
  font-family: inherit;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--text); background: var(--surface); border-color: var(--border); }

.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h3 { margin-bottom: 4px; }
.card .label { display: block; margin-bottom: 10px; }

.stat .value { font-family: var(--pixel); font-size: 2rem; line-height: 1.1; }
.stat .unit { color: var(--text-muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.stat.warn .value { color: var(--accent-orange); }
.stat.bad .value { color: var(--accent-pink); }
.stat.good .value { color: var(--accent-green); }

/* ---------- forms ---------- */

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field .hint { color: var(--text-muted); font-size: 11px; line-height: 1.5; }

input[type=text], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 1px var(--accent-orange-dim);
}
textarea { min-height: 380px; resize: vertical; line-height: 1.6; }
input::placeholder { color: var(--text-muted); }

.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }

.btn {
  padding: 9px 16px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  background: linear-gradient(rgba(255,255,255,.10), rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: rgba(255,255,255,.2); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(rgba(201,112,50,.35), rgba(201,112,50,.15)); border-color: rgba(201,112,50,.5); }
.btn-danger { background: linear-gradient(rgba(255,59,138,.25), rgba(255,59,138,.08)); border-color: rgba(255,59,138,.45); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--text-dim); }
.btn-sm { padding: 6px 11px; font-size: 11px; }
.btn-xs { padding: 2px 7px; font-size: 12px; line-height: 1.3; }
.btn:disabled { opacity: .5; cursor: progress; }

.confirm-box {
  border: 1px solid var(--accent-orange-dim);
  background: rgba(90,52,22,.14);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 8px;
}
.confirm-box .label { color: var(--accent-orange); margin: 0; }

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

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  text-align: left;
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid #141414; vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.addr { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.wrap-any { overflow-wrap: anywhere; }

.pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border: 1px solid var(--border-bright);
  color: var(--text-dim);
}
.pill.ok { color: var(--accent-green); border-color: rgba(74,222,128,.35); }
.pill.warn { color: var(--accent-orange); border-color: rgba(201,112,50,.45); }
.pill.bad { color: var(--accent-pink); border-color: rgba(255,59,138,.4); }
.pill.live { color: var(--accent-pink); border-color: rgba(255,59,138,.4); animation: pulse 1.6s ease-in-out infinite; }

.empty { color: var(--text-muted); padding: 26px 0; text-align: center; font-size: 12px; }

.note {
  border-left: 2px solid var(--accent-orange);
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(90,52,22,.12);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
}

/* A note about a FAILURE reads in red, not in the orange the informational notes use.
 * The two carry opposite instructions — one is context, the other is a list of things
 * that did not happen — and an operator scanning the page should not have to read both
 * to tell which is which. */
.note-bad { border-left-color: var(--accent-pink); background: rgba(255,59,138,.10); }
.note-bad ul { margin: 6px 0 4px; padding-left: 1.1rem; }
.note-bad li { margin: 2px 0; }
.note-bad code { color: var(--text); }

/* toolbar is the row above a table: what the table is on the left, what you can do to
 * it on the right. */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin: 4px 0 10px;
  flex-wrap: wrap;
}
.toolbar .label { margin: 0 8px 0 0; display: inline; }

/* ---------- job drawer ---------- */

.drawer {
  position: fixed;
  right: 0; bottom: 0; left: 0;
  z-index: 60;
  height: 46vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border-bright);
  box-shadow: 0 -20px 50px rgba(0,0,0,.6);
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 13px; }
.drawer-sub { font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere; }
.drawer-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.drawer-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 16px; border-top: 1px solid var(--border); font-size: 11px;
}

.logpane {
  flex: 1 1 auto;
  margin: 0;
  padding: 12px 16px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-dim);
  background: var(--background);
}
.logpane .l-stderr { color: var(--accent-pink); }
.logpane .l-supervisor { color: var(--accent-orange); }
.logpane .l-warn { color: var(--accent-orange); }
.logpane .l-err { color: var(--accent-pink); }
.logpane .l-ok { color: var(--accent-green); }

/* ---------- toasts ---------- */

.toasts { position: fixed; top: 64px; right: 20px; z-index: 80; display: grid; gap: 8px; max-width: 420px; }
.toast {
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-left: 2px solid var(--accent-orange);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.toast.bad { border-left-color: var(--accent-pink); }
.toast.good { border-left-color: var(--accent-green); }

/* ---------- misc ---------- */

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 4px 14px; font-size: 12px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* The left column holds a form, and a form column narrower than about 420px forces
 * every paired field (rate + distribution, floor + reserve + minimum) onto its own
 * line, which turns a short form into a long scroll. */
.split { display: grid; grid-template-columns: minmax(420px, 560px) 1fr; gap: var(--gap); align-items: start; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .drawer { height: 60vh; }
}

.scrollbox { max-height: 460px; overflow: auto; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--background); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-orange); }

/* The boot watchdog's card. It is styled here rather than inline because boot.js runs
 * under a script-src 'self' policy that forbids inline style attributes just as firmly
 * as inline script, and a diagnosis nobody can read is not one. */
.bootfail { border-color: var(--accent-orange-dim); max-width: 46rem; }
.bootfail h3 { color: var(--accent-orange); margin-bottom: .75rem; }
.bootfail ul { margin: .5rem 0 1rem; padding-left: 1.25rem; }
.bootfail li { margin: .35rem 0; }
.bootfail code { color: var(--text); word-break: break-all; }
.bootfail .mono-caps { margin-bottom: .2rem; }
