:root {
  --bg: #0b1223;
  --surface: #111827;
  --surface2: #1e293b;
  --border: #1e3a5f;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(ellipse at top left, #0d1f3c 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.site-header {
  background: #090e1aee;
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 20;
}

.header-badge {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.site-header h1 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.site-header p  { margin: 0; font-size: 0.78rem; color: var(--muted); }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  text-align: center;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Controls card */
.controls-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input,
select {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus { border-color: var(--accent); }

button, .btn {
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 12px rgba(59,130,246,0.35); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

.controls-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

/* Share row */
.share-row {
  margin: 0.75rem 0;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.share-row input {
  flex: 1;
  min-width: 200px;
  font-size: 0.82rem;
}

/* Main layout */
.main-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.panel-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* Risk badge */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.risk-low      { background: #14532d; color: #86efac; }
.risk-medium   { background: #78350f; color: #fde68a; }
.risk-high     { background: #7f1d1d; color: #fca5a5; }
.risk-critical { background: #450a0a; color: #ef4444; border: 1px solid #ef4444; }

/* Composite score bar */
.score-bar-wrap {
  margin: 0.75rem 0;
}

.score-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.score-bar-track {
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.score-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease, background 0.3s;
}

/* Heuristic table */
.heuristic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

.heuristic-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.heuristic-table td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #0f1a2e;
  vertical-align: middle;
}

.heuristic-table tr:last-child td { border-bottom: none; }

.mini-bar-track {
  height: 5px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  width: 70px;
  display: inline-block;
  vertical-align: middle;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* History panel */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  max-height: 340px;
  overflow-y: auto;
}

.history-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
}

.history-item:hover { border-color: var(--accent); }

.history-item .h-score {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
  text-align: right;
}

/* SVG graph — interactive force-directed layout */
#graph {
  width: 100%;
  height: 500px;
  border-radius: 10px;
  background: radial-gradient(ellipse at center, #0d1a35 0%, #070d1c 100%);
  border: 1px solid var(--border);
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

#graph circle { transition: filter 0.15s; }
#graph circle:hover { filter: brightness(1.3); }

/* Graph reset button */
#graph-reset-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  z-index: 10;
  opacity: 0.7;
}
#graph-reset-btn:hover { opacity: 1; }

/* Rationale */
.rationale-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.83rem;
  color: var(--muted);
  display: grid;
  gap: 0.3rem;
}

.rationale-list li::before { content: "› "; color: var(--accent); }

.hidden { display: none; }
