/* lightning-trader UI. The light "institutional" design of the chosen mockup
   (plan section 8). Colours are the plan's values; the environment colour is
   set by the server's configuration through the body class env-paper or
   env-live, never by the browser. */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin.woff2") format("woff2");
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --page: #F6F5F1;
  --panel: #FFFFFF;
  --border: #D8DBE0;
  --rule: #E6E8EB;
  --row: #ECEEF0;
  --ink: #1C1F24;
  --muted: #5E6670;
  --faint: #6B727C;
  --soft: #4A525C;
  --profit: #17794A;
  --profit-dark: #125E3A;
  --profit-bg: #E9F4EE;
  --profit-zone: #DDEFE5;
  --loss: #B4530F;
  --loss-dark: #8F3F0B;
  --loss-zone: #FBE6D6;
  --warn: #8A5A00;
  --best: #EEF0F3;
  --stop: #A11D2B;
  --paper: #1F5FBF;
  --live: #C8102E;
  /* The emergency alert's red: brighter than the LIVE banner and STOP ALL. */
  --emergency: #E4141B;
  --emergency-stripe: #CF0E15;
  /* An open position on the Trading screen: long and short (owner, 2026-11-26). */
  --long: #0B6477;
  --long-tint: #DDEEF1;
  --short: #6B2D7B;
  --short-tint: #F0E4F3;
  --env: var(--paper);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

body.env-live { --env: var(--live); }

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

a { color: var(--paper); }
a:hover { color: #16478F; }

code { font-size: 12px; background: var(--best); padding: 0 3px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--profit); }
.neg { color: var(--loss); }
.num { text-align: right; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 3px solid #1F5FBF; outline-offset: 2px; }

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

.banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--env);
  color: #FFFFFF;
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 18px;
  padding: 8px 24px;
  text-align: center;
}

.banner-name { font-weight: 700; letter-spacing: 0.2em; font-size: 14px; }
.banner-note { font-size: 12px; }

.offline {
  position: sticky;
  top: 40px;
  z-index: 950;
  background: var(--ink);
  color: #FFFFFF;
  padding: 8px 24px;
  text-align: center;
  font-weight: 600;
}

body.is-offline #app { opacity: 0.45; filter: grayscale(0.7); }

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

.button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  background: #FFFFFF;
  color: var(--ink);
  cursor: pointer;
}

.button.primary { background: var(--ink); color: #FFFFFF; }
.button.stop { background: var(--stop); border-color: var(--stop); color: #FFFFFF; font-weight: 700; }
.button.on { border-color: var(--profit); background: var(--profit-bg); color: var(--profit-dark); }
.button:disabled, .button[aria-disabled="true"] {
  border-color: #C9CDD3; background: transparent; color: var(--faint); cursor: not-allowed;
}
.button.stop:disabled { background: #E8C9CC; border-color: #E8C9CC; color: #5E2A30; }

.link-button {
  font: inherit; background: none; border: 0; padding: 4px; color: var(--paper);
  text-decoration: underline; cursor: pointer; min-height: 32px;
}

.stepper {
  font: inherit; font-size: 18px; width: 44px; height: 44px; flex: none;
  border: 1px solid #C9CDD3; background: #FFFFFF; color: var(--ink); cursor: pointer;
}
.stepper:disabled { color: var(--faint); cursor: not-allowed; }

/* ---------------------------------------------------------------- login */

.login { display: flex; justify-content: center; padding: 72px 16px; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 28px 32px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card h1 { font-size: 26px; }
.login-card p { margin: 0 0 10px; }
.login-card label { font-weight: 600; margin-top: 8px; }
.login-card input {
  font: inherit; min-height: 44px; padding: 0 10px; border: 1px solid #A9AFB7; background: #FFFFFF;
}
.login-card .button { margin-top: 12px; }
.form-error { color: var(--loss-dark); min-height: 18px; margin: 6px 0 0; font-weight: 600; }

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

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  padding: 22px 32px 18px;
  border-bottom: 1px solid var(--ink);
}

.pair { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1; }
.status-line { margin-top: 8px; color: var(--muted); font-size: 12px; }
.status-line strong { font-weight: 600; color: var(--ink); }
.status-line .state-ON { color: var(--profit); }
.status-line .state-STOPPED { color: var(--stop); }
.status-line .state-FLATTENING { color: var(--warn); }
.status-line .blocked { color: var(--loss-dark); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  padding: 0 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.tabs a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 12px 0 10px;
  border-bottom: 3px solid transparent;
}

.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs-user { margin-left: auto; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.notice { padding: 0 32px; }
.notice:not(:empty) { padding: 10px 32px; background: #FFF6DC; border-bottom: 1px solid #E8D9A8; }
.notice.error:not(:empty) { background: #FBE6D6; border-bottom-color: #E9C3A6; color: var(--loss-dark); }

.health { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); background: var(--panel); }
.health-item { flex: 1 1 150px; padding: 10px 32px; border-right: 1px solid var(--rule); }
.health-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.health-value { font-weight: 600; margin-top: 2px; }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 7px; vertical-align: 1px; background: var(--profit);
}
.dot.warn { background: #C08A00; border-radius: 0; }
.dot.down { background: var(--stop); border-radius: 0; transform: rotate(45deg); }

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

.screen {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 24px 32px 32px;
  align-items: flex-start;
}

.column-main { flex: 999 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.column-side { flex: 1 1 360px; max-width: 460px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

.panel { background: var(--panel); border: 1px solid var(--border); min-width: 0; flex: 1 1 420px; }
.column-main .panel, .column-side .panel { flex: none; }
.panel.wide { flex: 1 1 100%; }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
}

.panel-body { padding: 16px 20px; }
.empty { padding: 16px 20px; color: var(--muted); }

.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 500; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--row); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { padding-left: 20px; }
table.data th:last-child, table.data td:last-child { padding-right: 20px; }
table.data .num { text-align: right; }
table.data td.best { font-weight: 700; background: var(--best); }
table.data tr.solid-row td { background: var(--page); font-weight: 600; }
table.data tr.stale td { color: var(--faint); }
table.quotes { min-width: 720px; }

dl.facts { margin: 0; padding: 14px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; }

/* ---------------------------------------------------------------- prices */

.price .big { color: var(--soft); }
.price .pips { font-weight: 700; }

.consolidated { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.consolidated > div { padding: 18px 20px; border-right: 1px solid var(--rule); min-width: 0; }
.consolidated > div:last-child { border-right: 0; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.side-label { color: var(--muted); font-size: 12px; }
.side-price { font-size: 40px; margin-top: 4px; letter-spacing: -0.01em; white-space: nowrap; }
.side-size { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 8px; }
.kv > span:first-child { color: var(--muted); }

/* ---------------------------------------------------------------- the position cockpit */

/* The Trading screen is built around the open position (owner, 2026-11-26).
   A long position's block is edged in petrol, a short one's in plum. */
.cockpit { padding: 18px 22px 22px; border-left: 6px solid var(--border); }
.cockpit + .cockpit { border-top: 1px solid var(--ink); }
.cockpit.cockpit-long { border-left-color: var(--long); }
.cockpit.cockpit-short { border-left-color: var(--short); }
.cockpit-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.cockpit-side { font-size: 26px; font-weight: 700; letter-spacing: 0.04em; }
.cockpit-long .cockpit-side { color: var(--long); }
.cockpit-short .cockpit-side { color: var(--short); }
.cockpit-status { font-weight: 700; letter-spacing: 0.1em; font-size: 13px; padding: 4px 10px; color: #FFFFFF; background: var(--profit); }
.cockpit-status.status-OPENING { background: var(--muted); }
.cockpit-status.status-CLOSING { background: var(--warn); }
.cockpit-status.status-EXIT-FAILED { background: var(--stop); }
.cockpit-status.status-CLOSED { background: var(--ink); }
/* The last position, closed, stays until the next one starts (owner, 2026-11-26). */
.cockpit.cockpit-closed { background: var(--page); }
.cockpit-closed .cockpit-side { opacity: 0.8; }
.cockpit-age { font-size: 16px; font-weight: 600; }
.cockpit-id { margin-left: auto; font-size: 12px; }
.cockpit-main {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 40px;
  margin-top: 14px; padding: 14px 0; border-top: 1px solid var(--row); border-bottom: 1px solid var(--row);
}
.cockpit-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.cockpit-pnl-usd { font-size: 56px; font-weight: 700; line-height: 1.05; letter-spacing: -0.01em; }
.cockpit-pnl-pips { font-size: 20px; font-weight: 600; }
.cockpit-prices { display: flex; gap: 32px; }
.cockpit-price { font-size: 28px; font-weight: 600; }
.cockpit-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.button.close-position { border-color: var(--loss-dark); color: var(--loss-dark); }
.button.close-position:disabled { border-color: #C9CDD3; color: var(--faint); }
.cockpit .bar { height: 48px; margin-top: 18px; }
.cockpit-levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.level-field {
  font: inherit; font-size: 22px; font-weight: 600; width: 9ch; min-height: 44px; padding: 0 8px;
  border: 1px solid #A9AFB7; background: #FFFFFF; color: var(--ink);
}
.level-field.dirty { border-color: var(--ink); box-shadow: inset 0 -3px 0 var(--ink); }
.levels-intro { margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.cockpit h3 { margin-top: 20px; margin-bottom: 8px; }

/* The order size of every new entry (owner, 2026-11-26). */
.order-size {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 12px 22px; border-bottom: 1px solid var(--rule); background: var(--page);
}
.order-size-label { font-weight: 600; }
.order-size-row { display: flex; align-items: center; gap: 6px; }
.order-size-field {
  font: inherit; font-size: 18px; font-weight: 600; width: 9ch; min-height: 44px; padding: 0 8px;
  text-align: right; border: 1px solid #A9AFB7; background: #FFFFFF; color: var(--ink);
}
.order-size-field.dirty { border-color: var(--ink); box-shadow: inset 0 -3px 0 var(--ink); }
.order-size-unit { color: var(--muted); }
.order-size-actions { display: flex; gap: 8px; }
.order-size-actions .button { min-height: 36px; padding: 0 14px; }
.order-size-note { font-size: 12px; }
.order-size-note.bad { color: var(--loss-dark); font-weight: 600; }

/* FLAT: calm, with the last closed position and today's realized P&L. */
.cockpit-flat { padding: 28px 22px; }
.flat-word { font-size: 48px; font-weight: 700; letter-spacing: 0.2em; color: var(--soft); }
.flat-note { margin: 4px 0 18px; color: var(--muted); font-size: 15px; }
.flat-last { padding: 12px 0; border-top: 1px solid var(--row); border-bottom: 1px solid var(--row); }
.flat-last-line { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 16px; margin-top: 4px; }
.flat-today { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-top: 14px; }
.flat-today-value { font-size: 22px; font-weight: 700; }

/* The consolidated price beside the cockpit: the same figures, smaller. */
.consolidated.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.consolidated.compact > div { padding: 12px 16px; }
.consolidated.compact > div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--rule); }
.consolidated.compact .side-price { font-size: 30px; }

.bar { position: relative; height: 40px; background: #F1F2F4; border: 1px solid var(--border); margin-top: 6px; }
.bar > span { position: absolute; }
.bar .zone-loss { top: 0; bottom: 0; background: var(--loss-zone); }
.bar .zone-profit { top: 0; bottom: 0; background: var(--profit-zone); }
.bar .mark-sl, .bar .mark-tp { top: -4px; bottom: -4px; width: 3px; margin-left: -1px; }
.bar .mark-sl { background: var(--loss); }
.bar .mark-tp { background: var(--profit); }
.bar .mark-entry { top: 6px; bottom: 6px; width: 1px; background: var(--muted); }
.bar .mark-now {
  top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: var(--ink); border: 2px solid #FFFFFF;
}
.bar-labels { position: relative; height: 44px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.bar-labels > span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.bar-labels .now { color: var(--ink); font-weight: 600; }
.bar-labels .entry { top: 14px; }
.bar-labels .sl { color: var(--loss-dark); font-weight: 600; }
.bar-labels .tp { color: var(--profit-dark); font-weight: 600; }
.bar-labels .now { top: 28px; }

.level { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--row); }
.level-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.level-head label { font-weight: 600; }
.level.sl .level-head label { color: var(--loss-dark); }
.level.tp .level-head label { color: var(--profit-dark); }
.held { font-size: 11px; border: 1px solid var(--ink); padding: 1px 6px; }
.by-strategy { font-size: 11px; color: var(--muted); }
.level-value { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 2px; }

.level-value .delta { color: var(--muted); font-size: 12px; }
.slider-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.slider-row input[type="range"] { flex: 1; min-width: 0; height: 44px; margin: 0; cursor: pointer; }
.level.sl input[type="range"] { accent-color: var(--loss); }
.level.tp input[type="range"] { accent-color: var(--profit); }
.level-hint { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.level-hint .bad { color: var(--loss-dark); font-weight: 600; }

.apply-row { display: flex; gap: 8px; margin-top: 14px; }
.apply-row .button { flex: 1; }
.inline-confirm { margin-top: 14px; padding: 14px; border: 2px solid var(--env); background: var(--page); }
.inline-confirm .confirm-env { margin: 0 0 6px; }
.inline-confirm strong { display: block; }
.inline-confirm ul { margin: 6px 0 0; padding-left: 18px; }
.inline-confirm p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.position-note { margin-top: 12px; font-size: 12px; color: var(--muted); }
.position-note.bad { color: var(--loss-dark); font-weight: 600; }

/* ---------------------------------------------------------------- alerts */

ol.alerts { list-style: none; margin: 0; padding: 6px 20px 14px; max-height: 420px; overflow-y: auto; }
ol.alerts li { padding: 10px 0; border-bottom: 1px solid var(--row); }
ol.alerts li:last-child { border-bottom: 0; }
.alert-meta { color: var(--muted); font-size: 12px; }
.alert-emergency .alert-meta { color: var(--stop); font-weight: 600; }

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

.filters, .calendar-form, .settings-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 16px 20px;
}
.filters label, .settings-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.filters input, .settings-form input {
  font: inherit; font-weight: 400; min-height: 44px; padding: 0 10px; border: 1px solid #A9AFB7; background: #FFFFFF;
}
.settings-form .unit { font-weight: 400; color: var(--muted); }
.segmented { border: 0; padding: 0; margin: 0; display: flex; gap: 0; }
.segmented label {
  flex-direction: row; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 1px solid #A9AFB7; margin-left: -1px; cursor: pointer; font-weight: 600;
}
.segmented label:has(input:checked) { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.calendar-form { flex-direction: column; align-items: flex-start; }
#history-note { margin: 0; padding: 0 20px 10px; }

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

/* The two views of History: open positions and the closed history (owner, 2026-11-25). */
.subtabs { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 0; }
.subtabs a {
  display: flex; align-items: center; min-height: 44px; padding: 0 18px; margin-left: -1px;
  border: 1px solid #A9AFB7; background: var(--panel); color: var(--ink); font-weight: 600; text-decoration: none;
}
.subtabs a:first-child { margin-left: 0; }
.subtabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

/* ---------------------------------------------------------------- position strip */

/* Whether a position is open, at a glance (owner, 2026-11-26). Long and short
   have colours of their own, apart from the PAPER blue, the LIVE red, the
   health colours and the emergency red; P&L sits on a white chip so that its
   green or orange keeps its contrast. */
.position-strip { display: flex; flex-direction: column; gap: 4px; padding: 16px 32px 0; }
.strip-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  padding: 12px 20px; border: 1px solid var(--border); background: var(--panel); color: var(--muted);
}
.strip-flat .strip-line .strip-side { color: var(--ink); letter-spacing: 0.12em; }
.strip-unknown .strip-line { color: var(--loss-dark); font-weight: 600; }
.strip-line.strip-long { background: var(--long); border-color: var(--long); color: #FFFFFF; }
.strip-line.strip-short { background: var(--short); border-color: var(--short); color: #FFFFFF; }
.strip-side { font-size: 20px; font-weight: 700; letter-spacing: 0.06em; }
.strip-state {
  font-weight: 700; letter-spacing: 0.1em; padding: 3px 10px; background: #FFFFFF; color: var(--ink);
}
.strip-attention .strip-state { color: var(--loss-dark); }
.strip-pnl {
  display: inline-flex; align-items: baseline; gap: 10px; padding: 4px 12px;
  background: #FFFFFF; color: var(--ink); font-weight: 700;
}
.strip-pnl.pos { color: var(--profit); }
.strip-pnl.neg { color: var(--loss); }
.strip-pnl-usd { font-size: 28px; line-height: 1.1; }
.strip-pnl-pips { font-size: 14px; }
.strip-fact { display: inline-flex; flex-direction: column; font-size: 15px; font-weight: 600; }
.strip-last-pnl { font-weight: 700; }
.strip-label { font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; }

/* A position's row is the control that opens it onto its orders and fills
   (History and Today's positions, owner 2026-11-26): the whole row is
   clickable, the "▶ 2 orders" button in it is the keyboard's way in. */
table.data .toggle-col { width: 1%; padding-right: 4px; }
table.data tr.position-row { cursor: pointer; }
table.data tr.position-row:hover td { background: #E4E7EB; }
table.data tr.position-row.expanded td { background: var(--best); }
table.data tr.position-row.open-row td { font-weight: 600; }
table.data tr.position-row.open-long td { background: var(--long-tint); }
table.data tr.position-row.open-short td { background: var(--short-tint); }
table.data tr.position-row.open-long td:first-child { box-shadow: inset 5px 0 0 var(--long); }
table.data tr.position-row.open-short td:first-child { box-shadow: inset 5px 0 0 var(--short); }
.orders-toggle {
  font: inherit; font-size: 12px; font-weight: 600; min-height: 32px; padding: 0 10px; cursor: pointer;
  border: 1px solid #A9AFB7; background: #FFFFFF; color: var(--ink); white-space: nowrap;
}
tr.position-row:hover .orders-toggle { border-color: var(--ink); }
.orders-toggle[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
table.data tr.trades-row > td { padding: 0 20px 14px 52px; background: var(--best); white-space: normal; }
.table-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.table-tools .button { min-height: 36px; padding: 0 14px; }
.trades-box { background: var(--panel); border: 1px solid var(--border); min-height: 36px; }
.trades-box:not(:has(table)) { padding: 9px 12px; color: var(--muted); }
.trades-box > p { margin: 0; padding: 6px 12px; }

/* One position's orders, each followed by its fills. */
table.data.trades { font-size: 12px; }
table.data.trades th, table.data.trades td { padding: 6px 10px; }
table.data.trades th:first-child, table.data.trades td:first-child { padding-left: 12px; }
table.data.trades tr.order-row td { border-top: 1px solid var(--rule); }
table.data.trades tr.order-row .event { font-weight: 600; }
table.data.trades tr.fill-row td { color: var(--soft); }
table.data.trades tr.fill-row .event { padding-left: 26px; }

/* Orders and fills under the position they belong to. */
table.data tr.group-row th {
  text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); font-weight: 400;
  background: var(--page); border-bottom: 1px solid var(--border); padding-top: 12px;
}
table.data tbody.position-group + tbody.position-group tr.group-row th { border-top: 1px solid var(--ink); }

/* An open position with its orders and fills so far. */
.trade-card { padding: 16px 20px; }
.trade-card + .trade-card { border-top: 1px solid var(--ink); }
.trade-card-title { font-size: 18px; font-weight: 600; }
dl.trade-facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 10px 0 14px; }
dl.trade-facts > div { min-width: 0; }
dl.trade-facts dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
dl.trade-facts dd { margin: 2px 0 0; font-weight: 600; }

/* ---------------------------------------------------------------- emergency */

.emergency {
  position: fixed;
  inset: 40px 0 0 0; /* the banner above stays visible */
  z-index: 900;
  background: repeating-linear-gradient(
    -45deg, var(--emergency) 0 28px, var(--emergency-stripe) 28px 56px
  );
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.emergency-card { max-width: 760px; width: 100%; }
.emergency h1 { font-family: var(--sans); font-size: 44px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.emergency-item { margin-top: 20px; padding: 18px 20px; background: rgba(0, 0, 0, 0.28); border: 2px solid #FFFFFF; }
.emergency-item p { margin: 6px 0 0; font-size: 18px; line-height: 1.45; }
.emergency-item .meta { font-size: 13px; opacity: 0.95; }
.emergency-item .button { margin-top: 14px; background: #FFFFFF; color: var(--ink); border-color: #FFFFFF; font-size: 16px; }
.emergency-sound { margin-top: 16px; font-weight: 700; }
.emergency :focus-visible { outline-color: #FFFFFF; }

/* ---------------------------------------------------------------- dialog */

dialog.confirm {
  border: 3px solid var(--env); padding: 22px 24px; max-width: 520px; width: calc(100% - 32px);
  color: var(--ink); background: var(--panel); font: inherit;
}
dialog.confirm::backdrop { background: rgba(28, 31, 36, 0.55); }
.confirm-env {
  display: inline-block; margin: 0 0 10px; padding: 2px 8px; background: var(--env); color: #FFFFFF;
  font-weight: 700; letter-spacing: 0.2em; font-size: 12px;
}
dialog.confirm h2 { font-size: 22px; }
dialog.confirm p { line-height: 1.5; }
dialog.confirm .confirm-warning:not(:empty) { color: var(--loss-dark); font-weight: 600; }
dialog.confirm .check { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-weight: 600; }
dialog.confirm .check input { width: 20px; height: 20px; margin: 0; flex: none; }
.confirm-buttons { display: flex; gap: 8px; margin-top: 18px; }
.confirm-buttons .button { flex: 1; }

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 720px) {
  .top, .tabs, .screen, .notice { padding-left: 16px; padding-right: 16px; }
  .health-item { padding: 8px 16px; }
  .consolidated { grid-template-columns: 1fr; }
  .consolidated > div { border-right: 0; border-bottom: 1px solid var(--rule); }
  .side-price { font-size: 32px; }
  .position-strip { padding: 12px 16px 0; }
  .cockpit { padding: 14px 14px 18px; }
  .cockpit-pnl-usd { font-size: 40px; }
  .cockpit-levels { grid-template-columns: 1fr; }
  .cockpit-id { margin-left: 0; }
  .column-side { max-width: none; }
  table.data tr.trades-row > td { padding-left: 12px; padding-right: 12px; }
  .trade-card { padding: 14px 16px; }
}
