/* Mirror Control — dark operator surface.
   Palette and rules are recorded in DESIGN.md. Colour is reserved for state,
   so an amber value on this page always means something. */

:root {
  --bg: #0f1012;
  --surface: #16181c;
  --raised: #1c1f24;
  --line: #262a31;
  --line-strong: #333942;

  --text: #e8eaed;
  --dim: #9ba1ab;
  --faint: #7c8390;

  --live: #46b37f;
  --paused: #c9973e;
  --blocked: #c75b57;
  --idle: #6e757f;
  --danger: #c0413c;
  --danger-hi: #d24a44;

  --r: 10px;
  --r-lg: 14px;
  --pad: clamp(16px, 3vw, 28px);
  --tap: 44px;

  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .7);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

/* `hidden` outranks every display rule below. Without this, .login's own
   `display: grid` wins and the sign-in panel stays visible behind the app. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* Browser surfaces belong to the design too. */
::selection { background: rgba(70, 179, 127, .28); color: #fff; }
:root { caret-color: var(--live); accent-color: var(--live); scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 2px;
  border-radius: 4px;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------------------------------------------------------------- Sign in */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--pad);
}

.login__panel {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(24px, 5vw, 36px);
  box-shadow: var(--shadow);
}

.login__title { margin: 0; font-size: 1.35rem; font-weight: 600; letter-spacing: -.02em; }
.login__sub { margin: 6px 0 26px; color: var(--dim); font-size: .92rem; }

/* --------------------------------------------------------------- Topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--pad);
  padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(15, 16, 18, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar__name { margin: 0; font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.topbar__meta { margin: 2px 0 0; font-size: .76rem; color: var(--faint); }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar__status { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 0; }
.topbar__summary { margin: 0; font-size: .74rem; color: var(--dim); text-align: right; }
/* On a narrow phone the qualifier would push the buttons off the row. */
@media (max-width: 560px) { .topbar__summary { display: none; } }

.iconbtn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  transition: color .12s var(--ease), border-color .12s var(--ease), background .12s var(--ease);
}
.iconbtn:hover { color: var(--text); border-color: var(--line-strong); background: var(--raised); }
.iconbtn:active { transform: scale(.96); }
.iconbtn[data-busy="1"] { color: var(--live); }

/* ---------------------------------------------------------------- Badge */

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 13px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .76rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.badge--live    { color: var(--live);    border-color: rgba(70,179,127,.35);  background: rgba(70,179,127,.09); }
.badge--paused  { color: var(--paused);  border-color: rgba(201,151,62,.35);  background: rgba(201,151,62,.09); }
.badge--blocked { color: var(--blocked); border-color: rgba(199,91,87,.35);   background: rgba(199,91,87,.09); }
.badge--idle    { color: var(--faint); }

/* The one authored moment: only a genuinely live system breathes. */
.badge--live .dot { animation: breathe 3.4s var(--ease) infinite; }
@keyframes breathe {
  0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 rgba(70,179,127,.45); }
  50%      { opacity: .72; box-shadow: 0 0 0 5px rgba(70,179,127,0); }
}

/* ----------------------------------------------------------------- Page */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: clamp(22px, 3vw, 32px);
}

.block { animation: rise .4s var(--ease) both; }
.block:nth-child(2) { animation-delay: .04s; }
.block:nth-child(3) { animation-delay: .08s; }
.split .block:nth-child(2) { animation-delay: .12s; }
.block--last { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.h {
  margin: 0 0 14px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--faint);
}

.label {
  display: block;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ------------------------------------------------------- System facts */
/* Rules and space, not five little boxes. */

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--line);
}
@media (min-width: 620px) { .facts { grid-template-columns: repeat(2, 1fr); column-gap: 28px; } }
@media (min-width: 980px) { .facts { grid-template-columns: repeat(5, 1fr); } }

.facts__item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
@media (min-width: 980px) { .facts__item { border-bottom: none; } }

.fact { margin: 0; font-size: .95rem; font-weight: 500; }
.fact--live { color: var(--live); }
.fact--paused { color: var(--paused); }
.fact--blocked { color: var(--blocked); }
.fact--idle { color: var(--dim); }

/* --------------------------------------------------------- Symbol panels */

.symbols { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .symbols { grid-template-columns: repeat(2, 1fr); } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(17px, 2.4vw, 22px);
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow);
}

.panel--loading { min-height: 290px; position: relative; overflow: hidden; }
.shimmer { position: absolute; inset: 0; background:
  linear-gradient(100deg, transparent 20%, rgba(255,255,255,.035) 45%, transparent 70%);
  background-size: 220% 100%; animation: sweep 1.5s linear infinite; }
@keyframes sweep { to { background-position: -220% 0; } }

.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel__sym { margin: 0; font-size: 1.12rem; font-weight: 600; letter-spacing: -.01em; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }

.metric { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.metric__v { font-size: 1.16rem; font-weight: 600; }
.metric__v--ok { color: var(--live); }
.metric__v--bad { color: var(--blocked); }
.metric__note { font-size: .74rem; color: var(--faint); line-height: 1.4; }

.legs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px;
        border-top: 1px solid var(--line); padding-top: 16px; }
.leg__v { font-size: 1rem; font-weight: 500; }
.leg__v span { color: var(--faint); font-weight: 400; }
/* The kept legacy position: a quiet band above the live readings. */
.legs--baseline { border-top: none; padding-top: 0; }

.panel__foot {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.reason { margin: 0; font-size: .9rem; color: var(--dim); }
.reason strong { color: var(--text); font-weight: 600; }

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 14px;
  align-items: start;
}
.action .btn { width: 100%; }

/* The blocker callout: the first thing read inside a panel that has a problem. */
.callout {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  background: var(--raised);
}
.callout__title { margin: 0 0 4px; font-size: .95rem; font-weight: 600; }
.callout__body { margin: 0; font-size: .88rem; color: var(--dim); line-height: 1.5; }

.callout--paused  { border-color: rgba(201,151,62,.4);  background: rgba(201,151,62,.08); }
.callout--paused .callout__title  { color: var(--paused); }
.callout--blocked { border-color: rgba(199,91,87,.4);   background: rgba(199,91,87,.08); }
.callout--blocked .callout__title { color: var(--blocked); }
.callout--live    { border-color: rgba(70,179,127,.4);  background: rgba(70,179,127,.08); }
.callout--live .callout__title    { color: var(--live); }

/* A disabled control always travels with the sentence explaining itself. */
.action { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hint { font-size: .78rem; color: var(--faint); line-height: 1.45; }

.footnote { margin: 10px 0 0; font-size: .74rem; color: var(--faint); }

/* ------------------------------------------------------------- Row lists */

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row__main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row__title { font-size: .95rem; font-weight: 600; }
.row__note { font-size: .84rem; color: var(--dim); }
.row__time { font-size: .74rem; color: var(--faint); white-space: nowrap; padding-top: 2px; }

.row--empty { color: var(--faint); font-size: .89rem; padding: 22px 0; justify-content: center; }

/* Not-trading instruments are deliberately recessive against the live pair. */
.row--quiet .row__title { color: var(--dim); font-weight: 500; }
.row--quiet .row__note { color: var(--faint); }

/* The healthy empty state for alerts: reassuring, not blank. */
.row--ok {
  display: flex; align-items: center; justify-content: flex-start; gap: 9px;
  color: var(--live); font-size: .9rem; font-weight: 500;
  padding: 18px 0; border-bottom: 1px solid var(--line);
}

.tag {
  font-size: .66rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px; border: 1px solid var(--line); color: var(--faint);
  white-space: nowrap;
}
.tag--critical { color: var(--blocked); border-color: rgba(199,91,87,.4); background: rgba(199,91,87,.08); }
.tag--error { color: var(--paused); border-color: rgba(201,151,62,.4); background: rgba(201,151,62,.08); }
.tag--test { color: var(--faint); }

.split { display: grid; grid-template-columns: 1fr; gap: clamp(22px, 3vw, 32px); }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1fr; } }

/* -------------------------------------------------------------- Controls */

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  font: 600 .92rem/1 var(--ui);
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.btn:hover:not(:disabled) { background: #23272e; border-color: #414852; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn--primary { background: var(--text); color: #101114; border-color: var(--text); }
.btn--primary:hover:not(:disabled) { background: #fff; border-color: #fff; }

.btn--danger { background: transparent; color: var(--danger-hi); border-color: rgba(192,65,60,.5); }
.btn--danger:hover:not(:disabled) { background: rgba(192,65,60,.12); border-color: var(--danger); }

.btn--block { width: 100%; margin-top: 6px; }

.stopzone {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(16px, 2.4vw, 22px);
  background: var(--surface);
}
.stopzone__text { min-width: 0; }
.stopzone__title { margin: 0 0 4px; font-size: .95rem; font-weight: 600; }
.stopzone__copy { margin: 0; max-width: 62ch; font-size: .86rem; color: var(--dim); }

/* ----------------------------------------------------------------- Forms */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }

.input {
  min-height: var(--tap);
  width: 100%;
  padding: 10px 13px;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  font: 400 1rem/1.4 var(--ui);
  transition: border-color .12s var(--ease);
}
.input:hover { border-color: #414852; }
.input:focus { border-color: var(--live); outline: none; box-shadow: 0 0 0 3px rgba(70,179,127,.16); }
.input::placeholder { color: var(--faint); }

.help { margin: 0; font-size: .79rem; color: var(--faint); }

.notice {
  margin: 0 0 16px;
  padding: 11px 13px;
  border-radius: var(--r);
  font-size: .87rem;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--dim);
}
.notice--bad  { color: #e79a97; border-color: rgba(199,91,87,.45);  background: rgba(199,91,87,.1); }
.notice--warn { color: #e0b978; border-color: rgba(201,151,62,.45); background: rgba(201,151,62,.1); }
.notice--ok   { color: #7fcfa6; border-color: rgba(70,179,127,.45); background: rgba(70,179,127,.1); }

.confirmbox {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 18px;
  background: var(--raised);
}
.confirmbox__text { margin: 0; font-size: .88rem; color: var(--dim); }
.confirmbox__text strong { color: var(--text); }

/* ---------------------------------------------------------------- Modals */

.modal {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8);
}
.modal::backdrop { background: rgba(8, 9, 10, .68); backdrop-filter: blur(3px); }
.modal__body { padding: clamp(20px, 3.5vw, 28px); }
.modal__title { margin: 0 0 8px; font-size: 1.12rem; font-weight: 600; letter-spacing: -.01em; }
.modal__lede { margin: 0 0 20px; font-size: .9rem; color: var(--dim); }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal__actions .btn { flex: 1 1 auto; }
@media (min-width: 520px) { .modal__actions .btn { flex: 0 0 auto; } }

/* --------------------------------------------------------------- Motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
