/* ============================================================
   Crypto Garage v2 — mobile-first redesign stylesheet.
   Visual language ported from the design handoff (terminal/neon/daylight
   themes + 5 accents). Theme/accent tokens are injected on :root by
   js/core/theme.js; this file consumes the variables. Layout is mobile-first:
   fixed header -> step indicator -> scrollable screen -> sticky run-bar ->
   fixed bottom tab-bar. Safe areas via env(safe-area-inset-*). No device bezel.
   ============================================================ */

:root {
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --ff: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --fm: "JetBrains Mono", ui-monospace, "SF Mono", "Roboto Mono", monospace;

  /* Fallback token values (overwritten at runtime by theme.js for "terminal"). */
  --bg: #080b11;
  --stage: #04060a;
  --surface: #121826;
  --surface-2: #1a2231;
  --surface-3: #232d3e;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e9edf3;
  --text-muted: #92a0b3;
  --text-faint: #5d6b7e;
  --pos: #16c784;
  --neg: #f6465d;
  --warn: #f0b90b;
  --field-bg: #0b1016;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --accent: #16c784;
  --accent-soft: rgba(22, 199, 132, 0.14);
  --accent-line: rgba(22, 199, 132, 0.45);
  --accent-contrast: #04130c;
  --accent-glow: rgba(22, 199, 132, 0.35);

  /* Safe-area insets (0 on non-notched devices). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 76px; /* tab-bar content height incl. its own bottom padding */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }
.mono { font-family: var(--fm); letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tag-link { color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; }

/* ============================================================
   App shell (mobile-first full viewport)
   ============================================================ */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app-header {
  flex: 0 0 auto;
  padding: calc(14px + var(--safe-top)) 20px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  position: relative;
  z-index: 5;
}
.app-header .h-eyebrow {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 4px;
}
.app-header h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.05; }
.app-header .h-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }

.header-pill {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted); white-space: nowrap; cursor: pointer;
}
.header-pill svg { width: 15px; height: 15px; }
.header-avatar {
  width: 34px; height: 34px; border-radius: 999px; flex: none; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fm); font-weight: 600; font-size: 13px;
  color: var(--accent-contrast); background: var(--accent);
}

/* Screen scroll region */
.screen {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: 4px 16px 20px;
  scroll-behavior: smooth;
}
.screen::-webkit-scrollbar { width: 0; }
.screen.has-runbar { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px; margin-bottom: 14px;
}
.card.tight { padding: 14px; }
.card-head { margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.card-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; line-height: 1.45; }
.card-ic {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.card-ic svg { width: 15px; height: 15px; }

.section-label {
  font-family: var(--fm); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-faint); margin: 22px 4px 10px;
}

/* ============================================================
   Fields & inputs
   ============================================================ */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 7px;
}
.field-label .req { color: var(--accent); margin-left: 2px; }
.field-action-accent { color: var(--accent); font-size: 13px; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; line-height: 1.4; }
.field-status { font-size: 12.5px; color: var(--text-faint); margin: 8px 2px 0; min-height: 1em; }
.field-status.is-error { color: var(--neg); }
.field-status.is-success { color: var(--pos); }
.field-status.is-info { color: var(--text-muted); }

.input, .select, input[type="search"], input[type="text"], input[type="password"],
input[type="number"], input[type="datetime-local"], textarea.input {
  width: 100%; height: 50px; background: var(--field-bg);
  border: 1px solid var(--border); border-radius: var(--r); color: var(--text);
  font-family: var(--ff); font-size: 15.5px; padding: 0 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none; appearance: none;
}
.input.mono, input.mono { font-family: var(--fm); letter-spacing: -0.01em; }
.input::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, input:focus, textarea.input:focus {
  border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-2);
}
textarea.input { height: auto; padding: 12px 14px; line-height: 1.5; resize: vertical; }

/* native multi-line select (symbol list) */
select[size] { height: auto; padding: 6px; }
select[size] option { padding: 6px 8px; border-radius: 8px; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: translateY(-65%) rotate(45deg); pointer-events: none;
}
.select-wrap .select { padding-right: 40px; }

.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input, .input-affix input { padding-right: 52px; }
.input-affix .affix {
  position: absolute; right: 14px; font-family: var(--fm); font-size: 13px;
  color: var(--text-faint); pointer-events: none; display: flex; align-items: center;
}
.input-affix .affix.left { left: 14px; right: auto; }
.input-affix .affix.left svg { width: 16px; height: 16px; }
.input-affix.has-left .input, .input-affix.has-left input { padding-left: 40px; padding-right: 14px; }

/* ============================================================
   Segmented control
   ============================================================ */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 4px;
}
.seg.wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); }
.seg-btn {
  appearance: none; border: 0; background: transparent; color: var(--text-muted);
  font-family: var(--ff); font-size: 14px; font-weight: 500; height: 40px; border-radius: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s; white-space: nowrap;
}
.seg-btn svg { width: 15px; height: 15px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; box-shadow: 0 2px 10px var(--accent-glow); }
.seg.subtle .seg-btn.active { background: var(--surface-3); color: var(--text); box-shadow: none; }

/* ============================================================
   Stepper / slider / toggle
   ============================================================ */
.stepper {
  display: flex; align-items: center; background: var(--field-bg); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; height: 50px; min-width: 0;
}
.stepper button {
  width: 46px; height: 100%; flex: none; border: 0; cursor: pointer; background: transparent;
  color: var(--text-muted); font-size: 22px; line-height: 1; display: flex; align-items: center;
  justify-content: center; transition: background 0.12s, color 0.12s;
}
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper button:active { background: var(--accent-soft); color: var(--accent); }
.stepper input {
  flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; background: transparent;
  text-align: center; color: var(--text); font-family: var(--fm); font-size: 16px; outline: none;
}

.slider-row { display: flex; align-items: center; gap: 14px; }
.slider {
  -webkit-appearance: none; appearance: none; flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-3); outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 999px; background: var(--accent);
  cursor: pointer; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent-line), 0 2px 8px var(--accent-glow);
}
.slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 999px; background: var(--accent); border: 3px solid var(--bg); cursor: pointer; }
.slider-val { min-width: 56px; text-align: right; font-family: var(--fm); font-size: 14px; color: var(--text); }

.toggle {
  width: 50px; height: 30px; border-radius: 999px; flex: none; background: var(--surface-3);
  border: 1px solid var(--border); position: relative; cursor: pointer; transition: background 0.18s; padding: 0;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px;
  background: var(--text-faint); transition: transform 0.18s, background 0.18s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { transform: translateX(20px); background: var(--accent-contrast); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .tr-label { font-size: 14.5px; font-weight: 500; }
.toggle-row .tr-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; line-height: 1.4; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  appearance: none; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-family: var(--ff); font-size: 14.5px; font-weight: 500; height: 46px;
  padding: 0 18px; border-radius: var(--r); display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; box-shadow: 0 4px 16px var(--accent-glow); }
.btn--primary:hover { background: var(--accent); filter: brightness(1.06); border-color: var(--accent); }
.btn--danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--lg { height: 54px; font-size: 16px; }
.btn--sm { height: 38px; font-size: 13px; padding: 0 14px; border-radius: 10px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ============================================================
   Chips
   ============================================================ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; font-family: var(--fm); letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--text-muted);
}
.chip .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.chip strong { font-weight: 700; }
.chip--pos { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.chip--neg { background: color-mix(in srgb, var(--neg) 16%, transparent); color: var(--neg); }
.chip--warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip--info { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   Stats grid
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.stat-label { font-size: 11.5px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 13px; height: 13px; }
.stat-val { font-family: var(--fm); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }
.stat-val.pos { color: var(--pos); }
.stat-val.neg { color: var(--neg); }

/* ============================================================
   Wizard steps + run-bar
   ============================================================ */
.steps { display: flex; gap: 6px; padding: 0 16px 8px; position: relative; z-index: 4; flex: 0 0 auto; }
.step {
  flex: 1; cursor: pointer; border: 0; background: transparent; display: flex; flex-direction: column;
  gap: 7px; align-items: stretch; font-family: var(--ff); padding: 0;
}
.step .bar { height: 4px; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.step .lbl { font-size: 11.5px; color: var(--text-faint); text-align: left; transition: color 0.2s; display: flex; align-items: center; gap: 5px; }
.step.active .bar { background: var(--accent); }
.step.active .lbl { color: var(--text); font-weight: 600; }
.step.done .bar { background: var(--accent-line); }
.step.done .lbl { color: var(--text-muted); }
.step .num {
  width: 16px; height: 16px; border-radius: 999px; font-size: 9.5px; font-family: var(--fm);
  display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-faint);
}
.step .num svg { width: 9px; height: 9px; }
.step.active .num { background: var(--accent); color: var(--accent-contrast); }
.step.done .num { background: var(--accent-line); color: var(--accent-contrast); }

.runbar {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 10px 16px 12px; background: linear-gradient(0deg, var(--bg) 55%, transparent);
  z-index: 8; display: flex; gap: 10px; align-items: center;
}
.runbar .runbar-main { flex: 1; }
.runbar .runbar-back { flex: 0 0 auto; width: 52px; padding: 0; }
.runbar .btn--primary { box-shadow: 0 6px 20px var(--accent-glow); }

/* ============================================================
   Progress card
   ============================================================ */
.progress-card { background: var(--surface); border: 1px solid var(--accent-line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.progress-bar, .progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 12px 0 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; box-shadow: 0 0 12px var(--accent-glow); }
.progress-meta { display: flex; justify-content: space-between; font-family: var(--fm); font-size: 12px; color: var(--text-muted); }

/* ============================================================
   Tab bar
   ============================================================ */
.tabbar {
  flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(10px + var(--safe-bottom));
  background: var(--surface); border-top: 1px solid var(--border); position: relative; z-index: 9;
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0;
  color: var(--text-faint); font-family: var(--ff); font-size: 10.5px; font-weight: 500; transition: color 0.15s;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }
.tab-badge {
  position: absolute; top: 2px; left: 50%; margin-left: 6px; min-width: 16px; height: 16px;
  border-radius: 999px; padding: 0 4px; background: var(--neg); color: #fff; font-size: 9px;
  font-family: var(--fm); display: flex; align-items: center; justify-content: center; font-weight: 700;
}

/* ============================================================
   Charts
   ============================================================ */
.chart-wrap { position: relative; margin: 4px 0 2px; }
.equity-svg { width: 100%; display: block; height: 200px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; padding: 0 2px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar-col-val { font-size: 11px; color: var(--text-muted); }
.bar-col-bar { width: 100%; background: var(--accent); border-radius: 6px 6px 3px 3px; transition: height 0.5s ease; }
.bar-col-label { font-size: 10.5px; color: var(--text-faint); }

/* ============================================================
   Hero (results / admin) + risk summary
   ============================================================ */
.hero-card { background: linear-gradient(160deg, var(--accent-soft), transparent 70%); }
.hero-eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.hero-value { font-size: 38px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.hero-roi { font-size: 15px; font-weight: 600; margin-top: 2px; }
.hero-roi.pos { color: var(--pos); }
.hero-roi.neg { color: var(--neg); }
.hero-from { font-weight: 400; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.risk-summary { border-left: 3px solid var(--border-strong); }
.risk-summary--pos { border-left-color: var(--pos); }
.risk-summary--neg { border-left-color: var(--neg); }
.risk-summary--warn { border-left-color: var(--warn); }
.risk-headline { font-size: 15px; font-weight: 600; }
.risk-sub { font-size: 13px; margin-top: 6px; line-height: 1.5; }
.risk-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ============================================================
   Chains / list rows / kv
   ============================================================ */
.chain { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.chain-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chain-steps { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chain-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--accent); opacity: 0.9; }
.chain-dot.ins { background: var(--warn); }
.chain-dot.sl { background: var(--neg); }
.chain-steps-label { font-size: 13px; font-weight: 600; margin-left: 6px; }
.chain-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chain-meta .m-label { font-size: 10.5px; color: var(--text-faint); }
.chain-meta .m-val { font-size: 14px; margin-top: 2px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 14.5px; font-weight: 500; }
.list-row .lr-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.list-row .lr-ic { width: 38px; height: 38px; border-radius: 11px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.list-row.selected { border-color: var(--accent-line); background: var(--accent-soft); }
.kv { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-muted); flex: none; }
.kv .v { white-space: nowrap; text-align: right; }

/* ============================================================
   Empty state
   ============================================================ */
.empty { text-align: center; padding: 34px 18px; color: var(--text-faint); }
.empty .e-ic { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-faint); }
.empty .e-title { font-size: 15px; color: var(--text-muted); font-weight: 500; }
.empty .e-sub { font-size: 12.5px; margin-top: 5px; line-height: 1.5; }

/* ============================================================
   RSI inset (advanced step)
   ============================================================ */
.rsi-inset { margin-top: 4px; padding: 14px; background: var(--field-bg); border-radius: var(--r); border: 1px solid var(--border); }

/* ============================================================
   Required-capital block (auto deposit)
   ============================================================ */
.reqcap-card { padding: 16px; }
.reqcap-inset { background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; margin-bottom: 16px; }
.reqcap { display: flex; flex-direction: column; gap: 6px; }
.reqcap-head { display: flex; align-items: center; justify-content: space-between; }
.reqcap-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--fm); }
.reqcap-spinner { font-size: 11px; color: var(--text-faint); }
.reqcap-value-row { display: flex; align-items: baseline; gap: 8px; }
.reqcap-value { font-family: var(--fm); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.reqcap-value--muted { color: var(--text-faint); }
.reqcap--loading .reqcap-value { opacity: 0.55; }
.reqcap-unit { font-family: var(--fm); font-size: 14px; color: var(--text-muted); }
.reqcap-hint, .reqcap-note { font-size: 11.5px; color: var(--text-faint); line-height: 1.45; margin: 2px 0 0; }
.reqcap-note--error { color: var(--neg); }
.reqcap-warn { display: flex; gap: 10px; margin-top: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent); }
.reqcap-warn-icon { color: var(--warn); font-size: 16px; }
.reqcap-warn-text { font-size: 12.5px; color: var(--text); margin: 0; line-height: 1.45; }
.reqcap-warn-adjusted { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 0; }
.reqcap-breakdown { margin-top: 8px; }
.reqcap-breakdown summary { font-size: 12.5px; color: var(--accent); cursor: pointer; }
.reqcap-breakdown-table { width: 100%; border-collapse: collapse; font-family: var(--fm); font-size: 11.5px; margin-top: 8px; }
.reqcap-breakdown-table th, .reqcap-breakdown-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.reqcap-breakdown-table tr.is-reject td { color: var(--neg); }
.reqcap-breakdown-wrap { overflow-x: auto; }

/* ============================================================
   Grid preview (averaging ladder)
   ============================================================ */
.preview-head h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.preview-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.preview-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; }
.preview-stat-value { font-family: var(--fm); font-size: 18px; font-weight: 600; }
.preview-stat-label { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.preview-stat--warn .preview-stat-value { color: var(--warn); }
.preview-table-wrap { overflow-x: auto; }
.preview-table { width: 100%; border-collapse: collapse; font-family: var(--fm); font-size: 12px; }
.preview-table th, .preview-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.preview-table th:first-child, .preview-table td:first-child { text-align: left; }
.preview-table tr.is-base td { color: var(--accent); }

/* ============================================================
   Data-source controls (step 1)
   ============================================================ */
.field-grid { display: flex; flex-direction: column; gap: 0; }
.field-grid > .field { margin-bottom: 16px; }
.download-tools { margin-top: 4px; }
.symbol-field input[type="search"] { margin-bottom: 8px; }
.symbol-field select { margin-bottom: 6px; }

/* ============================================================
   Auth
   ============================================================ */
.auth-shell, .pending-shell { min-height: 100vh; }
.auth {
  position: relative; min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(40px + var(--safe-top)) 26px calc(40px + var(--safe-bottom));
  background: radial-gradient(120% 80% at 50% -10%, var(--accent-soft), transparent 60%), var(--bg);
  color: var(--text);
}
.auth-brand { text-align: center; margin-bottom: 30px; }
.auth-logo {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 16px; display: flex; align-items: center;
  justify-content: center; background: var(--accent); color: var(--accent-contrast); box-shadow: 0 10px 30px var(--accent-glow);
}
.auth-brand h1 { font-size: 27px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.auth-brand p { font-size: 13px; color: var(--text-faint); margin: 6px 0 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 22px; max-width: 420px; width: 100%; margin: 0 auto; }
.auth-tabs { display: flex; gap: 4px; background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 4px; margin-bottom: 20px; }
.auth-tabs button { flex: 1; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--text-muted); font-family: var(--ff); font-size: 14px; font-weight: 500; cursor: pointer; }
.auth-tabs button.active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); margin: 4px 0 18px; cursor: pointer; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--border-strong); flex: none; display: flex; align-items: center; justify-content: center; background: var(--field-bg); }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* ============================================================
   Appearance: accent dots
   ============================================================ */
.accent-row { display: flex; gap: 12px; }
.accent-dot { width: 34px; height: 34px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform 0.12s, border-color 0.12s; }
.accent-dot:hover { transform: scale(1.08); }
.accent-dot.is-active { border-color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================================
   Background customiser preview
   ============================================================ */
.bg-preview { height: 150px; border-radius: var(--r); overflow: hidden; position: relative; border: 1px solid var(--border); margin-bottom: 14px; background: var(--surface-2); }
.bg-img-layer { position: absolute; inset: 0; background-repeat: no-repeat; }
.bg-scrim { position: absolute; inset: 0; }
.bg-content { position: relative; z-index: 2; padding: 16px; }
.bg-content .t1 { font-size: 16px; font-weight: 600; }
.bg-content .t2 { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.bg-drop {
  position: absolute; z-index: 3; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: rgba(0,0,0,0.45); border: 1px solid var(--border-strong); color: #fff; font-size: 11.5px; cursor: pointer; max-width: 90%;
}
.bg-preview.has-image .bg-drop { background: rgba(0,0,0,0.35); }

/* ============================================================
   Bottom sheet
   ============================================================ */
.sheet { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.24s ease; }
.sheet.is-open .sheet-scrim { opacity: 1; }
.sheet-panel {
  position: relative; background: var(--surface); border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0; max-height: 82%; display: flex; flex-direction: column;
  box-shadow: 0 -20px 50px rgba(0,0,0,0.4); transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.22,1,0.36,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.is-open .sheet-panel { transform: translateY(0); }
.sheet-grip-wrap { display: flex; justify-content: center; padding: 10px 0 2px; }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); }
.sheet-head { padding: 8px 18px 12px; }
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-close { width: 38px; padding: 0; }
.sheet-body { overflow-y: auto; padding: 0 18px 18px; flex: 1; }
.sheet-footer { padding: 12px 18px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--border); }

/* ============================================================
   Toast
   ============================================================ */
.toast-stack { position: absolute; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 40; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r);
  padding: 13px 15px; font-size: 13.5px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); transition: opacity 0.22s ease, transform 0.22s ease; pointer-events: auto;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-ic { color: var(--accent); display: flex; }
.toast--error .toast-ic { color: var(--neg); }
.toast--warn .toast-ic { color: var(--warn); }

/* ============================================================
   Onboarding overlay
   ============================================================ */
.onboarding-overlay { position: absolute; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,0.55); }
.onboarding-card { max-width: 420px; width: 100%; margin: 0; }
.onboarding-card h2 { margin: 0 0 8px; font-size: 20px; }
.onboarding-steps { margin: 12px 0 16px; padding-left: 20px; color: var(--text-muted); font-size: 13.5px; line-height: 1.6; }

/* ============================================================
   Details (results)
   ============================================================ */
.results-details summary { font-size: 13px; color: var(--accent); cursor: pointer; padding: 8px 0; }

/* ============================================================
   Desktop widening — the design is mobile-first; on wide screens we cap the
   shell width and centre it so it doesn't stretch awkwardly.
   ============================================================ */
@media (min-width: 768px) {
  .app { max-width: 520px; margin: 0 auto; left: 50%; transform: translateX(-50%); right: auto; width: 100%; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .toast-stack { max-width: 488px; left: 50%; transform: translateX(-50%); right: auto; width: calc(100% - 32px); }
}

/* ============================================================
   Reduced motion — content is always visible at rest.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .toast { opacity: 1; transform: none; }
  .sheet-panel { transition: none; }
}
