/* ==========================================================================
   Fx9 — design system (light default, dark via [data-theme="dark"])
   ========================================================================== */
:root,
:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f3;
  --border: #e1e4e9;
  --border-strong: #cdd2da;
  --text: #15191e;
  --text-2: #464e5b;
  --text-3: #6b7482;
  --accent: #9a6400;
  --accent-strong: #7a4f00;
  --accent-soft: #fbf1de;
  --pos: #137333;
  --pos-soft: #e6f4ea;
  --neg: #c5221f;
  --neg-soft: #fce8e6;
  --warn: #8a5a00;
  --warn-soft: #fdf3d7;
  --info: #1a5fb4;
  --info-soft: #e8f0fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, 0.08);
  --focus: 0 0 0 3px rgba(26, 95, 180, 0.25);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1b2129;
  --surface-3: #222933;
  --border: #2a313c;
  --border-strong: #3a4250;
  --text: #e6e9ee;
  --text-2: #b4bbc6;
  --text-3: #8a93a0;
  --accent: #e2ac40;
  --accent-strong: #f0c060;
  --accent-soft: rgba(226, 172, 64, 0.13);
  --pos: #4ac26b;
  --pos-soft: rgba(74, 194, 107, 0.14);
  --neg: #f47067;
  --neg-soft: rgba(244, 112, 103, 0.14);
  --warn: #d9a23a;
  --warn-soft: rgba(217, 162, 58, 0.14);
  --info: #6cb6ff;
  --info-soft: rgba(108, 182, 255, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px rgba(108, 182, 255, 0.3);
  color-scheme: dark;
}

:root {
  --font: 'Noto Sans Thai', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-num: 'Plus Jakarta Sans', 'Noto Sans Thai', system-ui, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; color: var(--text); font-weight: 700; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }
p { margin: 0; }
a { color: var(--info); }
code, .mono { font-family: var(--font-mono); font-size: 0.85em; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon.sm { width: 15px; height: 15px; vertical-align: -2px; }
.icon.lg { width: 22px; height: 22px; }
i[data-icon] { display: inline-flex; font-style: normal; }

/* ---------- Top bar ---------- */
.topbar, .app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner, .header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.brand { display: flex; align-items: center; gap: 0.65rem; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-family: var(--font-num);
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, #c28a1c, #8a5a00);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 0.98rem; }
.brand-text small { color: var(--text-3); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav, .header-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-link, .header-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav-link:hover, .header-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
}
.conn::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}
.conn[data-state="live"]::before { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.conn[data-state="reconnecting"]::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Page layout ---------- */
.page, .main-wrapper { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.section { margin-top: 2rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.section-head h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 0.5rem; }
.section-head p { color: var(--text-3); font-size: 0.87rem; margin-top: 0.2rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }

/* ---------- Cards / panels ---------- */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  min-width: 0;
}
.main-card { padding: 1.35rem; }
.panel-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.95rem; font-weight: 700;
  margin-bottom: 0.15rem;
}
.panel-title .icon { color: var(--accent); }
.panel-sub { color: var(--text-3); font-size: 0.8rem; margin-bottom: 0.9rem; }
.card-heading h2, .card-heading h3 { display: flex; align-items: center; gap: 0.5rem; }
.card-heading .desc, .desc { color: var(--text-3); font-size: 0.87rem; margin-top: 0.3rem; }
.flex-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.muted, .text-dim { color: var(--text-3); }
.small { font-size: 0.8rem; }

/* ---------- Buttons & form controls ---------- */
.btn, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.87rem; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn-primary, .btn-gold { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-gold { color: #1b1300; }
.btn-primary:hover, .btn-gold:hover { background: var(--accent-strong); }
.btn:disabled, .btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.toggle-label, .switch {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.85rem; color: var(--text-2); cursor: pointer; user-select: none;
}
.toggle-label input, .switch input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

textarea, select, input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 0.87rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}
textarea:focus, select:focus, input:focus { outline: none; box-shadow: var(--focus); border-color: var(--info); }

/* ---------- Badges / pills / chips ---------- */
.badge, .badge-tag, .principle-verdict {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge.pos, .v-yes { background: var(--pos-soft); color: var(--pos); }
.badge.neg, .v-no { background: var(--neg-soft); color: var(--neg); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }

.text-success, .pos { color: var(--pos); }
.text-danger, .neg { color: var(--neg); }
.text-gold, .warn { color: var(--warn); }

/* ---------- Alerts ---------- */
.alert, .gatekeeper-summary {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.87rem;
  color: var(--text-2);
}
.alert .icon { margin-top: 2px; }
.alert-danger, .gatekeeper-summary.blocked { background: var(--neg-soft); border-color: transparent; color: var(--neg); }
.alert-warn, .gatekeeper-summary.hold { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.table, .log-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th, .log-table th {
  text-align: left;
  font-size: 0.74rem; font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td, .log-table td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tr:last-child td, .log-table tr:last-child td { border-bottom: 0; }
.table .sub { display: block; color: var(--text-3); font-size: 0.74rem; margin-top: 2px; }
.table .empty { color: var(--text-3); text-align: center; padding: 1.5rem; }

/* ---------- Collapsible sections ---------- */
details.fold { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
details.fold + details.fold { margin-top: 0.75rem; }
details.fold > summary {
  list-style: none;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  font-weight: 700; font-size: 0.95rem;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .icon { color: var(--accent); }
details.fold > summary .muted { font-weight: 400; font-size: 0.82rem; }
details.fold > summary::after { content: '+'; margin-left: auto; color: var(--text-3); font-weight: 400; font-size: 1.2rem; }
details.fold[open] > summary::after { content: '−'; }
details.fold > .fold-body { padding: 0 1.2rem 1.2rem; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.overview { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr); gap: 1rem; }

/* Price panel */
.price-label { color: var(--text-3); font-size: 0.82rem; font-weight: 500; }
.price {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 2.5rem; font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 0.25rem;
  transition: color 0.6s;
}
.price.flash-up { color: var(--pos); transition: none; }
.price.flash-down { color: var(--neg); transition: none; }
.price-change { display: inline-flex; align-items: center; gap: 0.3rem; font-family: var(--font-num); font-weight: 700; font-size: 0.95rem; color: var(--pos); }
.price-change.down { color: var(--neg); }
.price-change-note { color: var(--text-3); font-size: 0.75rem; margin-left: 0.35rem; font-weight: 400; font-family: var(--font); }
.meta-list { margin: 1rem 0 0; display: grid; gap: 0.55rem; border-top: 1px solid var(--border); padding-top: 0.9rem; }
.meta-list > div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.84rem; }
.meta-list dt { color: var(--text-3); display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.meta-list dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Status panel — the one-sentence answer for beginners */
.status-panel { display: flex; flex-direction: column; gap: 0.9rem; border-width: 1px; }
.status-panel[data-state="pass"] { border-color: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.status-panel[data-state="blocked"] { border-color: var(--border-strong); }
.status-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.status-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
  background: var(--info-soft); color: var(--info);
}
.status-panel[data-state="pass"] .status-chip { background: var(--pos-soft); color: var(--pos); }
.status-panel[data-state="blocked"] .status-chip { background: var(--neg-soft); color: var(--neg); }
.status-panel[data-state="hold"] .status-chip { background: var(--warn-soft); color: var(--warn); }
.status-title { font-size: 1.4rem; }
.status-desc { color: var(--text-2); font-size: 0.92rem; }
.status-actions { display: flex; align-items: center; gap: 0.75rem 1rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.25rem; }
.status-actions .muted { font-size: 0.78rem; }

/* Trade plan tiles */
.plan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; }
.plan-tile { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.65rem 0.75rem; background: var(--surface-2); min-width: 0; }
.plan-tile .k { color: var(--text-3); font-size: 0.74rem; font-weight: 600; }
.plan-tile .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 1.15rem; font-weight: 800; margin-top: 0.1rem; }
.plan-tile .s { color: var(--text-3); font-size: 0.72rem; margin-top: 0.15rem; }
.plan-tile.sl .v { color: var(--neg); }
.plan-tile.tp .v { color: var(--pos); }
.plan.muted-plan { opacity: 0.6; }
.plan-note { color: var(--text-3); font-size: 0.78rem; }

/* Decision steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; counter-reset: step; }
.step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.9rem 0.85rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.step-head { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--text-3); font-weight: 600; }
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
  flex: none;
}
.step-title { font-weight: 700; font-size: 0.9rem; margin-top: 0.45rem; }
.step-result { font-size: 0.84rem; color: var(--text-2); margin-top: 0.15rem; }
.step[data-state="pass"] { border-color: var(--pos); }
.step[data-state="pass"] .step-num { background: var(--pos); color: #fff; }
.step[data-state="fail"] { border-color: var(--neg); }
.step[data-state="fail"] .step-num { background: var(--neg); color: #fff; }
.step[data-state="skip"] { opacity: 0.6; }
.step[data-state="wait"] .step-num { background: var(--info-soft); color: var(--info); }

/* AI card */
.ai-verdict { display: flex; align-items: center; gap: 0.75rem; }
.ai-action {
  font-family: var(--font-num); font-weight: 800; font-size: 1.3rem;
  padding: 0.2rem 0.8rem; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text-2);
}
.ai-action.buy { background: var(--pos-soft); color: var(--pos); }
.ai-action.sell { background: var(--neg-soft); color: var(--neg); }
.meter { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 0.35rem; position: relative; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s; }
.meter .threshold { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.55; }
.kv { display: grid; gap: 0.45rem; margin-top: 0.9rem; }
.kv > div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.85rem; }
.kv dt, .kv .k { color: var(--text-3); }
.kv dd, .kv .v { margin: 0; font-weight: 600; text-align: right; }
.note-box { border: 1px dashed var(--border-strong); border-radius: var(--radius-md); padding: 0.7rem 0.8rem; font-size: 0.84rem; color: var(--text-2); background: var(--surface-2); }
.note-box strong { color: var(--text); }

/* Checklist */
.checklist { display: flex; flex-direction: column; gap: 0.45rem; }
.check-row { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.85rem; padding: 0.5rem 0.65rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.check-row .icon { margin-top: 2px; }
.check-row.pass .icon { color: var(--pos); }
.check-row.fail { background: var(--neg-soft); }
.check-row.fail .icon { color: var(--neg); }

/* Signal watch */
.watch { display: flex; flex-direction: column; gap: 0.55rem; }
.watch-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.6rem 0.7rem; }
.watch-item.ready { border-color: var(--accent); background: var(--accent-soft); }
.watch-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.84rem; font-weight: 700; }
.watch-head .dir { font-size: 0.7rem; }
.watch-bar { height: 5px; border-radius: 999px; background: var(--surface-3); margin: 0.45rem 0; overflow: hidden; }
.watch-bar > span { display: block; height: 100%; background: var(--accent); }
.watch-cond { display: flex; gap: 0.45rem; font-size: 0.78rem; color: var(--text-2); line-height: 1.6; }
.watch-cond .icon { width: 14px; height: 14px; margin-top: 4px; }
.watch-cond.ok .icon { color: var(--pos); }
.watch-cond.no .icon { color: var(--text-3); }
.watch-cond.pending .icon { color: var(--info); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.9rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.8rem 0.95rem; box-shadow: var(--shadow); }
.stat .k { color: var(--text-3); font-size: 0.78rem; font-weight: 600; display: flex; align-items: center; gap: 0.35rem; }
.stat .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 1.45rem; font-weight: 800; margin-top: 0.15rem; }
.stat .s { color: var(--text-3); font-size: 0.76rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.7rem; }

/* Indicators */
.ind-list { display: flex; flex-direction: column; }
.ind-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.ind-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ind-row:first-child { padding-top: 0; }
.ind-name { font-weight: 600; font-size: 0.88rem; }
.ind-help { grid-column: 1; color: var(--text-3); font-size: 0.78rem; }
.ind-val { grid-row: 1; grid-column: 2; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; white-space: nowrap; }
.ind-tag { grid-column: 2; text-align: right; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.4rem; }
.levels > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.5rem 0.6rem; text-align: center; }
.levels .k { font-size: 0.72rem; color: var(--text-3); }
.levels .v { font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; }

/* News */
.news-list { display: flex; flex-direction: column; }
.news-item { display: flex; gap: 0.75rem; justify-content: space-between; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.news-item:first-child { padding-top: 0; }
.news-item:last-child { border-bottom: 0; padding-bottom: 0; }
.news-headline { font-weight: 600; font-size: 0.88rem; line-height: 1.45; }
.news-meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; color: var(--text-3); font-size: 0.75rem; margin-top: 0.3rem; }
.news-link { color: var(--text-3); flex: none; margin-top: 2px; }
.news-link:hover { color: var(--info); }
.news-item.is-new .news-headline::before { content: 'ใหม่'; font-size: 0.66rem; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; margin-right: 6px; vertical-align: 2px; }

/* Glossary */
.glossary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem 1.5rem; margin: 0; }
.glossary > div { padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.glossary dt { font-weight: 700; font-size: 0.87rem; }
.glossary dd { margin: 0.15rem 0 0; color: var(--text-2); font-size: 0.83rem; }

.loading { display: flex; align-items: center; gap: 0.75rem; color: var(--text-3); font-size: 0.87rem; padding: 1rem 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes flashUpdate { from { box-shadow: 0 0 0 3px var(--accent-soft); } to { box-shadow: var(--shadow); } }
.flash-update { animation: flashUpdate 1.4s ease-out; }

/* ==========================================================================
   "Data sent to Jev" page
   ========================================================================== */
.prompt-box {
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.65;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1rem 1.2rem; margin: 0; color: var(--text-2);
}
.src-tag { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.src-twelve { background: var(--info-soft); color: var(--info); }
.src-finnhub { background: var(--accent-soft); color: var(--accent-strong); }
.src-calc { background: var(--pos-soft); color: var(--pos); }
.src-config { background: var(--surface-3); color: var(--text-2); }
.gap-high { color: var(--neg); font-weight: 700; }
.gap-med { color: var(--warn); font-weight: 700; }
.gap-low { color: var(--text-3); font-weight: 700; }
.questions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 0.8rem; }
.question-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.9rem 1rem; }
.question-card h4 { margin: 0 0 0.3rem; font-size: 0.9rem; }
.question-card ul { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--text-2); }

/* ==========================================================================
   System flow page
   ========================================================================== */
.flow-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.flow-counts { font-size: 0.85rem; color: var(--text-2); flex: 1 1 280px; }
.flow-copy-result { margin-top: 0.75rem; font-size: 0.85rem; }
.flow-minimap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.flow-mini-stage {
  font-size: 0.8rem; text-decoration: none; color: var(--text-2);
  padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
}
.flow-mini-stage:hover { border-color: var(--accent); color: var(--accent-strong); }
.flow-mini-count { color: var(--accent-strong); font-weight: 700; margin-left: 4px; }
.flow-mini-arrow { color: var(--text-3); display: inline-flex; }
.flow-stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.2rem 1.3rem 1.3rem; margin-top: 1rem; }
.flow-stage-head .desc { margin-top: 0.2rem; }
.flow-stage-arrow { display: flex; justify-content: center; color: var(--text-3); margin-top: 1rem; }
.flow-node-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 0.9rem; margin-top: 1rem; }
.flow-node {
  display: flex; flex-direction: column; gap: 0.55rem;
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: var(--radius-md); padding: 0.85rem 1rem; scroll-margin-top: 90px;
}
.flow-node-todo { border-left-color: var(--text-3); }
.flow-node header h4 { margin: 0; font-size: 0.93rem; }
.flow-code { display: inline-block; margin-top: 3px; font-size: 0.72rem; color: var(--text-3); word-break: break-all; }
.flow-does { margin: 0; padding-left: 1.1rem; font-size: 0.82rem; color: var(--text-2); line-height: 1.55; }
.flow-params { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.flow-param { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; background: var(--info-soft); color: var(--info); }
.flow-live { font-size: 0.78rem; color: var(--pos); font-weight: 500; word-break: break-word; }
.flow-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; font-size: 0.72rem; }
.flow-links > span { color: var(--text-3); margin-right: 2px; }
.flow-chip {
  font-size: 0.72rem; text-decoration: none; color: var(--text-2);
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.flow-chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.flow-edges { margin-top: 0.9rem; }
.flow-edges > summary { cursor: pointer; font-size: 0.85rem; color: var(--text-2); padding: 0.35rem 0; display: flex; align-items: center; gap: 0.4rem; }
.flow-edge-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 0.5rem; margin-top: 0.5rem; }
.flow-edge { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; scroll-margin-top: 90px; }
.flow-edge-line { flex: 1 1 260px; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.flow-edge-arrow { color: var(--text-3); display: inline-flex; }
.flow-edge-label { font-size: 0.8rem; color: var(--text-2); }
.flow-edge > .flow-editor { display: contents; }
.flow-edge .flow-edit-body { flex-basis: 100%; margin-top: 0; }
.flow-editor { margin-top: 0.2rem; }
.flow-edit-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: none; border: 1px dashed var(--border-strong); color: var(--text-3);
  font: inherit; font-size: 0.76rem; padding: 3px 10px; border-radius: 999px; cursor: pointer;
}
.flow-edit-toggle:hover { color: var(--accent-strong); border-color: var(--accent); }
.flow-edit-toggle[data-status="ready"] { color: var(--warn); border-style: solid; border-color: var(--warn); }
.flow-edit-toggle[data-status="draft"] { color: var(--text-2); border-style: solid; }
.flow-edit-toggle[data-status="done"] { color: var(--pos); border-style: solid; border-color: var(--pos); }
.flow-edit-body { margin-top: 0.45rem; }
.flow-edit-body textarea { resize: vertical; min-height: 70px; }
.flow-edit-meta { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.35rem; flex-wrap: wrap; }
.flow-edit-meta select { width: auto; padding: 0.3rem 0.5rem; font-size: 0.8rem; }
.flow-save-state { font-size: 0.74rem; color: var(--text-3); }
.flow-save-state.error { color: var(--neg); }
.has-note.flow-node, .has-note.flow-edge { border-color: var(--warn); }
.has-note.flow-node { border-left-color: var(--warn); }
.flow-filter-noted .flow-node:not(.has-note), .flow-filter-noted .flow-edge:not(.has-note) { display: none; }
@keyframes flowHighlight { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 3px transparent; } }
.flow-highlight { animation: flowHighlight 1.8s ease-out; }

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }

/* ==========================================================================
   Responsive + motion
   ========================================================================== */
@media (max-width: 1000px) {
  .overview { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .topbar-inner, .header-inner { flex-wrap: wrap; gap: 0.6rem; padding: 0.6rem 1rem; }
  .nav, .header-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .brand-text small { display: none; }
  .page, .main-wrapper { padding: 1rem 1rem 2.5rem; }
  .grid-2, .grid-3, .steps, .stats, .glossary { grid-template-columns: 1fr; }
  .plan { grid-template-columns: 1fr 1fr; }
  .price { font-size: 2.1rem; }
  .status-title { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.flow-live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pos); margin-right: 6px; vertical-align: 1px; }
.flow-edit-toggle .icon, .flow-edges > summary .icon { width: 14px; height: 14px; }
.card-heading h2 .icon, .card-heading h3 .icon { color: var(--accent); }

/* Multi-lens context */
.lens-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.lens { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 0.8rem 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.lens-support { border-top: 3px solid var(--pos); }
.lens-against { border-top: 3px solid var(--neg); }
.lens-neutral { border-top: 3px solid var(--warn); }
.lens-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.lens-title { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700; font-size: 0.85rem; }
.lens-title .icon { color: var(--accent); }
.lens-value { font-size: 0.84rem; font-weight: 500; color: var(--text); }
.lens-extra { font-size: 0.74rem; color: var(--text-3); }
.lens-detail { font-size: 0.74rem; color: var(--text-3); line-height: 1.5; margin-top: auto; padding-top: 0.25rem; }
.lens-events { list-style: none; margin: 0.1rem 0 0; padding: 0; font-size: 0.76rem; color: var(--text-2); display: grid; gap: 0.25rem; }
.lens-events .badge { font-size: 0.64rem; padding: 0 0.4rem; }
@media (max-width: 1000px) { .lens-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .lens-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Login page + user menu
   ========================================================================== */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-theme { position: fixed; top: 1rem; right: 1rem; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { padding: 2rem 1.75rem; box-shadow: var(--shadow-lg); }
.auth-brand { margin-bottom: 1.5rem; }
.auth-title { font-size: 1.35rem; margin-bottom: 0.25rem; }
.auth-form { display: grid; gap: 0.9rem; margin-top: 1.25rem; }
.field { display: grid; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field input { font-size: 0.95rem; padding: 0.6rem 0.75rem; }
input[type="email"], input[type="password"] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input[type="email"]:focus, input[type="password"]:focus { outline: none; box-shadow: var(--focus); border-color: var(--info); }
.auth-google { margin-top: 1.25rem; }
.google-btn-slot { display: flex; justify-content: center; min-height: 44px; }
.auth-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.1rem 0 -0.25rem; color: var(--text-3); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.auth-submit { width: 100%; padding: 0.7rem 1rem; font-size: 0.95rem; margin-top: 0.25rem; }

.user-menu { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--text-2); }
.user-menu .user-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .badge { font-size: 0.66rem; }
@media (max-width: 760px) { .user-menu .user-email { display: none; } }

/* ==========================================================================
   App shell: left sidebar + main area
   ========================================================================== */
:root { --sidebar-w: 248px; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0;
  width: var(--sidebar-w); height: 100vh; flex: none;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  overflow-y: auto;
  z-index: 30;
}
.sidebar-brand { padding: 0.25rem 0.5rem 1rem; border-bottom: 1px solid var(--border); margin-bottom: 0.75rem; }
.side-nav { display: flex; flex-direction: column; gap: 1rem; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text-3); text-transform: uppercase; padding: 0 0.65rem 0.3rem; }
.side-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
}
.side-link .icon { color: var(--text-3); }
.side-link:hover { background: var(--surface-3); color: var(--text); }
.side-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.side-link.active .icon { color: var(--accent); }
.side-badge { margin-left: auto; font-size: 0.66rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.side-badge.pos { background: var(--pos-soft); color: var(--pos); }
.side-badge.neg { background: var(--neg-soft); color: var(--neg); }
.side-badge.warn { background: var(--warn-soft); color: var(--warn); }
.side-badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.side-foot { margin-top: auto; padding: 1rem 0.65rem 0; font-size: 0.72rem; color: var(--text-3); line-height: 1.5; }

.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shell .topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 2rem;
  position: sticky; top: 0; z-index: 20;
}
.page-title { min-width: 0; }
.page-title h1 { font-size: 1.2rem; }
.page-title p { color: var(--text-3); font-size: 0.8rem; margin-top: 0.1rem; }
.nav-toggle { display: none; }
.shell .page { max-width: 1180px; width: 100%; margin: 0; padding: 1.75rem 2rem 3rem; }
.view > * + * { margin-top: 1.5rem; }
.view > .section { margin-top: 2.25rem; }
.section-head-sm { margin-bottom: 0; }
.section-head-sm h2 { font-size: 1rem; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 25; }

/* Overview summary cards (clickable) */
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin-top: 0.9rem !important; }
.summary-card { display: flex; flex-direction: column; gap: 0.75rem; text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
.summary-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.summary-body { font-size: 0.87rem; display: grid; gap: 0.5rem; flex: 1; }
.summary-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.summary-link { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; color: var(--accent-strong); }
.summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.summary-list li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.82rem; }
.summary-list .k { color: var(--text-3); min-width: 0; }
.summary-list .v { font-weight: 600; flex: 1; min-width: 0; }

/* Roomier detail views */
.shell .grid-2 { gap: 1.25rem; }
.shell .overview { gap: 1.25rem; }
.watch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.shell .lens-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.shell .lens { padding: 1rem 1.1rem; }
.guide-text { font-size: 0.92rem; line-height: 1.75; color: var(--text-2); }
.shell .glossary { margin-top: 0.5rem; }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .nav-toggle { display: inline-grid; }
  .shell .topbar { padding: 0.7rem 1rem; gap: 0.6rem; }
  .shell .page { padding: 1.25rem 1rem 2.5rem; }
  .watch-grid, .shell .lens-grid { grid-template-columns: 1fr; }
  .page-title p { display: none; }
}
@media (max-width: 760px) {
  .shell .topbar-right .conn { display: none; }
}

/* Roles: admin-only controls are hidden for members (the server enforces it too) */
:root[data-role="member"] .admin-only { display: none !important; }
.user-link { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-2); text-decoration: none; border-radius: var(--radius-sm); padding: 0.2rem 0.3rem; }
.user-link:hover { color: var(--text); background: var(--surface-3); }

/* Forms (users / account) */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1.25rem; margin-top: 0.5rem; }
.form-grid .form-actions { grid-column: 1 / -1; }
.form-stack { display: grid; gap: 0.9rem; margin-top: 0.5rem; max-width: 420px; }
.field input[type="text"], .field select { font-size: 0.92rem; padding: 0.55rem 0.7rem; }
.alert-ok { background: var(--pos-soft); border-color: transparent; color: var(--pos); }
.user-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.user-actions select { width: auto; padding: 0.3rem 0.5rem; font-size: 0.8rem; }
.table .you { font-size: 0.7rem; margin-left: 0.3rem; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

/* Fx9 logo */
.brand-logo { width: 36px; height: 36px; flex: none; border-radius: 9px; display: block; }

/* Asset switch — its own row of pills under the page title; picks the asset the detail views show */
.shell .topbar { flex-wrap: wrap; row-gap: 0.7rem; }
.asset-switch { order: 5; flex-basis: 100%; display: flex; gap: 0.5rem; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.asset-switch::-webkit-scrollbar { display: none; }
.asset-tab {
  display: inline-flex; align-items: center; gap: 0.45rem; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 0.8rem; padding: 0.38rem 0.8rem; border-radius: 999px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.asset-tab:hover { color: var(--text); border-color: var(--border-strong); }
.asset-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.asset-tab.active .asset-code { color: var(--accent-strong); }
.asset-tab:focus-visible { outline: none; box-shadow: var(--focus); }
.asset-code { font-weight: 700; letter-spacing: 0.02em; }
.asset-px { font-family: 'Fira Code', monospace; font-size: 0.74rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.asset-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.asset-dot.pos { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.asset-dot.neg { background: var(--neg); }
.asset-dot.warn { background: var(--warn); }
.asset-dot.closed { background: transparent; border: 1px solid var(--border-strong); }
@media (max-width: 560px) { .asset-px { display: none; } .asset-tab { padding: 0.38rem 0.7rem; } }

/* All markets page */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.market-card { display: flex; flex-direction: column; gap: 0.8rem; text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; border-top: 3px solid var(--border); }
.market-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.market-card[data-state="pos"] { border-top-color: var(--pos); }
.market-card[data-state="neg"] { border-top-color: var(--neg); }
.market-card[data-state="warn"] { border-top-color: var(--warn); }
.mk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.mk-name { font-weight: 700; font-size: 1.02rem; }
.mk-price { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.mk-price > span:first-child { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mk-chg { font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-chg-note { font-size: 0.72rem; color: var(--text-3); }
.mk-body { font-size: 0.86rem; display: grid; gap: 0.45rem; flex: 1; }
.mk-plan { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.mk-plan > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm, 8px); padding: 0.45rem 0.55rem; display: grid; gap: 0.1rem; }
.mk-plan .k { font-size: 0.72rem; color: var(--text-3); }
.mk-plan strong { font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.mk-foot { display: flex; align-items: center; gap: 0.4rem 0.9rem; flex-wrap: wrap; font-size: 0.76rem; color: var(--text-3); border-top: 1px solid var(--border); padding-top: 0.7rem; }
.mk-foot .summary-link { margin-left: auto; }

.asset-select { width: auto; font: inherit; font-size: 0.8rem; padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }

/* Win-rate goal */
.goal-rows { display: grid; gap: 0.9rem; margin-top: 0.9rem; }
.goal-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 64px auto; align-items: center; gap: 0.35rem 1rem; }
.goal-name { display: flex; flex-direction: column; line-height: 1.3; }
.goal-track { position: relative; height: 10px; background: var(--surface-3); border-radius: 999px; }
.goal-fill { display: block; height: 100%; border-radius: 999px; background: var(--border-strong); transition: width 0.4s; }
.goal-fill.pos { background: var(--pos); }
.goal-fill.warn { background: var(--warn); }
.goal-fill.neg { background: var(--neg); }
.goal-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 2px; }
.goal-val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.goal-val.pos { color: var(--pos); } .goal-val.warn { color: var(--warn); } .goal-val.neg { color: var(--neg); }
.goal-note { grid-column: 2 / -1; }
.rule-current td { background: var(--accent-soft); }
@media (max-width: 760px) {
  .goal-row { grid-template-columns: minmax(0, 1fr) auto; }
  .goal-track { grid-column: 1 / -1; order: 3; }
  .goal-val { order: 2; }
  .goal-row .badge { order: 4; justify-self: start; }
  .goal-note { grid-column: 1 / -1; order: 5; }
}

/* US economy page */
.bias-head { display: flex; align-items: center; gap: 0.6rem; margin: 0.9rem 0 0.7rem; }
.bias-badge { font-size: 0.9rem; padding: 0.3rem 0.8rem; }
.bias-meter { position: relative; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--warn-soft), var(--surface-3) 50%, var(--info-soft)); border: 1px solid var(--border); }
.bias-dot { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow); }
.bias-scale { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-3); margin-top: 0.35rem; }
.fed-rate { font-size: 1.7rem; font-weight: 700; margin: 0.6rem 0 0.4rem; font-variant-numeric: tabular-nums; }
.fed-moves { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; margin-top: 0.8rem; font-size: 0.74rem; }
.fed-moves .up { color: var(--info); } .fed-moves .down { color: var(--warn); }
.chain { display: flex; align-items: stretch; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.9rem; }
.chain-node { flex: 1 1 130px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.7rem 0.8rem; display: grid; gap: 0.4rem; align-content: start; }
.chain-node .k { font-size: 0.8rem; font-weight: 600; }
.chain-loop { border-style: dashed; }
.chain-arrow { display: flex; align-items: center; color: var(--text-3); }
@media (max-width: 1000px) { .shell .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .chain-arrow { transform: rotate(90deg); width: 100%; justify-content: center; } .chain-node { flex-basis: 100%; } }

/* Grid bot */
.grid-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.8rem; }
.suggest-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.suggest-notes { margin: 0.7rem 0; padding-left: 1.2rem; font-size: 0.86rem; color: var(--text-2); display: grid; gap: 0.3rem; }
.suggest-config { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; font-size: 0.86rem; }
.suggest-config .k { color: var(--text-3); margin-right: 0.35rem; }
.grid-plan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ladder { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
.ladder-row { display: flex; justify-content: space-between; padding: 0.28rem 0.7rem; font-size: 0.8rem; border-bottom: 1px solid var(--border); }
.ladder-row:last-child { border-bottom: 0; }
.ladder-row.buy { color: var(--pos); background: var(--pos-soft); }
.ladder-row.sell { color: var(--neg); background: var(--neg-soft); }
.ladder-row.empty { color: var(--text-3); font-style: italic; }
.grid-bot-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.grid-bot-head .panel-title { flex-wrap: wrap; }
.grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.table-compact td, .table-compact th { padding: 0.4rem 0.55rem; font-size: 0.78rem; }
.mb-1 { margin-bottom: 0.35rem; }
@media (max-width: 1000px) { .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid-stats, .grid-plan { grid-template-columns: 1fr; } }

.grid-mode-field { grid-column: 1 / -1; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; width: max-content; max-width: 100%; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 0.45rem 1rem; font-size: 0.85rem; cursor: pointer; border-right: 1px solid var(--border); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.segmented input:focus-visible + span { box-shadow: var(--focus); }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.grid-account { grid-column: 1 / -1; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.7rem 0.9rem; display: grid; gap: 0.4rem; }
.grid-killswitch { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.warn { color: var(--warn); }

/* Trading styles + bot dashboard */
.style-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; margin-top: 0.9rem; }
.style-card { position: relative; display: block; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.85rem 1rem; cursor: pointer; background: var(--surface); }
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-card .style-body { display: grid; gap: 0.35rem; }
.style-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.style-card.disabled { cursor: default; opacity: 0.55; border-style: dashed; }
#gridForm[data-style="accumulate"] .cls-only, #gridForm[data-style="classic"] .acc-only { display: none !important; }
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.1rem; }
.bot-card { display: grid; gap: 0.75rem; text-decoration: none; color: inherit; border-top: 3px solid var(--border); transition: border-color 0.15s, box-shadow 0.15s; }
.bot-card:hover { box-shadow: var(--shadow-lg); border-color: var(--accent); }
.bot-card[data-status="running"] { border-top-color: var(--pos); }
.bot-card[data-status="error"] { border-top-color: var(--neg); }
.bot-card-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; }
.bot-badges { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }
.bot-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem 1rem; font-size: 0.86rem; }
.bot-kpis .k { display: block; font-size: 0.72rem; color: var(--text-3); }
.bot-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.tp-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.tp-track span { display: block; height: 100%; background: var(--pos); border-radius: 999px; transition: width 0.4s; }
.tp-track span.neg { background: var(--neg); }
.bot-now { font-size: 0.95rem; line-height: 1.7; margin: 0.6rem 0 0.8rem; }
.bots-total { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bot-detail-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.table tfoot td { border-top: 2px solid var(--border-strong); font-weight: 600; }
@media (max-width: 1000px) { .style-cards, .bot-detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .style-cards, .bots-total, .bot-detail-stats, .bot-kpis { grid-template-columns: 1fr; } .bot-grid { grid-template-columns: 1fr; } }

.pair-select span { display: flex; gap: 0.35rem; align-items: baseline; }
.pair-select small { color: var(--text-3); font-family: 'Fira Code', monospace; font-size: 0.72rem; }

/* Capital allocation */
.alloc-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.alloc-bar span { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.75rem; font-weight: 700; white-space: nowrap; overflow: hidden; }
.alloc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.1rem; }
.alloc-card { display: grid; gap: 0.7rem; align-content: start; }
.alloc-card.skipped { opacity: 0.6; }
.alloc-card.reserve { border-style: dashed; }
.alloc-big { display: flex; align-items: baseline; gap: 0.6rem; }
.alloc-big span:first-child { font-size: 1.8rem; font-weight: 800; }
.alloc-edit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.alloc-edit label { display: grid; gap: 0.2rem; font-size: 0.72rem; color: var(--text-3); }
.alloc-edit input { font: inherit; font-size: 0.85rem; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); width: 100%; }
.alloc-crash { font-size: 0.8rem; background: var(--neg-soft); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; line-height: 1.6; }
.alloc-apply { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
@media (max-width: 560px) {
  .segmented { flex-wrap: wrap; width: 100%; }
  .segmented label { flex: 1 1 auto; }
  .segmented span { text-align: center; }
  .alloc-grid { grid-template-columns: 1fr; }
}

/* Allocation slider */
.alloc-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.alloc-head-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.alloc-slider { position: relative; height: 54px; overflow: visible; }
.alloc-slider .alloc-seg { flex-direction: column; line-height: 1.15; transition: width 0.05s; }
.alloc-slider .alloc-seg:first-child { border-radius: 8px 0 0 8px; }
.alloc-slider .alloc-seg:nth-child(4) { border-radius: 0 8px 8px 0; color: var(--text); }
.alloc-seg small { font-weight: 500; opacity: 0.9; font-size: 0.7rem; }
.alloc-handle { position: absolute; top: -6px; bottom: -6px; width: 22px; margin-left: -11px; padding: 0; border: 0; background: transparent; cursor: ew-resize; touch-action: none; z-index: 2; }
.alloc-handle i { display: block; margin: 0 auto; width: 6px; height: 100%; border-radius: 4px; background: var(--surface); border: 2px solid var(--text); box-shadow: var(--shadow); }
.alloc-handle:hover i, .alloc-handle.dragging i { background: var(--accent-soft); border-color: var(--accent); }
.alloc-handle:focus-visible { outline: none; }
.alloc-handle:focus-visible i { box-shadow: var(--focus); }
.info-note { color: var(--info); display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }

.compound-switch { align-items: flex-start; gap: 0.55rem; font-size: 0.85rem; line-height: 1.5; }
.compound-switch input { margin-top: 0.2rem; }

.lot-hint { font-size: 0.82rem; color: var(--text-3); background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.lot-hint.ok { color: var(--text-2); border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.lot-hint.bad { color: var(--neg); border-color: var(--neg); background: var(--neg-soft); }
.field.driver span { color: var(--accent-strong); font-weight: 600; }
