:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #171c23;
  --panel-2: #1e2530;
  --line: #313a48;
  --text: #e7edf5;
  --muted: #93a0b2;
  --accent: #9ec1ff;
  --good: #8fceab;
  --bad: #e39aa2;
  --warn: #e4c98a;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.7rem; cursor: pointer; }
button:hover { border-color: #526178; }
button:disabled { opacity: 0.45; cursor: default; }
input, select { background: #12171e; border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.6rem; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.nav { border-right: 1px solid var(--line); padding: 1.25rem 1rem; background: #141920; position: sticky; top: 0; height: 100vh; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.01em; }
.brand span { color: var(--muted); font-size: 0.82rem; }
.nav nav { display: flex; flex-direction: column; gap: 0.25rem; margin: 1.4rem 0; }
.nav nav a { padding: 0.45rem 0.6rem; border-radius: 6px; color: var(--text); }
.nav nav a.on, .nav nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav form { display: flex; flex-direction: column; gap: 0.35rem; }
.nav label, .filters label { color: var(--muted); font-size: 0.78rem; }
.fine { color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
main { padding: 1.4rem 1.6rem 3rem; min-width: 0; }
h1 { font-size: 1.45rem; font-weight: 650; margin: 0 0 0.35rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 0.6rem; }
.lede { color: var(--muted); margin: 0 0 1rem; max-width: 70rem; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.stat, .card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.stat { padding: 0.85rem 0.95rem; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span, .muted { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.card { padding: 0.9rem 1rem; }
.card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.card p { margin: 0.3rem 0; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin: 0.8rem 0; }
.filters label { display: flex; flex-direction: column; gap: 0.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
th, td { padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: #202733; font-weight: 600; }
th button { background: transparent; border: 0; padding: 0; color: var(--text); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 0.75rem; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.pager { display: flex; gap: 0.8rem; align-items: center; margin: 0.8rem 0; color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 0.1rem 0.45rem; font-size: 0.75rem; }
.badge.confirmed { color: var(--accent); background: #1b2740; }
.badge.possible { color: var(--warn); background: #2d2818; }
.badge.incomplete { color: var(--muted); background: #262c36; }
.badge.running { color: var(--good); background: #173126; }
.badge.stopped { color: var(--bad); background: #341d22; }
.sections { display: grid; gap: 0.9rem; }
.section { padding: 0.2rem 0 0.4rem; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 0.9rem; }
.chart { width: 100%; height: 220px; background: #12171e; border-radius: 8px; }
.chart polyline { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .zero { stroke: #3c4656; stroke-width: 1; }
.bar { height: 8px; background: #2a3340; border-radius: 99px; overflow: hidden; margin-top: 0.35rem; }
.bar span { display: block; height: 100%; background: var(--accent); }
.empty, .error { color: var(--muted); padding: 1rem; }
.error { color: var(--bad); }
.profile-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
ul.clean { margin: 0.3rem 0 0; padding-left: 1.1rem; }
ul.clean li { margin: 0.25rem 0; }
.sig { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 0.4rem; margin: 0.6rem 0 1rem; flex-wrap: wrap; }
.tabs a { border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.7rem; color: var(--text); }
.tabs a.on { background: var(--panel-2); color: var(--accent); text-decoration: none; }
.flow { width: 100%; min-height: 420px; background: #12171e; border: 1px solid var(--line); border-radius: 10px; }
.flow path { fill: none; stroke: #6e8eb8; stroke-width: 1.4; cursor: pointer; }
.flow path:hover { stroke: var(--accent); stroke-width: 2.4; }
.flow text { fill: var(--muted); font-size: 11px; cursor: pointer; }
.flow .node circle { fill: #314158; stroke: #9ec1ff; cursor: pointer; }
.flow .node.priority circle { fill: #24523a; }
.flow .node.historical circle { fill: #5a4a22; }
.flow .node text { fill: var(--text); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.8rem 0; }
a.button { border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.7rem; color: var(--text); background: var(--panel-2); }
a.button:hover { text-decoration: none; border-color: #526178; }
.intake { display: grid; gap: 0.6rem; padding: 1rem; margin: 0.8rem 0 1.2rem; }
.intake textarea { width: 100%; max-width: 46rem; background: #12171e; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem; }
.subnav { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.4rem 0 1rem; }

@media (max-width: 1100px) {
  .stats, .cards, .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav nav { flex-direction: row; flex-wrap: wrap; }
  .stats, .cards, .grid-2 { grid-template-columns: 1fr; }
}
