:root {
  --bg: #070809;
  --card: #121417;
  --card2: #181b20;
  --line: #262b33;
  --text: #f2f4f7;
  --muted: #8b949e;
  --link: #7eb6ff;
  --up: #22c55e;
  --down: #ef4444;
  --accent: #22c55e;
  --chip: #1c2128;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; max-width: 100%; }
body {
  font: 14px/1.45 "IBM Plex Sans", system-ui, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: rgba(7,8,9,.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  text-decoration: none;
}
.wordmark:hover { text-decoration: none; color: var(--text); }
.gmark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #22c55e, #1d4e89 55%, #c45c26);
}
.search { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.search-ico { position: absolute; left: 14px; pointer-events: none; }
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 11px 16px 11px 42px;
  color: var(--text);
  font: 14px "IBM Plex Sans", sans-serif;
}
.search input:focus { outline: 2px solid #22c55e55; border-color: #22c55e88; }
.suggest {
  position: absolute; top: 110%; left: 0; right: 0;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 14px; overflow: auto; max-height: 340px;
  box-shadow: var(--shadow); z-index: 30;
}
.suggest a { display: block; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--line); }
.suggest a:hover { background: var(--chip); text-decoration: none; }
.live-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(22, 48, 31, 0.7);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
  border-radius: 999px;
  padding: 5px 11px;
  font: 600 12px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  flex-shrink: 0;
  margin-left: auto;
}
.live-btn:hover {
  background: rgba(22, 48, 31, 0.95);
  border-color: rgba(34, 197, 94, 0.7);
}
.live-btn.paused {
  background: rgba(30, 35, 42, 0.7);
  border-color: var(--line);
  color: var(--muted);
}
.live-btn.paused:hover {
  background: rgba(40, 47, 56, 0.9);
  color: var(--text);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulseLive 2s infinite;
  display: inline-block;
  flex-shrink: 0;
}
.pulse-dot.paused {
  background: #8b949e;
  box-shadow: none;
  animation: none;
}
.pulse-dot.updating {
  background: #38bdf8;
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
  animation: pulseLive 0.8s infinite;
}
@keyframes pulseLive {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@keyframes flashGreen {
  0% { background-color: rgba(34, 197, 94, 0.28); }
  100% { background-color: transparent; }
}
@keyframes flashRed {
  0% { background-color: rgba(239, 68, 68, 0.28); }
  100% { background-color: transparent; }
}
.flash-up {
  animation: flashGreen 1.2s ease-out !important;
}
.flash-down {
  animation: flashRed 1.2s ease-out !important;
}
.topnav { display: flex; gap: 16px; align-items: center; }
.topnav a { color: var(--muted); font-weight: 500; }
.topnav a:hover { color: var(--text); text-decoration: none; }
.shell { display: flex; min-height: calc(100vh - 58px); width: 100%; max-width: 100%; min-width: 0; overflow-x: hidden; }
.sidebar {
  width: 220px; flex-shrink: 0; padding: 18px 12px 32px;
  border-right: 1px solid var(--line); background: #0b0d10;
}
.sidebar h3 {
  margin: 18px 10px 8px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.sidebar h3:first-child { margin-top: 2px; }
.sidebar .item, .sidebar .mini {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 10px; border-radius: 10px; color: var(--text);
}
.sidebar .item:hover, .sidebar .mini:hover { background: var(--chip); text-decoration: none; }
.sidebar .item.active { background: #16301f; color: #86efac; font-weight: 600; }
.chg.up, .up { color: var(--up); }
.chg.down, .down { color: var(--down); }
.main { flex: 1; padding: 22px 26px 56px; min-width: 0; max-width: 100%; overflow-x: hidden; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .9fr); gap: 16px; align-items: start; }
.grid-2 > * { min-width: 0; max-width: 100%; }
.card, .chart-box { min-width: 0; max-width: 100%; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
h1 { font-size: 28px; margin: 0 0 4px; font-weight: 700; letter-spacing: -.03em; }
.hero-num { font-size: 36px; font-weight: 700; letter-spacing: -.04em; line-height: 1.1; }
.meta { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.pill-row, .ranges, .inline, .form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill, .ranges button {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 10px; cursor: pointer;
  font: 13px/1 "IBM Plex Sans", sans-serif;
}
.pill.active, .ranges button.active {
  background: #16301f; color: #86efac; border-color: #225c38; font-weight: 600;
}
.btn {
  background: var(--accent); color: #04120a; border: 0; border-radius: 999px;
  padding: 8px 14px; font: 600 13px/1 "IBM Plex Sans", sans-serif; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.btn.outline {
  background: transparent; color: var(--accent); border: 1px solid #22c55e88;
}
.btn.sm { padding: 6px 11px; font-size: 12px; }
.indices { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.idx {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; min-width: 140px; color: var(--text);
}
.idx:hover { text-decoration: none; border-color: #3a424e; }
.idx .n { font-size: 12px; color: var(--muted); }
.idx .p { font-size: 18px; font-weight: 700; margin: 3px 0; }
.quote-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.quote-head .px { font-size: 34px; font-weight: 700; letter-spacing: -.03em; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600;
}
.badge.up { background: #14301f; color: #86efac; }
.badge.down { background: #3a1515; color: #fca5a5; }
.stats {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 16px;
}
.stats div {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.stats span { color: var(--muted); }
.chart-box { position: relative; user-select: none; }
canvas.chart { width: 100%; height: 280px; display: block; cursor: crosshair; touch-action: none; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 110px; max-width: 180px;
  padding: 8px 10px; border-radius: 10px;
  background: #12161d; border: 1px solid #2a313c;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  font-size: 12px; line-height: 1.35; color: var(--text);
}
.chart-tip .t { color: var(--muted); margin-bottom: 2px; }
.chart-tip .p { font-weight: 700; font-size: 13px; }
.chart-tip .d { margin-top: 4px; font-weight: 600; }
.chart-tip .d.up, .chart-delta.up strong { color: #22c55e; }
.chart-tip .d.down, .chart-delta.down strong { color: #ef4444; }
.chart-delta {
  position: absolute; top: 44px; left: 14px; z-index: 4; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(18, 22, 29, 0.92); border: 1px solid #2a313c;
  font-size: 12px; color: var(--muted);
}
.chart-delta strong { color: var(--text); font-size: 13px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 11px 10px; text-align: right; border-bottom: 1px solid var(--line);
}
table.data th { color: var(--muted); font-weight: 500; background: transparent; }
table.data td.left, table.data th.left { text-align: left; }
table.data tr:hover td { background: #161a20; }
table.data tr.totals td { font-weight: 700; background: #151a16; border-bottom: 0; }
.row-title { display: flex; align-items: center; gap: 10px; }
.av {
  width: 28px; height: 28px; border-radius: 50%;
  background: #243044; color: #dbeafe; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.news a { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.news .src { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: 14px "IBM Plex Sans", sans-serif; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; background: var(--card2); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #22c55e44; border-color: #22c55e77; }
.muted { color: var(--muted); }
.flash { color: #fca5a5; }
.desc { max-width: 760px; color: #d0d5dd; }
.note {
  background: #141a14; border: 1px solid #23402c; border-left: 3px solid var(--accent);
  padding: 10px 12px; border-radius: 10px; margin: 0 0 14px; color: #c6d4cc; font-size: 13px;
}
.seg {
  display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 12px; flex-wrap: wrap;
}
.seg button {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 8px 12px; cursor: pointer;
  font: 500 13px "IBM Plex Sans", sans-serif;
}
.seg button.active {
  background: #16301f; color: #86efac; border-color: #22c55e66;
}
.lock {
  display: inline-flex; align-items: center; gap: 6px;
  background: #1a2230; color: #9ec5ff; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; font-weight: 600;
}
.donut-wrap { display: flex; gap: 14px; align-items: center; }
.donut { width: 120px; height: 120px; border-radius: 50%; position: relative; }
.donut-center {
  position: absolute; inset: 28px; background: var(--card); border-radius: 50%;
  display: grid; place-items: center; text-align: center; font-size: 11px; color: var(--muted);
}
.legend { font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.legend b { color: var(--text); font-weight: 600; }
.cash-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.modal-root {
  position: fixed; inset: 0; background: rgba(0,0,0,.62);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal-root[hidden] { display: none !important; }
.modal {
  width: min(560px, 100%); background: #12151a; border: 1px solid var(--line);
  border-radius: 18px; padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.modal h2 { margin: 0; font-size: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.bottomnav { display: none; }
.table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  display: block;
}
.table-scroll table.data {
  width: max-content;
  min-width: 100%;
}
#q-clock, .meta {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 1200px) {
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 48px; }
  .topnav { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .search { max-width: 360px; min-width: 0; }
  .auth-user { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .shell { display: block; width: 100%; max-width: 100%; overflow-x: hidden; }
  .sidebar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: stretch;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar h3 { display: none; }
  .sidebar .item, .sidebar .mini {
    flex: 0 0 auto; white-space: nowrap; background: var(--chip);
    border: 1px solid var(--line); padding: 8px 12px;
  }
  .modal-grid { grid-template-columns: 1fr; }
  .main { max-width: 100%; min-width: 0; overflow-x: hidden; }
  .card, .chart-box, .grid-2 { max-width: 100%; min-width: 0; }
}

@media (max-width: 720px) {
  html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .top {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .wordmark { font-size: 16px; }
  .live-btn { order: 2; margin-left: auto; }
  .search { order: 3; flex: 1 1 100%; max-width: none; min-width: 0; }
  .topnav { display: none; }
  .bottomnav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
    background: rgba(7,8,9,.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
    padding: 6px 4px max(6px, env(safe-area-inset-bottom));
  }
  .bottomnav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 44px; padding: 6px 4px;
    color: var(--muted); font-size: 11px; font-weight: 600;
    text-decoration: none; border-radius: 10px;
  }
  .bottomnav a:hover, .bottomnav a:active { text-decoration: none; color: var(--text); }
  .bottomnav a.active { color: #86efac; background: #16301f55; }

  .shell {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
    min-height: calc(100dvh - 58px);
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }
  .sidebar {
    width: 100vw;
    max-width: 100vw;
  }
  .main {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 14px 12px calc(24px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }
  .grid-2, .card, .chart-box, .quote-head {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  h1 { font-size: 22px; }
  .hero-num { font-size: 28px; }
  .quote-head .px { font-size: 28px; }
  .card { padding: 14px; border-radius: 14px; margin-bottom: 12px; }
  canvas.chart { width: 100% !important; max-width: 100%; height: 220px; }

  .indices {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 4px;
  }
  .idx { min-width: 132px; flex: 0 0 auto; }

  .toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .ranges {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .ranges::-webkit-scrollbar { display: none; }
  .ranges button { flex: 0 0 auto; min-height: 40px; padding: 8px 12px; }
  .pill, .btn, .seg button { min-height: 40px; padding: 8px 12px; }

  .quote-head { gap: 10px; }
  .quote-head .inline { width: 100%; min-width: 0; }
  .quote-head .inline .btn, .quote-head select { flex: 1 1 auto; min-width: 0; }

  .grid-2 > * { min-width: 0 !important; max-width: 100%; }
  .card, .chart-box {
    min-width: 0 !important;
    max-width: 100%;
  }
  .toolbar, .ranges, .table-scroll, .indices {
    min-width: 0 !important;
  }
  .table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  table.data {
    display: table;
    width: max-content;
    max-width: none;
    min-width: 100%;
  }

  .stats { grid-template-columns: 1fr; gap: 0; }
  .modal-root {
    align-items: end; padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal {
    width: 100%; border-radius: 18px 18px 0 0;
    max-height: min(92dvh, 100%); overflow: auto;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  }
  .chart-delta { max-width: calc(100% - 24px); font-size: 11px; }
  .chart-tip { max-width: min(180px, 70vw); }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
  input, select, textarea, .search input { font-size: 16px; }
}

@media (max-width: 400px) {
  .hero-num { font-size: 24px; }
  .quote-head .px { font-size: 24px; }
  canvas.chart { height: 200px; }
}

/* Auth / login */
.auth-body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(1200px 600px at 50% -10%, #122018 0%, var(--bg) 55%);
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}
.auth-wordmark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--chip);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  font: 600 13px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
}
.auth-tab.active {
  background: #16301f;
  color: #86efac;
}
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 8px;
}
.auth-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card2);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font: 14px "IBM Plex Sans", sans-serif;
}
.auth-input:focus { outline: 2px solid #22c55e55; border-color: #22c55e88; }
.auth-error {
  margin: 10px 0 0;
  color: #fca5a5;
  background: #3a1515;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.auth-submit {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  font-size: 14px;
  min-height: 44px;
}
.auth-submit:disabled { opacity: .6; cursor: wait; }
.auth-user {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-right: 8px;
  align-self: center;
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: 500 12px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
  margin-left: 4px;
}
.logout-btn:hover { color: var(--text); border-color: #3a424e; }
@media (max-width: 860px) {
  .logout-btn { margin-left: auto; }
  .auth-card { padding: 22px 16px 18px; }
}

/* AI Overview Styles */
.ai-hero {
  background: linear-gradient(135deg, rgba(20, 48, 31, 0.45), rgba(18, 22, 29, 0.85) 60%, rgba(29, 78, 137, 0.25));
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 18px;
  padding: 22px 24px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.ai-hero::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.2), transparent 70%);
  pointer-events: none;
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.ai-badge.purple {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
}
.ai-badge.blue {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}
.ai-badge.orange {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}
.ai-badge.red {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.ai-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0 6px;
}
.ai-stat-box {
  background: rgba(18, 22, 29, 0.65);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.ai-stat-box .lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 4px;
}
.ai-stat-box .val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  transition: all 0.2s ease;
}
.timeline-item:hover {
  border-color: #3a424e;
  background: #15181e;
}
.timeline-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  background: #181d24;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
  flex-shrink: 0;
}
.timeline-date .m { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.timeline-date .d { font-size: 18px; font-weight: 700; color: var(--text); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.timeline-title { font-weight: 600; font-size: 14px; color: var(--text); }
.timeline-desc { font-size: 13px; color: #c0c6d0; line-height: 1.45; }
.ai-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.ai-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease;
}
.ai-card:hover {
  border-color: #384252;
}
.ai-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.ai-card-perf {
  text-align: right;
  flex-shrink: 0;
}
.ai-card-perf .pnl {
  font-weight: 700;
  font-size: 14px;
}
.ai-card-perf .sub {
  font-size: 11px;
  color: var(--muted);
}
.ai-card-text {
  font-size: 13px;
  color: #c5cbd5;
  line-height: 1.45;
}
.ai-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px;
}
.ai-takeaways {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.ai-takeaway-item {
  display: flex;
  gap: 12px;
  background: #11151a;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 14px 16px;
}
.ai-takeaway-item.warning {
  border-left-color: #f59e0b;
}
.ai-takeaway-item.info {
  border-left-color: #3b82f6;
}
.ai-takeaway-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Ask AI Copilot & Interactive Artifacts */
.ai-chat-card {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 160px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  position: relative;
}
.ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 22, 29, 0.75);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  gap: 10px;
}
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100dvh - 300px);
  min-height: 280px;
}
.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: fadeIn 0.2s ease-out;
}
.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.ai-msg.assistant {
  align-self: flex-start;
  max-width: 96%;
}
.ai-msg-bubble {
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}
.ai-msg.user .ai-msg-bubble {
  background: #16301f;
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #f0fdf4;
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-msg-bubble {
  background: #13171f;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  width: 100%;
}
.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  background: #1e2430;
  border: 1px solid var(--line);
}
.ai-msg.user .ai-msg-avatar {
  background: #153822;
  border-color: #22c55e44;
}
.ai-chat-artifact {
  margin: 14px 0 6px;
  background: #0b0e14;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 14px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.ai-chat-artifact::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #a855f7);
}
.ai-artifact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ai-artifact-title {
  font-weight: 600;
  font-size: 13px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-artifact-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.ai-chart-canvas-wrap {
  width: 100%;
  height: 260px;
  position: relative;
}
.ai-chat-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(18, 22, 29, 0.4);
}
.ai-chat-chip {
  background: #181d24;
  border: 1px solid var(--line);
  color: #94a3b8;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.ai-chat-chip:hover {
  background: #202732;
  color: var(--text);
  border-color: #475569;
}
.ai-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  background: #11151a;
  border-top: 1px solid var(--line);
  align-items: center;
}
.ai-chat-input {
  flex: 1;
  background: #181d24;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text);
  font: 14px "IBM Plex Sans", sans-serif;
  outline: none;
}
.ai-chat-input:focus {
  border-color: rgba(34, 197, 94, 0.5);
}
.ai-chat-send {
  background: var(--accent);
  color: #04120a;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ai-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}
.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #86efac;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

.ai-regenerate-btn {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.ai-regenerate-btn:hover {
  background: rgba(34, 197, 94, 0.25);
  border-color: #22c55e;
}
.ai-regenerate-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.ai-spin {
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Live AI Intelligence Desk styles
   ========================================================================== */
.live-hero {
  background: radial-gradient(1200px 500px at 50% -10%, rgba(245, 158, 11, 0.16) 0%, rgba(17, 21, 28, 0.95) 75%);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 18px;
  padding: 22px 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}
.live-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24, #22c55e, #38bdf8);
}
.live-radar-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  display: inline-block;
  position: relative;
  box-shadow: 0 0 10px #f59e0b;
}
.live-radar-dot::after {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 1.5px solid #f59e0b;
  animation: radarPulse 2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
@keyframes radarPulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.live-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.live-ribbon-item {
  background: #11151c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.live-ribbon-item:hover {
  border-color: rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
}
.live-ribbon-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.live-ribbon-val {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  font-family: var(--mono, monospace);
}
.live-ribbon-chg {
  font-size: 12px;
  font-weight: 600;
}

.live-scan-btn {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.35));
  border: 1px solid #f59e0b;
  color: #fef3c7;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.2);
}
.live-scan-btn:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(217, 119, 6, 0.5));
  border-color: #fbbf24;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}
.live-scan-btn:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.live-movers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.live-mover-card {
  background: #11151c;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s ease;
}
.live-mover-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: #141922;
}
.live-mover-card.up {
  border-left: 3px solid #22c55e;
}
.live-mover-card.down {
  border-left: 3px solid #ef4444;
}

.live-gameplan-box {
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.08), rgba(16, 20, 26, 0.95));
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-left: 4px solid #22c55e;
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 14px;
}
.live-gameplan-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  line-height: 1.5;
  color: #e2e8f0;
}
.live-gameplan-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.live-gameplan-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #153822;
  color: #86efac;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.live-catalysts-table {
  width: 100%;
  border-collapse: collapse;
}
.live-catalysts-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.live-catalysts-table tr:last-child td {
  border-bottom: none;
}
.live-impact-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.live-impact-badge.high {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.live-impact-badge.medium {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.live-impact-badge.low {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

/* AI Provider Switcher (Gemini vs Grok) */
.ai-switch-container {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  vertical-align: middle;
}
.ai-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: var(--sans, inherit);
  white-space: nowrap;
}
.ai-switch-btn:hover {
  color: #f1f5f9;
}
.ai-switch-btn.active.gemini {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.15);
}
.ai-switch-btn.active.grok {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.18);
}
.ai-switch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  transition: background 0.18s ease;
}
.ai-switch-btn.active.gemini .ai-switch-dot {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}
.ai-switch-btn.active.grok .ai-switch-dot {
  background: #f43f5e;
  box-shadow: 0 0 6px #f43f5e;
}

.ai-badge.grok {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}
.ai-badge.gemini {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

@media (max-width: 720px) {
  .ai-switch-container {
    order: 3;
    margin: 2px 0;
  }
}
