:root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6d6c66;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9b9992;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);
  --accent: #3987e5;
  --good-text: #0ca30c;
  --series-1: #3987e5;
  --series-2: #199e70;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9b9992;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);
    --accent: #3987e5;
    --good-text: #0ca30c;
    --series-1: #3987e5;
    --series-2: #199e70;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  font-size: 15px; line-height: 1.45;
}
.hidden { display: none !important; }

.icon {
  width: 1.1em; height: 1.1em; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.18em;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: -1px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.06);
  animation: rise-in 350ms var(--ease-out);
}
.login-sub { color: var(--ink-2); margin: 6px 0 20px; }

.logo { font-weight: 700; font-size: 18px; display: flex; align-items: center; white-space: pre; }
.logo span { color: var(--accent); }
.logo .icon { width: 20px; height: 20px; color: var(--accent); stroke-width: 2.2; margin-right: 8px; }

/* shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--surface-1); border-right: 1px solid var(--grid);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav:first-of-type { margin-top: 6px; }
.navsec {
  padding: 10px 12px 2px; color: var(--muted); font-size: 11px;
  letter-spacing: .07em; text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: none; border: none; padding: 10px 12px; border-radius: 8px;
  font-size: 15px; color: var(--ink-2); cursor: pointer; font-family: inherit;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-item .icon { width: 17px; height: 17px; stroke-width: 1.9; color: var(--muted); transition: color 150ms ease; }
.nav-item .ext { width: 12px; height: 12px; margin-left: auto; opacity: .6; }
.nav-item:hover { background: var(--grid); color: var(--ink); }
.nav-item:hover .icon { color: var(--ink-2); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 11%, transparent); color: var(--accent); font-weight: 600; }
.nav-item.active .icon { color: var(--accent); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--grid); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.theme-switch { display: flex; gap: 2px; background: var(--page); border: 1px solid var(--grid); border-radius: 8px; padding: 3px; }
.theme-switch button {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 6px; padding: 5px 0;
  color: var(--muted); cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button.active { background: var(--surface-1); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.theme-switch .icon { width: 14px; height: 14px; }

.main { flex: 1; padding: 28px 32px; max-width: 1160px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 24px; letter-spacing: -0.015em; }
h2 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.muted-text { color: var(--muted); font-size: 13px; }

/* controls */
.btn {
  font-family: inherit; font-size: 14px; border-radius: 8px; padding: 9px 16px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--ink);
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 150ms ease, border-color 150ms ease, filter 150ms ease, transform 160ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--grid); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
input {
  width: 100%; margin-top: 5px; padding: 9px 11px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--baseline); border-radius: 8px; background: var(--surface-1); color: var(--ink);
}
.form-error { color: var(--critical); font-size: 13px; margin-bottom: 10px; }

/* cards */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px;
}
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* overview tool cards */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tool-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 14px;
  transition: box-shadow 160ms var(--ease-out), border-color 160ms ease, transform 160ms var(--ease-out);
}
a.tool-card { text-decoration: none; color: inherit; }
a.tool-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.tool-head { display: flex; align-items: center; gap: 10px; }
.tool-head .tic {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.tool-head .tic .icon { width: 17px; height: 17px; }
.tool-name { font-weight: 700; font-size: 15px; }
.tool-sub { color: var(--muted); font-size: 12px; }
.tool-head .status { margin-left: auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: var(--good); }
.status.down { color: var(--critical); } .status.down::before { background: var(--critical); }
.status.na { color: var(--muted); } .status.na::before { background: var(--baseline); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 1px; }
.kpi .v.attn { color: var(--critical); }

/* stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .l { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

/* score hero */
.score-hero { display: flex; align-items: center; gap: 22px; }
.score-ring { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .track { stroke: var(--grid); }
.score-ring .fill { stroke: var(--series-1); transition: stroke-dashoffset 600ms var(--ease-out); }
.score-ring .val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; letter-spacing: -0.02em;
}
.score-meta h2 { margin-bottom: 4px; }
.score-meta .muted-text { max-width: 52ch; }

/* charts */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--page);
  font-size: 12px; padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  transform: translate(-50%, -130%); opacity: 0; transition: opacity 120ms ease;
}
.chart-tip.show { opacity: 1; }
.axis-lbl { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: color-mix(in srgb, var(--series-1) 10%, transparent); }
.chart-dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }

/* site tabs + add form */
.site-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  font-family: inherit; font-size: 13px; padding: 7px 14px; border-radius: 99px;
  border: 1px solid var(--baseline); background: var(--surface-1); color: var(--ink-2); cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out);
}
.chip:hover:not(.active) { border-color: var(--muted); color: var(--ink); }
.chip:active { transform: scale(0.97); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-add { border-style: dashed; color: var(--muted); }
.add-site { animation: rise-in 200ms var(--ease-out); }
.add-site-row { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; margin-top: 10px; }
.add-site-row select { margin-top: 0; }
.add-site-row input { margin-top: 0; }
@media (max-width: 760px) { .add-site-row { grid-template-columns: 1fr; } }

/* agent team */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.agent-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 15px;
  background: var(--page); display: flex; flex-direction: column; gap: 4px;
  transition: border-color 160ms ease, box-shadow 160ms var(--ease-out);
}
.agent-card:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.agent-idle { opacity: .75; }
.agent-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.agent-head .tic {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.agent-head .tic .icon { width: 13px; height: 13px; }
.agent-name { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; }
.agent-head .pill { padding: 2px 8px; font-size: 10.5px; white-space: nowrap; }
.agent-metric { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.agent-metric small { font-size: 14px; color: var(--muted); font-weight: 500; }
.agent-label { color: var(--muted); font-size: 11.5px; }
.agent-finding { color: var(--ink-2); font-size: 12.5px; margin-top: 6px; line-height: 1.4; }

/* issues list */
.issue {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 0;
  border-bottom: 1px solid var(--grid); font-size: 13.5px; color: var(--ink-2);
}
.issue:last-child { border-bottom: none; }
.issue .icon { width: 15px; height: 15px; color: var(--serious); margin-top: 2px; }
.issue-ok { color: var(--good-text); display: flex; gap: 8px; align-items: center; padding: 9px 0; font-size: 13.5px; }
.issue-ok .icon { color: var(--good-text); }

/* llm panel */
.llm-q { padding: 10px 0; border-bottom: 1px solid var(--grid); font-size: 13.5px; }
.llm-q:last-child { border-bottom: none; }
.llm-q .q { color: var(--ink-2); }
.llm-q .verdicts { display: flex; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; display: inline-flex; align-items: center; gap: 5px; }
.pill .icon { width: 12px; height: 12px; }
.pill-yes { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
.pill-no { background: var(--grid); color: var(--muted); }
.connect-note {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; color: var(--ink-2);
}
.connect-note code { background: var(--grid); border-radius: 5px; padding: 1px 6px; font-size: 12px; }

.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; align-items: start; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 0);
  background: var(--ink); color: var(--page); padding: 10px 20px; border-radius: 99px;
  font-size: 14px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: toast-in 250ms var(--ease-out);
}

@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 10px 14px; gap: 6px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .logo, .navsec { display: none; }
  .sidebar-footer { border: none; padding: 0; flex-direction: row; align-items: center; margin-left: auto; margin-top: 0; }
  .main { padding: 18px 14px; }
  .score-hero { flex-direction: column; align-items: flex-start; gap: 14px; }
}
