/* Basis Desk - one stylesheet, both themes, no external fonts. */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --ink: #e6edf3;
  --ink-dim: #9aa7b4;
  --line: #2a3441;
  --accent: #4c9aff;
  --accent-ink: #08131f;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --crit: #ff7b72;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

:root[data-theme="light"] {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel2: #f0f3f6;
  --ink: #1f2328;
  --ink-dim: #5b6570;
  --line: #d8dee4;
  --accent: #0969da;
  --accent-ink: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --crit: #a40e26;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

code, pre, .mono { font-family: var(--mono); }
.mono { font-size: 0.92em; }
.small { font-size: 0.85em; }
.muted { color: var(--ink-dim); }
.hidden { display: none !important; }

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

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand .sep { color: var(--ink-dim); }
.backlink { text-decoration: none; }
.topactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.credits { font-family: var(--mono); font-size: 0.85em; color: var(--ink-dim); }
.topup {
  font-size: 0.85em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
}

/* --- buttons -------------------------------------------------------------- */

button { font-family: inherit; font-size: 1em; cursor: pointer; }

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 11px;
}
.ghost:hover { background: var(--panel2); }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-weight: 600;
}
.primary:disabled { opacity: 0.45; cursor: not-allowed; }

.big {
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
}
.big:hover { border-color: var(--accent); }

.mini {
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85em;
}
.mini:hover { border-color: var(--accent); }

.linkish {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
}

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

main { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }

.hero h1 { font-size: 1.9rem; line-height: 1.25; margin: 18px 0 10px; }
.lede { font-size: 1.05rem; color: var(--ink); max-width: 74ch; }
.herobtns { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 18px 0;
}
.card h2 { font-size: 1.15rem; margin: 0 0 10px; }
.card h3 { font-size: 1.05rem; margin: 0 0 10px; }
.count {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 9px;
  margin-left: 6px;
}

.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.labelrow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.labelrow label { font-weight: 600; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1 1 240px; }

textarea, select, input[type="file"] {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.5;
}
select { font-family: var(--sans); font-size: 0.95rem; }
textarea { resize: vertical; }
textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.dropzone { border: 1px dashed transparent; border-radius: 10px; transition: border-color 0.15s, background 0.15s; }
.dropzone.dragging { border-color: var(--accent); background: rgba(76, 154, 255, 0.06); }
.droprow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.droprow input[type="file"] { width: auto; flex: 0 1 auto; font-size: 0.8rem; padding: 4px; }

.runrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }

.rungate {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--warn);
  border-radius: 8px;
  background: rgba(210, 153, 34, 0.08);
  font-size: 0.92em;
}
.gateaction { font-weight: 600; cursor: pointer; }

/* --- prescan ---------------------------------------------------------------- */
.prescan {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel2);
  margin-bottom: 14px;
}
.prescan h2 { font-size: 1rem; }
.flaglist { list-style: none; padding: 0; margin: 8px 0 0; }
.flaglist li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.92em; }
.progresshead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.steps { list-style: none; padding: 0; margin: 12px 0 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 5px 0; color: var(--ink-dim); }
.step-ic {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--line); flex: 0 0 auto;
}
.step.done { color: var(--ink); }
.step.done .step-ic { background: var(--ok); border-color: var(--ok); }
.step.live { color: var(--ink); }
.step.live .step-ic { border-color: var(--accent); background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- result ---------------------------------------------------------------------- */

.resulthead h2 { font-size: 1.35rem; }
.verdict {
  font-size: 1.03rem;
  border-left: 3px solid var(--line);
  padding-left: 12px;
  margin: 10px 0;
}
.sdkstrip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
}
.sdkbox { display: flex; flex-direction: column; min-width: 78px; }
.sdkbox strong { font-size: 1.25rem; }
.sdkarrow { color: var(--ink-dim); font-size: 1.3rem; }
.warnline {
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(210, 153, 34, 0.09);
}
.warnline ul { margin: 6px 0 0; padding-left: 18px; }
.warnline li { margin: 2px 0; word-break: break-word; }
pre.snippet, pre.bigpre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre;
  margin: 0;
}
pre.bigpre { max-height: 480px; overflow-y: auto; }
.tablewrap { overflow-x: auto; }
table.inv { width: 100%; border-collapse: collapse; font-size: 0.9em; min-width: 560px; }
table.inv th, table.inv td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.inv th { color: var(--ink-dim); font-weight: 600; font-size: 0.85em; }
.exportrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* --- history ------------------------------------------------------------------------- */

.history { list-style: none; padding: 0; margin: 0 0 10px; }
.history li { border-top: 1px solid var(--line); }
.history li:first-child { border-top: none; }
.histbtn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  padding: 9px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.histbtn:hover { background: var(--panel2); }
.histtitle { font-weight: 600; }
.histmeta { color: var(--ink-dim); }
.histload { margin: 0 0 10px 4px; }

.explain p { max-width: 78ch; }
/* --- footer + toasts -------------------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--line);
  padding: 20px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.9em;
}
.foot p { margin: 6px 0; max-width: 80ch; margin-left: auto; margin-right: auto; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(440px, calc(100vw - 32px)); }
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  font-size: 0.92em;
  transition: opacity 0.5s;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
.toast.gone { opacity: 0; }
.toast a { margin-left: 8px; font-weight: 600; }

/* --- docs pages ---------------------------------------------------------------------- */

.doc { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }
.doc h1 { font-size: 1.7rem; }
.doc h2 { font-size: 1.2rem; margin-top: 30px; }
.doc h3 { font-size: 1rem; margin-top: 22px; }
.doc p, .doc li { max-width: 80ch; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.9em; margin: 12px 0; }
.doc th, .doc td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { color: var(--ink-dim); }
.doc code { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 0.88em; }
.doc pre code { background: none; border: none; padding: 0; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 0; }
.tab {
  background: var(--panel2);
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 5px 12px;
  font-size: 0.85em;
}
.tab.active { background: var(--bg); color: var(--ink); font-weight: 600; }
.codegroup pre { border-radius: 0 8px 8px 8px; margin-top: 0; }
.codegroup pre[hidden] { display: none; }

.tokenrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.tokenbox {
  flex: 1 1 320px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  min-height: 44px;
}
.statebox { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel2); margin: 12px 0; }
.badge {
  font-family: var(--mono);
  font-size: 0.74em;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 8px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: color-mix(in srgb, var(--ok) 75%, var(--ink)); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: color-mix(in srgb, var(--bad) 75%, var(--ink)); }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: color-mix(in srgb, var(--warn) 75%, var(--ink)); }
.status-ok { color: var(--ok); } .status-warn { color: var(--warn); } .status-bad { color: var(--bad); }
.reconrow { display: grid; grid-template-columns: minmax(0, 12ch) 1fr; gap: 6px 12px; padding: 6px 0; border-bottom: 1px solid var(--line, #3a3f4b); }
.reconrow .mono { word-break: break-word; }
.labelrow select { max-width: 12rem; }
@media (max-width: 480px) { .herobtns .big { width: 100%; } .exportrow .mini { flex: 1 1 45%; } }
.tablewrap:focus-visible, pre.bigpre:focus-visible, .gateaction:focus-visible { outline: 3px solid var(--accent, #7aa2ff); outline-offset: 2px; }

/* --- Basis Desk additions ------------------------------------------------------ */
input[type="text"] {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset.group { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; margin: 0 0 14px; }
fieldset.group legend { font-weight: 700; padding: 0 6px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.grid3 .field > label { font-size: 0.88em; font-weight: 600; }
.checkfield { display: flex; align-items: flex-end; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.88em; }
.dropzone.droprow { padding: 8px; }
.verdictline { font-weight: 600; font-size: 1.02rem; margin: 4px 0 10px; }
.twocol { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 22px; }
table.inv.kv { min-width: 0; }
table.inv.kv td:last-child { text-align: right; white-space: nowrap; }
table.inv.num td + td, table.inv.num th + th, table.inv.grid td, table.inv.grid thead th + th { text-align: right; white-space: nowrap; }
table.inv tr.strong td { font-weight: 700; }
table.inv.grid th.base, table.inv.grid td.base { outline: 2px solid var(--accent); outline-offset: -2px; }
.flags { list-style: none; padding: 0; margin: 6px 0 12px; }
.flagrow { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--line); }
.flagrow:first-child { border-top: none; }
.verdict { border-left: 4px solid var(--line); padding: 6px 12px; font-weight: 700; }
.verdict.verdict-supportable { border-left-color: var(--ok); }
.verdict.verdict-stretched { border-left-color: var(--warn); }
.verdict.verdict-not_supportable { border-left-color: var(--bad); }
.driver, .option { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel2); }
.driverhead { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.driver p, .option p { margin: 6px 0 0; }
.recon { margin: 6px 0; padding-left: 20px; }
.recon.bad li { color: var(--bad); }
.histrow { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 8px 2px; }
.histrow .linkish { text-align: left; font-weight: 600; }
@media (max-width: 760px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .twocol { grid-template-columns: 1fr; } }
@media (max-width: 460px) { .grid3 { grid-template-columns: 1fr; } }
@media print {
  .topbar, .toasts, .exportrow, form, #progressPanel, #historyZone, .herobtns, .foot, .hero { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; break-inside: avoid; }
}

/* Basis Desk: a bond outside the delivery window is shown but struck through. */
.inv tr.struck td { text-decoration: line-through; opacity: 0.6; }
.inv tr.struck td:first-child { text-decoration: line-through; }
table.inv.trade { min-width: 0; }
table.inv.trade td:first-child { white-space: nowrap; width: 8em; color: var(--ink-dim); }
/* The carry model table carries long values (date ranges, DV01 in two units): let them wrap. */
#carryBody td:last-child { white-space: normal; overflow-wrap: anywhere; }
