:root {
  --bg: #0f1419;
  --surface: #1a2028;
  --border: #2a3340;
  --text: #e6e8eb;
  --muted: #8a93a0;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --gray: #6b7280;
  --accent: #3b82f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
}

#run-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

#run-btn:hover:not(:disabled) { opacity: 0.9; }
#run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.isp-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.isp-item strong { color: var(--text); margin-right: 0.35rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  position: relative;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.signal {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gray);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 currentColor;
}

.signal.green { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.signal.yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(234,179,8,0.5); }
.signal.red { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.signal.pending { background: var(--gray); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.metrics { display: grid; gap: 0.55rem; }

.metric {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.metric .label { color: var(--muted); }
.metric .value { font-weight: 500; }
.metric .value.pending { color: var(--muted); font-style: italic; }

.metric-right {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.signal-mini {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gray);
  flex-shrink: 0;
}

.signal-mini.green { background: var(--green); box-shadow: 0 0 5px rgba(34,197,94,0.5); }
.signal-mini.yellow { background: var(--yellow); box-shadow: 0 0 5px rgba(234,179,8,0.5); }
.signal-mini.red { background: var(--red); box-shadow: 0 0 5px rgba(239,68,68,0.5); }
.signal-mini.pending { background: var(--gray); animation: pulse 1.2s ease-in-out infinite; }

.threshold-tip {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.threshold-tip summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: inline-block;
}

.threshold-tip summary::-webkit-details-marker { display: none; }

.threshold-tip summary:hover { color: var(--text); }

.threshold-tip[open] summary { color: var(--text); margin-bottom: 0.5rem; }

.threshold-body { font-size: 0.75rem; }

.threshold-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.threshold-table th,
.threshold-table td {
  text-align: left;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

.threshold-table thead th { color: var(--muted); font-size: 0.7rem; }
.threshold-table tbody th { color: var(--text); font-weight: 500; }
.threshold-table tr:last-child th,
.threshold-table tr:last-child td { border-bottom: none; }

.threshold-table .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.threshold-table .dot.green { background: var(--green); }
.threshold-table .dot.yellow { background: var(--yellow); }
.threshold-table .dot.red { background: var(--red); }

@media (max-width: 480px) {
  .topbar { flex-direction: column; gap: 0.75rem; align-items: stretch; }
  .topbar h1 { text-align: center; }
}
