:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.head { text-align: center; margin-bottom: 24px; }
.head h1 { font-size: 1.9rem; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0; font-size: 1.02rem; }

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.field em { font-style: normal; opacity: 0.7; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
}
.field input:focus { outline: none; border-color: var(--accent); }

.run-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #06283d;
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.run-btn:hover { filter: brightness(1.05); }
.run-btn:active { transform: translateY(1px); }
.run-btn:disabled { opacity: 0.6; cursor: progress; }

.progress { margin-top: 18px; }
.bar {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width 0.3s ease;
}
.status { color: var(--muted); margin: 10px 0 0; font-size: 0.95rem; text-align: center; }

.result { margin-top: 22px; }

.verdict {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border-left: 8px solid var(--muted);
}
.verdict.green { border-left-color: var(--green); }
.verdict.yellow { border-left-color: var(--yellow); }
.verdict.red { border-left-color: var(--red); }
.verdict-emoji { font-size: 2.6rem; line-height: 1; }
.verdict-word { font-size: 1.5rem; font-weight: 700; }
.verdict-msg { margin: 4px 0 0; color: var(--muted); font-size: 1rem; }

.limited-by {
  margin: 12px 2px 0;
  font-size: 0.92rem;
  color: var(--muted);
}
.limited-by b { color: var(--text); }

.metrics {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.metric {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.metric-top { display: flex; align-items: center; justify-content: space-between; }
.metric-name { font-size: 0.9rem; color: var(--muted); }
.metric-val { font-size: 1.5rem; margin: 6px 0 2px; }
.metric-val b { font-weight: 700; }
.metric-hint { font-size: 0.78rem; color: var(--muted); opacity: 0.85; }

.chip {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: #334155;
  color: var(--muted);
}
.chip.great { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.chip.ok { background: rgba(234, 179, 8, 0.18); color: #facc15; }
.chip.poor { background: rgba(239, 68, 68, 0.18); color: #f87171; }

.history-wrap {
  margin-top: 28px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
}
.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-head h2 { font-size: 1.1rem; margin: 0; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
}
.table-scroll { overflow-x: auto; margin-top: 10px; }
.history { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.history th, .history td { text-align: left; padding: 8px 10px; white-space: nowrap; }
.history th { color: var(--muted); font-weight: 600; border-bottom: 1px solid #334155; }
.history tbody tr { border-bottom: 1px solid #273449; }
.history tbody tr:last-child { border-bottom: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }
.compare-hint { color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; }

/* Live monitor */
.monitor { margin-top: 22px; }
.monitor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.monitor-head h2 { font-size: 1.15rem; margin: 0; }
.monitor-controls { display: flex; align-items: center; gap: 10px; }
.interval-field { color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.interval-field select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.9rem;
}
.interval-field select:disabled { opacity: 0.5; }
.ghost-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ghost-btn:hover { border-color: var(--accent); }
.ghost-btn.active { background: rgba(239, 68, 68, 0.15); border-color: var(--red); color: #fca5a5; }
.monitor-sub { color: var(--muted); font-size: 0.86rem; margin: 12px 0 16px; }

.live-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.live-stat { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; text-align: center; }
.live-label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.live-value { font-size: 1.25rem; font-weight: 700; }
.live-value small { font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.live-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #334155;
  color: var(--muted);
}
.live-badge.green { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.live-badge.yellow { background: rgba(234, 179, 8, 0.18); color: #facc15; }
.live-badge.red { background: rgba(239, 68, 68, 0.18); color: #f87171; }

.monitor-graph {
  width: 100%;
  height: 160px;
  display: block;
  background: var(--panel-2);
  border-radius: 10px;
}
.monitor-stats { color: var(--muted); font-size: 0.8rem; margin: 10px 2px 0; text-align: right; }

.band-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; font-size: 0.78rem; color: var(--muted); }
.band-legend-label { color: var(--muted); }
.band-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.band-legend .sw.green { background: var(--green); }
.band-legend .sw.yellow { background: var(--yellow); }
.band-legend .sw.red { background: var(--red); }

@media (max-width: 480px) {
  .live-grid { grid-template-columns: repeat(2, 1fr); }
}

.foot { text-align: center; margin-top: 26px; }
.foot p { color: var(--muted); font-size: 0.82rem; }

@media (max-width: 480px) {
  .head h1 { font-size: 1.6rem; }
  .verdict-emoji { font-size: 2.2rem; }
  .verdict-word { font-size: 1.3rem; }
}
