:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-solid: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #edf2f7;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --good: #0f9f7a;
  --good-dark: #08735e;
  --warn: #d97706;
  --bad: #be123c;
  --shadow: 0 16px 34px rgba(15, 23, 42, 0.075);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --touch: 44px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -4%, rgba(37, 99, 235, 0.16), transparent 34rem),
    radial-gradient(circle at 94% 0%, rgba(15, 159, 122, 0.13), transparent 26rem),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 62%, #edf2f7 100%);
}

button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .table-shell:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -64px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(226, 232, 240, 0.88);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.045);
}
.topbar-inner {
  width: min(100%, 1540px);
  margin: 0 auto;
  min-height: 66px;
  padding: 10px 22px;
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #0f9f7a);
  color: #fff;
  font-weight: 950;
  letter-spacing: -0.06em;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}
.brand-text strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand-text small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

.top-nav {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  background: var(--surface-soft);
}
.top-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
}
.top-nav a:hover { color: #0f172a; background: #fff; }

.top-status {
  justify-self: end;
  min-width: 0;
  text-align: right;
  line-height: 1.2;
}
.top-status span {
  display: block;
  font-size: 12px;
  color: var(--primary);
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.top-status small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 470px;
}
.top-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }

.workspace {
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: 22px;
  display: grid;
  gap: 14px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 8px 2px 2px;
}
.eyebrow {
  margin: 0;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
  font-weight: 950;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin: 7px 0 8px;
  font-size: clamp(30px, 4.2vw, 56px);
  line-height: 0.98;
  letter-spacing: -0.058em;
}
h2 { margin: 3px 0 0; font-size: 19px; letter-spacing: -0.035em; }
h3 { margin: 0; font-size: 14px; letter-spacing: -0.02em; }
.lead { margin: 0; max-width: 900px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.hero-meta {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.hero-meta span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; }
.hero-meta strong { display: block; margin-top: 4px; font-size: 13px; line-height: 1.35; }

.panel, .kpi-grid article {
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.kpi-grid article { padding: 13px 14px; min-width: 0; }
.kpi-grid span, label small, .table-head p, footer { color: var(--muted); }
.kpi-grid span { display: block; font-size: 12px; font-weight: 850; }
.kpi-grid strong { display: block; margin-top: 5px; font-size: 25px; line-height: 1; letter-spacing: -0.045em; }
.kpi-grid small { display: block; margin-top: 7px; color: var(--faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.compact-head { padding: 14px 14px 0; }
.scanner-panel { padding-bottom: 14px; }
.progress-line { width: min(420px, 40vw); display: grid; gap: 6px; }
.progress-line small, .chart-head span { color: var(--muted); font-size: 12px; font-weight: 800; }
.progress { height: 7px; background: #e7eef7; border-radius: 999px; overflow: hidden; }
.progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--good));
  transition: width 0.22s ease;
}

.control-grid {
  padding: 12px 14px 0;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 84px 132px auto;
  gap: 9px;
  align-items: end;
}
.filters-strip {
  padding: 10px 14px 0;
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) repeat(4, minmax(82px, 0.46fr)) minmax(170px, 0.9fr);
  gap: 9px;
  align-items: end;
}
.symbols-box, .search-field, .sort-field { min-width: 0; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 850; color: #334155; }
textarea, input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
textarea { resize: vertical; min-height: 58px; line-height: 1.4; }
textarea:focus, input:focus, select:focus {
  border-color: rgba(37, 99, 235, 0.76);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
}
.button-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

button {
  border: 0;
  min-height: 40px;
  border-radius: 999px;
  padding: 9px 14px;
  background: #e8eef9;
  color: #1e293b;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}
button.secondary { background: #0f172a; color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); }

.chips {
  padding: 10px 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.chips label { display: inline-block; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.chips input:checked + span { background: #0f172a; border-color: #0f172a; color: #fff; }
.chips input:focus-visible + span { outline: 3px solid rgba(37, 99, 235, 0.28); outline-offset: 2px; }

.chart-card { padding: 14px; min-width: 0; }
.chart-wide { overflow: hidden; }
.chart-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.chart-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
canvas { width: 100%; display: block; }
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.table-panel { overflow: hidden; }
.table-head {
  padding: 14px 14px 10px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}
.table-head p { margin: 0; max-width: 520px; text-align: right; font-size: 12px; line-height: 1.45; }
#messages { padding: 0 14px 10px; }
.msg {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  color: #334155;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}
.msg.error { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.msg.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.msg.details summary { cursor: pointer; font-weight: 900; }
.msg.details ul { margin: 8px 0 0; padding-left: 18px; max-height: 190px; overflow: auto; }
.msg.details li + li { margin-top: 4px; }

.table-shell {
  height: clamp(390px, calc(100vh - 488px), 720px);
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #fff;
}
table {
  width: 100%;
  min-width: 1110px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
th, td {
  padding: 8px 7px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  color: #475569;
  text-align: left;
  font-size: 10px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.065em;
  box-shadow: 0 1px 0 var(--line);
}
th[data-sort] { cursor: pointer; }
th.sorted { color: var(--primary); }
th.sorted::after { content: " ↓"; }
tbody tr { background: #fff; }
tbody tr:hover { background: #f8fbff; }

th:nth-child(1), td:nth-child(1) { width: 66px; position: sticky; left: 0; z-index: 2; background: inherit; }
th:nth-child(1) { z-index: 4; background: #f8fafc; }
th:nth-child(2), td:nth-child(2) { width: 164px; }
th:nth-child(3), td:nth-child(3) { width: 76px; }
th:nth-child(4), td:nth-child(4),
th:nth-child(5), td:nth-child(5),
th:nth-child(6), td:nth-child(6),
th:nth-child(7), td:nth-child(7),
th:nth-child(8), td:nth-child(8) { width: 46px; }
th:nth-child(9), td:nth-child(9) { width: 54px; }
th:nth-child(10), td:nth-child(10),
th:nth-child(11), td:nth-child(11),
th:nth-child(12), td:nth-child(12) { width: 76px; }
th:nth-child(13), td:nth-child(13) { width: 44px; }
th:nth-child(14), td:nth-child(14) { width: 126px; }
th:nth-child(15), td:nth-child(15) { width: 68px; }
th:nth-child(16), td:nth-child(16) { width: 60px; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.symbol a, .yahoo-link { color: var(--primary); text-decoration: none; font-weight: 950; }
.symbol a:hover, .yahoo-link:hover { text-decoration: underline; }
.company { color: #334155; }
.latest { display: grid; gap: 1px; line-height: 1.14; }
.latest strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.latest span { display: block; color: var(--faint); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.score { font-weight: 950; color: #0f172a; }
.strong-buy-count { color: var(--good-dark); font-weight: 950; }
.buy-count { color: var(--primary); font-weight: 950; }
.sell-count { color: var(--bad); font-weight: 900; }
.muted, .muted-num { color: var(--faint); }
.positive { color: var(--good-dark); font-weight: 950; }
.negative { color: var(--bad); font-weight: 950; }
.empty-row { text-align: center; padding: 26px; color: var(--muted); }
.cache-age { color: var(--muted); font-size: 11px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.01em;
}
.badge.strong-buy { background: #ccfbf1; color: #0f766e; }
.badge.buy { background: #dbeafe; color: #1d4ed8; }
.badge.hold { background: #fef3c7; color: #92400e; }
.badge.underperform { background: #ffe4e6; color: #be123c; }
.badge.sell { background: #fecdd3; color: #9f1239; }
.badge.unknown { background: #e2e8f0; color: #475569; }
.cache-pill { display: inline-flex; border-radius: 999px; padding: 4px 7px; font-size: 10px; font-weight: 900; background: #eef2ff; color: #3730a3; }
.cache-pill.fresh { background: #dcfce7; color: #166534; }
.cache-pill.stale { background: #ffedd5; color: #9a3412; }

footer { padding: 2px 2px 24px; font-size: 12px; line-height: 1.5; }

@media (max-width: 1180px) {
  .topbar-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brand status actions"
      "nav nav nav";
    gap: 8px 12px;
  }
  .brand { grid-area: brand; }
  .top-nav { grid-area: nav; overflow-x: auto; justify-content: center; }
  .top-status { grid-area: status; }
  .top-actions { grid-area: actions; }
  .control-grid { grid-template-columns: minmax(280px, 1fr) 84px 132px; }
  .button-row { grid-column: 1 / -1; justify-content: flex-start; }
  .filters-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-field, .sort-field { grid-column: span 1; }
}

@media (max-width: 920px) {
  .workspace { padding: 16px; gap: 12px; }
  .hero { grid-template-columns: 1fr; }
  .hero-meta { min-width: 0; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts-grid { grid-template-columns: 1fr; }
  .progress-line { width: min(100%, 420px); }
  .panel-head, .table-head { align-items: stretch; flex-direction: column; }
  .table-head p { text-align: left; }
}

@media (max-width: 700px) {
  body { background: #f6f8fb; }
  .topbar { position: sticky; }
  .topbar-inner {
    min-height: auto;
    padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "status status"
      "nav nav";
  }
  .brand-mark { width: 36px; height: 36px; border-radius: 12px; }
  .brand-text strong { font-size: 14px; }
  .brand-text small { display: none; }
  .top-actions button { min-width: 74px; min-height: var(--touch); padding: 8px 12px; }
  .top-status { justify-self: stretch; text-align: left; }
  .top-status small { max-width: none; white-space: normal; }
  .top-nav {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .top-nav::-webkit-scrollbar { display: none; }
  .top-nav a { min-height: 38px; flex: 0 0 auto; }

  .workspace { padding: 12px; gap: 10px; }
  h1 { font-size: 32px; letter-spacing: -0.052em; }
  .lead { font-size: 14px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-grid article { padding: 12px; }
  .kpi-grid strong { font-size: 22px; }
  .panel, .kpi-grid article, .hero-meta { border-radius: 18px; }
  .compact-head { padding: 12px 12px 0; }
  .control-grid, .filters-strip { grid-template-columns: 1fr; padding-left: 12px; padding-right: 12px; }
  .button-row { justify-content: stretch; }
  .button-row button { flex: 1 1 auto; min-height: var(--touch); }
  .chips { padding: 9px 12px 0; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips span { min-height: var(--touch); flex: 0 0 auto; }
  textarea, input, select { min-height: var(--touch); font-size: 16px; }

  .chart-card { padding: 12px; }
  .chart-head { flex-direction: column; align-items: stretch; gap: 4px; }

  .table-shell {
    height: auto;
    max-height: none;
    overflow: visible;
    border-top: 0;
    background: transparent;
    padding: 0 10px 12px;
  }
  table, thead, tbody, tr, td { display: block; }
  table { min-width: 0; font-size: 13px; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.055);
    overflow: hidden;
  }
  tbody tr:hover { background: #fff; }
  th:nth-child(1), td:nth-child(1), th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3),
  th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5), th:nth-child(6), td:nth-child(6),
  th:nth-child(7), td:nth-child(7), th:nth-child(8), td:nth-child(8), th:nth-child(9), td:nth-child(9),
  th:nth-child(10), td:nth-child(10), th:nth-child(11), td:nth-child(11), th:nth-child(12), td:nth-child(12),
  th:nth-child(13), td:nth-child(13), th:nth-child(14), td:nth-child(14), th:nth-child(15), td:nth-child(15),
  th:nth-child(16), td:nth-child(16) {
    width: auto;
    position: static;
    left: auto;
    z-index: auto;
    background: transparent;
  }
  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex: 0 0 auto;
  }
  td.symbol {
    align-items: flex-start;
    background: #f8fafc;
    font-size: 17px;
    padding-top: 12px;
    padding-bottom: 10px;
  }
  td.symbol::before { content: "Ticker"; }
  td.company { color: #334155; }
  td.latest { display: flex; align-items: center; justify-content: space-between; }
  td.latest strong, td.latest span { text-align: right; }
  td:last-child { border-bottom: 0; }
  .num { text-align: right; }
  .empty-row { display: block; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 29px; }
  .top-actions button { min-width: 66px; padding-left: 10px; padding-right: 10px; }
  .brand { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* v7 list manager */
.list-selector {
  margin: 12px 14px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.list-selector select { font-weight: 850; }
.list-actions { justify-content: flex-end; }
.list-manager {
  margin: 10px 14px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}
.list-manager summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 11px 13px;
  cursor: pointer;
  color: #334155;
  font-size: 13px;
  font-weight: 950;
  background: #f8fafc;
}
.manager-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
}
.manager-text, .manager-actions, .discover-result { grid-column: 1 / -1; }
.manager-actions { justify-content: flex-start; }
.discover-result {
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}
.discover-result strong { color: var(--text); }

@media (max-width: 1180px) {
  .list-selector { grid-template-columns: 1fr; }
  .list-actions { justify-content: flex-start; }
}
@media (max-width: 700px) {
  .list-selector, .list-manager { margin-left: 12px; margin-right: 12px; }
  .manager-grid { grid-template-columns: 1fr; }
  .list-actions button, .manager-actions button { flex: 1 1 100%; min-height: var(--touch); }
  .list-manager summary { min-height: var(--touch); }
}

/* v8 production/mobile refinements */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}
body { touch-action: pan-y; }
.topbar, .workspace, .panel, .hero, .table-panel, .chart-card { max-width: 100%; }
.brand { gap: 0; }
.brand-text.wordmark strong {
  font-size: 18px;
  line-height: 1;
  letter-spacing: -0.055em;
  font-weight: 950;
  background: linear-gradient(135deg, #0f172a, #2563eb 58%, #0f9f7a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero {
  padding: 18px 20px;
  min-height: auto;
}
.hero h1 { max-width: 880px; }
.lead { max-width: 920px; }
.kpi-grid article { min-height: 92px; }
.panel { box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06); }
.chart-card {
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.94));
}
.chart-wide canvas { max-height: 238px; }
.charts-grid canvas { max-height: 184px; }
.table-panel { overflow: hidden; }
.table-shell {
  width: 100%;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.table-shell table { contain: paint; }
.list-selector select option:first-child { font-weight: 900; }
.discover-result { word-break: break-word; }

@media (max-width: 920px) {
  .topbar-inner {
    width: 100%;
    max-width: 100%;
  }
  .hero { padding: 16px; }
  .hero h1 { font-size: clamp(28px, 6vw, 42px); }
  .chart-wide canvas { max-height: 216px; }
  .charts-grid canvas { max-height: 170px; }
  .table-shell {
    overflow-x: auto;
    overflow-y: auto;
  }
}

@media (max-width: 700px) {
  :root { --radius-lg: 18px; --radius-md: 14px; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 80;
  }
  .topbar-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .brand-text.wordmark strong { font-size: 17px; }
  .top-nav {
    padding: 3px;
    border-radius: 14px;
    width: 100%;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(max-content, 1fr);
  }
  .top-nav a {
    justify-content: center;
    padding: 8px 10px;
    min-height: 40px;
    font-size: 12px;
  }
  .top-actions { gap: 6px; }
  .top-actions button {
    min-height: 40px;
    min-width: 68px;
    border-radius: 12px;
  }
  .top-status {
    border-radius: 12px;
    padding: 8px 10px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid var(--line-soft);
  }
  .workspace {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    gap: 10px;
  }
  .hero {
    padding: 14px;
    border-radius: 18px;
  }
  .hero h1 {
    font-size: 27px;
    line-height: .98;
  }
  .hero-meta { padding: 12px; }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-grid article {
    min-height: 78px;
    padding: 11px;
  }
  .kpi-grid article small { display: none; }
  .scanner-panel { overflow: clip; }
  .list-selector,
  .list-manager,
  .control-grid,
  .filters-strip,
  .chips {
    margin-left: 10px;
    margin-right: 10px;
  }
  .list-selector {
    padding: 10px;
    border-radius: 14px;
  }
  .symbols-box textarea,
  .manager-text textarea {
    max-height: 112px;
    resize: vertical;
  }
  .filters-strip label,
  .control-grid label,
  .manager-grid label,
  .list-selector label {
    min-width: 0;
  }
  .chart-card {
    padding: 10px;
    border-radius: 16px;
  }
  .chart-wide canvas { max-height: 196px; }
  .charts-grid canvas { max-height: 158px; }
  .chart-head h2 { font-size: 17px; }
  .chart-head h3 { font-size: 15px; }
  .chart-head p { display: none; }
  .table-panel { border-radius: 16px; }
  .table-head { padding: 12px; }
  .table-head p { font-size: 11px; }
  .table-shell {
    width: 100%;
    max-width: 100%;
    overflow: visible;
    touch-action: pan-y;
  }
  tbody {
    width: 100%;
    max-width: 100%;
  }
  tbody tr {
    width: 100%;
    max-width: 100%;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.052);
  }
  td {
    min-width: 0;
    max-width: 100%;
  }
  td > * { max-width: 62%; }
  td.symbol > * { max-width: 100%; }
  .latest { min-width: 0; }
  .latest strong, .latest span { max-width: 180px; }
  .badge { min-width: auto; }
}

@media (max-width: 380px) {
  .workspace { padding: 8px; }
  .top-nav a { padding-left: 8px; padding-right: 8px; }
  .kpi-grid { gap: 7px; }
  .kpi-grid strong { font-size: 20px; }
  td { gap: 8px; padding-left: 10px; padding-right: 10px; }
}
