/* mm24 dealing desk.
 *
 * Dark and dense on purpose: this is a screen someone watches, not a page
 * they read. The rules that matter:
 *
 *   - NUMBERS ARE TABULAR AND MONOSPACED. A price column that shifts as
 *     digits change is a column you cannot scan, and comparing two figures
 *     by eye is most of what this screen is for.
 *   - SIGN IS COLOUR, and only sign. Green and red are never used for
 *     anything else, so a red cell always means "this is costing money".
 *   - NOTHING IS ROUNDED HERE. Every figure is the string the server sent
 *     (public/format.js only trims trailing zeros). The columns are sized
 *     for 38-digit NUMERICs rather than clipping them.
 */

:root {
  --bg: #0b0e13;
  --panel: #12161f;
  --panel-2: #171c27;
  --line: #222a38;
  --ink: #dde3ec;
  --ink-dim: #8a94a6;
  --ink-faint: #5a6373;
  --up: #26a269;
  --up-ink: #4ddc9a;
  --down: #c01c28;
  --down-ink: #ff7b7b;
  --accent: #e8b339;
  --warn: #e07b39;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ------------------------------------------------------------------ header */

.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(180deg, #141924, #10141d);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand .mark { font-weight: 700; letter-spacing: .5px; color: var(--accent); font-size: 15px; }
.brand .sub { display: block; color: var(--ink-faint); font-size: 11px; }

.instrument { display: flex; align-items: center; gap: 8px; }
.instrument .hint { color: var(--ink-faint); font-size: 11px; }

/* The tape. Big, because it is the point of the screen. */
.tape { display: flex; align-items: stretch; gap: 1px; margin-left: auto; }
.tape .side, .tape .mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 14px; background: var(--panel); min-width: 112px;
}
.tape .label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.tape .px { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; }
.tape .bid .px { color: var(--up-ink); }
.tape .ask .px { color: var(--down-ink); }
.tape .mid .px { font-size: 14px; color: var(--ink-dim); }
/* A quote that has gone stale is dimmed rather than removed: an empty box
   reads as "loading", and this is "do not trade on this". */
.tape.stale { opacity: .38; filter: grayscale(.6); }

.status { display: flex; align-items: center; gap: 14px; font-size: 11px; color: var(--ink-dim); }
.dot-wrap { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.dot.live { background: var(--up); box-shadow: 0 0 6px var(--up); }
.dot.down { background: var(--down); }
.who { font-family: var(--mono); color: var(--accent); }

/* ------------------------------------------------------------------ banner */

.banner {
  margin: 0; padding: 9px 16px;
  background: #3a2a12; border-bottom: 1px solid #5a4420; color: #ffd79a;
  font-size: 12px;
}
.banner[hidden] { display: none; }

/* -------------------------------------------------------------------- grid */

.grid {
  display: grid; gap: 10px; padding: 10px;
  grid-template-columns: minmax(280px, 1.4fr) minmax(230px, .9fr) minmax(220px, .9fr) minmax(220px, .9fr);
  grid-template-areas: "chart ticket account settings" "ladder ticket account settings";
}
.chart-card { grid-area: chart; }
.ladder-card { grid-area: ladder; }
.ticket { grid-area: ticket; }
.account { grid-area: account; }
.settings { grid-area: settings; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr 1fr; grid-template-areas: "chart chart" "ladder ticket" "account settings"; }
}
@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "chart" "ladder" "ticket" "account" "settings"; }
  .tape { margin-left: 0; width: 100%; }
}

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; min-width: 0;
}
.card.wide { margin: 0 10px 10px; }
.card h2 {
  margin: 0 0 8px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .09em; color: var(--ink-dim);
}
.card h2 .muted { text-transform: none; letter-spacing: 0; color: var(--ink-faint); font-weight: 400; }

/* ------------------------------------------------------------------- chart */

#chart { width: 100%; height: 160px; display: block; }
#chart .line { fill: none; stroke: var(--accent); stroke-width: 1.4; }
#chart .area { fill: url(#g); opacity: .18; }
#chart .grid-line { stroke: var(--line); stroke-width: 1; }
#chart .last { fill: var(--accent); }
#chart text { fill: var(--ink-faint); font-size: 9px; font-family: var(--mono); }

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

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left; font-weight: 600; font-size: 10px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-faint);
  padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td {
  padding: 4px 8px; border-bottom: 1px solid #1a202b; white-space: nowrap;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
tbody tr:hover td { background: var(--panel-2); }
th.num, td.num { text-align: right; }
td.text { font-family: inherit; }
.scroll { overflow: auto; max-height: 340px; }
.ladder td { padding: 3px 8px; }
.ladder .bid { color: var(--up-ink); }
.ladder .ask { color: var(--down-ink); }
.empty { color: var(--ink-faint); font-family: inherit; text-align: center; padding: 14px; }

.up { color: var(--up-ink); }
.down { color: var(--down-ink); }
.flat { color: var(--ink-dim); }
.pill {
  font-family: inherit; font-size: 10px; padding: 1px 6px; border-radius: 3px;
  border: 1px solid var(--line); color: var(--ink-dim); text-transform: uppercase; letter-spacing: .05em;
}
.pill.long { color: var(--up-ink); border-color: #1d4634; background: #10211a; }
.pill.short { color: var(--down-ink); border-color: #4a2026; background: #1e1113; }
.pill.live { color: var(--accent); border-color: #4a3a12; background: #1d1810; }

/* ------------------------------------------------------------------ ticket */

.field { margin-bottom: 8px; }
.field label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin-bottom: 3px; }
input, select {
  width: 100%; padding: 6px 8px; background: #0c1017; color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--mono); font-size: 13px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[readonly] { color: var(--accent); background: #0a0d13; }
.inline { display: flex; gap: 6px; }
.inline input, .inline select { flex: 1 1 auto; }
.inline button { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-dim); margin: 6px 0 8px; }
.check input { width: auto; }

.presets { display: flex; gap: 5px; margin: -3px 0 8px; }
.presets button {
  flex: 1; padding: 3px 0; font-size: 11px; font-family: var(--mono);
  background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line); border-radius: 3px; cursor: pointer;
}
.presets button:hover { color: var(--ink); border-color: var(--ink-faint); }

.estimate { margin: 0 0 10px; font-size: 11px; }
.estimate div { display: flex; justify-content: space-between; padding: 2px 0; }
.estimate dt { color: var(--ink-faint); }
.estimate dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

button {
  padding: 7px 10px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-size: 12px; cursor: pointer;
}
button:hover { border-color: var(--ink-faint); }
button.ghost { background: transparent; color: var(--ink-dim); font-size: 11px; padding: 4px 9px; }
/* Row actions: small enough not to set the row height. `.tiny` is used by
   the cancel button in the open-orders table. */
button.tiny, td button {
  font-size: 10px; padding: 2px 7px; font-family: inherit;
  background: transparent; color: var(--ink-dim); border-color: var(--line);
}
button.tiny:hover, td button:hover { color: var(--ink); border-color: var(--ink-faint); }
td button:disabled { opacity: .4; cursor: default; }
.buttons { display: flex; gap: 6px; }
.buttons button { flex: 1; font-weight: 600; padding: 9px; }
button.buy { background: #11331f; border-color: #1d6b40; color: var(--up-ink); }
button.buy:hover { background: #164226; }
button.sell { background: #331316; border-color: #7a2630; color: var(--down-ink); }
button.sell:hover { background: #42171b; }

/* ----------------------------------------------------------------- account */

.equity { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.meter { margin: 8px 0 10px; }
.meter-bar { height: 5px; background: #2a1518; border-radius: 3px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--down), var(--warn), var(--up)); }
.meter-legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-faint); margin-top: 3px; }
.meter-legend span:nth-child(2) { font-family: var(--mono); color: var(--ink); }

.kv { margin: 0; font-size: 12px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px solid #1a202b; }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -10px -12px 8px; padding: 0 12px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--ink-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.bar { margin-bottom: 6px; }

/* ------------------------------------------------------------------- notes */

.msg { margin: 6px 0 0; font-size: 11px; min-height: 14px; }
.msg.err, .note.err { color: var(--down-ink); }
.msg.ok { color: var(--up-ink); }
.msg.muted, .note { color: var(--ink-faint); }
.note { font-size: 11px; margin: 6px 0 0; }
.foot { padding: 6px 16px 16px; font-size: 10px; color: var(--ink-faint); }
/* The deployed-build marker (#114): present on every page, never loud. */
.foot .build { display: block; margin-top: 2px; }

/* ------------------------------------------- sign in & account security */
/* #159 / #160 / #161. Three endpoints shipped with no UI, so a client
   still needed an operator to get in or to get a credential. */

.auth-card { max-width: 340px; margin: 10px auto; }
.auth-card form { display: flex; flex-direction: column; gap: 4px; }
.auth-card label, .security-card label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); }
.auth-card input, .security-card input[type="text"], .security-card input:not([type]) {
  width: 100%; box-sizing: border-box;
}
.auth-card button[type="submit"] { margin-top: 8px; }

.security-card { margin: 0 10px 10px; }
.sec-block { padding: 10px 0; border-top: 1px solid var(--line); }
.sec-block:first-of-type { border-top: none; padding-top: 0; }
.sec-block h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 600; margin: 0 0 4px;
}
.sec-block form { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.sec-block .hint { font-size: 11px; color: var(--ink-faint); margin: 0 0 6px; }

.pill { font-size: 10px; padding: 1px 6px; border-radius: 8px; border: 1px solid var(--line); }
.pill.ok { color: var(--up-ink); border-color: var(--up-ink); }
.pill.warnpill { color: var(--ink-faint); }

.perms { border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; margin: 4px 0; }
.perms legend { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); padding: 0 4px; }
.perms label { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; text-transform: none; letter-spacing: 0; }

/* A secret shown ONCE. Deliberately loud and deliberately not a toast:
   this is the only time the value exists in readable form, so it stays on
   screen until the user says they have it. */
.warn {
  font-size: 11px; color: var(--down-ink); border: 1px solid var(--down-ink);
  border-radius: 3px; padding: 6px 8px; margin: 8px 0 4px;
}
.secret {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; background: var(--line); border-radius: 3px; padding: 8px;
  margin: 0 0 6px; white-space: pre-wrap; word-break: break-all; user-select: all;
}
button.danger { color: var(--down-ink); border-color: var(--down-ink); }

/* --------------------------------------------------------------- nav (#168) */

/* ONE nav, identical on both signed-in pages. Each page used to carry a
   bare link to the other, which meant nothing told you where you were —
   and the two headers had already drifted apart in markup. */
.nav { display: flex; gap: 2px; margin-left: 4px; }
.nav a {
  display: inline-flex; align-items: center;
  padding: 6px 12px; min-height: 32px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-dim); text-decoration: none;
  border: 1px solid transparent; border-radius: 4px;
}
.nav a:hover { color: var(--ink); background: var(--panel); }
/* The current page is marked by `aria-current`, so the styling and what a
   screen reader announces cannot disagree — one attribute drives both. */
.nav a[aria-current="page"] {
  color: var(--accent); background: var(--panel); border-color: var(--line);
}

/* The session you are reading this on. Marked rather than hidden: knowing
   which row is yours is the whole point of the list. */
tr.current-session td { color: var(--ink); background: rgba(255, 255, 255, .03); }

/* -------------------------------------------------------- phone (#168) */

/* Below this width the header is taller than the content it introduces
   unless it stacks, and 11px controls at 4px padding are under any
   reasonable tap target. */
@media (max-width: 680px) {
  .top { gap: 10px 14px; padding: 10px 12px; }
  .nav { margin-left: 0; width: 100%; }
  .nav a { flex: 1; justify-content: center; min-height: 40px; }
  .status { width: 100%; flex-wrap: wrap; gap: 10px; }
  .status button, .status a { min-height: 36px; }

  /* 16px, because anything smaller makes iOS Safari zoom the page on
     focus and the user then has to pinch back out to see the form. */
  .sec-block input, .auth-card input { font-size: 16px; }
  .sec-block button, .auth-card button { min-height: 40px; }

  /* Tables stay as tables and scroll sideways. Collapsing them to cards
     was the alternative and it loses the column alignment that makes a
     row of figures readable at all. */
  .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .scroll table { min-width: 460px; }
}
