:root {
  --bg: #0a101b;
  --panel: #111827;
  --panel-2: #172235;
  --line: rgba(148, 163, 184, .16);
  --line-2: rgba(148, 163, 184, .28);
  --text: #e8eef8;
  --muted: #9aa8c2;
  --faint: #67758e;
  --cyan: #24b7ca;
  --cyan-deep: #175f78;
  --green: #39b976;
  --green-deep: #1b7a48;
  --amber: #d5a345;
  --red: #d6697b;
  --violet: #8b80ff;
  --shadow: 0 18px 42px rgba(0, 0, 0, .28);
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  background: #0a101b;
}
.app-shell[hidden], .modal-backdrop[hidden] { display: none; }
.app-shell { min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: rgba(10, 16, 27, 0.96); /* rich dark navy */
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line-2);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}
.brand { display: flex; gap: 12px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--line-2); margin-bottom: 18px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(36, 183, 202, .14);
  border: 1px solid var(--line-2);
  font-weight: 800;
}
.brand h1 { margin: 0; font-size: 16px; }
.brand p, .side-note { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.nav-title { margin: 0 0 10px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .14em; opacity: 0.55; }
.nav { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.nav-btn {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-btn:hover {
  background: rgba(36, 183, 202, 0.06);
  border-color: rgba(36, 183, 202, 0.12);
  color: var(--text);
  transform: translateX(3px);
}
.nav-btn.active {
  background: linear-gradient(135deg, rgba(36, 183, 202, 0.15) 0%, rgba(36, 183, 202, 0.04) 100%);
  border-color: rgba(36, 183, 202, 0.3);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(36, 183, 202, 0.08);
}
.nav-btn span:last-child { color: var(--faint); font-size: 12px; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line-2);
}
.sidebar-dev-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  opacity: 0.7;
}
.main { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 30px; }
.topbar p { margin: 6px 0 0; color: var(--muted); max-width: 76ch; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.account-widget { display: flex; align-items: center; gap: 8px; }
.account-label {
  max-width: 220px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.help-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  background: rgba(255, 255, 255, .03);
}
.help-icon:hover { border-color: rgba(36, 183, 202, .45); background: rgba(36, 183, 202, .1); }
.status {
  min-width: 120px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.status.loading { color: #b9efcd; border-color: rgba(57, 185, 118, .28); }
.status.error { color: #ffd0d7; border-color: rgba(214, 105, 123, .35); }
.screen { display: none; }
.screen.active { display: block; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.g-pricing { grid-template-columns: .5fr 1.5fr; }
.dashboard-upper { margin-top: 16px; }
.dashboard-lower { margin-top: 16px; }
.card {
  background: linear-gradient(180deg, rgba(17, 24, 39, .98), rgba(14, 20, 34, .98));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.eyebrow { display: block; margin-bottom: 8px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.card h3, .card h4 { margin: 0 0 6px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.helper-copy { color: var(--muted); line-height: 1.6; margin: 8px 0 0; font-size: 14px; }
.empty-state {
  margin-top: 16px;
  padding: 26px;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .02);
}
.empty-state h3 { margin: 0 0 6px; }
.empty-state p { margin: 0; color: var(--muted); }
.metric-row { margin-top: 16px; }
.metric { padding: 16px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.metric .label { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.metric .value { font-size: 24px; font-weight: 800; overflow-wrap: anywhere; }
.metric .note { margin-top: 6px; color: var(--muted); font-size: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.field-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; display: flex; align-items: center; }

/* ── Tooltips (info icons) ── */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  cursor: help;
  color: var(--faint);
  opacity: 0.65;
  font-size: 13px;
  vertical-align: middle;
  transition: opacity .15s ease, color .15s ease;
  position: relative;
}
.info-icon:hover {
  opacity: 1;
  color: var(--cyan);
}
.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: rgba(17, 24, 39, .98);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  width: 220px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 1000;
  text-align: left;
  line-height: 1.4;
  font-family: var(--font);
}
.info-icon:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
.info-icon::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  border-width: 5px 5px 0;
  border-style: solid;
  border-color: var(--line-2) transparent transparent;
  display: block;
  width: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 1000;
}
.info-icon:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

body.light .info-icon::after {
  background: rgba(255, 255, 255, .98);
  color: var(--text);
}
body.light .info-icon::before {
  border-color: var(--line-2) transparent transparent;
}
.field input, .field select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
}
.field input:disabled { color: var(--muted); background: rgba(17, 24, 39, .68); }
.field-missing input, .field-missing select { border-color: #d6697b !important; }
.field-missing::after { content: 'missing value'; color: #d6697b; font-size: 11px; margin-top: -4px; }
.field input:focus, .field select:focus { border-color: rgba(36, 183, 202, .5); box-shadow: 0 0 0 3px rgba(36, 183, 202, .12); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn { padding: 12px 18px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-weight: 600; transition: all 0.2s; }
.btn:hover { border-color: rgba(57, 185, 118, 0.35); background: rgba(57, 185, 118, 0.05); }
.btn.small { padding: 9px 12px; font-size: 13px; }
.btn.primary { border-color: transparent; background: linear-gradient(135deg, var(--green), var(--green-deep)); color: #fff; }
.btn.primary:hover { background: linear-gradient(135deg, #2d945e, #18683e); }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}
.chart { width: 100%; height: 330px; margin-top: 14px; }
.dashboard-upper .chart { height: 560px; }
.dashboard-lower .chart { height: 420px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.tab { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.tab.active { background: rgba(57, 185, 118, .08); color: var(--text); border-color: rgba(57, 185, 118, .2); }
.model-card { padding: 14px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); cursor: pointer; margin-bottom: 10px; }
.model-card.active { background: rgba(36, 183, 202, .08); border-color: rgba(36, 183, 202, .24); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 14px; }
.risk-summary { margin-top: 16px; }
.explain-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.explain-list div { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .02); }
.explain-list strong { display: block; margin-bottom: 5px; color: var(--text); }
.explain-list span { color: var(--muted); font-size: 13px; line-height: 1.55; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; background: rgba(255, 255, 255, .02); }
.error { margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: rgba(214, 105, 123, .1); color: #ffd0d7; border: 1px solid rgba(214, 105, 123, .25); font-size: 14px; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 32px);
  background: var(--bg);
}
.modal {
  width: 100%;
  max-width: 1020px;
  height: 82vh;
  max-height: 92vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e1422;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.auth-modal-shell {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 0;
  align-items: stretch;
  padding: 0;
  border-radius: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(10px, 1.6vw, 16px);
  padding: clamp(18px, 3vw, 32px);
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 15, 28, .96), rgba(12, 20, 35, .98));
  overflow: hidden;
}
.auth-hero h2 { margin: 0; font-size: clamp(24px, 4vw, 42px); line-height: 1.04; max-width: 12ch; }
.auth-hero p { margin: 0; color: var(--muted); line-height: 1.7; max-width: 62ch; font-size: clamp(13px, 1.4vw, 15px); }
.auth-hero ul { margin: 0; padding-left: 20px; color: var(--text); line-height: 1.7; font-size: clamp(12px, 1.2vw, 14px); }
.auth-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(16px, 2.5vw, 28px);
  border-radius: 0;
  border: none;
  background: rgba(14, 20, 34, .98);
  overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.compact-tabs { margin-top: 0; }
.captcha-field { margin-top: 8px; }
.captcha-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.captcha-question {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--cyan);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  user-select: none;
}
.captcha-svg {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.captcha-svg svg {
  width: 100%;
  max-width: clamp(160px, 22vw, 220px);
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.captcha-refresh {
  padding: 10px 14px !important;
  font-size: 18px !important;
  line-height: 1;
}
.auth-switch {
  margin: clamp(10px, 1.6vw, 16px) 0 0;
  text-align: center;
  color: var(--muted);
  font-size: clamp(11px, 1.2vw, 13px);
}
.auth-switch .btn-link { font-size: clamp(11px, 1.2vw, 13px); }

/* ── Auth form spacing ── */
.auth-head { margin-bottom: clamp(14px, 2.5vw, 22px); }
.auth-head h3 { font-size: clamp(16px, 2vw, 20px); margin: 4px 0 0; }
.auth-fields { display: flex; flex-direction: column; gap: clamp(10px, 1.6vw, 16px); margin-bottom: 8px; }
.auth-fields .field { gap: 5px; }
.auth-fields .field label { font-size: clamp(11px, 1.2vw, 13px); }
.auth-actions { display: flex; flex-direction: column; gap: clamp(8px, 1.2vw, 12px); margin-top: clamp(14px, 2vw, 20px); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(8px, 1.2vw, 12px); }
.full-width { width: 100%; text-align: center; padding: clamp(10px, 1.4vw, 14px); font-size: clamp(14px, 1.4vw, 15px); }

/* ── Button loading spinner ── */
.btn.loading {
  position: relative;
  pointer-events: none;
  opacity: .8;
}
.btn.loading::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btnSpin 0.7s linear infinite;
}
@keyframes btnSpin {
  to { transform: rotate(360deg); }
}
.btn-link { background: none; border: none; color: var(--muted); font-size: 13px; padding: 6px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--cyan); }
.settings-icon { padding: 0 !important; width: 34px; height: 34px; display: grid; place-items: center; }

/* ── Scrollbar ── */
.auth-form-panel::-webkit-scrollbar,
.settings-content::-webkit-scrollbar,
.indicator-modal-body::-webkit-scrollbar,
.indicator-params-body::-webkit-scrollbar { width: 6px; }
.auth-form-panel::-webkit-scrollbar-track,
.settings-content::-webkit-scrollbar-track,
.indicator-modal-body::-webkit-scrollbar-track,
.indicator-params-body::-webkit-scrollbar-track { background: transparent; }
.auth-form-panel::-webkit-scrollbar-thumb,
.settings-content::-webkit-scrollbar-thumb,
.indicator-modal-body::-webkit-scrollbar-thumb,
.indicator-params-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

/* ── Settings panel ── */
.settings-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(3,7,18,.78);
  padding: 18px;
}
.settings-backdrop[hidden] { display: none; }
.settings-drawer {
  width: clamp(600px, 88vw, 820px);
  height: clamp(400px, 65vh, 560px);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.settings-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.settings-head h2 { margin: 0; font-size: 20px; }
.settings-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); flex: 1; overflow: hidden; }
.settings-nav {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 14px 0;
}
.settings-nav-btn {
  width: 100%; text-align: left; padding: 13px 18px;
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer;
}
.settings-nav-btn:hover, .settings-nav-btn.active { color: var(--text); background: rgba(57, 185, 118, .06); }
.settings-nav-btn.danger { color: var(--red); }
.settings-nav-btn.danger:hover, .settings-nav-btn.danger.active { background: rgba(214,105,123,.08); color: #ff909f; }
.settings-content { padding: 22px; overflow-y: auto; flex: 1; min-height: 0; }
.settings-section { display: none; flex-direction: column; gap: 16px; }
.settings-section.active { display: flex; }
.checkbox-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1.5; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; cursor: pointer; accent-color: var(--red); }
.settings-section h3 { margin: 0 0 8px; font-size: 18px; }
.settings-section textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 13px; color: var(--text); resize: vertical; outline: none;
  font: inherit;
}
.settings-section textarea:focus { border-color: rgba(36,183,202,.5); }
.danger-card {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px; border: 1px solid rgba(214,105,123,.25); border-radius: 8px;
  background: rgba(214,105,123,.06);
}
.danger-card strong { display: block; color: #ff909f; margin-bottom: 4px; }
.danger-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.danger-btn {
  background: rgba(214,105,123,.14) !important;
  border-color: rgba(214,105,123,.35) !important;
  color: #ff909f !important;
}
.danger-btn:hover { background: rgba(214,105,123,.24) !important; }

/* ── Plan card & usage in settings ── */
.plan-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.settings-usage-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,.02);
}
.settings-usage-item .label { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.settings-usage-item .value { font-size: 26px; font-weight: 800; }
.settings-usage-bar {
  height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden;
}
.settings-usage-bar-fill { height: 100%; border-radius: 2px; background: var(--cyan); }

/* ── Subscription UI ── */
.greyed-out {
  position: relative;
  pointer-events: none;
  user-select: none;
  overflow: hidden !important;
  max-height: 100vh;
}
.greyed-out * {
  pointer-events: none !important;
}
.greyed-out::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(3,7,18,.72);
  z-index: 5;
  border-radius: 8px;
}
.greyed-out .upgrade-banner {
  pointer-events: auto;
}
.upgrade-banner {
  position: fixed;
  top: 50%;
  left: calc(250px + (100vw - 250px) / 2);
  transform: translate(-50%, -50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(14,20,34,.98);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 340px;
  max-width: 480px;
}
.upgrade-banner strong { font-size: 20px; display: block; margin-bottom: 6px; color: var(--text); }
.upgrade-banner p { margin: 0; color: var(--muted); font-size: 15px; }
.upgrade-banner .btn { margin-top: 4px; }
.forecast-blocked {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  flex-direction: column;
  gap: 12px;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  padding: 14px 16px 0;
  min-width: 260px;
  overflow: hidden;
  animation: toastIn 0.5s ease forwards;
}
.toast.removing {
  animation: toastOut 0.35s ease forwards;
}
.toast-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.toast-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
}
.toast-icon.success { background: rgba(57,185,118,.18); color: #39b976; }
.toast-icon.error { background: rgba(214,105,123,.18); color: #d6697b; }
.toast-icon.info { background: rgba(36,183,202,.18); color: #24b7ca; }
.toast-message { font-size: 13px; line-height: 1.45; color: var(--text); }
.toast-bar {
  height: 3px;
  background: var(--cyan);
  border-radius: 0 0 10px 10px;
  margin: 0 -16px;
  transform-origin: left;
  animation: toastBar 3s linear forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}
@keyframes toastBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ── Light theme ── */
body.light {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --line: rgba(0,0,0,.08);
  --line-2: rgba(0,0,0,.16);
  --text: #1a1f2e;
  --muted: #5c6378;
  --faint: #8b92a8;
  background: var(--bg);
  color: var(--text);
}
body.light .card { background: var(--panel); border-color: var(--line); }
body.light .sidebar { background: var(--panel); border-color: var(--line); }
body.light .modal { background: var(--panel); }
body.light .modal-backdrop { background: var(--bg); }
body.light .settings-drawer { background: var(--panel); }
body.light .settings-nav-btn:hover, body.light .settings-nav-btn.active { background: rgba(57, 185, 118, .06); }
body.light .auth-hero { background: linear-gradient(180deg, rgba(240,242,246,.96), rgba(255,255,255,.98)); }
body.light .auth-form-panel { background: var(--panel); }
body.light .field input, body.light .field select, body.light .settings-section textarea { background: #f4f6f9; }
body.light .status { border-color: var(--line-2); }
body.light .empty-state { background: rgba(0,0,0,.02); }
body.light table th { background: rgba(0,0,0,.02); }
body.light .metric { background: rgba(0,0,0,.02); }
body.light .btn { background: #e8ecf2; border-color: var(--line-2); color: var(--text); transition: all 0.2s; }
body.light .btn:hover { border-color: var(--green); background: rgba(57, 185, 118, 0.05); }
body.light .btn.primary { background: linear-gradient(135deg, var(--green), var(--green-deep)); color: #fff; }
body.light .btn.primary:hover { background: linear-gradient(135deg, #2d945e, #18683e); }
body.light .icon-btn { background: rgba(0,0,0,.02); color: var(--text); }

body.light .settings-nav-btn.danger:hover,
body.light .settings-nav-btn.danger.active {
  color: var(--red);
}
body.light .danger-card strong {
  color: var(--red);
}
body.light option {
  background-color: var(--panel);
  color: var(--text);
}
body.light .brand-mark {
  background: rgba(36, 183, 202, .08);
  border-color: var(--line);
}

@media (max-width: 700px) {
  .settings-body { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 8px; }
  .settings-nav-btn { white-space: nowrap; padding: 10px 14px; font-size: 13px; }
}
.help-body { background: #0a101b; }
.help-page { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 52px; }
.help-hero { margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.help-hero h1 { margin: 14px 0 10px; font-size: 40px; letter-spacing: 0; }
.help-hero p { margin: 0; color: var(--muted); max-width: 78ch; line-height: 1.7; }
.back-link { color: var(--cyan); text-decoration: none; font-weight: 700; }
.help-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.help-section h2 { margin: 0 0 10px; font-size: 24px; }
.help-section h3 { margin: 0 0 8px; font-size: 16px; }
.help-section p { margin: 0 0 12px; color: var(--muted); line-height: 1.75; }
.help-section strong { color: var(--text); }

/* ════════════════════════════════════════════════════════════════════════════
   KLineChart Container & Toolbar
   ════════════════════════════════════════════════════════════════════════════ */

.kline-chart-card {
  display: flex; flex-direction: column;
  padding: 0 !important;
  min-height: 520px; height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a101b;
  position: relative;
}
body.light .kline-chart-card { background: #ffffff; }

/* ── Delayed Data Banner ── */
.chart-delay-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: rgba(213, 163, 69, 0.12);
  border-bottom: 1px solid rgba(213, 163, 69, 0.2);
  font-size: 12px;
  color: var(--amber);
  flex-shrink: 0;
}
.chart-delay-banner span { line-height: 1.4; }
.chart-delay-dismiss {
  background: none; border: none;
  color: var(--amber);
  font-size: 18px; cursor: pointer;
  padding: 0 4px; line-height: 1;
  opacity: 0.7;
}
.chart-delay-dismiss:hover { opacity: 1; }
body.light .chart-delay-banner { background: rgba(213, 163, 69, 0.08); }

/* ── Chart Toolbar ── */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  flex-wrap: wrap;
}
body.light .chart-toolbar { background: rgba(0,0,0,0.02); }

/* Drawing Tools — left side, vertical bar style */
.chart-drawing-tools {
  display: flex; gap: 3px;
}
.chart-drawing-tools .drawing-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s ease;
}
.chart-drawing-tools .drawing-btn svg {
  width: 16px; height: 16px;
  stroke-width: 2px;
  display: block;
}
.chart-drawing-tools .drawing-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.chart-drawing-tools .drawing-btn.active { background: rgba(36, 183, 202, 0.16); border-color: rgba(36, 183, 202, 0.35); color: var(--cyan); }
.drawing-clear { color: var(--red) !important; }
.drawing-clear:hover { background: rgba(235, 77, 75, 0.12) !important; }

/* Chart Type Dropdown */
.chart-type-dropdown-wrap {
  position: relative;
}
.chart-type-btn {
  font-size: 14px;
}
.chart-type-dropdown {
  position: absolute;
  top: 100%; left: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 150px;
  z-index: 100;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  padding: 4px 0;
}
.chart-type-option {
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.chart-type-option:hover { background: rgba(36,183,202,0.1); }
.chart-type-option.active { color: var(--cyan); }

/* Right actions */
.chart-actions-right {
  display: flex; gap: 3px;
  margin-left: auto;
}
.chart-action-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s ease;
}
.chart-action-btn svg {
  width: 16px; height: 16px;
  stroke-width: 2px;
  display: block;
}
.chart-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* Custom Save text button */
.chart-save-text-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid rgba(36, 183, 202, 0.35);
  background: rgba(36, 183, 202, 0.12);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
}
.chart-save-text-btn:hover {
  background: var(--cyan);
  color: #121824;
  box-shadow: 0 0 12px rgba(36, 183, 202, 0.35);
  border-color: transparent;
}

/* Custom Indicators text button */
.chart-indicators-txt-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-right: 4px;
}
.chart-indicators-txt-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2px;
  display: block;
}
.chart-indicators-txt-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: var(--line);
}

/* Bigger fullscreen toggle button */
.chart-action-btn#chart-fullscreen-toggle {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line-2);
}
.chart-action-btn#chart-fullscreen-toggle svg {
  width: 18px;
  height: 18px;
}
.chart-action-btn#chart-fullscreen-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

/* ── Indicator Popup Modal ── */
.indicator-modal-backdrop {
  position: fixed;
  inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
}
.indicator-modal {
  position: relative; /* Restricts absolute-positioned child panels (like settings) to the modal */
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(620px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 56px rgba(0,0,0,0.5);
  transition: width 0.22s ease-in-out, height 0.22s ease-in-out, max-height 0.22s ease-in-out;
}
.indicator-modal.settings-active {
  width: min(460px, 90vw) !important;
  height: 380px !important;
}
.indicator-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.indicator-modal-header h3 { margin: 0; font-size: 17px; }
.indicator-modal-close {
  background: none; border: none;
  color: var(--muted); font-size: 22px; cursor: pointer;
  padding: 0 4px; line-height: 1;
}
.indicator-modal-close:hover { color: var(--text); }

.indicator-modal-body {
  flex: 1; overflow-y: auto;
  padding: 12px 20px;
}
.indicator-modal-search {
  margin-bottom: 12px;
}
.indicator-modal-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}

/* Category tags for indicators */
.indicator-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  display: inline-block;
}
.tag-trend {
  background: rgba(36,183,202,0.08);
  border-color: rgba(36,183,202,0.25);
  color: var(--cyan);
}
.tag-momentum {
  background: rgba(162,110,237,0.08);
  border-color: rgba(162,110,237,0.25);
  color: #a26eed;
}
.tag-volatility {
  background: rgba(240,173,78,0.08);
  border-color: rgba(240,173,78,0.25);
  color: #f0ad4e;
}
.tag-volume {
  background: rgba(57,185,118,0.08);
  border-color: rgba(57,185,118,0.25);
  color: #39b976;
}

.indicator-modal-list {
  display: flex; flex-direction: column; gap: 2px;
}
.indicator-modal-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.indicator-modal-item:hover { background: rgba(36,183,202,0.06); }
.indicator-modal-item .ind-desc { color: var(--muted); font-size: 11px; }
.indicator-modal-item .ind-add {
  font-size: 18px; font-weight: 700;
  color: var(--cyan);
  width: 24px; text-align: center;
  flex-shrink: 0;
}
.indicator-modal-item .ind-gear {
  font-size: 15px; cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
}
.indicator-modal-item .ind-gear:hover { color: var(--text); }

/* Indicator params panel */
.indicator-params-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--panel);
  display: flex; flex-direction: column;
  z-index: 5;
}
.indicator-params-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.indicator-params-header h4 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.indicator-params-close {
  background: none; border: none;
  color: var(--muted); font-size: 22px; cursor: pointer;
  line-height: 1; padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s ease, transform 0.1s ease;
}
.indicator-params-close:hover {
  color: var(--text);
  transform: scale(1.15);
}
.indicator-params-body {
  flex: 1; overflow-y: auto;
  padding: 14px 20px;
}
.indicator-param-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.indicator-param-row label {
  font-size: 13px; color: var(--text);
}
.indicator-param-row input {
  width: 80px; padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px; text-align: right;
}
.indicator-params-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}
.indicator-params-apply {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: rgba(36,183,202,0.18);
  color: var(--cyan);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.indicator-params-apply:hover { background: rgba(36,183,202,0.28); }

/* Active indicators bar at bottom of modal */
.indicator-modal-active {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 20px;
  border-top: 1px solid var(--line);
}
.indicator-modal-active .indicator-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(139,128,255,0.12);
  border: 1px solid rgba(139,128,255,0.25);
  color: var(--violet);
  font-size: 11px; font-weight: 600;
}
.indicator-modal-active .pill-remove {
  cursor: pointer; font-size: 14px; line-height: 1; opacity: 0.6;
}
.indicator-modal-active .pill-remove:hover { opacity: 1; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .kline-chart-card { height: 400px; min-height: 350px; }
  .chart-toolbar { gap: 6px; padding: 6px 8px; }
  .indicator-modal { width: 96vw; }
}
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 14px; }
.help-grid article { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: rgba(255, 255, 255, .02); }
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-grid, .field-grid-3, .g4, .g3, .g-main, .g-pricing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-upper .chart { height: 460px; }
  .dashboard-lower .chart { height: 360px; }
}
@media (max-width: 700px) {
  .main { padding: 16px; }
  .nav, .field-grid, .field-grid-3, .g4, .g3, .g2, .g-pricing { grid-template-columns: 1fr; }
  .chart { height: 280px; }
  .dashboard-upper .chart { height: 420px; }
  .dashboard-lower .chart { height: 280px; }
  .auth-modal-shell { grid-template-columns: 1fr; padding: 12px; }
  .auth-hero { padding: 18px; }
  .auth-hero h2 { font-size: 30px; }
  .auth-form-panel { padding: 18px; overflow-y: visible; }
  .settings-drawer { height: auto; max-height: 95vh; }
  .upgrade-banner { left: 50%; min-width: 280px; max-width: 90vw; }
  .topbar h2 { font-size: 24px; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .account-widget { flex-wrap: wrap; }
  .help-hero h1 { font-size: 30px; }
  .help-grid, .explain-list { grid-template-columns: 1fr; }
}

/* ── Instrument search dropdown ── */
.instrument-field { position: relative; grid-column: 1 / -1; }
.instrument-search-wrap { position: relative; }
.instrument-search-wrap input#instrument-search {
  width: 100%;
  padding-right: 38px;
}
.instrument-search-wrap .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
  font-size: 15px;
}
.instrument-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  z-index: 100;
  background: rgba(14, 20, 34, .97);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 24px 54px rgba(0, 0, 0, .45);
  animation: dropIn .18s ease-out;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.instrument-dropdown::-webkit-scrollbar { width: 6px; }
.instrument-dropdown::-webkit-scrollbar-track { background: transparent; }
.instrument-dropdown::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.instrument-section-title {
  padding: 10px 14px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--faint);
  user-select: none;
}
.instrument-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .12s;
}
.instrument-result:hover,
.instrument-result.active {
  background: rgba(36, 183, 202, .1);
}
.instrument-result .ir-ticker {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  min-width: 90px;
  color: var(--text);
}
.instrument-result .ir-name {
  flex: 1;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.instrument-result .ir-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ir-badge {
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1;
}
.ir-badge.exchange {
  background: rgba(139, 128, 255, .14);
  color: #b0a8ff;
  border: 1px solid rgba(139, 128, 255, .22);
}
.ir-badge.type {
  background: rgba(36, 183, 202, .1);
  color: var(--cyan);
  border: 1px solid rgba(36, 183, 202, .2);
}
.instrument-dropdown .no-results {
  padding: 18px 14px;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}
.instrument-selected-display {
  display: flex;
  align-items: center;
  gap: 8px;
}
body.light .instrument-dropdown {
  background: rgba(245, 247, 250, .97);
}
body.light .instrument-result:hover,
body.light .instrument-result.active {
  background: rgba(36, 183, 202, .07);
}
body.light .ir-badge.exchange {
  background: rgba(139, 128, 255, .08);
}
body.light .ir-badge.type {
  background: rgba(36, 183, 202, .06);
}

/* ── Composable Strategy Builder Styles ── */
.strategy-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .strategy-layout {
    grid-template-columns: 1fr;
  }
}
.strategy-sidebar {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 500px;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 10px;
}
.strategy-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
}
.strategy-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line-2);
  cursor: pointer;
  transition: all 0.15s;
}
.strategy-item:hover,
.strategy-item.active {
  background: rgba(36, 183, 202, 0.1);
  border-color: var(--cyan);
}
.strategy-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.strategy-item-info .name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.strategy-item-info .desc {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.strategy-item-menu-container {
  position: relative;
}
.strategy-menu-trigger {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.strategy-menu-trigger:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.15);
}
.strategy-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  min-width: 110px;
  animation: dropIn 0.15s ease-out;
}
.strategy-menu-dropdown button {
  background: none;
  border: none;
  padding: 8px 14px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  transition: background 0.1s;
}
.strategy-menu-dropdown button:hover {
  background: rgba(36, 183, 202, 0.12);
  color: var(--cyan);
}
.strategy-menu-dropdown button.menu-item-delete {
  color: var(--red);
}
.strategy-menu-dropdown button.menu-item-delete:hover {
  background: rgba(214, 105, 123, 0.12);
  color: #f7a8b4;
}
body.light .strategy-menu-dropdown {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}
body.light .strategy-menu-dropdown button {
  color: #1e293b;
}
body.light .strategy-menu-dropdown button:hover {
  background: #f1f5f9;
}
.strategy-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.workspace-actions {
  display: flex;
  gap: 8px;
}
.workspace-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 2px;
}
.workspace-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s;
}
.workspace-tab:hover,
.workspace-tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}
.rules-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.rule-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line-2);
  border-radius: 8px;
}
@media (min-width: 768px) {
  .rule-row {
    grid-template-columns: 2.2fr 1fr 2.2fr auto;
    align-items: start;
  }
}
.rule-operand-select,
.rule-op-select {
  width: 100%;
}
.rule-delete-btn {
  background: none;
  border: none;
  color: #d6697b;
  cursor: pointer;
  font-size: 16px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.operand-config {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.01);
  border-left: 2px solid var(--cyan);
  border-radius: 0 4px 4px 0;
}
.operand-config-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.operand-config-row input,
.operand-config-row select {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}
.operand-config-row label {
  font-size: 11px;
  color: var(--muted);
  min-width: 60px;
}
.backtest-progress-container {
  margin: 16px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 8px;
  border: 1px solid var(--line-2);
}
.progress-bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 13.5px;
}
.progress-bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--cyan);
  border-radius: 4px;
  width: 0%;
  transition: width 0.1s ease;
}
.heatmap-container {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
  font-size: 11px;
  margin-top: 10px;
}
.heatmap-cell {
  padding: 8px 4px;
  text-align: center;
  border-radius: 3px;
  font-family: var(--mono);
}
.heatmap-cell.header {
  font-weight: bold;
  background: transparent;
  color: var(--text);
}
.heatmap-cell.positive {
  background: rgba(57, 185, 118, 0.15);
  color: #39b976;
}
.heatmap-cell.negative {
  background: rgba(214, 105, 123, 0.15);
  color: #d6697b;
}
.heatmap-cell.empty {
  background: rgba(255, 255, 255, 0.02);
  color: var(--faint);
}
.audit-log-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid var(--line-2);
}
.audit-item {
  display: flex;
  gap: 8px;
}
.audit-item.warning {
  color: #d5a345;
}
.audit-item.info {
  color: var(--cyan);
}
.audit-item.success {
  color: #39b976;
}
.audit-item.error {
  color: #d6697b;
}

body.light .strategy-item {
  background: #ffffff;
}
body.light .rule-row {
  background: #f8fafc;
  border-color: #cbd5e1;
}
body.light .rule-row select,
body.light .rule-row input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}
body.light .operand-config {
  background: rgba(36, 183, 202, 0.05);
}
body.light .heatmap-cell.empty {
  background: rgba(0, 0, 0, 0.02);
}
body.light .audit-log-container {
  background: rgba(0, 0, 0, 0.02);
}

/* ── Green Backtest Button ── */
.btn.green-btn {
  background: linear-gradient(135deg, var(--green), #2d945e);
  color: #fff;
  border-color: transparent;
}
.btn.green-btn:hover {
  background: linear-gradient(135deg, #2ea366, #247c4e);
}
body.light .btn.green-btn {
  background: linear-gradient(135deg, var(--green), #2d945e);
  color: #fff;
}
body.light .btn.green-btn:hover {
  background: linear-gradient(135deg, #2ea366, #247c4e);
}

/* ── Composable Rule Row select/input general overrides ── */
.rule-row select,
.rule-row input {
  background: var(--bg-card);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  outline: none;
  font-size: 13px;
  transition: all 0.15s ease;
}
.rule-row select:focus,
.rule-row input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(36, 183, 202, 0.15);
}
.operand-config {
  background: rgba(36, 183, 202, 0.03);
  border-left: 2px solid var(--cyan);
  border-radius: 4px;
  padding: 10px;
  margin-top: 8px;
}

/* ── Light Mode Select / Input dropdown options visibility overrides ── */
body.light select,
body.light option,
body.light input {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

/* ── Light Mode Rule Row & config row specific select/input overrides ── */
body.light .rule-row select,
body.light .rule-row input,
body.light .operand-config select,
body.light .operand-config input {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

/* ── Custom styling for option elements to ensure readability on all browsers ── */
select option {
  background-color: var(--panel-2);
  color: var(--text);
  padding: 8px;
}

body.light select option {
  background-color: #ffffff;
  color: #0f172a;
}

/* ── General hidden attribute helper overrides ── */
[hidden],
.strategy-menu-dropdown[hidden] {
  display: none !important;
}

/* ── Custom Popup Modals ── */
.custom-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: popupFadeIn .2s ease-out;
}
.custom-popup-card {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  width: 90%;
  max-width: 460px;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: popupScaleIn .2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
@keyframes popupFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popupScaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.custom-popup-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.custom-popup-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.custom-popup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.custom-popup-field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
}
.custom-popup-field input,
.custom-popup-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.custom-popup-field textarea {
  min-height: 80px;
  resize: vertical;
}
.custom-popup-field input:focus,
.custom-popup-field textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(36, 183, 202, 0.2);
  outline: none;
}
.custom-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
body.light .custom-popup-overlay {
  background: rgba(240, 244, 248, 0.85);
}
body.light .custom-popup-card {}

/* ── Interactive Indicator Legend Overlay ── */
.kline-chart-card {
  position: relative;
}
.chart-indicators-legend {
  position: absolute;
  top: 85px; /* Sits cleanly below OHLC canvas tooltip */
  left: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none; /* Let mouse clicks pass through to chart */
}
.legend-indicator-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text);
  pointer-events: auto; /* Re-enable pointer events for row items */
  background: rgba(10, 16, 27, 0.65); /* semi-transparent backdrop for readability */
  padding: 3px 8px;
  border-radius: 4px;
  width: max-content;
}
body.light .legend-indicator-row {
  background: rgba(240, 244, 248, 0.85);
}
.legend-indicator-name {
  font-weight: 700;
  color: var(--muted);
  cursor: default;
}
body.light .legend-indicator-name {
  color: #4a5568;
}
.legend-indicator-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  opacity: 0.5; /* slightly visible by default so users discover them */
  transition: opacity 0.15s ease;
}
.legend-indicator-row:hover .legend-indicator-actions {
  opacity: 1;
}
.legend-btn {
  cursor: pointer;
  font-size: 12px; /* slightly larger and clearer */
  color: rgba(255, 255, 255, 0.75); /* clear white in dark mode */
  display: inline-block;
  transition: color 0.1s ease, transform 0.1s ease;
}
body.light .legend-btn {
  color: rgba(10, 16, 27, 0.65); /* dark gray in light mode */
}
.legend-btn:hover {
  color: #ffffff; /* pure white on hover */
  transform: scale(1.15);
}
body.light .legend-btn:hover {
  color: #000000; /* pure black on hover */
}
.legend-close-btn:hover {
  color: #ef4444 !important;
}
.legend-eye-hidden {
  opacity: 0.22 !important;
  color: #a0aec0 !important;
}
.legend-indicator-values {
  margin-left: 6px;
  font-family: monospace;
  font-size: 11px;
}
.legend-val-item {
  margin-right: 6px;
}
.legend-val-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}
.legend-val-num {
  font-weight: 600;
}

/* Deletion Modal and Red Zone Styling */
@keyframes modal-fade-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
#delete-account-backdrop .settings-drawer,
#logout-confirm-backdrop .settings-drawer {
  animation: modal-fade-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Custom styled checkbox/radio row transitions */
.checkbox-row input[type="radio"] {
  width: 16px;
  height: 16px;
  margin-top: 0;
  cursor: pointer;
}
.checkbox-row span {
  transition: color 0.15s ease;
}
.checkbox-row:hover span {
  color: var(--text) !important;
}

/* Make custom label button hover look premium */
label[for="import-settings-file"]:hover {
  background: rgba(255,255,255,0.08) !important;
  border-color: var(--muted) !important;
}

/* Custom Reasons Scrollbar */
.delete-reasons-list::-webkit-scrollbar {
  width: 6px;
}
.delete-reasons-list::-webkit-scrollbar-track {
  background: transparent;
}
.delete-reasons-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.delete-reasons-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Rotating Loader Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════════════
   NEWS TERMINAL — Premium Financial News Screen
   ══════════════════════════════════════════════════════════════════════ */

.news-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

/* ── Header bar with filters ── */
.news-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px 20px;
  border-radius: 12px;
}

.news-right-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-btn:hover {
  color: var(--text);
  border-color: var(--muted);
  background: rgba(148, 163, 184, 0.06);
}

.filter-btn.active {
  background: linear-gradient(135deg, rgba(36, 183, 202, 0.18) 0%, rgba(36, 183, 202, 0.05) 100%);
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(36, 183, 202, 0.12);
}

.news-select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
}
.news-select:focus { border-color: var(--cyan); }

/* ── Stats ribbon ── */
.news-stats-ribbon {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.news-stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  transition: border-color 0.2s ease;
}
.news-stat-chip:hover { border-color: var(--line-2); }
.news-stat-value {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.news-stat-chip .stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stat-dot.dot-equities  { background: var(--cyan); }
.stat-dot.dot-crypto    { background: var(--violet); }
.stat-dot.dot-forex     { background: var(--green); }
.stat-dot.dot-commodities { background: var(--amber); }
.stat-dot.dot-total     { background: var(--text); }
.stat-dot.dot-bullish   { background: var(--green); }
.stat-dot.dot-bearish   { background: var(--red); }

/* ── Vertical list layout ── */
.news-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Individual row ── */
.news-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
}

.news-row:hover {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--line-2);
  border-left-color: inherit;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Asset-specific left border colours */
.news-row.asset-equities  { border-left-color: var(--cyan); }
.news-row.asset-crypto    { border-left-color: var(--violet); }
.news-row.asset-forex     { border-left-color: var(--green); }
.news-row.asset-commodities { border-left-color: var(--amber); }
.news-row.asset-other     { border-left-color: var(--muted); }

/* ── Metadata cluster (right column) ── */
.news-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
  padding-top: 2px;
}

/* ── Tags (shared) ── */
.news-tag {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1.4;
  white-space: nowrap;
}
.tag-equities    { background: rgba(36, 183, 202, 0.12); color: var(--cyan); }
.tag-crypto      { background: rgba(139, 128, 255, 0.12); color: var(--violet); }
.tag-forex       { background: rgba(57, 185, 118, 0.12); color: var(--green); }
.tag-commodities { background: rgba(213, 163, 69, 0.12); color: var(--amber); }
.tag-other       { background: rgba(148, 163, 184, 0.08); color: var(--muted); }
.tag-bullish     { background: rgba(57, 185, 118, 0.12); color: var(--green); border: 1px solid rgba(57, 185, 118, 0.2); }
.tag-bearish     { background: rgba(214, 105, 123, 0.12); color: var(--red); border: 1px solid rgba(214, 105, 123, 0.2); }
.tag-neutral     { background: rgba(148, 163, 184, 0.1); color: var(--muted); }

.news-region {
  font-size: 9.5px;
  color: var(--faint);
  font-weight: 600;
  background: var(--panel-2);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  width: fit-content;
}

/* ── Content block (center, flex-1) ── */
.news-row-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.news-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}
.news-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}
.news-row:hover .news-title a { color: var(--cyan); }

/* ── Description (max 3 lines) ── */
.news-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}


.news-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

/* ── Pulse dot for recent articles ── */
.news-live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 3px;
  animation: live-pulse 2s infinite ease-in-out;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(57, 185, 118, 0.5); }
  50%      { opacity: 0.6; box-shadow: 0 0 0 4px rgba(57, 185, 118, 0); }
}

/* ── Skeleton loading ── */
@keyframes skeleton-pulse {
  0%   { opacity: 0.6; }
  50%  { opacity: 0.25; }
  100% { opacity: 0.6; }
}
.news-row.skeleton-row {
  border-color: var(--line);
  border-left-color: var(--line);
  pointer-events: none;
  min-height: 72px;
}
.skeleton-bar {
  background: var(--line-2);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s infinite ease-in-out;
}

/* ── Empty / error state ── */
#news-empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
  font-size: 14px;
}
#news-empty-state p { max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* ── Responsive breakpoints ── */
@media (max-width: 900px) {
  .news-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .news-row-meta {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: 4px;
  }
  .news-header { flex-direction: column; align-items: stretch; }
  .news-right-filters {
    display: flex;
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }
  .news-stats-ribbon { flex-direction: column; }
}
@media (max-width: 600px) {
  .news-container { padding: 12px; gap: 14px; }
  .news-row { padding: 12px 14px; }
  .filter-btn { padding: 6px 10px; font-size: 11px; }
}