/*
  臺灣期貨與臺股選股工作台
  Professional Financial Dashboard Styles
  Fixed light theme
*/

:root {
  color-scheme: light;

  /* Font Family Definition */
  --font-sans: 'Plus Jakarta Sans', 'Noto Sans TC', system-ui, -apple-system, sans-serif;

  /* Light Theme Variables (Default) */
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #2563eb;
  --blue-glow: #3b82f6;
  --green: #16a34a;
  --green-glow: #10b981;
  --red: #dc2626;
  --red-glow: #ef4444;
  --amber: #d97706;
  --amber-glow: #f59e0b;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -5px rgba(15, 23, 42, 0.04);

  /* Excel styles - Light Mode */
  --excel-border: #cfd8dc;
  --excel-th-bg: #f8fafc;
  --excel-td-bg: #ffffff;
  --excel-matrix-bg: #eff6ff;
  --excel-yellow-bg: #fff7cc;
  --excel-green-bg: #ecfdf5;
  --excel-next-bg: #fffbeb;
  --excel-event-bg: #fecdd3;
  --excel-event-text: #9f1239;
  --excel-event-border: rgba(190, 18, 60, 0.68);
  --excel-yellow-head: #fef3c7;
  --excel-green-head: #d1fae5;
  --excel-next-head: #fef3c7;
  --excel-matrix-head: #dbeafe;
  --sheet-date-col: 56px;
  --sheet-num-col: 64px;
  --sheet-compact-col: 54px;
  --sheet-matrix-col: 42px;
  --sheet-price-col: 58px;
  --sheet-change-col: 34px;
  --sheet-pad-x: 4px;
  --sheet-pad-y: 5px;
  --sheet-font-size: 11.5px;
  --sheet-head-font-size: 11.5px;
}

/* Excel replay workbench */
.excel-replay-workspace {
  max-width: 1720px;
}

.excel-import-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.excel-import-actions input {
  width: min(520px, 48vw);
}

.excel-metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.excel-metric,
.excel-empty-panel {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.excel-metric span,
.excel-metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.excel-metric strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
}

.excel-brief-section,
.excel-monitor-section,
.excel-minute-section,
.excel-replay-summary {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 18px;
  box-shadow: var(--shadow);
}

.excel-brief {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 14px;
}

.excel-brief > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.excel-brief strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}

.excel-brief ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.excel-group-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.excel-group-tabs button {
  min-width: 58px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.excel-group-tabs button.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.excel-option-board,
.excel-minute-board {
  max-height: 560px;
}

.excel-option-table,
.excel-minute-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12px;
}

.excel-option-table th,
.excel-minute-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #dbeafe;
  color: var(--ink);
  border: 1px solid var(--excel-border);
  padding: 8px 6px;
  text-align: center;
  font-weight: 900;
}

.excel-option-table td,
.excel-minute-table td {
  border: 1px solid var(--excel-border);
  background: var(--panel);
  padding: 7px 6px;
  text-align: right;
  white-space: nowrap;
}

.excel-option-table td:first-child,
.excel-minute-table td:first-child {
  color: var(--blue);
  font-weight: 900;
  text-align: left;
}

.excel-option-table tr.is-min-cp td {
  background: #fff7ed;
  color: #9a3412;
  font-weight: 900;
}

.excel-option-table .up,
.excel-minute-table .up {
  color: var(--red);
  font-weight: 800;
}

.excel-option-table .down,
.excel-minute-table .down {
  color: var(--green);
  font-weight: 800;
}

@media (max-width: 980px) {
  .excel-import-actions {
    width: 100%;
    justify-content: stretch;
  }

  .excel-import-actions input,
  .excel-import-actions button,
  .excel-import-actions .entry-button {
    width: 100%;
  }

  .excel-metric-grid,
  .excel-brief {
    grid-template-columns: 1fr;
  }

  .excel-group-tabs {
    justify-content: flex-start;
  }
}

/* Global Elements styling */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  letter-spacing: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
}

button {
  cursor: pointer;
  outline: none;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar h2,
.section-heading h3 {
  margin: 0;
  font-weight: 800;
  color: var(--ink);
}

.caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 4px;
}

.workspace {
  padding: 30px 24px;
  min-width: 0;
  max-width: 1620px;
  margin: 0 auto;
  width: 100%;
}

/* Header & layouts */
.topbar,
.section-heading,
.section-actions {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.section-actions > p[hidden] {
  display: none !important;
}

.topbar {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

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

.brand-title img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: block;
}

.section-heading {
  margin-bottom: 16px;
}

.section-actions {
  gap: 12px;
}

.topbar h2 {
  font-size: 26px;
  background: linear-gradient(135deg, var(--ink), var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.actions label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

/* Premium Form Elements */
input[type="date"],
input[type="text"],
input[type="url"],
select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

input[type="date"]:hover,
input[type="text"]:hover,
input[type="url"]:hover,
select:hover {
  border-color: var(--blue-glow);
}

input[type="date"]:focus,
input[type="text"]:focus,
input[type="url"]:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

select {
  padding-right: 32px;
  font-size: 13px;
  font-weight: 600;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}

/* Buttons */
.actions button,
.entry-button,
#exportWorkbookBtn,
#exportOptionVolumeBtn,
#exportInstitutionalBtn,
#exportOfficialInstitutionalBtn,
#exportYahooMarginBtn,
.quick-score-form button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08);
}

.actions button:hover,
.entry-button:hover,
#exportWorkbookBtn:hover,
#exportOptionVolumeBtn:hover,
#exportInstitutionalBtn:hover,
#exportOfficialInstitutionalBtn:hover,
#exportYahooMarginBtn:hover,
.quick-score-form button:hover {
  background: var(--blue-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.16);
}

.actions button:active,
.entry-button:active,
#exportWorkbookBtn:active,
#exportOptionVolumeBtn:active,
#exportInstitutionalBtn:active,
#exportOfficialInstitutionalBtn:active,
#exportYahooMarginBtn:active {
  transform: translateY(0);
}

.actions button:disabled,
#exportOfficialInstitutionalBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.entry-button {
  text-decoration: none;
}

.entry-button.secondary,
#exportWorkbookBtn,
#exportOptionVolumeBtn,
#exportInstitutionalBtn,
#exportOfficialInstitutionalBtn,
#exportYahooMarginBtn {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.entry-button.secondary:hover,
#exportWorkbookBtn:hover,
#exportOptionVolumeBtn:hover,
#exportInstitutionalBtn:hover,
#exportOfficialInstitutionalBtn:hover,
#exportYahooMarginBtn:hover {
  background: var(--line);
  color: var(--ink);
  border-color: var(--muted);
  box-shadow: none;
}

/* Range Progress indicator */
.range-progress {
  margin-top: 10px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}

.range-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.range-progress-title {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}

.range-spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: range-spin 0.8s linear infinite;
}

.range-progress.is-complete .range-spinner {
  animation: none;
  border-color: var(--green);
  background: var(--green);
}

.range-progress.is-error .range-spinner {
  animation: none;
  border-color: var(--red);
  background: var(--red);
}

.range-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
  margin-top: 14px;
}

.range-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--blue-glow));
  transition: width 0.2s ease;
}

.range-progress.is-complete .range-progress-fill {
  background: var(--green);
}

.range-progress.is-error .range-progress-fill {
  background: var(--red);
}

#rangeProgressPercent {
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
}

#rangeProgressText {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

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

/* Login Page visually upgraded styling */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 40%),
              var(--bg);
}

.login-shell {
  width: min(100%, 400px);
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px 30px;
}

.login-logo {
  display: block;
  width: min(220px, 100%);
  height: auto;
  margin: 0 0 24px;
}

.login-panel h1 {
  margin: 8px 0 28px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
}

.login-form button {
  height: 44px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
}

.login-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* Anomaly Workbench Overview & cards */
.anomaly-workspace {
  max-width: 1540px;
}

.anomaly-topbar {
  margin-bottom: 24px;
}

.anomaly-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.anomaly-overview article,
.anomaly-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.anomaly-overview article {
  padding: 20px;
  transition: all 0.25s ease;
}

.anomaly-overview article:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.anomaly-overview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.anomaly-overview strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  font-weight: 800;
}

/* KPI numbers specific gradients */
#watchCount {
  color: var(--blue);
  background: linear-gradient(135deg, var(--blue), var(--blue-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
#researchCount {
  color: var(--amber);
  background: linear-gradient(135deg, var(--amber), var(--amber-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
#priorityCount {
  color: var(--green);
  background: linear-gradient(135deg, var(--green), var(--green-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
#riskCount {
  color: var(--red);
  background: linear-gradient(135deg, var(--red), var(--red-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.anomaly-overview p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.anomaly-section {
  padding: 20px;
  margin-top: 24px;
}

.anomaly-filters {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.filter-button:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.filter-button.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

/* Beautiful Stock Workbench Tables */
.anomaly-table-wrap {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.anomaly-table th,
.anomaly-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.anomaly-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 700;
}

.anomaly-table tr {
  transition: background-color 0.15s ease;
}

.anomaly-table tbody tr:hover {
  background: var(--panel-2);
}

.anomaly-table td strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.anomaly-table td span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.stock-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.stock-cell-main {
  grid-area: main;
  min-width: 0;
}

.stock-sub .stock-price,
.stock-sub .stock-value {
  display: inline;
  margin-top: 0;
}

.card-sparkline {
  display: none;
}

/* Column sizing for Stock Grid */
.anomaly-table th:nth-child(1),
.anomaly-table td:nth-child(1) {
  width: 17%;
}

.anomaly-table th:nth-child(2),
.anomaly-table td:nth-child(2) {
  width: 21%;
  white-space: normal;
}

.anomaly-table th:nth-child(3),
.anomaly-table td:nth-child(3) {
  width: 7%;
}

.anomaly-table th:nth-child(4),
.anomaly-table td:nth-child(4) {
  width: 9%;
}

.anomaly-table th:nth-child(5),
.anomaly-table td:nth-child(5) {
  width: 11%;
}

.anomaly-table th:nth-child(6),
.anomaly-table td:nth-child(6) {
  width: 18%;
  white-space: normal;
}

.anomaly-table th:nth-child(7),
.anomaly-table td:nth-child(7) {
  width: 7%;
}

.anomaly-table th:nth-child(8),
.anomaly-table td:nth-child(8) {
  width: 10%;
}

/* Status badging & pills */
.risk-pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 24px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.anomaly-table .risk-pill,
.anomaly-table .score-pill {
  display: inline-flex;
  margin-top: 0;
}

.risk-pill.normal {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.risk-pill.warning {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
}

.score-pill.strong {
  background: rgba(37, 99, 235, 0.12);
  color: var(--blue);
}

.score-pill.watch {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.score-pill.wait {
  background: var(--panel-2);
  color: var(--muted);
}

.dimension-mini {
  display: grid;
  grid-template-columns: 44px minmax(34px, auto);
  align-items: center;
  gap: 4px;
  width: max-content;
  min-width: 82px;
  margin-top: 7px;
}

.dimension-mini svg {
  width: 44px;
  height: 44px;
  display: block;
}

.dimension-mini span {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
}

.mini-radar-ring {
  fill: rgba(37, 99, 235, 0.04);
  stroke: rgba(100, 116, 139, 0.3);
  stroke-width: 1.2;
}

.mini-radar-spoke {
  stroke: rgba(100, 116, 139, 0.18);
  stroke-width: 1;
}

.mini-radar-area {
  fill: rgba(37, 99, 235, 0.2);
}

.mini-radar-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

/* Research button setup */
.research-button {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--blue);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.research-button:hover,
.research-button.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

/* Inline Research detailed workbench */
.research-panel-body {
  margin-top: 4px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 20px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

.research-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.research-head strong,
.research-head span {
  display: block;
}

.research-head strong {
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
}

.research-head span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
}

.research-links {
  display: flex;
  flex: 1 1 auto;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.research-links a,
.copy-stock-code-button,
.copy-prompt-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid var(--line);
}

.research-links a {
  background: var(--panel);
  color: var(--ink);
}

.research-links a:hover {
  background: var(--panel-2);
  border-color: var(--muted);
}

.copy-stock-code-button {
  background: var(--panel);
  color: var(--ink);
}

.copy-stock-code-button:hover {
  background: var(--panel-2);
  border-color: var(--muted);
}

.copy-prompt-button {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.copy-prompt-button:hover {
  background: var(--blue-glow);
  border-color: var(--blue-glow);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.dimension-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 320px) minmax(240px, 1fr);
  gap: 16px;
  align-items: center;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.04), rgba(15, 118, 110, 0.03));
  padding: 16px;
}

.dimension-copy h4,
.dimension-copy p {
  margin: 0;
}

.dimension-copy h4 {
  margin-top: 4px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}

.dimension-copy p:last-child {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.setup-note {
  margin-top: 10px;
  border-left: 3px solid var(--amber);
  background: rgba(245, 158, 11, 0.08);
  border-radius: 8px;
  padding: 9px 10px;
}

.setup-note strong,
.setup-note span {
  display: block;
}

.setup-note strong {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 900;
}

.setup-note span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dimension-radar {
  display: grid;
  place-items: center;
}

.radar-chart {
  width: min(320px, 100%);
  height: auto;
}

.radar-ring {
  fill: none;
  stroke: rgba(100, 116, 139, 0.28);
  stroke-width: 1;
}

.radar-spoke {
  stroke: rgba(100, 116, 139, 0.22);
  stroke-width: 1;
}

.radar-area {
  fill: rgba(37, 99, 235, 0.18);
}

.radar-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.radar-dot {
  fill: #fff;
  stroke: var(--blue);
  stroke-width: 2.5;
}

.radar-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.dimension-bars {
  display: grid;
  gap: 10px;
}

.dimension-bar {
  display: grid;
  gap: 5px;
}

.dimension-bar div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dimension-bar strong {
  color: var(--ink);
  font-size: 12.5px;
}

.dimension-bar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dimension-bar i {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.18);
}

.dimension-bar i::before {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  content: "";
}

.research-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 18px;
}

.research-columns section {
  min-width: 0;
  background: var(--panel);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.research-columns h4 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 800;
  border-left: 3px solid var(--blue);
  padding-left: 8px;
}

.research-columns ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.research-columns li {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.research-columns li:first-child {
  border-top: 0;
  padding-top: 0;
}

.research-columns li strong {
  display: block;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
}

.research-columns li span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.research-detail-row td {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--bg);
  padding: 8px;
  white-space: normal;
}

.inline-research {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* Prompt fallback copy panels */
.prompt-fallback {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  border: 1px solid var(--blue-glow);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.03);
  padding: 16px;
}

.prompt-fallback-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.prompt-fallback h4 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.prompt-fallback p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.select-prompt-button {
  height: 32px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--panel);
  color: var(--blue);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.15s ease;
}

#exportInstitutionalBtn {
  min-width: 124px;
}

.select-prompt-button:hover {
  background: var(--blue);
  color: #ffffff;
}

.prompt-fallback-textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  outline: none;
}

/* SVG Chart visual redesign */
.stock-detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  margin-bottom: 18px;
}

.stock-detail-grid h4,
.detail-subsections h4 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 800;
  border-left: 3px solid var(--blue);
  padding-left: 8px;
}

.chart-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chart-tab {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.chart-tab:hover {
  color: var(--ink);
}

.chart-tab.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.detail-chart {
  width: 100%;
  height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chart-wrap {
  position: relative;
}

.detail-chart .chart-grid {
  stroke: var(--line);
  stroke-width: 0.8;
}

.detail-chart .chart-axis {
  stroke: var(--line);
  stroke-width: 1.5;
}

.detail-chart polyline {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-chart text {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.detail-chart .chart-y-label {
  text-anchor: end;
}

.detail-chart .chart-pct-label {
  text-anchor: start;
}

.detail-chart .chart-axis-title {
  text-anchor: end;
  font-weight: 700;
  fill: var(--muted);
}

.detail-chart .chart-summary,
.detail-chart .chart-last-label {
  fill: var(--blue);
  font-weight: 700;
}

.detail-chart .chart-hover-line {
  stroke: var(--muted);
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
}

.detail-chart .chart-hover-dot {
  fill: var(--panel);
  stroke: var(--blue);
  stroke-width: 2.5;
}

.detail-chart .chart-hover-zone {
  fill: transparent;
  pointer-events: all;
  cursor: crosshair;
}

.detail-chart .chart-last-dot {
  fill: var(--panel);
  stroke: var(--blue);
  stroke-width: 2.5;
}

/* Custom Interactive Tooltip */
.chart-tooltip {
  position: absolute;
  z-index: 50;
  width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  transition: opacity 0.1s ease;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip strong {
  margin-bottom: 6px;
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.chart-tooltip span {
  color: var(--ink);
  font-weight: 500;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

/* Company grid details lists */
.detail-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
}

.detail-list li strong,
.detail-list li span {
  display: block;
}

.detail-list li strong {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}

.detail-list li span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.detail-subsections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 18px;
}

.detail-subsections article {
  border-top: 1px solid var(--line);
  margin: 0;
  padding-top: 10px;
}

.detail-subsections article + article {
  margin-top: 10px;
}

.detail-subsections strong,
.detail-subsections span {
  display: block;
}

.detail-subsections strong {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
}

.detail-subsections span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 3px;
}

.anomaly-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 20px;
  margin-top: 24px;
}

/* User Flow Checklists styling */
.flow-list {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.flow-list li {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 14px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.flow-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.flow-list strong {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Scoring quick forms */
.quick-score-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.quick-score-form label {
  display: grid;
  gap: 6px;
}

.quick-score-form label:first-child {
  grid-column: 1 / -1;
}

.quick-score-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quick-score-form input,
.quick-score-form select {
  width: 100%;
}

.quick-score-form button {
  grid-column: 1 / -1;
  height: 40px;
}

.quick-result {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.quick-result strong,
.quick-result span {
  display: block;
}

.quick-result strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.codex-brief {
  margin-top: 16px;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 16px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.brief-section {
  scroll-margin-top: 24px;
}

.brief-section:focus {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

/* Backtesting Panels */
.backtest-result {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.backtest-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.backtest-warning {
  margin: 0;
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.05);
  color: var(--amber);
  padding: 12px 14px;
  font-weight: 550;
  line-height: 1.5;
  font-size: 13px;
}

.backtest-metrics article,
.backtest-date-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.backtest-metrics span,
.backtest-date-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.backtest-metrics strong,
.backtest-date-list strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.backtest-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.backtest-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
}

.backtest-table th,
.backtest-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

.backtest-table th {
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 750;
}

.backtest-date-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* Home Dashboard Subfeature cards */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.status-grid article,
.data-section,
.assistant-section,
.workbook-section,
.option-volume-section,
.institutional-section,
.official-institutional-section,
.yahoo-margin-section,
.live-entry-section,
.live-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.status-grid article {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.status-grid span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.status-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
}

.status-grid .range-card strong {
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
}

.status-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.status-card-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  margin-top: 14px;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
}

.status-card-link:hover {
  background: var(--blue-glow);
  transform: translateY(-1px);
}

.subfeature-card {
  border-color: var(--blue-glow);
  background: linear-gradient(180deg, var(--panel) 0%, rgba(37, 99, 235, 0.02) 100%);
}

.data-section {
  padding: 20px;
  margin-top: 24px;
}

.workbook-section,
.assistant-section,
.option-volume-section,
.institutional-section,
.official-institutional-section,
.yahoo-margin-section,
.live-entry-section,
.live-section {
  padding: 20px;
  margin-top: 24px;
}

.assistant-section {
  overflow: hidden;
  border-color: #d6e0ed;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 251, 255, 0.98));
}

.assistant-heading {
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid #e1e8f2;
}

.assistant-meta {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  text-align: right;
}

.assistant-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.assistant-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.assistant-hero {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: stretch;
}

.assistant-narrative,
.assistant-signal-stack {
  min-width: 0;
  padding: 16px;
  border: 1px solid #dce6f1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 35, 65, 0.06);
}

.assistant-narrative {
  position: relative;
  padding-left: 18px;
}

.assistant-narrative::before {
  content: "";
  position: absolute;
  inset: 16px auto 16px 0;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2563eb, #0f9f6e);
}

.assistant-kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.assistant-narrative p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  font-weight: 820;
}

.assistant-signal-stack {
  display: grid;
  align-content: space-between;
  gap: 14px;
}

.assistant-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.assistant-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #dce6f1;
  border-radius: 6px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.assistant-pill strong {
  color: var(--ink);
  font-size: 12.5px;
}

.assistant-pill.up strong {
  color: var(--red);
}

.assistant-pill.down strong {
  color: var(--green);
}

.assistant-source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.assistant-source {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #dce6f1;
  border-radius: 999px;
  color: var(--muted);
  background: #ffffff;
  font-size: 11.5px;
  font-weight: 750;
}

.assistant-source.ready {
  border-color: rgba(10, 153, 88, 0.22);
  color: #087f4e;
  background: #eefaf4;
}

.assistant-source.missing {
  border-color: rgba(205, 83, 83, 0.2);
  color: #a04b4b;
  background: #fff6f5;
}

.assistant-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
}

.assistant-metric {
  min-height: 92px;
  padding: 13px 12px;
  border: 1px solid #dce6f1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 35, 65, 0.045);
}

.assistant-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.assistant-metric strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.2;
  font-weight: 850;
}

.assistant-metric p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.assistant-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.assistant-columns article {
  padding: 14px 16px;
  border: 1px solid #dce6f1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 35, 65, 0.045);
}

.assistant-columns h4 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.assistant-columns ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.6;
}

.assistant-columns li + li {
  margin-top: 6px;
}

.live-meta,
.option-volume-meta,
.institutional-meta,
.official-institutional-meta,
.yahoo-margin-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  text-align: right;
}

/* Beautiful Spreadsheet Layouts */
.workbook-board {
  margin-top: 16px;
  max-height: 580px;
  overflow: auto;
  border: 1px solid #94a3b8;
  border-radius: 0;
  background: #ffffff;
}

.option-volume-board {
  margin-top: 16px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid #94a3b8;
  border-radius: 0;
  background: #ffffff;
}

.institutional-board {
  margin-top: 16px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #94a3b8;
  border-radius: 0;
  background: #ffffff;
}

.official-institutional-board {
  margin-top: 16px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #94a3b8;
  border-radius: 0;
  background: #ffffff;
}

.yahoo-margin-board {
  margin-top: 16px;
  max-height: 380px;
  overflow: auto;
  border: 1px solid #94a3b8;
  border-radius: 0;
  background: #ffffff;
}

.live-board {
  margin-top: 16px;
  max-height: 480px;
  overflow: auto;
  border: 1px solid #94a3b8;
  border-radius: 0;
  background: #ffffff;
}

.live-page-board {
  max-height: calc(100vh - 210px);
}

.sheet-wrap {
  min-width: 0;
  scrollbar-gutter: stable;
}

.workbook-split {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: max-content;
  min-width: max-content;
  margin-left: auto;
  margin-right: auto;
}

.sheet-split {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: max-content;
  min-width: max-content;
  margin-left: auto;
  margin-right: auto;
}

.workbook-split .excel-sheet {
  margin-left: 0;
  margin-right: 0;
}

.sheet-split .option-volume-sheet,
.sheet-split .institutional-sheet,
.sheet-split .official-institutional-sheet,
.sheet-split .yahoo-margin-sheet {
  margin-left: 0;
  margin-right: 0;
}

.workbook-split .excel-sheet thead tr:nth-child(2) th {
  height: 38px;
}

.workbook-date-sheet .workbook-date-head {
  height: 66px;
}

.option-volume-date-sheet th,
.institutional-date-sheet th,
.official-institutional-date-sheet th,
.yahoo-margin-date-sheet th {
  height: 66px;
}

.institutional-date-sheet th {
  height: 83px;
}

.excel-sheet,
.option-volume-sheet,
.institutional-sheet,
.official-institutional-sheet,
.yahoo-margin-sheet,
.live-sheet {
  border-collapse: collapse;
  width: max-content;
  max-width: none;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid #94a3b8;
  font-size: var(--sheet-font-size);
  font-weight: 500;
  font-family: var(--font-sans);
}

.excel-sheet {
  min-width: max-content;
}

.option-volume-sheet {
  min-width: max-content;
}

.yahoo-margin-sheet {
  min-width: max-content;
}

.official-institutional-sheet {
  min-width: max-content;
}

.institutional-sheet {
  min-width: max-content;
}

.excel-sheet thead,
.option-volume-sheet thead,
.institutional-sheet thead,
.official-institutional-sheet thead,
.yahoo-margin-sheet thead {
  position: sticky;
  top: 0;
  z-index: 30;
}

.excel-sheet th,
.excel-sheet td,
.option-volume-sheet th,
.option-volume-sheet td,
.institutional-sheet th,
.institutional-sheet td,
.official-institutional-sheet th,
.official-institutional-sheet td,
.yahoo-margin-sheet th,
.yahoo-margin-sheet td,
.live-sheet td {
  border: 1px solid var(--excel-border);
  border-color: #b8c6d6;
  min-width: var(--sheet-num-col);
  padding: var(--sheet-pad-y) var(--sheet-pad-x);
  height: 28px;
  line-height: 1.3;
  white-space: nowrap;
}

.excel-sheet th,
.option-volume-sheet th,
.institutional-sheet th,
.official-institutional-sheet th,
.yahoo-margin-sheet th {
  text-align: center;
  font-weight: 800;
  font-size: var(--sheet-head-font-size);
  background: var(--excel-th-bg);
  color: var(--ink);
  line-height: 1.16;
  white-space: normal;
  box-shadow: inset 0 0 0 1px #94a3b8;
  background-clip: padding-box;
}

.excel-sheet td,
.option-volume-sheet td,
.institutional-sheet td,
.official-institutional-sheet td,
.yahoo-margin-sheet td,
.live-sheet td {
  background: var(--excel-td-bg);
  color: var(--ink);
}

/* Dynamic Spreadsheet category mappings */
.excel-sheet .sticky-col,
.option-volume-sheet .sticky-col,
.institutional-sheet .sticky-col,
.official-institutional-sheet .sticky-col,
.yahoo-margin-sheet .sticky-col,
.live-sheet .sticky-col {
  position: sticky;
  left: 0;
  z-index: 20;
  background: #ffffff !important;
  box-shadow: inset 0 0 0 1px #94a3b8, 1px 0 0 #94a3b8;
}

.excel-sheet th.sticky-col,
.option-volume-sheet th.sticky-col,
.institutional-sheet th.sticky-col,
.official-institutional-sheet th.sticky-col,
.yahoo-margin-sheet th.sticky-col {
  z-index: 40;
}

.excel-sheet .sheet-date {
  color: var(--blue);
  font-weight: 700;
  min-width: var(--sheet-date-col);
  width: var(--sheet-date-col);
  text-align: left;
}

.excel-sheet .sheet-date.week-mark {
  color: var(--blue-glow);
  text-decoration: none;
}

.excel-sheet td span,
.live-sheet td span {
  display: inline-block;
  margin-left: 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.excel-sheet .price-value {
  margin-left: 0;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.excel-sheet .contract-month {
  user-select: none;
}

/* 臺灣盤面慣例：漲紅、跌綠。 */
.excel-sheet .change.up,
.option-volume-sheet .change.up,
.official-institutional-sheet .change.up,
.yahoo-margin-sheet .change.up {
  color: var(--red);
  font-weight: 700;
}

.excel-sheet .change.down,
.option-volume-sheet .change.down,
.official-institutional-sheet .change.down,
.yahoo-margin-sheet .change.down {
  color: var(--green);
  font-weight: 700;
}

.excel-sheet .change.flat,
.option-volume-sheet .change.flat,
.official-institutional-sheet .change.flat,
.yahoo-margin-sheet .change.flat {
  color: var(--muted);
}

/* Polished pastel category cells */
.excel-sheet .matrix-cell {
  background: var(--excel-matrix-bg);
}

.excel-sheet .matrix-col {
  min-width: var(--sheet-matrix-col);
  width: var(--sheet-matrix-col);
  padding-left: 3px;
  padding-right: 3px;
}

.excel-sheet .price-head,
.excel-sheet .price-cell {
  min-width: var(--sheet-price-col);
  width: var(--sheet-price-col);
}

.excel-sheet .change-head,
.excel-sheet .change-cell {
  min-width: var(--sheet-change-col);
  width: var(--sheet-change-col);
  padding-left: 3px;
  padding-right: 3px;
}

.excel-sheet .next-cell {
  background: var(--excel-next-head);
}

.excel-sheet .post-matrix-head,
.excel-sheet .post-matrix-cell {
  border-left-color: #64748b;
  border-left-width: 3px;
  box-shadow: inset 3px 0 0 #64748b, inset 0 0 0 1px #94a3b8;
}

.excel-sheet .post-matrix-cell {
  padding-left: 6px;
}

.excel-sheet .emphasis-head,
.excel-sheet .emphasis-cell,
.excel-sheet .emphasis-cell .price-value {
  font-weight: 900;
  font-style: italic;
}

.excel-sheet .event-cell,
.excel-sheet .matrix-cell.event-cell {
  background: var(--excel-event-bg);
  color: var(--excel-event-text);
  font-weight: 800;
  box-shadow: inset 0 0 0 2px var(--excel-event-border);
  position: relative;
}

/* Columns head overrides */
.excel-sheet .date-head,
.option-volume-sheet .date-head,
.institutional-sheet .date-head,
.official-institutional-sheet .date-head,
.yahoo-margin-sheet .date-head {
  background: #ffffff;
  min-width: var(--sheet-date-col);
  width: var(--sheet-date-col);
}

.excel-sheet .matrix-head {
  background: var(--excel-matrix-head);
}

.excel-sheet .green-head {
  background: var(--excel-green-head);
}

.excel-sheet .index-head {
  background: var(--excel-th-bg);
}

.excel-sheet .yellow-head {
  background: var(--excel-yellow-head);
}

.excel-sheet .purple-head {
  background: #d7b5ff;
}

.excel-sheet .next-head {
  background: var(--excel-next-head);
}

.excel-sheet .index-cell {
  background: var(--excel-green-bg);
}

.excel-sheet .future-cell {
  background: var(--excel-yellow-bg);
}

.excel-sheet .purple-cell {
  background: #d7b5ff;
}

/* Option volume table color coding */
.option-volume-sheet th {
  background: #d1fae5;
  border-color: #94a3b8;
  color: #0f172a;
  font-weight: 850;
}

.option-volume-sheet td {
  background: #ffffff;
  border-color: #b8c6d6;
  font-size: 12.5px;
  font-weight: 650;
  height: 31px;
}

.option-volume-data-sheet thead tr:first-child th:nth-child(3),
.option-volume-data-sheet thead tr:nth-child(2) th:nth-child(n+5),
.option-volume-data-sheet tbody td:nth-child(n+6):nth-child(-n+9) {
  background: var(--excel-next-head);
}

.option-volume-data-sheet thead tr:first-child th:nth-child(2),
.option-volume-data-sheet thead tr:nth-child(2) th:nth-child(-n+4),
.option-volume-data-sheet tbody td:nth-child(n+2):nth-child(-n+5) {
  background: var(--excel-green-head);
}

.option-volume-data-sheet thead tr:first-child th:nth-child(1),
.option-volume-data-sheet tbody td.option-volume-purple {
  font-style: italic;
  font-weight: 900 !important;
}

.option-volume-data-sheet thead tr:first-child th:nth-child(1),
.option-volume-sheet tbody td.option-volume-purple {
  background: #eadcff;
}

.option-volume-data-sheet thead tr:nth-child(2) th:nth-child(6),
.option-volume-data-sheet thead tr:nth-child(2) th:nth-child(8),
.option-volume-data-sheet tbody td:nth-child(7),
.option-volume-data-sheet tbody td:nth-child(9) {
  background: #eadcff !important;
}

.option-volume-sheet .volume-date {
  background: #ffffff;
  color: var(--blue);
  font-weight: 850;
  min-width: var(--sheet-date-col);
  width: var(--sheet-date-col);
  text-align: left;
}

.institutional-sheet th {
  background: #eeeeee;
  color: #111827;
  font-size: var(--sheet-head-font-size);
  line-height: 1.18;
  min-width: var(--sheet-compact-col);
  white-space: normal;
}

.institutional-sheet th:first-child,
.institutional-sheet .institutional-date {
  min-width: var(--sheet-date-col);
  width: var(--sheet-date-col);
}

.institutional-data-sheet th:first-child,
.institutional-data-sheet td:first-child {
  min-width: var(--sheet-compact-col);
  width: auto;
}

.institutional-sheet td {
  font-size: var(--sheet-font-size);
  font-weight: 650;
  min-width: var(--sheet-compact-col);
}

.institutional-sheet .institutional-date {
  background: var(--panel);
  color: var(--blue);
  font-weight: 800;
  text-align: left;
}

.institutional-sheet .p3-yellow {
  background: var(--excel-next-head);
}

.institutional-sheet .p3-orange {
  background: #ffc94d;
}

.institutional-sheet .p3-gray {
  background: #bfbfbf;
}

.institutional-sheet .p3-purple {
  background: #d7b5ff;
  font-style: italic;
  font-weight: 900;
}

.institutional-sheet .p3-blue {
  background: #a8dcff;
}

.institutional-sheet .p3-white {
  background: #ffffff;
}

.institutional-data-sheet thead tr:first-child th:nth-child(3),
.institutional-data-sheet thead tr:first-child th:nth-child(5),
.institutional-data-sheet thead tr:nth-child(2) th:nth-child(5),
.institutional-data-sheet thead tr:nth-child(2) th:nth-child(n+9):nth-child(-n+11),
.institutional-data-sheet thead tr:nth-child(3) th:nth-child(-n+2),
.institutional-data-sheet thead tr:nth-child(3) th:nth-child(n+6):nth-child(-n+10),
.institutional-data-sheet tbody td:nth-child(n+5):nth-child(-n+6),
.institutional-data-sheet tbody td:nth-child(n+10):nth-child(-n+14) {
  background: var(--excel-next-head);
}

.institutional-data-sheet thead tr:first-child th:nth-child(4),
.institutional-data-sheet thead tr:first-child th:nth-child(6),
.institutional-data-sheet thead tr:nth-child(2) th:nth-child(n+6):nth-child(-n+8),
.institutional-data-sheet thead tr:nth-child(2) th:nth-child(n+12):nth-child(-n+14),
.institutional-data-sheet thead tr:nth-child(3) th:nth-child(n+3):nth-child(-n+5),
.institutional-data-sheet thead tr:nth-child(3) th:nth-child(n+11):nth-child(-n+16),
.institutional-data-sheet tbody td:nth-child(n+7):nth-child(-n+9),
.institutional-data-sheet tbody td:nth-child(n+15):nth-child(-n+20) {
  background: var(--excel-green-head);
}

.institutional-sheet tbody td.num.p3-purple-soft {
  background: #eadcff;
  font-style: italic;
  font-weight: 900;
}

.institutional-sheet .is-negative {
  color: var(--green);
  font-weight: 800;
}

.institutional-sheet .is-positive {
  color: var(--red);
  font-weight: 800;
}

.institutional-sheet .is-flat {
  color: #111827;
}

.institutional-sheet tbody td.num.p3-purple,
.institutional-sheet tbody td.num.p3-purple-soft {
  font-style: italic;
  font-weight: 900;
}

.institutional-data-sheet thead tr:nth-child(3) th:nth-child(2),
.institutional-data-sheet thead tr:nth-child(3) th:nth-child(9),
.institutional-data-sheet thead tr:nth-child(3) th:nth-child(16),
.institutional-data-sheet tbody td:nth-child(6),
.institutional-data-sheet tbody td:nth-child(13),
.institutional-data-sheet tbody td:nth-child(20) {
  font-style: italic;
  font-weight: 900;
}

.official-institutional-sheet th {
  background: #f8fafc;
}

.official-institutional-data-sheet thead tr:first-child th:nth-child(1),
.official-institutional-data-sheet thead tr:nth-child(2) th:nth-child(-n+4),
.official-institutional-data-sheet tbody td:nth-child(-n+4) {
  background: var(--excel-next-head);
}

.official-institutional-data-sheet thead tr:first-child th:nth-child(2),
.official-institutional-data-sheet thead tr:nth-child(2) th:nth-child(n+5):nth-child(-n+8),
.official-institutional-data-sheet tbody td:nth-child(n+5):nth-child(-n+8) {
  background: var(--excel-green-head);
}

.official-institutional-data-sheet tbody td:nth-child(4),
.official-institutional-data-sheet tbody td:nth-child(8) {
  font-weight: 800;
}

.official-institutional-data-sheet tbody td.change:nth-child(1),
.official-institutional-data-sheet tbody td.change:nth-child(4) {
  font-style: italic;
  font-weight: 900;
}

.official-institutional-sheet .official-institutional-date {
  background: var(--panel);
  color: var(--blue);
  font-weight: 700;
  min-width: var(--sheet-date-col);
  width: var(--sheet-date-col);
  text-align: left;
}

.yahoo-margin-sheet th {
  background: var(--excel-matrix-head);
}

.yahoo-margin-financing-sheet thead th,
.yahoo-margin-financing-sheet tbody td {
  background: var(--excel-next-head);
}

.yahoo-margin-data-sheet tbody td:nth-child(1),
.yahoo-margin-data-sheet tbody td:nth-child(2) {
  background: #f0fdf4;
}

.yahoo-margin-financing-sheet tbody td.change:nth-child(1) {
  font-style: italic;
  font-weight: 900;
}

.yahoo-margin-financing-sheet tbody td.margin-purple {
  background: #d7b5ff;
}

.yahoo-margin-data-sheet tbody td:nth-child(4),
.yahoo-margin-data-sheet tbody td:nth-child(5) {
  background: var(--excel-next-bg);
}

.yahoo-margin-sheet .margin-date {
  background: var(--panel);
  color: var(--blue);
  font-weight: 700;
  min-width: var(--sheet-date-col);
  width: var(--sheet-date-col);
  text-align: left;
}

/* Live DDE snapshot layout */
.live-sheet {
  background: var(--excel-td-bg);
}

.live-sheet td.live-head {
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  padding: 16px !important;
}

.selected-stock-bar {
  display: none;
}

/* Visual Toasts notifications */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 2147483400;
  transform: translateX(-50%);
  max-width: min(480px, calc(100vw - 40px));
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: 14.5px;
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.is-error {
  background: var(--red);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Responsive breakdowns */
@media (max-width: 1024px) {
  .anomaly-workspace {
    padding: 20px 14px;
  }

  .anomaly-topbar {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  .anomaly-topbar .actions {
    gap: 8px;
  }

  .anomaly-topbar .actions button,
  .anomaly-topbar .entry-button {
    height: 36px;
    padding: 0 13px;
    font-size: 12.5px;
  }

  .anomaly-overview {
    gap: 10px;
    margin-bottom: 14px;
  }

  .anomaly-overview article {
    padding: 14px 16px;
  }

  .anomaly-overview strong {
    margin-top: 4px;
    font-size: 28px;
  }

  .anomaly-overview p {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
  }

  .anomaly-section {
    margin-top: 14px;
    padding: 14px;
    border-radius: 10px;
  }

  .anomaly-section .section-heading {
    gap: 10px;
  }

  .anomaly-section .section-heading h3 {
    font-size: 24px;
  }

  .anomaly-section .option-volume-meta {
    font-size: 12px;
  }

  .filter-button {
    height: 31px;
    padding: 0 12px;
    font-size: 12px;
  }

  .anomaly-table-wrap {
    margin-top: 10px;
  }

  .anomaly-table {
    min-width: 780px;
  }

  .anomaly-table th,
  .anomaly-table td {
    padding: 9px 8px;
    font-size: 12.5px;
  }

  .anomaly-table td strong {
    font-size: 13px;
  }

  .anomaly-table td span {
    font-size: 11px;
  }

  .stock-sub .stock-value {
    display: none;
  }

  .dimension-mini {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 1px;
    min-width: 42px;
    width: 42px;
    margin-top: 0;
  }

  .dimension-mini svg {
    width: 34px;
    height: 34px;
  }

  .dimension-mini span {
    font-size: 9.5px;
    white-space: nowrap;
  }

  .anomaly-grid {
    grid-template-columns: 1fr;
  }
  .stock-detail-grid {
    grid-template-columns: 1fr;
  }
  .dimension-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .assistant-hero,
  .assistant-columns {
    grid-template-columns: 1fr;
  }

  .assistant-chip-row,
  .assistant-source-row {
    justify-content: flex-start;
  }

  .assistant-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .anomaly-overview {
    grid-template-columns: 1fr 1fr;
  }

  .anomaly-overview article {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
    min-height: 0;
  }

  .anomaly-overview span {
    grid-column: 1 / -1;
    font-size: 12px;
  }

  .anomaly-overview strong {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    font-size: 30px;
    line-height: 1;
  }

  .anomaly-overview p {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
  }

  .anomaly-section .section-heading {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto;
    align-items: center;
  }

  .anomaly-section .section-heading > .option-volume-meta {
    grid-column: 1 / -1;
    order: 3;
    margin: -2px 0 0;
  }

  .anomaly-filters {
    justify-content: flex-end;
    gap: 7px;
  }

  .backtest-metrics,
  .backtest-date-list,
  .research-columns,
  .detail-subsections,
  .detail-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --sheet-date-col: 52px;
    --sheet-num-col: 54px;
    --sheet-compact-col: 46px;
    --sheet-matrix-col: 40px;
    --sheet-price-col: 54px;
    --sheet-change-col: 32px;
    --sheet-pad-x: 3px;
    --sheet-pad-y: 4px;
    --sheet-font-size: 11px;
    --sheet-head-font-size: 10.5px;
  }

  .workspace {
    padding: 18px 12px;
  }

  .anomaly-workspace {
    padding: 12px 8px;
  }

  .anomaly-topbar {
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .anomaly-topbar .brand-title img {
    width: 34px;
    height: 34px;
  }

  .anomaly-topbar h2 {
    font-size: 21px;
  }

  .anomaly-topbar .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    width: 100%;
  }

  .anomaly-topbar .actions button,
  .anomaly-topbar .entry-button {
    width: 100%;
    height: 34px;
    padding: 0 9px;
    font-size: 11.5px;
  }

  .anomaly-overview {
    gap: 8px;
    margin-bottom: 10px;
  }

  .anomaly-overview article {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 10px;
    border-radius: 9px;
  }

  .anomaly-overview span {
    font-size: 11px;
  }

  .anomaly-overview strong {
    font-size: 24px;
  }

  .anomaly-overview p {
    font-size: 11px;
    line-height: 1.25;
  }

  .anomaly-section {
    margin-top: 10px;
    padding: 10px;
    border-radius: 9px;
  }

  .assistant-section {
    padding: 12px;
    margin-top: 14px;
    border-radius: 9px;
  }

  .assistant-heading {
    gap: 8px;
  }

  .assistant-meta {
    width: 100%;
    text-align: left;
  }

  .assistant-narrative,
  .assistant-signal-stack {
    padding: 12px;
  }

  .assistant-narrative p {
    font-size: 14px;
  }

  .assistant-metrics {
    grid-template-columns: 1fr;
  }

  .assistant-metric {
    min-height: 0;
  }

  .anomaly-section .section-heading {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .anomaly-section .section-heading h3 {
    font-size: 21px;
  }

  .anomaly-section .section-heading > .option-volume-meta {
    grid-column: auto;
    margin: 0;
  }

  .anomaly-filters {
    justify-content: flex-start;
  }

  .filter-button {
    height: 30px;
    padding: 0 10px;
  }

  .anomaly-table {
    min-width: 760px;
  }

  .anomaly-table th,
  .anomaly-table td {
    padding: 8px 7px;
    font-size: 12px;
  }

  .risk-pill,
  .score-pill {
    min-width: 40px;
    height: 22px;
    font-size: 10.5px;
  }

  .research-button {
    height: 28px;
    padding: 0 8px;
    font-size: 11.5px;
  }

  .workbook-section,
  .option-volume-section,
  .institutional-section,
  .official-institutional-section,
  .yahoo-margin-section,
  .live-entry-section,
  .live-section {
    padding: 14px;
  }

  .section-heading {
    align-items: flex-start;
    gap: 10px;
  }

  .section-actions {
    gap: 8px;
  }

  .section-actions button {
    padding: 0 12px;
  }

  .live-meta,
  .option-volume-meta,
  .institutional-meta,
  .official-institutional-meta,
  .yahoo-margin-meta {
    font-size: 11.5px;
  }

  .excel-sheet td span,
  .live-sheet td span {
    margin-left: 3px;
    font-size: 10px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .actions label {
    width: 100%;
  }

  input,
  select,
  .actions button {
    width: 100%;
  }

  .topbar h2 {
    font-size: 22px;
  }
}

@media (max-width: 780px) {
  .anomaly-workspace {
    padding: 10px 8px;
  }

  .selected-stock-bar {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 8px;
    right: 8px;
    z-index: 2147483200;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    padding: 7px;
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-110%);
    transition: opacity 0.16s ease, transform 0.16s ease;
  }

  .selected-stock-bar[hidden] {
    display: none;
  }

  .selected-stock-bar.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .selected-stock-bar-main,
  .selected-stock-bar-close {
    border: 0;
    font: inherit;
  }

  .selected-stock-bar-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "title meta"
      "risk risk";
    align-items: center;
    gap: 2px 8px;
    min-width: 0;
    padding: 5px 6px;
    border-radius: 9px;
    background: rgba(37, 99, 235, 0.07);
    color: var(--ink);
    text-align: left;
  }

  .selected-stock-bar-title {
    grid-area: title;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 900;
    white-space: nowrap;
  }

  .selected-stock-bar-meta {
    grid-area: meta;
    min-width: 0;
    color: var(--blue);
    font-size: 11px;
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .selected-stock-bar-risk {
    grid-area: risk;
    min-width: 0;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .selected-stock-bar-close {
    width: 54px;
    height: 42px;
    border: 1px solid rgba(220, 38, 38, 0.22);
    border-radius: 10px;
    background: rgba(254, 226, 226, 0.9);
    color: var(--red);
    font-size: 12px;
    font-weight: 900;
  }

  .anomaly-topbar {
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  .anomaly-topbar .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    width: 100%;
  }

  .anomaly-topbar .actions button,
  .anomaly-topbar .entry-button {
    width: 100%;
    height: 34px;
    padding: 0 8px;
    font-size: 11.5px;
  }

  .anomaly-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .anomaly-overview article {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 10px;
    border-radius: 9px;
    column-gap: 8px;
  }

  .anomaly-overview span {
    font-size: 11px;
  }

  .anomaly-overview strong {
    font-size: 25px;
  }

  .anomaly-overview p {
    font-size: 11px;
    line-height: 1.25;
  }

  .anomaly-section {
    padding: 10px;
    margin-top: 10px;
  }

  .anomaly-section .section-heading {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .anomaly-section .section-heading h3 {
    font-size: 24px;
  }

  .anomaly-section .section-heading > .option-volume-meta {
    grid-column: auto;
    margin: 0;
    font-size: 12px;
  }

  .anomaly-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    justify-content: stretch;
  }

  .filter-button {
    width: 100%;
    height: 32px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 12px;
  }

  .anomaly-table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .anomaly-table {
    display: block;
    min-width: 0;
  }

  .anomaly-table thead {
    display: none;
  }

  .anomaly-table tbody {
    display: grid;
    gap: 7px;
  }

  .anomaly-table .candidate-row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "stock stock stock"
      "reason reason reason"
      "volume strength kd"
      "risk risk action";
    gap: 5px 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    padding: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
  }

  .anomaly-table .candidate-row:hover,
  .anomaly-table .candidate-row:focus-visible {
    background: var(--panel);
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
    outline: none;
  }

  .anomaly-table .candidate-row > td {
    display: block;
    width: auto !important;
    border: 0;
    padding: 0;
    white-space: normal;
  }

  .anomaly-table .candidate-row > td:nth-child(1) {
    grid-area: stock;
  }

  .anomaly-table .candidate-row > td:nth-child(2) {
    grid-area: reason;
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.2;
  }

  .anomaly-table .candidate-row > td:nth-child(3) {
    grid-area: volume;
  }

  .anomaly-table .candidate-row > td:nth-child(4) {
    grid-area: strength;
  }

  .anomaly-table .candidate-row > td:nth-child(5) {
    grid-area: kd;
  }

  .anomaly-table .candidate-row > td:nth-child(6) {
    grid-area: risk;
    justify-self: stretch;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: left;
    min-width: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.18;
  }

  .anomaly-table .candidate-row > td:nth-child(7) {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
  }

  .anomaly-table .candidate-row > td:nth-child(8) {
    grid-area: action;
    align-self: center;
    justify-self: end;
  }

  .anomaly-table .candidate-row > td:nth-child(3),
  .anomaly-table .candidate-row > td:nth-child(4),
  .anomaly-table .candidate-row > td:nth-child(5) {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    border-radius: 7px;
    background: var(--panel-2);
    padding: 2px 5px;
    box-sizing: border-box;
    white-space: nowrap;
  }

  .anomaly-table .candidate-row > td:nth-child(3)::before,
  .anomaly-table .candidate-row > td:nth-child(4)::before,
  .anomaly-table .candidate-row > td:nth-child(5)::before {
    display: inline-block;
    min-width: 0;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
  }

  .anomaly-table .candidate-row > td:nth-child(3)::before {
    content: "量能";
  }

  .anomaly-table .candidate-row > td:nth-child(4)::before {
    content: "相對";
  }

  .anomaly-table .candidate-row > td:nth-child(5)::before {
    content: "KD";
  }

  .anomaly-table .candidate-row .num {
    text-align: left;
    font-size: 11.5px;
    font-weight: 800;
  }

  .anomaly-table .candidate-row .kd-cell {
    font-size: 0;
  }

  .anomaly-table .candidate-row .kd-cell::after {
    content: attr(data-compact);
    color: var(--ink);
    font-size: 11.5px;
    font-weight: 800;
  }

  .stock-cell {
    grid-template-columns: minmax(92px, 0.64fr) 72px minmax(0, 1fr);
    grid-template-areas: "main radar spark";
    align-items: center;
    gap: 8px;
    padding-right: 52px;
  }

  .card-sparkline {
    grid-area: spark;
    position: relative;
    display: block;
    min-width: 0;
    min-height: 58px;
    margin-top: 0;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.06);
    padding: 6px 7px 14px;
  }

  .card-sparkline svg {
    width: 100%;
    height: 38px;
    display: block;
  }

  .card-sparkline polyline {
    fill: none;
    stroke: var(--blue);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .card-sparkline.is-down polyline {
    stroke: var(--red);
  }

  .card-sparkline span {
    position: absolute;
    right: 7px;
    bottom: 2px;
    margin: 0;
    color: var(--blue);
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
  }

  .anomaly-table td strong {
    font-size: 15px;
  }

  .anomaly-table td span {
    font-size: 12px;
  }

  .stock-sub .stock-value {
    display: none;
  }

  .anomaly-table .dimension-mini {
    grid-area: radar;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1px;
    min-height: 58px;
    min-width: 0;
    width: 100%;
    margin: 0;
    border-radius: 8px;
    background: rgba(100, 116, 139, 0.08);
    padding: 2px 6px;
    box-sizing: border-box;
  }

  .anomaly-table .dimension-mini svg {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
  }

  .anomaly-table .dimension-mini span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
  }

  .risk-pill,
  .score-pill {
    min-width: 42px;
    height: 24px;
    font-size: 11px;
  }

  .research-button {
    width: 74px;
    height: 30px;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 11.5px;
  }

  .anomaly-table .research-detail-row {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .anomaly-table .research-detail-row > td {
    display: block;
    width: 100% !important;
    padding: 0 !important;
    border: 0;
    box-sizing: border-box;
  }

  .research-panel-body {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border-radius: 10px;
  }
}
