:root {
  --bg: #0a0f16;
  --panel: #121a24;
  --line: #263447;
  --text: #edf4ff;
  --muted: #93a7bd;
  --blue: #58a6ff;
  --green: #35d07f;
  --red: #ff6b6b;
  --yellow: #f2cc60;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside { border-right: 1px solid var(--line); padding: 22px; background: #0d141d; }
.brand { color: var(--blue); font-size: 24px; font-weight: 800; }
.module { color: var(--muted); font-size: 12px; margin-top: 6px; }
nav { display: grid; gap: 10px; margin-top: 36px; }
nav a { color: var(--muted); text-decoration: none; padding: 10px 12px; border-radius: 8px; }
nav a:hover, nav a.active { background: var(--panel); color: var(--text); }
main { padding: 26px 32px 60px; }
header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; }
p { color: var(--muted); margin-top: 8px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.card .name { color: var(--muted); font-size: 12px; }
.card strong { display: block; margin-top: 8px; font-size: 26px; }
.decision { display: grid; gap: 10px; }
.tag { display: inline-flex; width: fit-content; padding: 3px 8px; border-radius: 999px; font-size: 12px; background: #1f2b3a; color: var(--blue); }
.tag.buy { color: var(--green); background: rgba(53,208,127,.12); }
.tag.pause, .tag.error, .tag.review { color: var(--red); background: rgba(255,107,107,.12); }
.tag.wait, .tag.off_cycle { color: var(--yellow); background: rgba(242,204,96,.12); }
.warning { border-color: rgba(242,204,96,.55); background: rgba(242,204,96,.08); }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs button { color: var(--muted); min-width: 78px; }
.tabs button.active { background: rgba(88,166,255,.16); color: var(--blue); border-color: rgba(88,166,255,.55); }
.perf-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.perf-stats div { background: #0d141d; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.perf-stats span { color: var(--muted); font-size: 12px; }
.perf-stats strong { display: block; margin-top: 6px; font-size: 20px; }
.performance-warning { margin: 0 0 12px; border: 1px solid rgba(242,204,96,.45); background: rgba(242,204,96,.08); color: #f5d77e; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.performance-warning[hidden] { display: none; }
.chart-wrap { position: relative; height: 360px; border: 1px solid var(--line); border-radius: 8px; background: #0d141d; overflow: hidden; }
.chart-wrap svg { width: 100%; height: 100%; display: block; }
.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid rgba(88,166,255,.45);
  border-radius: 8px;
  background: rgba(10,15,22,.94);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  pointer-events: none;
}
.chart-tooltip[hidden], .chart-hover[hidden] { display: none; }
.chart-tooltip strong { display: block; margin-bottom: 8px; }
.chart-tooltip span { display: block; color: #c9d8e8; font-size: 12px; line-height: 1.8; }
.tooltip-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; }
.tooltip-dot.value { background: var(--green); }
.tooltip-dot.cost { background: var(--red); }
.chart-hover-line { stroke: rgba(183,216,255,.55); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-hover-dot.value-dot { fill: var(--green); stroke: #0d141d; stroke-width: 2; }
.chart-hover-dot.cost-dot { fill: var(--red); stroke: #0d141d; stroke-width: 2; }
.chart-hit-area { fill: transparent; pointer-events: all; cursor: crosshair; }
.grid-line { stroke: rgba(147,167,189,.14); stroke-width: 1; stroke-dasharray: 3 4; }
.grid-line.vertical { stroke: rgba(147,167,189,.11); }
.axis-zero { stroke: rgba(147,167,189,.28); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 12px; }
.axis-label.endpoint { fill: #b7d8ff; font-size: 13px; }
.value-area { fill: url(#valueFill); }
.value-line { fill: none; stroke: var(--green); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.cost-line { fill: none; stroke: #ff5f57; stroke-width: 2.1; stroke-dasharray: 5 7; stroke-linecap: round; stroke-linejoin: round; }
.last-dot { fill: var(--green); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.chart-empty[hidden] { display: none; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend-line { display: inline-block; width: 22px; height: 0; border-top: 3px solid; margin-right: 6px; vertical-align: middle; }
.green-line { border-color: var(--green); }
.red-dash { border-color: #ff5f57; border-top-style: dashed; }
.rule-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(88,166,255,.14), rgba(53,208,127,.08));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 18px;
}
.eyebrow { color: var(--green); font-size: 12px; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.rule-pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rule-pills span { border: 1px solid rgba(88,166,255,.35); background: rgba(88,166,255,.10); color: #b7d8ff; border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.rule-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 18px;
}
.rule-card.compact { padding-bottom: 8px; }
.rule-title { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rule-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rule-block {
  background: #0d141d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.rule-block h3 { margin-bottom: 8px; font-size: 16px; }
.rule-block p, .rule-block li { color: #b7c7d8; line-height: 1.7; }
.rule-block ul { margin: 8px 0 0; padding-left: 18px; }
.rule-block.metric strong { display: block; font-size: 18px; margin-bottom: 8px; }
.rule-block.metric span { display: inline-flex; margin-top: 12px; color: var(--green); background: rgba(53,208,127,.10); border-radius: 999px; padding: 4px 8px; font-size: 12px; }
.rule-table th, .rule-table td { white-space: normal; }
.rule-table td:last-child { color: var(--green); font-weight: 700; }
.score-range-label { display: inline-block; min-width: 82px; }
.threshold-separator { color: rgba(147,167,189,.55); margin: 0 9px 0 2px; }
.threshold-value {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid rgba(88,166,255,.42);
  border-radius: 999px;
  background: rgba(88,166,255,.12);
  color: #b7d8ff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}
.rule-note {
  margin-top: 14px;
  border: 1px solid rgba(88,166,255,.35);
  background: rgba(88,166,255,.10);
  border-radius: 8px;
  padding: 14px;
  color: #d7e8ff;
  line-height: 1.7;
}
.muted { color: var(--muted); }
.green { color: var(--green); }
.red { color: var(--red); }
.yellow { color: var(--yellow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; }
button, input, select, textarea {
  background: #162232;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
button { cursor: pointer; color: var(--blue); }
button:disabled { cursor: not-allowed; opacity: .45; }
form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
textarea { grid-column: span 2; min-height: 38px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(0, 1fr)) auto auto; gap: 10px; margin-bottom: 14px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
pre { white-space: pre-wrap; color: var(--muted); }
@media (max-width: 980px) {
  .layout { display: block; }
  aside { position: static; }
  main { padding: 18px; }
  header { flex-direction: column; }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; }
  .perf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-hero, .rule-title { flex-direction: column; }
  .rule-pills { justify-content: flex-start; }
  .rule-grid, .rule-grid.three { grid-template-columns: 1fr; }
  form { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .pagination { justify-content: flex-start; }
  textarea { grid-column: auto; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 8px; }
  td { border: 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; }
  td::before { content: attr(data-label); color: var(--muted); }
}
