:root {
  --bg: #0b0b11;
  --panel: #14141d;
  --panel-2: #191923;
  --inset: #191923;
  --border: #1f1f2c;
  --border-2: #232333;
  --text: #e8e8f0;
  --ink-2: #b6b6c8;
  --muted: #8e8ea6;
  --muted-2: #6e6e86;
  --green: #3ddc97;
  --red: #ff6b81;
  --amber: #f0bd5e;
  --blue: #8b7cf6;
  --accent-soft: #a394ff;
  --r-panel: 18px;
  --r-card: 14px;
  --r-pill: 20px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
h1, h2, h3, .brand-name, .page-title, .metric, .stat-value, .tile-value,
.score-circle, .ticker-value, table th, .table-title { font-family: var(--font-display); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.brand-icon { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(150deg, var(--blue), #5b4bd6); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.brand-name { font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--muted-2); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: none;
  border: none;
  color: #9a9ab0;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #1a1a26; color: var(--text); }
.nav-item.active { background: #1c1c2b; color: var(--accent-soft); font-weight: 500; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: inherit; opacity: .85; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.conn-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.conn-dot.on { background: var(--green); box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.conn-dot.off { background: var(--red); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.ticker-bar {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: #0e0e15;
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
}
.ticker-item { display: flex; align-items: baseline; gap: 9px; }
.ticker-label { color: var(--muted-2); font-weight: 500; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.ticker-value { font-weight: 600; font-size: 14px; }
.ticker-change { font-size: 12px; font-weight: 600; }
.ticker-change.up { color: var(--green); }
.ticker-change.down { color: var(--red); }
.ticker-clock { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.page-title { font-size: 30px; font-weight: 600; letter-spacing: -.6px; margin: 0 0 22px; }

main { width: 100%; padding: 26px 28px 40px; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 14px; overflow-x: auto; }
  .brand { border-bottom: none; border-right: 1px solid var(--border); padding: 0 14px 0 0; margin: 0 14px 0 0; flex-shrink: 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { border-top: none; margin: 0 0 0 14px; padding: 0; }
  .ticker-bar { padding: 10px 14px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 20px;
  margin-bottom: 20px;
}
.panel.section-pad { padding: 20px 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }

.panel h2 { margin-top: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

textarea, input, select {
  background: var(--inset);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
textarea { width: 100%; min-height: 90px; resize: vertical; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.grid input, .grid select { width: 100%; }

.row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }

button.primary {
  background: var(--accent-soft);
  color: #1a1434;
  border: none;
  padding: 10px 18px;
  border-radius: 11px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
button.primary:hover { background: #b8abff; }
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
button.secondary:hover { border-color: #3a3358; }

.warnings { color: var(--amber); font-size: 12px; margin-top: 8px; }
.warnings div { margin-top: 2px; }

.score-header { display: flex; align-items: center; gap: 20px; }
.score-circle {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  border: 6px solid var(--border);
}
.verdict { font-size: 16px; font-weight: 600; }
.verdict-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.flags { margin-top: 14px; }
.flag { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.35); color: var(--red);
  padding: 8px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid #191922; }
th { color: var(--muted-2); font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--border); }
tbody tr:hover td { background: var(--inset); }

.bar-bg { background: var(--inset); border-radius: 6px; height: 8px; width: 100%; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.positive, .badge.target_hit { background: rgba(61,220,151,0.15); color: var(--green); }
.badge.negative, .badge.sl_hit { background: rgba(255,107,129,0.15); color: var(--red); }
.badge.neutral, .badge.pending { background: rgba(240,189,94,0.15); color: var(--amber); }
.badge.partial { background: rgba(139,124,246,0.15); color: var(--blue); }

.tag { font-size: 11.5px; padding: 5px 11px; border-radius: var(--r-pill); display: inline-block; }
.tag-strong { background: #15352a; color: #5fe0a8; }
.tag-moderate { background: #332a12; color: var(--amber); }
.tag-weak { background: #331a20; color: #ff8b9d; }
.text-up { color: var(--green); }
.text-down { color: var(--red); }
.text-warn { color: var(--amber); }

.headline { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.headline a { color: var(--text); text-decoration: none; }
.headline a:hover { text-decoration: underline; }
.headline .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }

.hidden { display: none !important; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } .grid { grid-template-columns: repeat(2, 1fr); } }

select.outcome-select { font-size: 12px; padding: 4px 6px; }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; font-size: 13px; }
.kv div span { color: var(--muted); display: block; font-size: 11px; }

.disclaimer { color: var(--muted); font-size: 11px; margin-top: 24px; line-height: 1.5; }

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-card {
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 24px;
}
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.auth-card input { width: 100%; margin-top: 2px; }
.auth-switch { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.auth-switch a { color: var(--blue); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding: 0 6px; }
.user-email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
}
.modal {
  position: fixed;
  top: 5vh; left: 50%; transform: translateX(-50%);
  width: min(760px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 20px;
  z-index: 101;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.raw-text-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  margin: 0 0 16px;
}

.trade-setup {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 16px;
}
.trade-setup .ts-item { text-align: center; }
.trade-setup .ts-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.trade-setup .ts-value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.trade-setup .ts-value.buy { color: var(--green); }
.trade-setup .ts-value.sl { color: var(--red); }
.trade-setup .ts-value.target { color: var(--blue); }
.history-row-clickable { cursor: pointer; }
.history-row-clickable:hover { background: var(--panel-2); }

.screener-check { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.screener-check:last-child { border-bottom: none; }
.screener-check .check-icon { width: 16px; text-align: center; flex-shrink: 0; }
.screener-check.pass .check-icon { color: var(--green); }
.screener-check.fail .check-icon { color: var(--red); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.summary-tile { background: var(--inset); border: 1px solid #23232f; border-radius: var(--r-card); padding: 15px 16px; }
.summary-tile .tile-value { font-size: 23px; font-weight: 600; letter-spacing: -.5px; }
.summary-tile .tile-label { font-size: 10.5px; color: var(--muted-2); margin-top: 5px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---- dashboard index cards + promo ------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; align-items: stretch; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-panel);
  padding: 18px 18px 0; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.card-id { display: flex; gap: 11px; align-items: center; }
.glyph { width: 34px; height: 34px; border-radius: 11px; background: #1c1c2b; display: flex; align-items: center;
  justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 13px; }
.label { font-size: 10.5px; color: var(--muted-2); letter-spacing: .08em; text-transform: uppercase; }
.card-name { font-size: 13.5px; font-weight: 500; }
.go { width: 26px; height: 26px; border-radius: 50%; border: 1px solid #2a2a3c; display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: var(--muted); }
.metric { font-size: 32px; font-weight: 600; letter-spacing: -1px; }
.metric small { font-size: 19px; color: var(--muted); font-weight: 600; }
.delta { font-size: 12px; margin-top: 4px; }
.spark { width: 100%; height: 74px; margin-top: auto; display: block; }

.promo { border-radius: var(--r-panel); padding: 22px; display: flex; flex-direction: column; gap: 14px;
  background: radial-gradient(120% 90% at 85% 5%, #6b4bd8 0%, #3a2a86 42%, #1b1636 100%); border: 1px solid #3a3070; }
.promo h3 { margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 1.25; font-weight: 600; color: #fff; letter-spacing: -.4px; }
.promo p { margin: 0; font-size: 12.5px; line-height: 1.5; color: #cfc6f5; }
.promo-tag { font-size: 10.5px; background: #ffffff1f; color: #e4dcff; padding: 4px 10px; border-radius: var(--r-pill); }
.btn { text-align: center; padding: 11px; border-radius: 12px; font-size: 13px; cursor: pointer; border: 0; font-family: inherit; }
.btn-primary { background: var(--accent-soft); color: #1a1434; font-weight: 600; }
.btn-primary:hover { background: #b8abff; }
.btn-ghost { background: #ffffff12; border: 1px solid #ffffff2e; color: #e9e3ff; }
.btn-ghost:hover { background: #ffffff1f; }

.scanner-filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tab {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; cursor: pointer;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--panel-2); color: var(--blue); border-color: var(--blue); }

.dir-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.dir-badge.ce { background: rgba(52,211,153,0.15); color: var(--green); }
.dir-badge.pe { background: rgba(248,113,113,0.15); color: var(--red); }
.dir-badge.near { background: rgba(251,191,36,0.15); color: var(--amber); }
.dir-badge.unavailable { background: var(--panel-2); color: var(--muted); }

.condition-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.condition-row:last-child { border-bottom: none; }
.condition-row .cond-label { display: flex; align-items: center; gap: 6px; }
.condition-row .cond-values { color: var(--muted); text-align: right; }
.condition-row.fail .cond-label { color: var(--red); }
.condition-row.pass .cond-label { color: var(--green); }
.provisional-tag { font-size: 10px; color: var(--amber); border: 1px solid var(--amber); border-radius: 4px; padding: 0 4px; }

.channels-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.channels-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.close-link { color: var(--muted); font-size: 12px; text-decoration: none; }
.close-link:hover { color: var(--text); text-decoration: underline; }

.browse-panel {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.browse-panel input#browse-search { width: 100%; margin-top: 10px; }
.browse-scroll { max-height: 340px; overflow-y: auto; }

.channel-list { margin-top: 14px; }
.channel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.channel-row:last-child { border-bottom: none; }
.channel-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.channel-dot.on { background: var(--green); box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.channel-info { flex: 1; min-width: 0; }
.channel-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-id { color: var(--muted); font-size: 11px; margin-top: 2px; }
.channel-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.pill-toggle {
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
}
.pill-toggle.on { background: rgba(52,211,153,0.15); color: var(--green); }
.pill-toggle.off { background: var(--panel-2); color: var(--muted); }

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 4px;
  line-height: 1;
}
.icon-btn:hover { color: var(--red); }

.add-btn {
  background: rgba(52,211,153,0.15);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.35);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.add-btn:hover { background: rgba(52,211,153,0.25); }

.channel-empty { color: var(--muted); font-size: 13px; padding: 16px 4px; }
