:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --panel-2: #edf2f6;
  --text: #17202a;
  --muted: #657284;
  --line: #d9e1ea;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --green: #16803c;
  --red: #c24132;
  --shadow: 0 10px 24px rgba(23, 32, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
button { font: inherit; }
a { color: inherit; }
main { min-height: 100vh; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 249, 0.93);
  backdrop-filter: blur(12px);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.1; }
h2 { font-size: 16px; }
h3 { margin-top: 18px; font-size: 13px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0; }

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 18px 24px;
}
.stock-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 28px;
}
.sidebar, .content { display: flex; flex-direction: column; gap: 16px; }
.content, .panel { min-width: 0; }
.panel, .metric, .empty, .error {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel { padding: 14px; }
.muted, .lead { color: var(--muted); line-height: 1.55; }
.lead { margin-top: 10px; }
.panel-note { margin-top: 8px; font-size: 12px; }

.primary, .ghost, .link-button, .preset {
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.primary {
  min-width: 112px;
  padding: 10px 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.ghost { padding: 7px 10px; background: #fff; color: var(--text); }
.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}
.action-group { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; min-width: 0; }
.primary-action { border-color: var(--accent); background: var(--accent); color: #fff; }
.secondary-action { background: #fff; color: var(--accent); }
.full { width: 100%; margin-top: 12px; }
.ghost:hover, .preset:hover, .link-button:hover { border-color: var(--accent); }
.link-button {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  margin-top: 12px;
  padding: 10px 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
.preset-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.preset {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 12px;
  background: #fff;
  text-align: left;
}
.preset span { font-weight: 800; }
.preset small { color: var(--muted); line-height: 1.45; }
.preset.active { border-color: var(--accent); background: #eefaf7; }

.metrics-grid, .details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.details-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.metric { padding: 12px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 6px; font-size: 24px; }
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.logic-box, .info-toggle {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}
.logic-box {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
}
.logic-box strong { font-size: 13px; }
.logic-box span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.info-row .info-toggle { flex: 1 1 240px; margin-bottom: 0; }
.info-toggle summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}
.info-toggle summary::-webkit-details-marker { display: none; }
.info-toggle summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 900;
}
.info-toggle[open] summary::after { content: "-"; }
.info-toggle p {
  padding: 0 11px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.panel-toggle { margin-bottom: 12px; }
.summary-meta { margin-left: auto; margin-right: 8px; color: var(--muted); font-weight: 600; }
.backtest-content { padding: 0 11px 11px; }
.backtest-content > p { padding: 0 0 9px; }
.backtest-tabs { display: flex; gap: 4px; margin: 0 0 8px; }
.backtest-tab { border: 1px solid var(--line); background: var(--panel); color: var(--muted); padding: 5px 9px; border-radius: 5px; cursor: pointer; }
.backtest-tab.active { color: var(--text); border-color: var(--accent); background: #eefaf7; }
.backtest-table-wrap { margin-top: 2px; background: var(--panel); }
.backtest-table { min-width: 760px; }
.backtest-table th:first-child, .backtest-table td:first-child { width: 140px; }
.backtest-table th:last-child, .backtest-table td:last-child { width: 150px; }
.backtest-table td strong { display: block; }
.backtest-table td span { margin-top: 3px; }
.translation-box {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}
.translation-box strong { font-size: 13px; }
.translation-box p { color: var(--muted); line-height: 1.55; }
.coverage-box {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}
.coverage-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.coverage-box div { display: grid; gap: 4px; }
.coverage-box .coverage-row { display: flex; }
.coverage-box strong { font-size: 13px; }
.coverage-box span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chip {
  border-radius: 999px;
  background: var(--panel-2);
  padding: 5px 8px;
  color: #405164;
  font-size: 12px;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--panel-2);
  color: #405164;
  font-size: 12px;
  font-weight: 800;
}
.green-badge {
  background: #e8f7ee;
  color: var(--green);
}
.warn-badge {
  background: #fff2d8;
  color: #9a5a00;
}
.rating-change-reasons { color: #526273; line-height: 1.45; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.screen-table th:nth-child(1), .screen-table td:nth-child(1) { width: 52px; }
.screen-table th:nth-child(2), .screen-table td:nth-child(2) { width: 188px; }
.screen-table th:nth-child(3), .screen-table td:nth-child(3) { width: 156px; }
.screen-table th:nth-child(4), .screen-table td:nth-child(4),
.screen-table th:nth-child(5), .screen-table td:nth-child(5),
.screen-table th:nth-child(6), .screen-table td:nth-child(6),
.screen-table th:nth-child(7), .screen-table td:nth-child(7) { width: 74px; }
.screen-table th:nth-child(8), .screen-table td:nth-child(8) { width: 88px; }
.screen-table th:nth-child(9), .screen-table td:nth-child(9) { width: 86px; }
.history-table th:nth-child(1), .history-table td:nth-child(1) { width: 190px; }
.history-table th:nth-child(2), .history-table td:nth-child(2) { width: 150px; }
.history-table th:nth-child(3), .history-table td:nth-child(3) { width: 180px; }
.history-table th:nth-child(4), .history-table td:nth-child(4) { width: 150px; }
.history-table th:nth-child(5), .history-table td:nth-child(5) { width: 90px; }
.history-table th:nth-child(6), .history-table td:nth-child(6) { width: 150px; }
.history-table th:nth-child(7), .history-table td:nth-child(7) { width: 120px; }
.rating-cell strong { color: var(--accent); }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: #f9fbfd; color: var(--muted); font-size: 12px; font-weight: 800; }
td span {
  display: block;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tr.selected { background: #eef6ff; }
.green { color: var(--green); font-weight: 800; }
.red { color: var(--red); font-weight: 800; }
.score { width: 84px; height: 7px; border-radius: 999px; background: #dfe6ee; overflow: hidden; }
.score span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #f7fafc;
}
.kv span { color: var(--muted); }
.kv strong { text-align: right; }
ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.news-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.news-list a {
  display: block;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  line-height: 1.45;
  text-decoration: none;
}
.news-list span { display: block; color: var(--muted); font-size: 12px; }
.empty-inline {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
}
.report pre {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
  color: #263445;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.empty, .error { padding: 22px; }
.empty { min-height: 220px; }
.empty p { margin-top: 8px; color: var(--muted); }
.error { border-color: #f4b4ad; background: #fff5f3; color: var(--red); font-weight: 700; }

@media (max-width: 980px) {
  .workspace, .details-grid, .metrics-grid { grid-template-columns: 1fr; }
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .primary { width: 100%; }
}
@media (max-width: 640px) {
  .workspace, .topbar { padding-left: 12px; padding-right: 12px; }
  .section-head { flex-direction: column; }
  .chips { justify-content: flex-start; }
}
