:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0b1727;
  --surface-2: #0e1c2e;
  --surface-3: #102238;
  --border: #21344a;
  --border-soft: #172a40;
  --text: #e7eef7;
  --muted: #8799af;
  --faint: #5f738b;
  --bull: #31c9c6;
  --bull-soft: rgba(49, 201, 198, .12);
  --bear: #ff6972;
  --bear-soft: rgba(255, 105, 114, .12);
  --amber: #f5b942;
  --amber-soft: rgba(245, 185, 66, .12);
  --blue: #4388f7;
  --radius: 4px;
  --font-ui: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.dashboard-page {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #f0f3fa;
  --border: #dfe3eb;
  --border-soft: #eceff4;
  --text: #131722;
  --muted: #787b86;
  --faint: #9598a1;
  --bull: #089981;
  --bull-soft: rgba(8, 153, 129, .08);
  --bear: #f23645;
  --bear-soft: rgba(242, 54, 69, .07);
  --amber: #b7791f;
  --amber-soft: rgba(183, 121, 31, .08);
  --blue: #2962ff;
}

button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 10px;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 30px;
}

.brand-block h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.topbar-meta,
.detail-source-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-meta strong,
.detail-source-meta strong { color: var(--text); font-weight: 500; }

.meta-separator,
.detail-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.source-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--bull);
  font-weight: 600;
  white-space: nowrap;
}

.source-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px var(--bull-soft);
}

.source-state.warning { color: var(--amber); }
.source-state.error { color: var(--bear); }
.source-state.loading { color: var(--muted); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.updated-at { color: var(--muted); font-size: 12px; white-space: nowrap; }

.primary-button {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  color: white;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.primary-button:hover { background: #1e53e5; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.primary-button svg { width: 17px; height: 17px; }
.primary-button.busy svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.metric-rail {
  min-height: 86px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 8px 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 11px 20px;
  border-right: 1px dashed var(--border);
}

.metric-cell:last-child { border-right: 0; }
.metric-cell > span { color: var(--muted); font-size: 13px; }
.metric-cell div { display: flex; align-items: baseline; gap: 15px; }
.metric-cell strong { font-family: var(--font-mono); font-size: 27px; line-height: 1; }
.metric-cell small { color: var(--muted); font-size: 12px; }
.metric-cell.bullish strong { color: var(--bull); }
.metric-cell.bearish strong { color: var(--bear); }
.metric-cell.attention strong { color: var(--amber); }
.metric-cell.muted strong { color: var(--muted); }

.ai-summary-section {
  margin: 0 0 10px;
  padding: 15px 18px;
  background: linear-gradient(135deg, #f8faff, #ffffff 55%);
  border: 1px solid #d9e2f3;
  border-radius: var(--radius);
}

.ai-summary-heading,
.ai-commentary-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ai-summary-heading h2,
.ai-commentary-heading h2 { margin: 2px 0 0; color: var(--text); font-size: 15px; }
.section-kicker { color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ai-summary-state,
.ai-commentary-heading > span { padding: 3px 8px; color: var(--blue); background: rgba(41, 98, 255, .08); border-radius: 999px; font-size: 11px; font-weight: 600; }
.ai-summary-state.unavailable,
.ai-commentary-heading > span.unavailable { color: var(--muted); background: var(--surface-3); }
.ai-summary-state.partial { color: var(--amber); background: var(--amber-soft); }
.ai-summary-headline { margin: 10px 0 12px; color: #334155; font-size: 14px; line-height: 1.65; }
.ai-summary-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ai-summary-groups article { padding: 10px 12px; background: #fff; border: 1px solid var(--border-soft); }
.ai-summary-groups article > div { display: flex; flex-direction: column; gap: 4px; }
.ai-summary-groups article strong { font-size: 12px; }
.ai-summary-groups article strong em { margin-left: 4px; color: var(--blue); font-family: var(--font-mono); font-style: normal; }
.ai-summary-groups article span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.ai-summary-groups nav { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ai-summary-groups nav a { display: inline-flex; gap: 5px; padding: 3px 6px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-soft); text-decoration: none; font-size: 11px; }
.ai-summary-groups nav a span { color: var(--muted); }
.ai-summary-meta { display: block; margin-top: 10px; color: var(--faint); }

.portfolio-workspace {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--border-soft);
}

.search-control,
.select-control {
  height: 38px;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.search-control {
  min-width: 300px;
  flex: 0 1 360px;
  padding: 0 12px;
  gap: 9px;
}

.search-control svg { width: 18px; height: 18px; color: var(--muted); }
.search-control input {
  width: 100%;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}
.search-control input::placeholder { color: var(--faint); }

.select-control { padding-left: 13px; color: var(--muted); }
.select-control span { color: var(--muted); font-size: 12px; }
.select-control select {
  min-width: 122px;
  height: 100%;
  padding: 0 32px 0 7px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  cursor: pointer;
  font-size: 13px;
}
.select-control option { color: var(--text); background: var(--surface); }
.row-count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

.global-message,
.detail-error {
  margin-bottom: 10px;
  padding: 10px 12px;
  color: #8a5b12;
  background: var(--amber-soft);
  border: 1px solid rgba(183, 121, 31, .32);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.55;
}

.global-message.error,
.detail-error {
  color: var(--bear);
  background: var(--bear-soft);
  border-color: rgba(242, 54, 69, .30);
}

.table-frame {
  min-height: 300px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
}

.portfolio-table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  table-layout: fixed;
}

.portfolio-table thead { position: sticky; top: 0; z-index: 2; }
.portfolio-table th {
  height: 44px;
  padding: 0 16px;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.portfolio-table th:nth-child(1) { width: 15%; }
.portfolio-table th:nth-child(2) { width: 11%; }
.portfolio-table th:nth-child(3),
.portfolio-table th:nth-child(4) { width: 25%; }
.portfolio-table th:nth-child(5) { width: 10%; text-align: center; }
.portfolio-table th:nth-child(6) { width: 10%; }
.portfolio-table th:nth-child(7) { width: 4%; }

.portfolio-table tbody tr {
  height: 104px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 120ms ease;
}
.portfolio-table tbody tr:last-child { border-bottom: 0; }
.portfolio-table tbody tr.market-group-row {
  height: 36px;
  background: #eef2f7;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.portfolio-table tbody tr.market-group-row:first-child { border-top: 0; }
.portfolio-table td.market-group-cell { padding: 0 16px; color: var(--text); }
.market-group-cell strong { font-size: 13px; font-weight: 700; }
.market-group-cell span { margin-left: 9px; color: var(--muted); font-size: 11px; }
.portfolio-table tbody tr.data-row { cursor: pointer; }
.portfolio-table tbody tr.data-row:hover { background: #f5f7fa; }
.portfolio-table tbody tr.priority-row {
  background: var(--bull-soft);
  box-shadow: inset 2px 0 0 var(--bull);
}
.portfolio-table td { padding: 9px 16px; color: var(--text); vertical-align: middle; }

.cell-stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cell-main { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { color: var(--muted); font-size: 12px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.symbol-code { font-family: var(--font-mono); letter-spacing: .01em; }
.symbol-name { margin-left: 7px; font-family: var(--font-ui); font-weight: 600; }
.position-summary { display: flex; gap: 7px; }
.position-summary span + span::before { content: "·"; margin-right: 7px; color: var(--faint); }
.quote-price { font-family: var(--font-mono); font-size: 16px; }
.tone-bullish { color: var(--bull) !important; }
.tone-bearish { color: var(--bear) !important; }
.tone-attention { color: var(--amber) !important; }
.timeframe-cell { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.timeframe-heading { min-width: 0; display: flex; align-items: center; gap: 8px; }
.timeframe-heading > span {
  min-width: 22px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.timeframe-heading > a,
.timeframe-heading > strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timeframe-heading > a:hover { color: var(--blue) !important; text-decoration: underline; text-underline-offset: 2px; }
.timeframe-context { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.score-pair { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border-soft); }
.score-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 18px 20px 1fr;
  align-items: baseline;
  gap: 4px;
  padding: 4px 7px;
  color: var(--muted);
  background: var(--surface);
  font-family: var(--font-mono);
  font-style: normal;
}
.score-item + .score-item { border-left: 1px solid var(--border-soft); }
.score-item i { color: var(--muted); font-family: var(--font-ui); font-size: 9px; font-style: normal; }
.score-item b { font-size: 11px; font-weight: 700; }
.score-item strong { justify-self: end; font-size: 12px; font-weight: 600; }
.score-item.long.bullish b,
.score-item.long.bullish strong { color: var(--bull); }
.score-item.short.bearish b,
.score-item.short.bearish strong { color: var(--bear); }
.timeframe-cell.unavailable { padding: 7px 9px; border: 1px dashed var(--border); background: var(--surface-2); }
.timeframe-cell.unavailable small { overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.combined-score { display: grid; gap: 8px; font-family: var(--font-mono); }
.combined-score span { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.combined-score i { color: var(--muted); font-family: var(--font-ui); font-size: 10px; font-style: normal; }
.combined-score strong { font-size: 17px; }
.combined-score .long strong { color: var(--bull); }
.combined-score .short strong { color: var(--bear); }
.detail-link { color: var(--muted); text-align: center; }
.detail-link:hover { color: var(--blue); }
.detail-link svg { width: 20px; height: 20px; }

.error-row td { height: 76px; }
.error-title { color: var(--bear); font-weight: 600; }
.error-copy { color: var(--muted); font-size: 12px; }
.pending-row td { height: 76px; }
.pending-title { color: var(--amber); font-weight: 600; }
.pending-copy { color: var(--muted); font-size: 12px; }
.empty-row td { height: 180px; color: var(--muted); text-align: center; }
.loading-row td { height: 180px; text-align: center; }
.loading-line {
  display: block;
  width: 240px;
  height: 10px;
  margin: 7px auto;
  background: var(--border-soft);
  border-radius: 20px;
  animation: pulse 1.4s ease-in-out infinite;
}
.loading-line.short { width: 150px; }
@keyframes pulse { 50% { opacity: .4; } }

.app-footer,
.detail-footer {
  min-height: 37px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--faint);
  font-size: 11px;
}

/* Detail page */
.detail-page {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #d8e0e8;
  --border-soft: #e8edf2;
  --text: #17212b;
  --muted: #64748b;
  --faint: #94a3b8;
  --bull: #0f8f73;
  --bull-soft: rgba(15, 143, 115, .10);
  --bear: #d64050;
  --bear-soft: rgba(214, 64, 80, .10);
  --amber: #b7791f;
  --amber-soft: rgba(183, 121, 31, .10);
  --blue: #2563eb;
}
.detail-page .detail-source-meta strong { color: var(--text); }
.detail-shell { min-height: 100vh; display: flex; flex-direction: column; padding: 0 14px; }
.detail-topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border-soft);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 600;
}
.back-link:hover { color: #0f172a; }
.back-link svg { width: 20px; height: 20px; }
.symbol-heading { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.symbol-heading strong { font-family: var(--font-mono); font-size: 20px; }
.symbol-heading span { font-size: 17px; color: #475569; }
.quote-heading { display: flex; align-items: baseline; gap: 10px; margin-left: 20px; white-space: nowrap; }
.quote-heading span { color: var(--muted); font-size: 11px; }
.quote-heading strong { color: var(--bull); font-family: var(--font-mono); font-size: 22px; }
.quote-heading em { color: var(--muted); font-family: var(--font-mono); font-size: 13px; font-style: normal; }
.detail-topbar-spacer { flex: 1; }
.detail-source-meta { gap: 14px; font-size: 11px; }
.detail-source-meta .source-state { font-size: 11px; }

.detail-error { margin: 10px 0 0; }
.detail-workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  align-items: start;
  grid-template-columns: minmax(680px, 1.85fr) minmax(390px, 1fr);
  gap: 10px;
  padding-top: 10px;
}
.chart-panel,
.analysis-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chart-panel { min-height: 690px; display: flex; flex-direction: column; overflow: hidden; }
.chart-toolbar {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.chart-toolbar > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chart-toolbar strong { font-size: 13px; }
.chart-toolbar #chart-subtitle { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-intervals {
  display: inline-flex;
  flex: none;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chart-intervals button {
  height: 27px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  font-size: 11px;
}
.chart-intervals button:hover { color: var(--text); }
.chart-intervals button.active { color: white; background: #2563eb; }
.chart-legend { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 15px; height: 2px; background: currentColor; }
.legend-line.bullish { color: var(--bull); }
.legend-line.bearish { color: var(--bear); }
.legend-pb { color: #8b5cf6; font-weight: 700; }
.chart-pattern-strip {
  min-height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
  background: #fbfcfe;
  white-space: nowrap;
  scrollbar-width: thin;
}
.chart-pattern-strip[hidden] { display: none; }
.chart-pattern-strip::before {
  content: "图上形态";
  flex: none;
  color: var(--muted);
  font-size: 10px;
}
.chart-pattern-chip {
  min-height: 25px;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 6px;
  border: 1px solid #dbe3ec;
  border-left-width: 3px;
  border-radius: 4px;
  background: #ffffff;
  color: #475569;
  font-size: 10px;
}
.chart-pattern-chip > b {
  min-width: 16px;
  color: #475569;
  font-size: 12px;
  text-align: center;
}
.chart-pattern-chip > strong { color: #334155; font-size: 11px; font-weight: 600; }
.chart-pattern-chip > em { color: var(--muted); font-style: normal; }
.chart-pattern-chip.bullish { border-left-color: var(--bull); }
.chart-pattern-chip.bearish { border-left-color: var(--bear); }
.chart-pattern-chip.bullish > b { color: var(--bull); }
.chart-pattern-chip.bearish > b { color: var(--bear); }
.chart-pattern-chip.target_undershoot { border-left-color: #b7791f; }
.chart-pattern-chip.target_undershoot > b { color: #b7791f; }
.tv-chart { min-height: 620px; flex: 1; }

.analysis-rail { min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.analysis-section { padding: 14px 16px; }
.analysis-section h2 { margin: 0 0 12px; color: #334155; font-size: 13px; font-weight: 600; }

.ai-commentary-section { border-color: #d9e2f3; background: linear-gradient(135deg, #f8faff, #fff 62%); }
.ai-commentary-section > p { margin: 10px 0 12px; color: #27364a; line-height: 1.7; }
.ai-commentary-section > p small { display: block; margin-top: 4px; color: var(--faint); }
.ai-commentary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ai-commentary-grid article { padding: 10px; background: rgba(255,255,255,.7); border: 1px solid var(--border-soft); }
.ai-commentary-grid strong { font-size: 12px; }
.ai-commentary-grid p { margin: 5px 0; color: #475569; line-height: 1.55; }
.ai-commentary-grid span { display: block; color: var(--blue); font-size: 12px; }
.ai-commentary-grid small,
.ai-commentary-observations small { display: block; margin-top: 5px; color: var(--faint); font-size: 10px; overflow-wrap: anywhere; }
.ai-commentary-observations ul { display: grid; gap: 6px; margin: 10px 0; padding: 0; list-style: none; }
.ai-commentary-observations li { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; padding: 8px 10px; background: #fff; border-left: 2px solid var(--blue); }
.ai-commentary-observations li.conflict { border-left-color: var(--amber); }
.ai-commentary-observations li b { color: #334155; font-size: 11px; }
.ai-commentary-observations li span { color: #475569; font-size: 12px; }
.ai-commentary-observations li em { grid-column: 2; color: var(--blue); font-size: 11px; font-style: normal; }
.ai-commentary-observations li small { grid-column: 2; }
.ai-commentary-observations > p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.ai-commentary-observations > p b { margin-right: 7px; color: #334155; }
.ai-commentary-meta { display: block; margin-top: 10px; color: var(--faint); }
.section-kicker { color: var(--muted); font-size: 11px; }
.conclusion-row { display: flex; align-items: flex-start; gap: 16px; margin-top: 8px; }
.conclusion-row h1 {
  min-width: 0;
  flex: 1;
  margin: 0;
  color: var(--bull);
  font-size: clamp(20px, 1.65vw, 28px);
  font-weight: 600;
  line-height: 1.25;
}
.confidence { min-width: 76px; padding-left: 14px; border-left: 1px solid var(--border-soft); text-align: center; }
.confidence span { display: block; color: var(--muted); font-size: 10px; }
.confidence strong { display: block; margin-top: 5px; color: var(--bull); font-family: var(--font-mono); font-size: 18px; }
.conclusion-section p { margin: 12px 0 0; color: #526174; font-size: 12px; line-height: 1.75; }

.pattern-list { display: grid; gap: 8px; }
.pattern-card { padding-left: 10px; border-left: 3px solid #94a3b8; }
.pattern-card.bullish { border-left-color: var(--bull); }
.pattern-card.bearish { border-left-color: var(--bear); }
.pattern-card.target_undershoot { border-left-color: var(--amber); background: var(--amber-soft); padding-top: 7px; padding-bottom: 7px; padding-right: 8px; }
.pattern-card > div { display: flex; align-items: baseline; gap: 8px; }
.pattern-card strong { color: var(--text); font-family: var(--font-mono); font-size: 14px; }
.pattern-card b { color: #334155; font-size: 11px; font-weight: 600; }
.pattern-card em { margin-left: auto; color: var(--muted); font-size: 9px; font-style: normal; white-space: nowrap; }
.pattern-card p { margin: 5px 0 0; color: #64748b; font-size: 10px; line-height: 1.45; }
.pattern-card > span { display: inline-block; margin-top: 4px; color: #2563eb; font-family: var(--font-mono); font-size: 10px; }
.candidate-card { padding: 9px 10px; border-left: 3px solid var(--amber); background: var(--amber-soft); }
.candidate-card > div { display: flex; align-items: baseline; gap: 8px; }
.candidate-card strong { color: #9a6700; font-family: var(--font-mono); font-size: 14px; }
.candidate-card b { color: #334155; font-size: 11px; font-weight: 600; }
.candidate-card em { margin-left: auto; color: #9a6700; font-size: 9px; font-style: normal; white-space: nowrap; }
.candidate-card p { margin: 5px 0; color: #64748b; font-size: 10px; line-height: 1.45; }
.candidate-card > span { display: block; color: #475569; font-family: var(--font-mono); font-size: 10px; line-height: 1.5; }
.candidate-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }

.opportunity-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.opportunity-card { display: grid; grid-template-columns: 95px 1fr; gap: 12px; min-width: 0; padding: 2px 14px 2px 0; }
.opportunity-card + .opportunity-card { padding-left: 14px; border-left: 1px solid var(--border-soft); }
.opportunity-grade { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.opportunity-grade span { font-size: 13px; }
.opportunity-grade strong { font-family: var(--font-mono); font-size: 28px; }
.opportunity-grade small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.opportunity-card.long .opportunity-grade span,
.opportunity-card.long .opportunity-grade strong { color: var(--bull); }
.opportunity-card.short .opportunity-grade span,
.opportunity-card.short .opportunity-grade strong { color: var(--bear); }
.opportunity-copy { display: flex; flex-direction: column; justify-content: center; gap: 5px; min-width: 0; }
.opportunity-copy p { margin: 0; color: #64748b; font-size: 10px; line-height: 1.4; }
.opportunity-copy b { color: #334155; font-weight: 500; }

.analysis-lower-grid { min-height: 0; flex: 1; display: grid; grid-template-columns: 1.2fr .8fr; gap: 10px; }
.analysis-lower-grid > div { display: flex; flex-direction: column; gap: 10px; }
.evidence-section { flex: 1; }
.evidence-section ul { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.evidence-section li { position: relative; padding-left: 12px; color: #526174; font-size: 11px; line-height: 1.45; }
.evidence-section li::before { content: ""; position: absolute; left: 0; top: .55em; width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.structure-section table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.structure-section th { padding: 0 4px 7px 0; color: var(--muted); text-align: left; font-size: 10px; font-weight: 500; }
.structure-section th:nth-child(1) { width: 28%; }
.structure-section th:nth-child(2) { width: 26%; }
.structure-section td { padding: 7px 4px 7px 0; border-top: 1px solid var(--border-soft); color: #526174; font-size: 10px; }
.structure-section td:nth-child(2) { color: var(--text); font-family: var(--font-mono); }
.structure-kind.swing_high, .structure-kind.range_high, .structure-kind.signal_high { color: var(--bear); }
.structure-kind.swing_low, .structure-kind.range_low, .structure-kind.signal_low { color: var(--bull); }
.structure-kind.breakout_boundary { color: var(--amber); }

.timeline-section { min-height: 0; }
.timeline-section ol { margin: 0; padding: 0; list-style: none; }
.timeline-section li { position: relative; padding: 0 0 18px 17px; color: #526174; font-size: 10px; line-height: 1.5; border-left: 1px solid var(--border); }
.timeline-section li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline-section li::before { content: ""; position: absolute; left: -4px; top: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.timeline-section li.bullish::before { background: var(--bull); }
.timeline-section li.bearish::before { background: var(--bear); }
.timeline-section li.neutral::before { background: var(--amber); }
.timeline-section time { display: block; color: var(--muted); }
.timeline-section strong { display: block; margin-top: 2px; color: #334155; font-weight: 600; }
.timeline-section span { color: var(--faint); font-family: var(--font-mono); }
.analysis-footnote { display: flex; justify-content: space-between; gap: 14px; padding: 0 3px; color: var(--faint); font-size: 9px; }
.detail-footer { justify-content: flex-start; border-top: 1px solid var(--border-soft); }

@media (max-width: 1180px) {
  .brand-block { gap: 18px; }
  .topbar-meta { gap: 10px; }
  .detail-source-meta { display: none; }
  .detail-workspace { grid-template-columns: minmax(560px, 1.65fr) minmax(360px, 1fr); }
  .opportunity-list { grid-template-columns: 1fr; }
  .opportunity-card + .opportunity-card { margin-top: 12px; padding: 12px 0 0; border-top: 1px solid var(--border-soft); border-left: 0; }
  .analysis-lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .ai-summary-groups { grid-template-columns: 1fr; }
  .ai-commentary-grid { grid-template-columns: 1fr; }
  .app-shell, .detail-shell { padding: 0 8px; }
  .topbar { align-items: flex-start; padding: 12px 4px; }
  .brand-block { flex-direction: column; align-items: flex-start; gap: 6px; }
  .meta-separator { display: none; }
  .updated-at { display: none; }
  .metric-rail { grid-template-columns: 1fr 1fr; }
  .metric-cell:nth-child(2) { border-right: 0; }
  .metric-cell:nth-child(-n+2) { border-bottom: 1px dashed var(--border); }
  .toolbar { flex-wrap: wrap; padding: 9px 0; }
  .search-control { flex: 1 0 100%; min-width: 0; }
  .row-count { margin-left: 0; }
  .detail-topbar { flex-wrap: wrap; gap: 10px; padding: 9px 0; }
  .quote-heading { margin-left: 0; }
  .detail-workspace { display: flex; flex-direction: column; }
  .chart-panel { flex: none; height: 580px; min-height: 0; }
  .tv-chart { flex: 1; height: auto; min-height: 0; }
  .analysis-lower-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 13px; }
  .topbar-meta { flex-wrap: wrap; }
  .primary-button { padding: 0 11px; }
  .metric-cell { min-height: 76px; padding: 11px 13px; }
  .metric-cell strong { font-size: 24px; }
  .select-control { flex: 1; }
  .select-control select { min-width: 0; }
  .row-count { width: 100%; }
  .app-footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 2px; padding: 8px 0; }
  .detail-divider, .detail-topbar-spacer { display: none; }
  .symbol-heading { order: 3; width: 100%; }
  .quote-heading { order: 4; }
  .detail-topbar .primary-button { margin-left: auto; }
  .chart-toolbar { align-items: flex-start; flex-direction: column; }
  .chart-legend { flex-wrap: wrap; }
  .chart-pattern-strip { padding-inline: 9px; }
  .chart-pattern-chip > em { display: none; }
  .analysis-lower-grid { grid-template-columns: 1fr; }
  .opportunity-list { grid-template-columns: 1fr; }
  .analysis-footnote { flex-direction: column; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
