:root {
  --ink: #1a222a;
  --muted: #68737d;
  --line: #e2e6ea;
  --accent: #16745f;
  --accent-soft: #e7f3ef;
  --variable: #8a97a3;
  --signal: #c9612f;
  --warn-bg: #fdf3df;
  --warn-ink: #7a5714;
  --error-bg: #f9e7e4;
  --error-ink: #8e3029;
}

* { box-sizing: border-box; }
body {
  margin: 0 auto;
  padding: 32px 20px 60px;
  max-width: 880px;
  font: 15px/1.55 ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
  font-variant-numeric: tabular-nums;
}

header { margin-bottom: 20px; }
h1 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
a { color: var(--accent); }

#data-status { min-height: 1.2em; font-size: 0.85rem; color: var(--muted); margin: 0 0 14px; }
#data-status[data-type="error"] { color: var(--error-ink); }
#data-status[data-type="warning"] { color: var(--warn-ink); }

#fallback { border: 1px dashed var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 18px; font-size: 0.9rem; }
#fallback p { margin: 0 0 10px; }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.sk {
  display: block; border-radius: 8px;
  background: linear-gradient(90deg, #eef1f3 25%, #f8fafb 40%, #eef1f3 55%);
  background-size: 300% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-row { display: flex; gap: 36px; margin-bottom: 22px; }
.sk-stat { width: 110px; height: 52px; }
.sk-chart { height: 280px; margin-bottom: 22px; }
.sk-line { height: 16px; margin-bottom: 10px; }
.sk-line.short { width: 60%; }

.now { display: flex; gap: 36px; flex-wrap: wrap; margin-bottom: 22px; }
.now span { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.now strong { font-size: 1.6rem; font-weight: 650; }
.now small { display: block; color: var(--muted); }

.chart-wrap { position: relative; margin-bottom: 22px; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.grid line { stroke: #eef1f3; }
.grid text, .axis-labels text { fill: var(--muted); font-size: 11px; text-anchor: end; }
.axis-labels text { text-anchor: middle; }
.fixed-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.variable-line { fill: none; stroke: var(--variable); stroke-width: 1.5; stroke-dasharray: 1 0; stroke-linejoin: round; }
.signal-points circle { fill: var(--signal); stroke: #fff; stroke-width: 1.5; }
.chart-hit { fill: transparent; pointer-events: all; }
.chart-cursor { stroke: #b3bec7; stroke-dasharray: 3 3; }
.chart-focus { fill: #fff; stroke: var(--accent); stroke-width: 2; }
#chart-tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  border-radius: 6px; padding: 7px 10px; font-size: 0.78rem; line-height: 1.45; width: max-content;
}
#chart-tooltip b { color: #7fd6b8; }
.legend { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }
.key { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin: 0 5px 0 14px; }
.key:first-child { margin-left: 0; }
.key-fixed { border-color: var(--accent); }
.key-variable { border-color: var(--variable); }
.key-signal { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--signal); }

#missing-section { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 12px 16px 14px; margin-bottom: 18px; }
#missing-section.flash { outline: 2px solid var(--signal); }
#missing-note { margin: 0 0 10px; font-size: 0.88rem; }
#missing-inputs { display: flex; flex-direction: column; gap: 6px; }
#missing-inputs .month-row { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
#missing-inputs .month-row b { width: 110px; font-weight: 600; }
#missing-inputs label { display: flex; align-items: center; gap: 5px; color: var(--warn-ink); }
#missing-inputs input { width: 76px; padding: 4px 7px; border: 1px solid #dcc78f; border-radius: 5px; font: inherit; background: #fff; }
#estimate-note { display: block; margin-top: 8px; font-size: 0.78rem; opacity: 0.85; }

.own-rate { margin-bottom: 16px; font-size: 0.88rem; }
.own-rate label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.own-rate input { width: 76px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; font: inherit; }
.own-rate small { display: block; margin-top: 3px; color: var(--muted); max-width: 620px; }

.run { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
#run-backtest {
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 7px; padding: 9px 18px; cursor: pointer;
}
#run-backtest:disabled { opacity: 0.45; cursor: default; }
progress { flex: 1; max-width: 260px; accent-color: var(--accent); }

.verdict { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.verdict > strong { font-size: 2.4rem; font-weight: 700; color: var(--accent); line-height: 1; }
.verdict b { display: block; font-size: 1.05rem; }
.verdict span { color: var(--muted); font-size: 0.85rem; }

.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 12px; }
.stats div { display: flex; gap: 8px; align-items: baseline; }
.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 0; font-weight: 600; font-size: 0.9rem; }

.cost { background: var(--accent-soft); border-radius: 7px; padding: 9px 13px; font-size: 0.85rem; margin: 0 0 8px; }
.cost b { font-weight: 650; }
.meta { color: var(--muted); font-size: 0.78rem; margin: 0 0 20px; }

.table-section { margin-top: 8px; }
.table-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.filter button, #export-results {
  font: inherit; font-size: 0.82rem; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; padding: 5px 10px; cursor: pointer; color: var(--muted);
}
.filter button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
#export-results:disabled { opacity: 0.45; cursor: default; }
.table-scroll { max-height: 480px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.84rem; }
th { position: sticky; top: 0; background: #f6f8f9; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
td { padding: 6px 12px; border-bottom: 1px solid #f0f2f4; }
.num, th.num { text-align: right; }
tr.manual td { background: var(--warn-bg); }
.action-low { color: var(--muted); }
.action-watch { color: var(--warn-ink); }
.action-medium { color: var(--signal); font-weight: 600; }
.action-high { color: var(--error-ink); font-weight: 700; }
#table-empty { padding: 14px; color: var(--muted); }

.footnote { margin-top: 26px; font-size: 0.78rem; color: var(--muted); }

@media (max-width: 600px) {
  .now { gap: 18px; }
  .now strong { font-size: 1.25rem; }
  .stats { flex-direction: column; gap: 4px; }
}
