/* ============================================================
   CONVERGE — Design System
   All design tokens, layout primitives, and component styles.
   Imported once via index.html.
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:            #0b0b0f;
  --bg-1:          #101015;
  --bg-2:          #15151c;
  --surface:       rgba(255,255,255,0.025);
  --surface-hi:    rgba(255,255,255,0.045);
  --surface-hover: rgba(255,255,255,0.06);
  --border:        rgba(255,255,255,0.07);
  --border-hi:     rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.18);

  --text:       #fafafa;
  --text-soft:  #c5c5cc;
  --text-muted: #8a8a95;
  --text-dim:   #55555e;

  --accent:      #7c5cff;
  --accent-glow: rgba(124,92,255,0.25);
  --accent-2:    #a78bfa;

  --green:      #00d389;
  --green-soft: rgba(0,211,137,0.12);
  --green-glow: rgba(0,211,137,0.3);
  --red:        #ff5470;
  --red-soft:   rgba(255,84,112,0.12);
  --red-glow:   rgba(255,84,112,0.3);
  --amber:      #ffb547;
  --amber-soft: rgba(255,181,71,0.12);
  --blue:       #4ea8ff;
  --blue-soft:  rgba(78,168,255,0.12);
  --pink:       #ff6eb6;
  --pink-soft:  rgba(255,110,182,0.12);

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%,  rgba(124,92,255,0.08), transparent 60%),
    radial-gradient(ellipse 80% 50% at 80% 100%, rgba(0,211,137,0.05),  transparent 60%),
    var(--bg);
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.mono { font-family: 'Geist Mono', monospace; font-variant-numeric: tabular-nums; }

/* ── Nav ─────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(11,11,15,0.72);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  max-width: 1440px; margin: 0 auto;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
  text-decoration: none; color: var(--text);
  flex-shrink: 0;
}
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, #5a3ee5 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px var(--accent-glow);
  position: relative; overflow: hidden;
}
.logo-mark::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.25), transparent 50%);
}
.logo-mark svg { position: relative; z-index: 1; }

.tabs { display: flex; gap: 2px; margin-right: auto; flex-wrap: wrap; }
.tab {
  background: none; border: none;
  color: var(--text-muted);
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s; letter-spacing: -0.01em;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.tab:hover  { color: var(--text); background: var(--surface); }
.tab.active { color: var(--text); background: var(--surface-hi); }

.ai-badge {
  font-size: 9px; font-weight: 700; padding: 1px 4px;
  background: linear-gradient(135deg, var(--accent), #9b5cf6);
  color: white; border-radius: 3px; letter-spacing: 0.04em;
}

.nav-right { display: flex; align-items: center; gap: 14px; }
.ticker {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px;
}
.ticker-label { color: var(--text-muted); font-weight: 500; }
.ticker-val   { color: var(--text); font-weight: 600; font-family: 'Geist Mono', monospace; }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.6; transform:scale(0.85); } }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #00d389);
  border: 1px solid var(--border-hi); cursor: pointer;
}

/* ── Layout ──────────────────────────────────────────────── */
#view-mount {
  max-width: 1440px; margin: 0 auto;
  padding: 28px 24px 80px;
  position: relative; z-index: 1;
}

.page-header {
  display: flex; align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px; gap: 24px;
}
.page-title {
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.035em; line-height: 1.1;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 12px;
}
.page-sub   { color: var(--text-muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted); margin-bottom: 8px;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; cursor: pointer; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep     { color: var(--text-dim); }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: all 0.15s; letter-spacing: -0.01em; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-hi); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.08) inset, 0 8px 24px -8px var(--accent-glow);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.green {
  background: var(--green); color: #00150d; border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 8px 24px -8px var(--green-glow);
}
.btn.green:hover  { filter: brightness(1.06); }
.btn.red   { background: var(--red); color: white; border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.lg    { padding: 10px 18px; font-size: 14px; font-weight: 600; }
.btn.sm    { padding: 5px 10px; font-size: 12px; }
.btn.full  { width: 100%; justify-content: center; }

/* ── Segmented control ───────────────────────────────────── */
.segmented {
  display: flex; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px; gap: 2px;
}
.seg {
  background: none; border: none;
  color: var(--text-muted); font-family: inherit;
  font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 4px;
  cursor: pointer; transition: all 0.12s;
  display: inline-flex; align-items: center; gap: 4px;
}
.seg:hover  { color: var(--text-soft); }
.seg.active { color: var(--text); background: var(--surface-hi); box-shadow: 0 0 0 1px var(--border-hi); }

/* ── Toggle group ────────────────────────────────────────── */
.toggle-group {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 16px;
}
.toggle-btn {
  background: none; border: none; padding: 9px;
  border-radius: 4px; font-family: inherit;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.toggle-btn.active.yes   { background: var(--green); color: #00150d; box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 2px 6px var(--green-glow); }
.toggle-btn.active.no    { background: var(--red);   color: white;   box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 2px 6px var(--red-glow); }
.toggle-btn.active.long  { background: var(--green); color: #00150d; box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 2px 6px var(--green-glow); }
.toggle-btn.active.short { background: var(--red);   color: white;   box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 2px 6px var(--red-glow); }
.toggle-btn.active.mkt   { background: var(--surface-hi); color: var(--text); box-shadow: 0 0 0 1px var(--border-hi); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-hi); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-soft);
}
.card-meta { font-size: 11px; color: var(--text-muted); font-family: 'Geist Mono', monospace; }
.card-body       { padding: 18px; }
.card-body.dense { padding: 0; }

/* ── KPI cards ───────────────────────────────────────────── */
.kpi {
  padding: 18px;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  position: relative; overflow: hidden;
}
.kpi-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 10px;
}
.kpi-value {
  font-size: 28px; font-weight: 600; letter-spacing: -0.035em;
  line-height: 1.1; font-variant-numeric: tabular-nums;
}
.kpi-value.sm { font-size: 22px; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; margin-top: 6px;
  font-family: 'Geist Mono', monospace;
}
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-family: 'Geist Mono', monospace; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; background: var(--surface-hi);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 11px; font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
.badge.green  { background: var(--green-soft);  color: var(--green);   border-color: transparent; }
.badge.red    { background: var(--red-soft);    color: var(--red);     border-color: transparent; }
.badge.amber  { background: var(--amber-soft);  color: var(--amber);   border-color: transparent; }
.badge.blue   { background: var(--blue-soft);   color: var(--blue);    border-color: transparent; }
.badge.accent { background: var(--accent-glow); color: var(--accent-2); border-color: transparent; }
.badge.pink   { background: var(--pink-soft);   color: var(--pink);    border-color: transparent; }
.badge-dot    { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.venue-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
}
.venue-chip.poly      { background: var(--pink-soft); color: var(--pink); }
.venue-chip.spot      { background: var(--blue-soft); color: var(--blue); }
.venue-chip.lev       { background: var(--accent-glow); color: var(--accent-2); }
.venue-chip.composite { background: linear-gradient(90deg, var(--pink-soft), var(--blue-soft)); color: var(--text); }

.status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.status-chip.live       { background: var(--green-soft); color: var(--green); }
.status-chip.paper      { background: var(--amber-soft); color: var(--amber); }
.status-chip.draft      { background: var(--surface-hi); color: var(--text-muted); }
.status-chip.backtested { background: var(--blue-soft);  color: var(--blue); }

.pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 6px currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

.conv-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; background: var(--accent-glow);
  color: var(--accent-2); border-radius: 999px;
  font-size: 11px; font-weight: 600;
}

/* ── Forms ───────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px;
}
.field-label .hint { color: var(--text-dim); font-family: 'Geist Mono', monospace; font-size: 11px; }

.input, select.input {
  width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: 'Geist Mono', monospace;
  font-size: 13px; padding: 8px 12px;
  border-radius: var(--radius-sm); outline: none; transition: all 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

select.input {
  font-family: 'Geist', sans-serif; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8a95' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 2px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; background: var(--accent);
  cursor: pointer; border-radius: 50%;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px var(--accent-glow);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; background: var(--accent);
  cursor: pointer; border-radius: 50%;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px var(--accent-glow);
}

.range-field { margin-bottom: 14px; }
.range-field:last-child { margin-bottom: 0; }
.range-field-top {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 8px;
}
.range-field-label { font-size: 13px; color: var(--text-soft); }
.range-field-val {
  font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 600;
  color: var(--accent-2); padding: 2px 7px;
  background: var(--accent-glow); border-radius: 4px;
  min-width: 50px; text-align: center;
}

.cb-list { display: flex; flex-direction: column; gap: 2px; }
.cb {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; cursor: pointer; padding: 6px 8px;
  border-radius: 5px; transition: background 0.12s; margin: 0 -8px;
}
.cb:hover { background: var(--surface); }
.cb input {
  appearance: none; width: 15px; height: 15px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface); border-radius: 4px;
  cursor: pointer; position: relative; transition: all 0.12s; flex-shrink: 0;
}
.cb input:checked { background: var(--accent); border-color: var(--accent); }
.cb input:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px; border: solid white;
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.cb-weight {
  margin-left: auto; font-family: 'Geist Mono', monospace;
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-hi); padding: 2px 6px; border-radius: 4px;
}

.switch {
  position: relative; width: 36px; height: 20px;
  background: var(--surface-hi); border: 1px solid var(--border-hi);
  border-radius: 999px; cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; left: 2px; top: 1px;
  width: 14px; height: 14px; background: var(--text-muted);
  border-radius: 50%; transition: all 0.2s;
}
.switch.on { background: var(--green); border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.switch.on::after { left: 17px; background: white; }

/* ── Summary block ───────────────────────────────────────── */
.summary {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin: 16px 0;
}
.sum-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
.sum-line .k { color: var(--text-muted); }
.sum-line .v { font-family: 'Geist Mono', monospace; font-weight: 500; font-variant-numeric: tabular-nums; }
.sum-line.big { padding-top: 10px; margin-top: 6px; border-top: 1px dashed var(--border); font-size: 13px; }
.sum-line.big .k { color: var(--text-soft); font-weight: 500; }
.sum-line.big .v { font-size: 15px; font-weight: 600; }
.v.green  { color: var(--green); }
.v.red    { color: var(--red); }
.v.accent { color: var(--accent-2); }

/* ── Tables ──────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; color: var(--text-muted); font-weight: 500;
  border-bottom: 1px solid var(--border); letter-spacing: 0.02em; white-space: nowrap;
}
.table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-family: 'Geist Mono', monospace; font-variant-numeric: tabular-nums;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface); }
.table .side-cell { font-family: 'Geist', sans-serif; }
.pos { color: var(--green); font-weight: 500; }
.neg { color: var(--red);   font-weight: 500; }
.up  { color: var(--green); }
.down{ color: var(--red); }

/* ── Chart containers ────────────────────────────────────── */
.chart-wrap   { padding: 18px; }
.chart-legend {
  display: flex; gap: 18px;
  padding: 0 18px 14px;
  font-size: 11px; color: var(--text-muted);
}
.leg-item { display: flex; align-items: center; gap: 6px; }
.leg-dot  { width: 8px; height: 2px; border-radius: 1px; }

/* ── Insight callout ─────────────────────────────────────── */
.insight {
  margin-top: 14px; padding: 12px 14px;
  background: var(--accent-glow); border: 1px solid rgba(124,92,255,0.2);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-soft); line-height: 1.5;
}
.insight strong { color: var(--accent-2); font-weight: 600; }

/* ── Sub-tabs (used inside views) ────────────────────────── */
.sub-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.sub-tab {
  background: none; border: none; color: var(--text-muted);
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 10px 14px; cursor: pointer; position: relative; transition: color 0.15s;
}
.sub-tab:hover  { color: var(--text); }
.sub-tab.active { color: var(--text); }
.sub-tab.active::after {
  content: ''; position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--accent);
}

/* ── Params panel ────────────────────────────────────────── */
.params-panel { padding: 18px; }
.param-group  { margin-bottom: 22px; }
.param-group:last-child { margin-bottom: 0; }
.param-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  font-weight: 600; margin-bottom: 12px;
}
.param-group-hint { font-size: 11px; color: var(--text-dim); text-transform: none; letter-spacing: normal; font-weight: 400; }

/* ── Deploy panel ────────────────────────────────────────── */
.deploy-panel { padding: 18px; }
.deploy-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.deploy-row:last-child { border-bottom: none; }
.deploy-row-left { display: flex; flex-direction: column; gap: 3px; }
.deploy-row-title { font-size: 13px; font-weight: 500; }
.deploy-row-desc  { font-size: 11px; color: var(--text-muted); }

/* ── Action strip (dashboard) ────────────────────────────── */
.action-strip {
  display: grid; grid-template-columns: auto 1fr auto auto;
  gap: 24px; align-items: center;
  padding: 20px 24px;
  background: linear-gradient(90deg, rgba(124,92,255,0.06), rgba(0,211,137,0.04));
  border: 1px solid var(--border-hi); border-radius: var(--radius);
  position: relative; overflow: hidden; margin-bottom: 12px;
}
.action-strip::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
}
.action-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #5a3ee5);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.action-main { display: flex; flex-direction: column; gap: 2px; }
.action-title { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.action-desc  { font-size: 13px; color: var(--text-muted); }
.action-specs { display: flex; gap: 24px; padding-right: 16px; border-right: 1px solid var(--border); }
.action-spec  { display: flex; flex-direction: column; gap: 2px; }
.action-spec-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.action-spec-val   { font-size: 14px; font-weight: 600; font-family: 'Geist Mono', monospace; }

/* ── Signal bars (dashboard) ─────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: baseline; }
.bar-top { display: flex; align-items: center; justify-content: space-between; grid-column: 1 / -1; }
.bar-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); font-weight: 500; }
.bar-val   { font-family: 'Geist Mono', monospace; font-size: 13px; font-weight: 500; color: var(--text); }
.bar-track { grid-column: 1 / -1; height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill  { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--green), #6fe7b9); box-shadow: 0 0 12px var(--green-glow); transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }
.bar-fill.med    { background: linear-gradient(90deg, var(--amber), #ffcd7a); box-shadow: 0 0 12px rgba(255,181,71,0.3); }
.bar-fill.accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px var(--accent-glow); }

.sig-icon {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--surface-hi); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-2); flex-shrink: 0;
}

/* ── News (dashboard) ────────────────────────────────────── */
.news { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.news:last-child { border-bottom: none; }
.news-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.news-src   { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.news-title { font-size: 13px; color: var(--text); line-height: 1.45; }

/* ── Polymarket ──────────────────────────────────────────── */
.mkt-item {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s;
}
.mkt-item:last-child { border-bottom: none; }
.mkt-item:hover { background: var(--surface); }
.mkt-item.selected { background: linear-gradient(90deg, var(--accent-glow), transparent); position: relative; }
.mkt-item.selected::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.mkt-head  { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mkt-window { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: var(--text-muted); padding: 2px 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.mkt-time  { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.mkt-q     { font-size: 13px; font-weight: 500; line-height: 1.4; margin-bottom: 10px; color: var(--text); }
.mkt-bar   { height: 4px; background: var(--red-soft); border-radius: 2px; overflow: hidden; position: relative; margin-bottom: 6px; }
.mkt-bar-yes { height: 100%; background: var(--green); border-radius: 2px; }
.mkt-odds-row { display: flex; justify-content: space-between; font-size: 11px; font-family: 'Geist Mono', monospace; font-weight: 500; }
.mkt-yes { color: var(--green); }
.mkt-no  { color: var(--red); }

/* ── Order book ──────────────────────────────────────────── */
.ob { font-size: 12px; font-family: 'Geist Mono', monospace; font-variant-numeric: tabular-nums; }
.ob-head { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 10px 16px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; font-family: 'Geist', sans-serif; border-bottom: 1px solid var(--border); }
.ob-row  { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 6px 16px; position: relative; font-weight: 500; }
.ob-row.ask { color: var(--red); }
.ob-row.bid { color: var(--green); }
.ob-row > span:nth-child(2), .ob-row > span:nth-child(3) { text-align: right; color: var(--text-soft); }
.ob-row.ask > span:nth-child(2), .ob-row.ask > span:nth-child(3) { color: rgba(255,84,112,0.7); }
.ob-row.bid > span:nth-child(2), .ob-row.bid > span:nth-child(3) { color: rgba(0,211,137,0.7); }
.ob-fill-bg { position: absolute; right: 0; top: 0; bottom: 0; background: var(--green-soft); }
.ob-row.ask .ob-fill-bg { background: var(--red-soft); }
.ob-row > span { position: relative; z-index: 1; }
.ob-spread { padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; font-size: 11px; color: var(--text-muted); font-family: 'Geist', sans-serif; font-weight: 500; }

/* ── Leverage display ────────────────────────────────────── */
.lev-display { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; padding: 16px; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lev-big { font-size: 36px; font-weight: 600; letter-spacing: -0.04em; color: var(--accent-2); line-height: 1; font-variant-numeric: tabular-nums; }
.lev-big span { font-size: 18px; color: var(--text-muted); font-weight: 400; margin-left: 2px; }
.lev-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.lev-marks { display: flex; justify-content: space-between; font-family: 'Geist Mono', monospace; font-size: 10px; color: var(--text-dim); margin-top: 6px; }

/* ── Strategy cards ──────────────────────────────────────── */
.strategies-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.strategy-card {
  padding: 18px;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s; position: relative; overflow: hidden;
}
.strategy-card:hover { border-color: var(--border-hi); transform: translateY(-1px); box-shadow: 0 12px 32px -12px rgba(0,0,0,0.5); }
.strategy-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.strategy-card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; margin-bottom: 4px; }
.strategy-card-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.strategy-metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 14px 0; }
.sm-item  { display: flex; flex-direction: column; gap: 2px; }
.sm-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.sm-val   { font-size: 15px; font-weight: 600; font-family: 'Geist Mono', monospace; }
.sm-val.green { color: var(--green); }
.sm-val.red   { color: var(--red); }
.strategy-sparkline { height: 40px; margin: 10px 0 14px; }
.strategy-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.strategy-footer-meta { font-size: 11px; color: var(--text-muted); font-family: 'Geist Mono', monospace; }
.strategy-card.new {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 260px; border-style: dashed; background: transparent;
  color: var(--text-muted); gap: 8px; text-align: center;
}
.strategy-card.new:hover { background: var(--surface); color: var(--text); border-color: var(--accent); }
.strategy-card.new .plus-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-hi); border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center; margin-bottom: 6px;
}

/* ── Leaderboard ─────────────────────────────────────────── */
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table th { text-align: left; padding: 12px 16px; font-size: 11px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border); letter-spacing: 0.02em; white-space: nowrap; }
.lb-table th.sortable { cursor: pointer; }
.lb-table th.sortable:hover { color: var(--text); }
.lb-table th .sort-icon { opacity: 0.4; margin-left: 4px; }
.lb-table th.active-sort { color: var(--text); }
.lb-table th.active-sort .sort-icon { opacity: 1; color: var(--accent-2); }
.lb-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-family: 'Geist Mono', monospace; font-variant-numeric: tabular-nums; }
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr { cursor: pointer; transition: background 0.1s; }
.lb-table tr:hover td { background: var(--surface); }
.rank { font-family: 'Geist', sans-serif; font-size: 16px; font-weight: 600; color: var(--text-muted); width: 32px; }
.rank.top-1 { color: #ffd666; }
.rank.top-2 { color: #c5c5cc; }
.rank.top-3 { color: #d08c5a; }
.strat-name-cell { display: flex; align-items: center; gap: 10px; font-family: 'Geist', sans-serif; }
.strat-name-cell .sn { font-weight: 600; font-size: 14px; }
.strat-name-cell .sd { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.mini-spark { width: 80px; height: 24px; vertical-align: middle; }

/* ── Strategy detail ─────────────────────────────────────── */
.detail-hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; padding: 24px;
  background: radial-gradient(ellipse at 100% 0%, var(--accent-glow), transparent 60%), linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--border-hi); border-radius: var(--radius-lg); margin-bottom: 20px;
}
.detail-hero-left h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.detail-hero-left p  { color: var(--text-soft); font-size: 14px; line-height: 1.5; max-width: 560px; margin-bottom: 16px; }
.detail-hero-tags    { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-hero-right   { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* ── AI Builder ──────────────────────────────────────────── */
.builder-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chat-pane { display: flex; flex-direction: column; height: 580px; }
.chat-history { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }
.chat-bubble { display: flex; flex-direction: column; gap: 4px; max-width: 88%; }
.chat-bubble.user { align-self: flex-end; }
.chat-bubble.ai   { align-self: flex-start; }
.bubble-text { padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.55; }
.chat-bubble.user .bubble-text { background: var(--accent); color: white; border-radius: 12px 12px 3px 12px; }
.chat-bubble.ai   .bubble-text { background: var(--surface-hi); border: 1px solid var(--border); color: var(--text-soft); border-radius: 12px 12px 12px 3px; }
.bubble-meta { font-size: 10px; color: var(--text-dim); }
.chat-bubble.user .bubble-meta { text-align: right; }
.chat-templates { padding: 10px 18px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px; }
.template-chip { font-size: 11px; padding: 4px 10px; background: var(--surface-hi); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; color: var(--text-muted); transition: all 0.12s; white-space: nowrap; }
.template-chip:hover { color: var(--text); border-color: var(--accent); background: var(--accent-glow); }
.chat-input-row { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row textarea { flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: 13px; padding: 9px 12px; border-radius: var(--radius-sm); outline: none; resize: none; height: 40px; transition: all 0.15s; }
.chat-input-row textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.preview-pane { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; height: 580px; }
.preview-pane::-webkit-scrollbar { width: 4px; }
.preview-pane::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }
.rule-block { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 8px; }
.rule-block-head { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.rule-block code { display: block; font-family: 'Geist Mono', monospace; font-size: 12px; line-height: 1.8; }
code .kw  { color: var(--accent-2); }
code .val { color: var(--green); }
code .op  { color: var(--text-dim); }
code .fn  { color: var(--amber); }
code .cmt { color: var(--text-dim); font-style: italic; }

/* ── Backtest / Optimizer ────────────────────────────────── */
.opt-tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.opt-tab { background: none; border: none; color: var(--text-muted); font-family: inherit; font-size: 13px; font-weight: 500; padding: 10px 14px; cursor: pointer; position: relative; transition: color 0.15s; }
.opt-tab:hover  { color: var(--text); }
.opt-tab.active { color: var(--text); }
.opt-tab.active::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--accent); }
.opt-content         { display: none; }
.opt-content.active  { display: block; }
.opt-mode-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 16px; }
.opt-mode-btn { padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; text-align: center; transition: all 0.15s; }
.opt-mode-btn:hover  { border-color: var(--border-hi); }
.opt-mode-btn.active { border-color: var(--accent); background: var(--accent-glow); }
.opt-mode-btn .mode-icon { font-size: 18px; margin-bottom: 6px; }
.opt-mode-btn .mode-name { font-size: 12px; font-weight: 600; color: var(--text); }
.opt-mode-btn .mode-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.progress-bar-wrap  { margin: 12px 0; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.progress-bar-track { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.progress-bar-fill  { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 3px; animation: opt-progress 2s ease-in-out infinite; }
@keyframes opt-progress { 0%,100% { opacity:1; } 50% { opacity:0.65; } }
.heatmap-wrap { padding: 16px 18px; }
.heatmap-grid { display: grid; grid-template-columns: repeat(10,1fr); gap: 3px; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; cursor: pointer; transition: transform 0.1s; position: relative; }
.hm-cell:hover { transform: scale(1.2); z-index: 1; }

/* ── AI Bot ──────────────────────────────────────────────── */
.bot-layout { display: grid; grid-template-columns: 280px 1fr 300px; gap: 12px; margin-bottom: 12px; }
.bot-status-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.bot-run-state { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.bot-run-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green-glow); animation: pulse-dot 2s ease-in-out infinite; }
.bot-run-indicator.idle { background: var(--text-dim); box-shadow: none; animation: none; }
.feed-scroll { max-height: 440px; overflow-y: auto; }
.feed-scroll::-webkit-scrollbar { width: 4px; }
.feed-scroll::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }
.feed-item { display: flex; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 12px; border-left: 2px solid transparent; }
.feed-item:last-child { border-bottom: none; }
.feed-item.entry  { border-left-color: var(--green); }
.feed-item.exit   { border-left-color: var(--red); }
.feed-item.skip   { border-left-color: var(--text-dim); }
.feed-item.signal { border-left-color: var(--accent); }
.feed-item.system { border-left-color: var(--amber); }
.feed-time    { font-family: 'Geist Mono', monospace; color: var(--text-dim); white-space: nowrap; flex-shrink: 0; font-size: 11px; }
.feed-content { flex: 1; line-height: 1.5; color: var(--text-soft); }
.feed-content b { color: var(--text); font-weight: 500; }
.feed-pnl { font-family: 'Geist Mono', monospace; font-size: 11px; white-space: nowrap; align-self: center; flex-shrink: 0; }
.reasoning-item { padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 12px; }
.reasoning-item:last-child { border-bottom: none; }
.reasoning-head { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 600; margin-bottom: 8px; }
.rb-row  { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.rb-label { font-size: 11px; color: var(--text-muted); min-width: 90px; flex-shrink: 0; }
.rb-track { flex: 1; height: 3px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.rb-fill  { height: 100%; border-radius: 2px; }
.rb-val   { font-family: 'Geist Mono', monospace; font-size: 11px; color: var(--text); min-width: 32px; text-align: right; }
.emergency-btn {
  width: 100%; padding: 11px; margin-top: 10px;
  background: var(--red-soft); border: 1.5px solid var(--red);
  color: var(--red); font-family: inherit; font-size: 13px; font-weight: 700;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s; letter-spacing: 0.02em;
}
.emergency-btn:hover { background: var(--red); color: white; box-shadow: 0 4px 20px var(--red-glow); }
.bot-start-btn {
  width: 100%; padding: 11px; margin-bottom: 8px;
  background: var(--green); border: none; color: #00150d;
  font-family: inherit; font-size: 13px; font-weight: 700;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
  box-shadow: 0 4px 16px var(--green-glow);
}
.bot-start-btn:hover { filter: brightness(1.08); }
.bot-start-btn.paused { background: var(--surface-hi); color: var(--text-muted); border: 1px solid var(--border); box-shadow: none; }

/* ── Portfolio ───────────────────────────────────────────── */
.portfolio-mid    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.portfolio-bottom { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.alloc-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.alloc-item:last-child { border-bottom: none; }
.alloc-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alloc-name { font-size: 13px; flex: 1; }
.alloc-track { flex: 2; height: 5px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.alloc-fill  { height: 100%; border-radius: 3px; }
.alloc-pct { font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--text-muted); min-width: 38px; text-align: right; }
.alloc-val { font-family: 'Geist Mono', monospace; font-size: 11px; color: var(--text-muted); min-width: 72px; text-align: right; }
.risk-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.risk-item:last-child { border-bottom: none; }
.risk-label { color: var(--text-muted); }
.risk-val   { font-family: 'Geist Mono', monospace; font-weight: 500; }
.risk-sub   { font-size: 10px; color: var(--text-dim); margin-top: 1px; }
.ai-insight-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.5; color: var(--text-soft); }
.ai-insight-item:last-child { border-bottom: none; }
.ai-icon { width: 20px; height: 20px; border-radius: 5px; background: var(--accent-glow); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 10px; margin-top: 1px; }
.ai-icon.warn { background: var(--amber-soft); }
.ai-icon.good { background: var(--green-soft); }
.exchange-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.exchange-row:last-child { border-bottom: none; }
.exchange-name   { font-weight: 500; min-width: 80px; }
.exchange-assets { flex: 1; display: flex; gap: 8px; flex-wrap: wrap; }
.exchange-asset  { font-family: 'Geist Mono', monospace; font-size: 11px; color: var(--text-muted); background: var(--surface-hi); padding: 2px 7px; border-radius: 4px; }
.exchange-val    { font-family: 'Geist Mono', monospace; font-weight: 500; color: var(--text); }

/* ── Chat widget (global floating) ──────────────────────── */
#chat-mount { position: fixed; bottom: 28px; right: 28px; z-index: 500; }

.chat-fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5a3ee5);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 1px rgba(255,255,255,0.08) inset;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.chat-fab:hover { transform: scale(1.06); box-shadow: 0 6px 32px var(--accent-glow); }
.chat-fab .fab-badge {
  position: absolute; top: -3px; right: -3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--bg);
  font-size: 9px; font-weight: 700; color: #00150d;
  display: flex; align-items: center; justify-content: center;
}

.chat-panel {
  position: absolute; bottom: 64px; right: 0;
  width: 360px;
  background: var(--bg-1); border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) inset;
  display: none; flex-direction: column;
  overflow: hidden; transform-origin: bottom right;
}
.chat-panel.open { display: flex; animation: panel-in 0.2s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes panel-in { from { opacity:0; transform: scale(0.9) translateY(8px); } to { opacity:1; transform: scale(1) translateY(0); } }

.chat-panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(124,92,255,0.08), transparent);
}
.chat-panel-avatar {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #5a3ee5);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-panel-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.chat-panel-sub   { font-size: 11px; color: var(--green); display: flex; align-items: center; gap: 5px; }
.chat-panel-close {
  margin-left: auto; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 4px;
  border-radius: 5px; transition: all 0.15s;
}
.chat-panel-close:hover { color: var(--text); background: var(--surface); }

.chat-panel-msgs {
  flex: 1; overflow-y: auto; padding: 14px; max-height: 360px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-panel-msgs::-webkit-scrollbar { width: 3px; }
.chat-panel-msgs::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.widget-bubble { display: flex; flex-direction: column; gap: 3px; max-width: 85%; }
.widget-bubble.user { align-self: flex-end; }
.widget-bubble.ai   { align-self: flex-start; }
.widget-bubble .wb-text { padding: 8px 12px; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.widget-bubble.user .wb-text { background: var(--accent); color: white; border-radius: 10px 10px 3px 10px; }
.widget-bubble.ai   .wb-text { background: var(--surface-hi); border: 1px solid var(--border); color: var(--text-soft); border-radius: 10px 10px 10px 3px; }
.widget-bubble .wb-time { font-size: 10px; color: var(--text-dim); }
.widget-bubble.user .wb-time { text-align: right; }

.chat-panel-quick { padding: 8px 14px; display: flex; flex-wrap: wrap; gap: 5px; border-top: 1px solid var(--border); }
.quick-chip { font-size: 11px; padding: 3px 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; color: var(--text-muted); transition: all 0.12s; white-space: nowrap; }
.quick-chip:hover { color: var(--text); border-color: var(--accent); }

.chat-panel-input {
  display: flex; gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--border); align-items: center;
}
.chat-panel-input input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 12px;
  padding: 8px 12px; border-radius: var(--radius-sm); outline: none; transition: all 0.15s;
}
.chat-panel-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.chat-panel-input input::placeholder { color: var(--text-dim); }

/* ── Scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* ── Utility ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr;   gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }

.flex-col { display: flex; flex-direction: column; gap: 12px; }
.mb-12 { margin-bottom: 12px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.trade-log-wrap { max-height: 380px; overflow-y: auto; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
  .builder-grid, .bot-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .portfolio-mid, .portfolio-bottom { grid-template-columns: 1fr; }
  .strategies-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 780px) {
  .strategies-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .action-strip { grid-template-columns: 1fr; gap: 14px; }
}

/* ── Theme toggle button ─────────────────────────────────── */
.theme-toggle {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.15s; flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-hi); color: var(--text); border-color: var(--border-hi); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
html.light .theme-toggle .icon-moon { display: none; }
html.light .theme-toggle .icon-sun  { display: block; }

/* ── Theme transition (applied briefly during switch) ───────  */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition:
    background-color 0.22s ease,
    border-color     0.22s ease,
    color            0.14s ease,
    box-shadow       0.22s ease !important;
}
html.theme-switching svg *,
html.theme-switching canvas,
html.theme-switching .pulse,
html.theme-switching input[type=range] {
  transition: none !important;
}

/* ── Light mode token overrides ──────────────────────────── */
html.light {
  /* Backgrounds */
  --bg:            #f2f2f7;
  --bg-1:          #e8e8ef;
  --bg-2:          #dedee7;
  --surface:       rgba(0,0,0,0.045);
  --surface-hi:    rgba(0,0,0,0.075);
  --surface-hover: rgba(0,0,0,0.095);
  --border:        rgba(0,0,0,0.09);
  --border-hi:     rgba(0,0,0,0.15);
  --border-strong: rgba(0,0,0,0.22);

  /* Text */
  --text:       #0e0e14;
  --text-soft:  #35353d;
  --text-muted: #62627a;
  --text-dim:   #94949f;

  /* Accent — slightly darker for light bg contrast */
  --accent:      #5e3af0;
  --accent-glow: rgba(94,58,240,0.12);
  --accent-2:    #4b2ee0;   /* was #a78bfa — near-invisible on light */

  /* Functional — all darkened significantly for WCAG AA on #f2f2f7 */
  --green:      #007a50;   /* was #00d389 */
  --green-soft: rgba(0,122,80,0.11);
  --green-glow: rgba(0,122,80,0.22);
  --red:        #cc1e40;   /* was #ff5470 */
  --red-soft:   rgba(204,30,64,0.10);
  --red-glow:   rgba(204,30,64,0.22);
  --amber:      #8f5a00;   /* was #ffb547 — original was near-unreadable on light */
  --amber-soft: rgba(143,90,0,0.10);
  --blue:       #1158b8;   /* was #4ea8ff */
  --blue-soft:  rgba(17,88,184,0.10);
  --pink:       #a81870;   /* was #ff6eb6 */
  --pink-soft:  rgba(168,24,112,0.10);
}

/* body gradient */
html.light body {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%,  rgba(94,58,240,0.06), transparent 60%),
    radial-gradient(ellipse 80% 50% at 80% 100%, rgba(0,122,80,0.04),  transparent 60%),
    var(--bg);
}

/* grid lines: flip to dark-on-light */
html.light body::before {
  background-image:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
}

/* nav */
html.light .nav { background: rgba(242,242,247,0.88); }

/* chat panel: shadow too heavy, bg fix */
html.light .chat-panel {
  background: var(--bg-1);
  box-shadow: 0 12px 40px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.06);
}

/* strategy card hover shadow too heavy */
html.light .strategy-card:hover {
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.15);
}

/* rank silver near-invisible on light bg */
html.light .rank.top-2 { color: #808090; }

/* ob-row semi-transparent rgba colors need boosting */
html.light .ob-row.ask > span:nth-child(2),
html.light .ob-row.ask > span:nth-child(3) { color: rgba(204,30,64,0.75); }
html.light .ob-row.bid > span:nth-child(2),
html.light .ob-row.bid > span:nth-child(3) { color: rgba(0,122,80,0.80); }

/* select arrow: use darker stroke for light bg */
html.light select.input {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2362627a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* chart theme tokens — read by charts.js */
:root {
  --chart-grid:  rgba(255,255,255,0.06);
  --chart-price: #fafafa;
}
html.light {
  --chart-grid:  rgba(0,0,0,0.07);
  --chart-price: #1a1a28;
}

/* dashboard hero score number gradient */
.score-number {
  background: linear-gradient(135deg, #fff 30%, #b8bfff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
html.light .score-number {
  background: linear-gradient(135deg, var(--text) 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
