:root {
  color-scheme: light;
  --paper: #ffffff;
  --queue: #f4f4f5;
  --ink: #16161d;
  --muted: #6b6b73;
  --line: #e5e5e5;
  --red: #d41434;
  --ok: #1f6b3a;
  --focus: #16161d;
  --rail: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #16161d;
    --queue: #111116;
    --ink: #f4f4f5;
    --muted: #9a9aa3;
    --line: #2a2a32;
    --red: #ff3358;
    --ok: #47a366;
    --focus: #f4f4f5;
  }
}
html[data-theme="light"] {
  color-scheme: light;
  --paper: #ffffff;
  --queue: #f4f4f5;
  --ink: #16161d;
  --muted: #6b6b73;
  --line: #e5e5e5;
  --red: #d41434;
  --focus: #16161d;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #16161d;
  --queue: #111116;
  --ink: #f4f4f5;
  --muted: #9a9aa3;
  --line: #2a2a32;
  --red: #ff3358;
  --ok: #47a366;
  --focus: #f4f4f5;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}
.app.is-rail-folded { --rail: 42px; }
.rail {
  position: relative;
  align-self: start;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  min-width: 0;
}
.rail a {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  color: var(--muted);
}
.rail a.is-on {
  border-color: var(--line);
  color: var(--ink);
}
.rail .word { display: none; }
.app.is-rail-folded .rail a {
  opacity: 0;
  pointer-events: none;
}
.app.is-rail-folded .rail { padding-left: 3px; padding-right: 3px; }
.rail-spacer { flex: 1; }
.rail-bottom {
  display: grid;
  gap: 10px;
  place-items: center;
}
.theme-button,
.rail-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  line-height: 1;
}
.theme-button:hover,
.rail-toggle:hover { color: var(--ink); }
.theme-wrap { position: relative; }
.theme-menu {
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0;
  min-width: 160px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 8px;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--ink) 14%, transparent);
  z-index: 5;
}
.theme-menu[hidden] { display: none; }
.theme-menu button {
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
}
.theme-menu button.is-on {
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--ink);
}
.app.is-rail-folded .rail-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: rotate(180deg);
}
.page-shell {
  min-height: 0;
  overflow: hidden;
}
.page {
  display: none;
  height: 100vh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.page.is-on { display: block; animation: pageIn 180ms ease both; }
.dashboard-page {
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
}
.dashboard-page.is-on { display: grid; }
.dashboard-page.is-queue-folded {
  grid-template-columns: 0 minmax(0, 1fr);
}
.dashboard-page.is-queue-folded .queue {
  border-right: 0;
  overflow: hidden;
}
.analysis-page {
  overflow: auto;
  padding: 36px 40px 64px;
}
.queue {
  background: var(--queue);
  border-right: 1px solid var(--line);
  overflow: auto;
  min-width: 0;
}
.work {
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.work .sheet { transition: opacity 180ms ease, transform 180ms ease; }
.work.is-switching .sheet { opacity: 0.18; transform: translateY(4px); }
.work.is-switching::before {
  content: "";
  position: absolute;
  inset: 28px 48px auto;
  height: 180px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--muted) 12%, transparent), transparent);
  opacity: 0.5;
  pointer-events: none;
}
.scroll-thin {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.scroll-thin:hover {
  scrollbar-color: color-mix(in srgb, var(--muted) 38%, transparent) transparent;
}
.scroll-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: transparent; }
.scroll-thin:hover::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 38%, transparent);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ok { color: var(--ok); }
.bad { color: var(--red); }
.muted { color: var(--muted); }
.analysis-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.analysis-head h1 { font-size: 24px; font-weight: 500; margin: 0 0 6px; }
.analysis-head p { color: var(--muted); margin: 0; max-width: 620px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}
.kpi {
  border: 1px solid var(--line);
  padding: 18px 18px 16px;
}
.kpi h2 {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.stat {
  font-size: 36px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.delta { color: var(--ok); font-weight: 500; }
.vs { color: var(--muted); margin: 0; }
.row { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 8px; }
.row span { color: var(--muted); }
.row b { color: var(--ink); font-weight: 500; }
.scoreline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 18px;
}
.scoreline > div {
  border: 1px solid var(--line);
  padding: 14px 16px;
}
.scoreline b {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.1;
  margin-bottom: 5px;
}
.scoreline span {
  color: var(--muted);
}
.analysis-visuals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 30px;
}
.mini-chart {
  border: 1px solid var(--line);
  padding: 16px 18px;
  background: color-mix(in srgb, var(--queue) 55%, var(--paper));
}
.mini-chart h2 {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}
.bar-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 9px 0;
  color: var(--muted);
}
.bar-row b {
  color: var(--ink);
  font-weight: 500;
  font-size: 13px;
}
.bar-track {
  height: 8px;
  background: var(--line);
  overflow: hidden;
}
.bar-track i {
  display: block;
  width: var(--w);
  height: 100%;
  background: var(--ok);
}
.bar-track.is-risk i { background: var(--red); }
.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.model-row:last-child { border-bottom: 0; }
.model-row span { color: var(--ink); }
.model-row b {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
}
.model-row em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-style: normal;
}
.reports {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}
.reports-lead { margin-bottom: 16px; }
.reports h2 {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
}
.compare-table th,
.compare-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.compare-table thead th {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.compare-table thead th em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 400;
}
.compare-table tbody th {
  width: 22%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.compare-table td b {
  display: block;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
}
.compare-table tr:last-child th,
.compare-table tr:last-child td { border-bottom: 0; }
.verdict {
  color: var(--ink);
  margin: 14px 0 0;
}
.compare { color: var(--muted); margin: 0; }
@media (max-width: 860px) {
  .app { grid-template-columns: 48px minmax(0, 1fr); }
  .rail { padding: 12px 6px; }
  .dashboard-page.is-on { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 34vh) minmax(0, 1fr); }
  .queue { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi-grid, .scoreline, .analysis-visuals { grid-template-columns: 1fr; }
  .compare-table { display: block; overflow-x: auto; }
  .analysis-page { padding: 24px 20px 48px; }
}
@media (min-width: 861px) and (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-visuals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .app, .page, .work .sheet { transition: none; animation: none; }
}
