:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --up: #35c76a;
  --down: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.topbar nav { display: flex; gap: 20px; align-items: center; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn-lg { padding: 12px 22px; font-size: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.card.narrow { max-width: 460px; margin: 40px auto; }
.card h2 { margin: 0 0 16px; font-size: 1rem; color: var(--muted); font-weight: 600; }

.summary { margin-bottom: 22px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-change { font-size: 0.9rem; font-weight: 600; }
.stat-change.up { color: var(--up); }
.stat-change.down { color: var(--down); }

table.snapshots { width: 100%; border-collapse: collapse; }
table.snapshots th, table.snapshots td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
table.snapshots th { color: var(--muted); font-weight: 600; }
table.snapshots .num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.link-danger {
  background: none; border: none; color: var(--down);
  cursor: pointer; font: inherit; padding: 0;
}
.link-danger:hover { text-decoration: underline; }
form { display: inline; }

.card.narrow form { display: flex; flex-direction: column; gap: 16px; }
.card.narrow label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.card.narrow input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
}

.alert {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid var(--down);
  color: #ffb3b3;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.upload-progress { margin-top: 18px; }
.up-bar {
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.up-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.up-status { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
/* Parsing phase: upload is done (bar full), server is working — pulse it. */
.upload-progress.parsing .up-fill { animation: up-pulse 1s ease-in-out infinite; }
@keyframes up-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.results { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 20px; }
.results h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.result-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.result-list li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.result-list li.ok { border-left: 3px solid var(--up); }
.result-list li.fail { border-left: 3px solid var(--down); }
.result-list .r-icon { font-weight: 700; line-height: 1.5; }
.result-list li.ok .r-icon { color: var(--up); }
.result-list li.fail .r-icon { color: var(--down); }
.result-list .r-body { display: flex; flex-direction: column; gap: 2px; }
.result-list .r-file { font-weight: 600; word-break: break-all; }
.result-list .r-msg { color: var(--muted); }

.empty { text-align: center; padding: 80px 20px; }
.empty h1 { font-size: 1.6rem; }
.empty p { color: var(--muted); margin-bottom: 24px; }

/* Chart */
#chart { width: 100%; }
.chart-wrap { position: relative; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.c-area { fill: rgba(79, 140, 255, 0.12); stroke: none; }
.c-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.c-xlabel { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.c-ylabel { fill: var(--muted); font-size: 11px; text-anchor: end; }
.c-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.c-focus { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.c-hit { cursor: crosshair; }

/* Hover tooltip — light card with dark text for high readability on the
   dark chart. Positioned above the focused point; centered via transform. */
.c-tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  background: #ffffff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.c-tip-date { color: #6b7280; font-size: 0.72rem; }
.c-tip-val { color: #0f1115; font-weight: 700; font-variant-numeric: tabular-nums; }

footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}
