:root {
  --bg: #f3f2ec;
  --paper: #f7f6f0;
  --paper-strong: #fffef9;
  --ink: #292d2b;
  --muted: #686e69;
  --faint: #969c95;
  --brand: #5f7766;
  --brand-dark: #435948;
  --brand-soft: #dfe4dc;
  --line: rgba(82, 105, 89, .25);
  --line-soft: rgba(82, 105, 89, .14);
  --danger: #b85e4e;
  --danger-soft: #f6ded8;
  --warning: #b47a1c;
  --warning-soft: #f6e7c9;
  --success: #4e7c5b;
  --success-soft: #dce8dd;
  --shadow: 0 16px 42px rgba(52, 62, 54, .08);
  --radius: 7px;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shell: 1500px;
}

html[data-theme="dark"] {
  --bg: #1e2420;
  --paper: #252c27;
  --paper-strong: #2a322c;
  --ink: #edf0ec;
  --muted: #b4bcb4;
  --faint: #899189;
  --brand: #93ad99;
  --brand-dark: #b0c5b4;
  --brand-soft: #344138;
  --line: rgba(178, 202, 184, .24);
  --line-soft: rgba(178, 202, 184, .12);
  --danger-soft: #49302c;
  --warning-soft: #463a23;
  --success-soft: #2d4032;
  --shadow: 0 18px 50px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 12%, rgba(105, 130, 111, .10), transparent 26%),
    radial-gradient(circle at 88% 3%, rgba(105, 130, 111, .06), transparent 27%),
    var(--bg);
  font-family: var(--sans);
  line-height: 1.55;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }
.shell { width: min(calc(100% - 64px), var(--shell)); margin-inline: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}
.topbar-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.wordmark {
  display: inline-block;
  color: var(--ink);
  font-size: 1.45rem;
  font-style: italic;
  font-weight: 750;
  letter-spacing: -.055em;
  line-height: 1;
  text-decoration: none;
}
.wordmark span { color: var(--brand); }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.topbar-label,
.eyebrow {
  color: var(--brand);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brand);
  background: transparent;
  cursor: pointer;
}
.logout {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .11em;
  text-decoration: none;
  text-transform: uppercase;
}

.page { padding: 42px 0 80px; }
.page-heading { margin-bottom: 34px; }
.section-title { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 24px; }
.section-title > span {
  color: var(--brand);
  font-family: var(--mono);
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: .15em;
}
.section-title h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 750;
  letter-spacing: -.025em;
  text-transform: lowercase;
}
.section-title i { height: 1px; background: var(--line-soft); }
.page-heading p { margin: 20px 0 0; color: var(--muted); font-size: 1rem; }

.scan-console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, .8fr);
  gap: clamp(30px, 6vw, 90px);
  align-items: end;
  margin-bottom: 26px;
  padding: clamp(30px, 5vw, 58px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(247, 246, 240, .76);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .scan-console { background: rgba(37, 44, 39, .9); }
.scan-console h2 {
  margin: 12px 0 15px;
  max-width: 720px;
  font-size: clamp(2.2rem, 4.4vw, 4.7rem);
  line-height: .96;
  letter-spacing: -.055em;
}
.scan-console p { margin: 0; max-width: 720px; color: var(--muted); font-size: 1.02rem; }
.scan-form { display: grid; gap: 10px; }
.scan-form label {
  color: var(--brand);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.scan-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.scan-row input {
  min-width: 0;
  min-height: 56px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper-strong);
  font-family: var(--mono);
  outline: none;
}
.scan-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(95, 119, 102, .12); }
.scan-row button {
  min-height: 56px;
  padding: 0 24px;
  border: 1px solid var(--brand-dark);
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  font-size: .79rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
}
.scan-row button:hover { transform: translateY(-1px); }
.scan-row button:disabled { opacity: .55; transform: none; cursor: wait; }
.scan-row button span { margin-left: 8px; font-size: 1rem; }
.form-note { font-size: .83rem !important; color: var(--faint) !important; }

.loading-panel,
.error-panel {
  margin: 22px 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.loading-panel { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 18px; }
.loading-panel strong { display: block; margin-bottom: 3px; }
.loading-panel span { color: var(--muted); font-size: .9rem; }
.loading-line { height: 3px; overflow: hidden; border-radius: 999px; background: var(--brand-soft); }
.loading-line i { display: block; width: 42%; height: 100%; background: var(--brand); animation: scan 1.15s ease-in-out infinite; }
@keyframes scan { from { transform: translateX(-120%); } to { transform: translateX(340%); } }
.error-panel { border-color: rgba(184, 94, 78, .4); color: #8e3f33; background: var(--danger-soft); font-weight: 650; }

.dashboard { margin-top: 28px; }
.dashboard-meta {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(247, 246, 240, .62);
}
.dashboard-meta > div:not(.dashboard-actions) { display: grid; gap: 2px; }
.dashboard-meta span { color: var(--faint); font-family: var(--mono); font-size: .66rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.dashboard-meta strong { font-size: .92rem; }
.dashboard-actions { margin-left: auto; display: flex; gap: 8px; }
.dashboard-actions button,
.text-button {
  border: 0;
  color: var(--brand);
  background: transparent;
  font-size: .73rem;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.8fr repeat(3, 1fr);
  gap: 18px;
}
.card,
.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  box-shadow: 0 12px 32px rgba(48, 58, 50, .055);
}
.card { min-height: 330px; padding: 34px; }
.card-corner {
  position: absolute;
  top: 0;
  right: 0;
  width: 38px;
  height: 38px;
  background: linear-gradient(225deg, rgba(95, 119, 102, .14) 0 49%, transparent 50%);
}
.card-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 25px;
  place-items: center;
  border-radius: 50%;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 1.28rem;
  font-weight: 900;
}
.score-card h3 { margin: 10px 0 9px; font-size: clamp(1.8rem, 2.8vw, 2.9rem); letter-spacing: -.045em; }
.score-card > p { max-width: 520px; margin: 0; color: var(--muted); }
.score-wrap { display: flex; align-items: center; gap: 26px; margin-top: 28px; }
.score-ring {
  --score: 0deg;
  position: relative;
  display: grid;
  width: 130px;
  height: 130px;
  flex: 0 0 auto;
  place-content: center;
  border-radius: 50%;
  background: conic-gradient(var(--brand) var(--score), var(--brand-soft) 0);
}
.score-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--paper); }
.score-ring span,
.score-ring small { position: relative; z-index: 1; text-align: center; }
.score-ring span { font-size: 2.8rem; line-height: .95; letter-spacing: -.06em; }
.score-ring small { color: var(--muted); font-size: .72rem; }
.score-label { display: block; margin-bottom: 6px; color: var(--brand) !important; }
.score-wrap strong { font-size: 1.2rem; }

.metric-card .eyebrow { display: block; margin-bottom: 14px; }
.metric-list { display: grid; margin-top: 6px; }
.metric-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-bottom: 1px solid var(--line-soft);
}
.metric-row:last-child { border-bottom: 0; }
.metric-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.metric-dot.pass { background: var(--success); }
.metric-dot.warn { background: var(--warning); }
.metric-dot.fail { background: var(--danger); }
.metric-name { color: var(--muted); font-size: .9rem; }
.metric-value { font-size: .9rem; font-weight: 750; text-align: right; }
.connection-state { margin: -3px 0 8px; color: var(--muted); font-size: .8rem; }
.connection-state.connected { color: var(--success); }
.connection-state.disconnected { color: var(--warning); }

.panel { margin-top: 20px; padding: 28px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-head h3 { margin: 5px 0 0; font-size: 1.45rem; letter-spacing: -.035em; }
.count-badge {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-family: var(--mono);
  font-size: .69rem;
  font-weight: 800;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th {
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--brand);
  font-family: var(--mono);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-align: left;
  text-transform: uppercase;
}
td { padding: 14px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: .88rem; vertical-align: top; }
td:first-child { color: var(--ink); font-weight: 650; max-width: 520px; overflow-wrap: anywhere; }
.severity,
.status-pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .65rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.severity.high { color: #9e4334; background: var(--danger-soft); }
.severity.medium { color: #8e6218; background: var(--warning-soft); }
.severity.low { color: #386644; background: var(--success-soft); }
.status-pill { color: var(--brand); background: var(--brand-soft); }
.all-clear,
.empty-state { padding: 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.rank-list { display: grid; }
.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, auto);
  gap: 18px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.rank-row:last-child { border-bottom: 0; }
.rank-key { overflow: hidden; color: var(--ink); font-size: .9rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.rank-stat { color: var(--muted); font-family: var(--mono); font-size: .72rem; text-align: right; }
.rank-stat strong { display: block; color: var(--ink); font-size: .8rem; }
.page-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.page-chip {
  max-width: 100%;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  background: var(--paper-strong);
  font-family: var(--mono);
  font-size: .7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-chip.bad { color: var(--danger); border-color: rgba(184, 94, 78, .35); }

.history-panel { margin-top: 28px; }
.history-list { display: grid; }
.history-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(4, minmax(90px, .6fr));
  gap: 18px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.history-row:last-child { border-bottom: 0; }
.history-site strong { display: block; }
.history-site span,
.history-cell span { color: var(--faint); font-family: var(--mono); font-size: .66rem; text-transform: uppercase; }
.history-cell strong { display: block; margin-top: 2px; font-size: .85rem; }
.history-score { font-size: 1.2rem !important; }
.footer { padding: 26px 0 40px; color: var(--faint); font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-shell { width: min(100%, 470px); }
.login-card {
  display: grid;
  gap: 12px;
  padding: clamp(30px, 7vw, 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.login-mark { margin-bottom: 22px; }
.login-card h1 { margin: 2px 0 0; font-size: clamp(2.5rem, 10vw, 4.4rem); line-height: .95; letter-spacing: -.06em; }
.login-card p { margin: 0 0 10px; color: var(--muted); }
.login-card label { color: var(--brand); font-family: var(--mono); font-size: .72rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.login-card input { min-height: 54px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--paper-strong); outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(95, 119, 102, .12); }
.login-card button { min-height: 54px; margin-top: 4px; border: 0; border-radius: var(--radius); color: #fff; background: var(--brand-dark); font-size: .78rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; cursor: pointer; }
.login-error { padding: 10px 12px; border: 1px solid rgba(184, 94, 78, .36); border-radius: var(--radius); color: #8e3f33; background: var(--danger-soft); }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: 1.3fr 1fr; }
  .score-card { grid-row: span 2; }
  .scan-console { grid-template-columns: 1fr; align-items: start; }
}
@media (max-width: 760px) {
  .shell { width: min(calc(100% - 30px), var(--shell)); }
  .topbar-label { display: none; }
  .page { padding-top: 28px; }
  .section-title { grid-template-columns: auto auto 1fr; gap: 12px; }
  .scan-console { padding: 25px 20px; }
  .scan-row { grid-template-columns: 1fr; }
  .summary-grid,
  .detail-grid { grid-template-columns: 1fr; }
  .score-card { grid-row: auto; }
  .card { min-height: 0; padding: 26px 22px; }
  .dashboard-meta { align-items: flex-start; flex-direction: column; gap: 12px; }
  .dashboard-actions { margin-left: 0; }
  .loading-panel { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .history-site { grid-column: 1 / -1; }
}

@media print {
  .topbar, .scan-console, .history-panel, .dashboard-actions, .footer, .loading-panel, .error-panel { display: none !important; }
  body { background: #fff; }
  .shell { width: 100%; }
  .page { padding: 0; }
  .card, .panel { box-shadow: none; break-inside: avoid; }
  .summary-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
}

.success-panel {
  margin: 0 0 20px;
  padding: 14px 18px;
  border: 1px solid rgba(78, 124, 91, .34);
  border-radius: var(--radius);
  color: #386644;
  background: var(--success-soft);
  font-weight: 700;
}
.small-action,
.setup-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  color: #fff;
  background: var(--brand);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}
.small-action.secondary,
.setup-link.secondary {
  color: var(--brand);
  background: transparent;
}
.setup-link { margin-top: 8px; }
.connection-state strong { display: block; font-size: .82rem; }
.connection-state span { display: block; margin-top: 3px; color: var(--faint); font-size: .74rem; line-height: 1.45; }
.small-action:disabled { opacity: .55; cursor: wait; }
.history-row { cursor: pointer; transition: background-color .15s ease; }
.history-row:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }

/* ── Security detail: mixed content + notes ───────────────────────── */
.detail-note { margin: 12px 0 0; color: var(--warning); font-size: .78rem; line-height: 1.5; }
.mixed-content { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.mixed-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--danger); margin-bottom: 8px; }
.mixed-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: .82rem; }
.mixed-kind {
  flex: 0 0 auto; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--danger); background: var(--danger-soft); border-radius: 4px; padding: 2px 7px;
}
.mixed-url { color: var(--muted); font-family: var(--mono); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Response timing breakdown ────────────────────────────────────── */
.timing-breakdown { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.timing-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 10px; }
.timing-row { display: grid; grid-template-columns: 118px 1fr 62px; align-items: center; gap: 10px; padding: 4px 0; }
.timing-label { font-size: .78rem; color: var(--muted); }
.timing-bar { height: 7px; background: var(--brand-soft); border-radius: 4px; overflow: hidden; }
.timing-bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; min-width: 2px; }
.timing-ms { font-family: var(--mono); font-size: .74rem; color: var(--ink); text-align: right; }

@media (max-width: 640px) {
  .timing-row { grid-template-columns: 92px 1fr 54px; gap: 8px; }
}
