:root {
  --bg: #0f1419;
  --bg-elev: #171e27;
  --bg-elev2: #1f2832;
  --border: #2a3542;
  --text: #e6edf3;
  --muted: #8b98a5;
  --primary: #3d8bfd;
  --primary-hover: #5a9dff;
  --crit: #f0506e;
  --high: #ff922b;
  --med: #ffd43b;
  --low: #4dabf7;
  --info: #8b98a5;
  --ok: #37b24d;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}
h1, h2, h3 { line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.error { color: var(--crit); }

/* Login */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 10px;
}
.brand { margin: 0; font-size: 1.6rem; }
.login-card label { font-weight: 600; margin-top: 8px; }
input {
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 1rem; width: 100%;
}
input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* Buttons */
.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 10px 16px;
  font-size: .95rem; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-elev2); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-sm { font-weight: 700; }
.badge {
  display: inline-block; min-width: 10px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-elev2); color: var(--muted); font-size: .8rem;
}
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--crit); }

/* Layout */
.container { max-width: 1040px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.panel h2, .panel h3 { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

/* Form */
.audit-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
.hint { color: var(--muted); font-size: .82rem; margin: 0; }
.actions { display: flex; align-items: center; gap: 12px; }

/* Result head */
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.result-head h2 { margin: 0; word-break: break-all; }
.health {
  padding: 8px 16px; border-radius: 999px; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border); background: var(--bg-elev2);
}
.health.good { color: var(--ok); border-color: var(--ok); }
.health.warn { color: var(--high); border-color: var(--high); }
.health.bad { color: var(--crit); border-color: var(--crit); }

/* Severity row */
.severity-row { display: flex; flex-wrap: wrap; gap: 10px; }
.sev-chip {
  display: flex; flex-direction: column; align-items: center; min-width: 78px;
  padding: 10px; border-radius: 8px; background: var(--bg-elev2); border: 1px solid var(--border);
}
.sev-chip .n { font-size: 1.5rem; font-weight: 700; }
.sev-chip .l { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sev-chip.critical .n { color: var(--crit); }
.sev-chip.high .n { color: var(--high); }
.sev-chip.medium .n { color: var(--med); }
.sev-chip.low .n { color: var(--low); }
.sev-chip.info .n { color: var(--info); }

/* Key-value */
.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.tag { font-size: .78rem; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--border); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.bad { color: var(--crit); border-color: var(--crit); }
.tag.na { color: var(--muted); }

/* Findings */
.findings, .hypotheses, .reco, .datasource { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.finding { border-left: 3px solid var(--border); padding: 8px 12px; background: var(--bg-elev2); border-radius: 0 8px 8px 0; }
.finding.critical { border-left-color: var(--crit); }
.finding.high { border-left-color: var(--high); }
.finding.medium { border-left-color: var(--med); }
.finding.low { border-left-color: var(--low); }
.finding.info { border-left-color: var(--info); }
.finding .f-top { display: flex; gap: 8px; align-items: center; }
.finding .sev { font-size: .72rem; text-transform: uppercase; font-weight: 700; }
.finding .f-rec { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.finding .f-ev { color: var(--muted); font-size: .8rem; margin-top: 4px; font-family: ui-monospace, monospace; word-break: break-all; }

.reco li, .hypotheses li { padding: 8px 12px; background: var(--bg-elev2); border-radius: 8px; }
.datasource li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-elev2); border-radius: 8px; }

/* History */
.history { width: 100%; border-collapse: collapse; font-size: .9rem; }
.history th, .history td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.history th { color: var(--muted); font-weight: 600; }
.history td.url { word-break: break-all; max-width: 320px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { text-decoration: underline; }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { text-align: center; padding: 24px; }
@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 6px; }
}
