/* ---------------------------------------------------------------------------
   Helios dashboard styles.

   Mobile first: the layout is a single column by default and only spreads out
   on wider screens, because the phone is where this will actually be read -
   standing in a kitchen, deciding whether to approve a trade.

   No external fonts, no icon library, no framework. The content security
   policy forbids loading anything from another origin, and a dashboard that
   still renders correctly on a hotel wifi with two bars is worth more than one
   that looks fashionable on a fast connection.
--------------------------------------------------------------------------- */

:root {
  --bg: #0f1216;
  --bg-raised: #171c22;
  --bg-sunken: #0b0e11;
  --border: #262d36;
  --text: #e6eaef;
  --text-muted: #98a3b0;
  --accent: #5b9dd9;
  --good: #3fa66a;
  --warn: #d9a441;
  --bad: #d95c5c;
  --radius: 10px;
  --gap: 1rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-raised: #ffffff;
    --bg-sunken: #eceef1;
    --border: #d8dde3;
    --text: #1a1f26;
    --text-muted: #5c6672;
    --accent: #2b6cb0;
    --good: #2f8551;
    --warn: #9a6a12;
    --bad: #b23b3b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* --- Top bar --------------------------------------------------------------*/
.topbar {
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}

.topbar-right { display: flex; align-items: center; gap: 0.4rem; }

.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
}

.chip-mode { color: var(--text); }
.chip-backtest { border-color: var(--border); }
.chip-paper { border-color: var(--accent); color: var(--accent); }
.chip-live-supervised,
.chip-live-auto { border-color: var(--bad); color: var(--bad); font-weight: 650; }

.chip-link:hover { color: var(--text); border-color: var(--accent); }

.inline { display: inline; margin: 0; }

/* --- Page -----------------------------------------------------------------*/
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.narrow { max-width: 30rem; margin: 2rem auto; padding: 0 1rem; }

section { margin-bottom: 2.5rem; }

h1 {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

h2 { font-size: 1.1rem; margin: 0 0 0.35rem; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

code, pre {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  overflow-x: auto;
}

code { background: var(--bg-sunken); padding: 0.1rem 0.3rem; border-radius: 4px; }
pre code { background: none; padding: 0; }

a { color: var(--accent); }

/* --- Cards and grid -------------------------------------------------------*/
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: var(--gap);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

@media (min-width: 40rem) {
  .grid { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
}

.stat { display: flex; flex-direction: column; gap: 0.15rem; }
.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.stat-value { font-size: 1.5rem; font-weight: 620; }
.stat-note { font-size: 0.82rem; color: var(--text-muted); }
.stat-good .stat-value { color: var(--good); }
.stat-bad .stat-value { color: var(--bad); }

/* --- Alerts and banners ---------------------------------------------------*/
.alert {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: var(--gap);
  border: 1px solid var(--border);
  background: var(--bg-raised);
}
.alert p:last-child { margin-bottom: 0; }
.alert-error { border-color: var(--bad); }
.alert-warn  { border-color: var(--warn); }
.alert-ok    { border-color: var(--good); }

.banner {
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
}
.banner-halt {
  background: var(--bad);
  color: #fff;
  border: none;
}
.banner-halt h2 { margin: 0 0 0.25rem; }
.banner-halt p { margin: 0; }

.banner-notice {
  background: var(--bg-raised);
  border: 1px solid var(--warn);
}
.banner-notice h2 { margin: 0 0 0.25rem; color: var(--warn); }
.banner-notice p { margin: 0; }

/* Trade approvals.
   Deliberately unlike .banner-notice above. A notice asks "have you seen
   this?" and authorises nothing; an approval authorises a trade. If the two
   looked alike, clearing notices by reflex would become approving trades by
   reflex, and the approval step would look like a control while being a
   habit. Hence a different colour, a heavier border, and choices that cannot
   be answered with one thoughtless tap. */
.banner-approval {
  background: var(--bg-raised);
  border: 2px solid var(--accent);
  border-left-width: 6px;
}
.banner-approval h2 { margin: 0 0 0.25rem; color: var(--accent); }
.banner-approval p { margin: 0; }

.card-approval {
  border-left: 6px solid var(--accent);
}
.approval-headline { font-size: 1.05rem; margin-bottom: 0.35rem; }

/* Both choices are shown, side by side, with neither pre-selected and neither
   styled as the obvious one to press. */
.approval-choices {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.approval-choices .btn { flex: 1; }
.btn-approve {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-refuse {
  background: transparent;
  border-color: var(--muted);
}

/* Drills.
   Marked so they cannot be mistaken for a real trade even at a glance on a
   phone. The habituation argument runs backwards here: rehearsing "approve
   whatever appears" would build precisely the reflex the approval step exists
   to prevent, so a drill has to look like a drill, not like practice at
   approving trades. Hatched border, muted colour, and a label that is the
   first thing read. */
.card-drill {
  border: 2px dashed var(--muted);
  border-left-width: 6px;
  opacity: 0.95;
}
.drill-tag {
  display: inline-block;
  margin: 0 0 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--muted);
  color: var(--bg);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn-drill {
  background: transparent;
  border-color: var(--muted);
  border-style: dashed;
}

/* --- Forms ----------------------------------------------------------------*/
label {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0.85rem 0 0.3rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 1rem; /* 16px stops iOS zooming in on focus */
  font-family: inherit;
}

input:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px; /* comfortable tap target */
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
.btn-danger  { background: var(--bad); border-color: var(--bad); color: #fff; }

/* --- Tables ---------------------------------------------------------------*/
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th, td {
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

.cell-note {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

.row-deviates { background: color-mix(in srgb, var(--warn) 8%, transparent); }

.tag {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  margin-left: 0.3rem;
}
.tag-ok { color: var(--good); }
.tag-warn { color: var(--warn); }
.tag-bad { color: var(--bad); }

.details {
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-word;
  max-width: 22rem;
}

/* --- Activity feed --------------------------------------------------------*/
.feed { list-style: none; padding: 0; margin: 0; }

.feed li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.feed-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.feed-event { font-weight: 600; }
.feed-actor, .feed-subject { color: var(--text-muted); }

/* --- Details/summary ------------------------------------------------------*/
summary { cursor: pointer; font-weight: 550; }
details[open] summary { margin-bottom: 0.6rem; }

/* --- Footer ---------------------------------------------------------------*/
.footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer p { margin: 0.25rem 0; }
.footer-warn { color: var(--warn); }
