/* Order Flow — terminal.
   A trading terminal is a committed visual world, so this page stays dark in every host theme.
   Every colour is painted explicitly and nothing is left to inherit from the viewer's ground.
   Palette and type pairing are carried over verbatim from index.html. */

:root {
  --ground: #0b0e14;
  --surface: #131822;
  --surface-2: #1a212e;
  --line: #252e3d;
  --ink: #dde3ec;
  --muted: #7c8798;
  --retail: #35d07f;
  --maker: #ff5c5c;
  --flow: #ffb020;

  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --wrap: 1080px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

.num, .mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a { color: var(--flow); text-decoration: none; border-bottom: 1px solid var(--line); }
a:hover { border-bottom-color: var(--flow); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--flow);
  outline-offset: 2px;
}

/* ── Status bar ───────────────────────────────────────────────────────────── */

.statusbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #080a0f;
  border-bottom: 1px solid var(--line);
}

.statusbar-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  min-height: 52px;
}

.brand {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.035em;
  margin-right: 22px;
  white-space: nowrap;
}
.brand .slash { color: var(--flow); }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.stat {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  line-height: 1.35;
  padding: 5px 16px 5px 0;
  margin-right: 16px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.stat:last-child { border-right: 0; }
.stat .k {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.stat .v { color: var(--ink); font-size: 13px; }
.stat .v.retail { color: var(--retail); }
.stat .v.maker { color: var(--maker); }
.stat .v.flow { color: var(--flow); }
.stat .v.dim { color: var(--muted); }

.wallet-slot { display: flex; align-items: center; gap: 10px; padding: 6px 0; }

/* ── Layout ───────────────────────────────────────────────────────────────── */

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px 120px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0 0 26px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 16px 20px 13px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--flow); border-bottom-color: var(--flow); }
.tab .badge-count {
  display: inline-block;
  margin-left: 7px;
  color: var(--ground);
  background: var(--flow);
  border-radius: 2px;
  padding: 0 5px;
  font-size: 10px;
}
/* An author `display` beats the UA rule behind the `hidden` attribute, so restate it. */
.tab .badge-count[hidden] { display: none; }

.panel[hidden] { display: none; }

h2.section {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--flow);
  margin: 0 0 18px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.prose {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--muted);
  max-width: 66ch;
}
.prose strong { color: var(--ink); font-weight: 400; font-style: italic; }
.prose.tight { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 22px 24px;
  margin: 0 0 20px;
}
.card > :last-child { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }

.card-head {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}
@media (max-width: 780px) { .grid2 { grid-template-columns: 1fr; } }

/* ── Controls ─────────────────────────────────────────────────────────────── */

.btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  color: var(--flow);
  border: 1px solid var(--flow);
  border-radius: 2px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--flow); color: var(--ground); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn.safe { color: var(--retail); border-color: var(--retail); }
.btn.safe:hover:not(:disabled) { background: var(--retail); color: var(--ground); }
.btn.risk { color: var(--maker); border-color: var(--maker); }
.btn.risk:hover:not(:disabled) { background: var(--maker); color: var(--ground); }
.btn.ghost { color: var(--muted); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 6px 11px; font-size: 10px; letter-spacing: 0.1em; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label.field {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

input[type="number"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  background: var(--ground);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 14px;
  width: 130px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.45;
}
.check input { margin-top: 3px; accent-color: var(--flow); width: 15px; height: 15px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.readout div {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  padding-right: 28px;
  margin-right: 28px;
  border-right: 1px solid var(--line);
}
.readout div:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.readout .k {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.readout .v { font-size: 21px; letter-spacing: -0.01em; }
.readout .v.flow { color: var(--flow); }

/* ── Open rolls ───────────────────────────────────────────────────────────── */

.rolls { margin: 0 0 30px; }
.rolls:empty { display: none; }

.roll {
  border: 1px solid var(--flow);
  border-radius: 3px;
  background: var(--surface);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.roll.expired { border-color: var(--maker); }
.roll.done { border-color: var(--line); }

.roll-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.roll-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--flow);
}
.roll.expired .roll-title { color: var(--maker); }
.roll.done .roll-title { color: var(--retail); }
.roll-id {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
}
.roll-id b { color: var(--ink); font-weight: 600; }

.rolling {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--flow);
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--flow);
  animation: pulse 1.15s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.25; transform: scale(0.7); } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.meter {
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin: 14px 0;
}
.meter i { display: block; height: 100%; background: var(--flow); transition: width 0.5s linear; }
.roll.expired .meter i { background: var(--maker); }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 18px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  margin: 12px 0;
}
.kv dt { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: 10px; padding-top: 2px; }
.kv dd { margin: 0; color: var(--ink); word-break: break-all; }

/* ── Tokens ───────────────────────────────────────────────────────────────── */

.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
@media (min-width: 700px) {
  .token-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
}

.token {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.token.retail { border-color: rgba(53, 208, 127, 0.35); }
.token.maker { border-color: rgba(255, 92, 92, 0.35); }
.token.sel { outline: 2px solid var(--flow); outline-offset: -2px; }

.token .art {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--ground);
  image-rendering: pixelated;
}
.token .art.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--line);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.token .meta { padding: 11px 12px 12px; }
.token .name {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.token .name .alpha { color: var(--maker); font-size: 11px; }
.token.retail .name .id { color: var(--retail); }
.token.maker .name .id { color: var(--maker); }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.retail { color: var(--retail); border-color: rgba(53, 208, 127, 0.4); }
.tag.maker { color: var(--maker); border-color: rgba(255, 92, 92, 0.4); }
.tag.flow { color: var(--flow); border-color: rgba(255, 176, 32, 0.4); }
.tag.on { background: var(--surface-2); }

.token .pick {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.token .pick input { accent-color: var(--flow); width: 14px; height: 14px; }
.token .pick.off { opacity: 0.4; cursor: not-allowed; }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.scroller { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  min-width: 560px;
}
th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 9.5px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td.retail { color: var(--retail); }
td.maker { color: var(--maker); }
td.flow { color: var(--flow); }
td.dim { color: var(--muted); }
td.wide { white-space: normal; min-width: 220px; }
tr.mine td { background: rgba(255, 176, 32, 0.05); }

/* ── Messages ─────────────────────────────────────────────────────────────── */

.msgs {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(440px, calc(100vw - 40px));
}

.msg {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 3px;
  padding: 13px 15px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.msg.err { border-left-color: var(--maker); }
.msg.ok { border-left-color: var(--retail); }
.msg.info { border-left-color: var(--flow); }

.msg h4 {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 6px;
  color: var(--ink);
}
.msg.err h4 { color: var(--maker); }
.msg.ok h4 { color: var(--retail); }
.msg.info h4 { color: var(--flow); }
.msg p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; font-family: var(--serif); }
.msg p + p { margin-top: 7px; }
.msg .raw {
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--line);
  word-break: break-all;
  max-height: 5.4em;
  overflow: auto;
}
.msg .x {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px;
}
.msg { position: relative; padding-right: 30px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */

.veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(6, 8, 12, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.veil[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--maker);
  border-radius: 3px;
  max-width: 560px;
  width: 100%;
  padding: 28px 30px;
  max-height: 90vh;
  overflow: auto;
}
.modal h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--maker);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.modal .prose { max-width: none; margin: 0 0 14px; }
.modal .odds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 2px;
  margin: 18px 0;
}
.modal .odds > div { background: var(--ground); padding: 14px 16px; }
.modal .odds b {
  display: block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  margin-bottom: 3px;
}
.modal .odds .win b { color: var(--retail); }
.modal .odds .lose b { color: var(--maker); }
.modal .odds span { font-size: 12.5px; color: var(--muted); font-family: var(--serif); }

.empty {
  font-family: var(--serif);
  color: var(--muted);
  font-size: 16px;
  padding: 34px 0;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 3px;
}

.note {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.note b { color: var(--flow); font-weight: 600; }

.warn {
  border-left: 2px solid var(--maker);
  padding-left: 14px;
  margin: 16px 0;
}
.warn .prose { color: var(--ink); }

footer.foot {
  margin-top: 60px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.95;
  word-break: break-all;
}
footer.foot b { color: var(--ink); font-weight: 600; }

@media (max-width: 620px) {
  .statusbar-inner { min-height: 0; padding: 8px 16px; }
  .stat { padding-right: 12px; margin-right: 12px; }
  .wrap { padding: 0 16px 100px; }
  .card { padding: 18px 16px; }
  .msgs { left: 16px; right: 16px; max-width: none; }
}
