/* HedgeBot mobile dashboard — same minimal system as the desktop app
   (hark.com principles: one clear statement, small supporting copy,
   whitespace, hairlines, not card boxes). Notion principles layered
   on top (principles only — no Notion branding or content): generous
   whitespace, one strong headline number per screen with muted
   secondary labels, restrained colour (near-black text, one
   violet accent, status colours only where they mean something),
   content in a single readable column, subtle dividers instead of
   heavy card borders. Light, phone-first, self-contained. No external
   fonts, no CDN, no images. */

:root {
  color-scheme: light;
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e7e3dd;
  --border-strong: #d8d3cc;
  --text: #1b1d1f;
  --muted: #6f7378;
  --faint: #9a9da2;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #f1eafe;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-text: #b3261e;
  --ok: #177245;
  --warn: #b45309;
  --amber-bright: #d97706;
  --amber-soft: #fdf0d5;
  --radius: 16px;
}

* { box-sizing: border-box; }

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

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.6;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hidden { display: none !important; }

/* ---------- Header: clean top bar, stays visible while scrolling ---------- */

.topbar {
  padding: 24px 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
/* Logo: the user's chosen HB monogram, as-is, in the header. */
.brand-logo { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 9px; object-fit: cover; background: #000; }

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
  margin-left: 6px;
}

.engine-line { margin-top: 12px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--muted);
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }

.status-pill.status-running { color: var(--ok); border-color: #bcd8c6; }
.status-pill.status-running::before { background: var(--ok); }
.status-pill.status-stopped { color: var(--danger); border-color: #eec5c1; }
.status-pill.status-stopped::before { background: var(--danger); }

.relay-note,
.updated-line {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Layout ---------- */

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 40px;
}

.screen h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 4px 0 8px;
}

h2 {
  font-size: 11px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.hint {
  font-size: 14px;
  color: var(--muted);
  margin: 8px 0;
}

/* ---------- Status / error area ---------- */

.status-area {
  margin-bottom: 16px;
  font-size: 15px;
}

.status-area:empty { display: none; }

.status-area .banner {
  display: block;
  padding: 12px 14px;
  border-radius: 0 12px 12px 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--faint);
  background: var(--surface);
  color: var(--muted);
}

.status-area .banner-error {
  border-left-color: var(--danger);
  background: #fbecea;
  color: #7a1a14;
}

.status-area .banner-warn {
  border-left-color: var(--warn);
  background: #faf3df;
  color: #5c3d00;
}

.status-area .banner-ok {
  border-left-color: var(--ok);
  background: #e9f4ec;
  color: #14532d;
}

/* ---------- Cards & stats: flat sections, hairlines, one hero number ---------- */

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
  margin-bottom: 8px;
}

.card {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 20px 0 24px;
  margin-bottom: 8px;
}

.cards .card { margin-bottom: 0; }

/* One strong headline number: "Profit today" spans the full width
   as the hero stat; the rest stay in the two-column grid below it. */
.cards .card:first-child { grid-column: 1 / -1; }
.cards .card:first-child .stat-value { font-size: 40px; }

.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.stat-value.negative { color: var(--danger); }
.stat-value.positive { color: var(--ok); }

.state-note {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 16px;
}

.state-note:empty { display: none; }

/* ---------- Lists ---------- */

.books-list,
.placements-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.books-list li,
.placements-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  font-size: 15px;
}

.books-list li:first-child,
.placements-list li:first-child { border-top: 0; padding-top: 0; }

.book-status,
.placement-status {
  font-weight: 700;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.book-status.status-online,
.placement-status.status-settled,
.placement-status.status-placed { color: var(--ok); }

.book-status.status-logging_in { color: var(--warn); }

.book-status.status-degraded,
.placement-status.status-exposed { color: var(--warn); }

/* Inactive (offline) is muted grey — the neutral "not connected"
   state. Login error is red, visually distinct from Inactive. */
.book-status.status-offline { color: var(--muted); }

.book-status.status-login_error { color: var(--danger); }

.placement-status.status-aborted { color: var(--danger); }

.placement-detail { min-width: 0; }
.placement-game { font-weight: 600; }
.placement-meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.placement-amounts {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Forms & buttons ---------- */

label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

input[type="text"],
input[type="url"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 17px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

#pairing-code {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-weight: 700;
}

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

.btn {
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  flex: 1 1 auto;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: #e5b6b1;
}

.action-status {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  min-height: 1.4em;
}

.action-status:empty { display: none; }

/* ---------- Footer ---------- */

.foot {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* Wider phones / small tablets: 3 stat columns. */
@media (min-width: 480px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
