:root,
[data-theme="dark"] {
  --bg: #0f1216;
  --bg-accent: #13181f;
  --panel: #171b21;
  --panel-2: #1e242c;
  --border: #2a313a;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --gray: #6e7681;
  --code-bg: #0a0d11;
  --shadow: none;
  --sidebar: #12161c;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f5f8;
  --bg-accent: #e8edf3;
  --panel: #ffffff;
  --panel-2: #f4f6f9;
  --border: #d5dbe3;
  --text: #1b2430;
  --muted: #5b6776;
  --accent: #245fd4;
  --accent-soft: rgba(36, 95, 212, 0.1);
  --green: #1a7f37;
  --yellow: #9a6700;
  --red: #c62828;
  --gray: #6e7681;
  --code-bg: #eef2f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --sidebar: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* Shell + sidebar: only the main pane scrolls; sidebar stays put. */
.shell {
  display: flex;
  height: 100%;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.sidebar {
  width: 248px; flex: 0 0 248px;
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  overflow: hidden;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { letter-spacing: 0.8px; font-size: 13px; }
.brand-text span { color: var(--muted); font-size: 11px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none;
}
.nav-link svg { width: 18px; height: 18px; fill: currentColor; flex: 0 0 18px; }
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.is-active {
  color: var(--accent); background: var(--accent-soft); font-weight: 600;
}

.sidebar-footer { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; background: var(--panel);
  text-decoration: none; color: inherit;
}
.sidebar-user:hover { border-color: var(--accent); }
.sidebar-user.is-active { border-color: var(--accent); background: var(--accent-soft); }
.sidebar-user-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.username { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex: 0 0 34px;
}
.avatar-lg { width: 56px; height: 56px; font-size: 22px; flex-basis: 56px; }
.settings-profile { display: flex; align-items: center; gap: 16px; }
.settings-name { margin: 0 0 6px; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; max-width: 920px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .input, .form-grid input, .form-grid textarea { width: 100%; }
.section-head .card-title { margin: 0; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } }

.secret-list { display: flex; flex-direction: column; gap: 8px; }
.secret-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2);
}
.secret-row-meta { min-width: 0; flex: 1; }
.secret-row-title { font-weight: 600; }
.secret-once { display: inline-block; margin-top: 6px; word-break: break-all; }

.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  margin-top: 12px;
}
.access-item dt { color: var(--muted); font-size: 12px; }
.access-item dd { margin: 4px 0 0; }
.key-fp { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.vault-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.vault-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}
.vault-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.vault-form { display: flex; flex-direction: column; gap: 4px; max-width: 520px; }
.vault-form-actions { display: flex; gap: 8px; margin-top: 10px; }
.vault-hint { margin: 4px 0 0; }
.cred-table { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cred-head, .cred-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(110px, 0.7fr) minmax(100px, 0.6fr) minmax(200px, 1.6fr) auto auto;
  gap: 10px 14px;
  align-items: start;
}
.cred-head {
  padding: 0 14px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.cred-row { align-items: center; }
.cred-user { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; }
.cred-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.extras-block { margin-top: 22px; padding-top: 8px; border-top: 1px solid var(--border); }
@media (max-width: 900px) {
  .cred-head { display: none; }
  .cred-row { grid-template-columns: 1fr; }
  .cred-actions { justify-content: flex-start; }
}

.hub-modal[hidden] { display: none !important; }
.hub-modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: 16px;
}
.hub-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 12, 16, 0.55);
}
.hub-modal-panel {
  position: relative; z-index: 1;
  width: min(480px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  padding: 22px;
}
.hub-modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 32px; height: 32px; margin: 0; padding: 0;
  border: 0; border-radius: 8px;
  background: var(--panel); color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.hub-modal-close:hover { color: var(--text); background: var(--panel-2); }
.hub-modal-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.hub-modal-panel .login-form,
.hub-modal-panel .login-form .input,
.hub-modal-panel .login-form input { width: 100%; max-width: none; }
.secret-modal-head {
  margin: 4px 0 16px;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}
.secret-modal-head label { margin-top: 0; }
.secret-modal-body {
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.modal-title { margin: 0 36px 6px 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions .btn-primary { width: auto; padding: 8px 16px; }
.modal-error { display: none; }
.modal-error.is-visible { display: block; margin: 8px 0 0; }
.secret-abandon {
  display: none;
  margin-top: 14px; padding: 12px 14px;
  border: 1px solid var(--yellow); border-radius: 8px; background: var(--panel-2);
}
.secret-abandon.is-visible { display: block; }
.secret-abandon p { margin: 0 0 10px; }
.secret-abandon[hidden] { display: none !important; }
.hub-modal.is-abandoning [data-secret-main-actions] { display: none; }
body.modal-open { overflow: hidden; }

.password-field { position: relative; display: block; margin: 6px 0 12px; }
.password-field .input,
.password-field input { width: 100%; padding-right: 42px; margin: 0; }
.password-field.has-copy .input,
.password-field.has-copy input { padding-right: 76px; }
.password-copy,
.password-toggle {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; margin: 0; padding: 0;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.password-toggle { right: 4px; }
.password-copy { right: 38px; }
.password-copy:hover,
.password-toggle:hover { color: var(--text); }
.password-copy.is-copied { color: var(--green); }
.password-copy svg,
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.password-toggle .icon-eye-off { display: none; }
.password-field.is-visible .icon-eye { display: none; }
.password-field.is-visible .icon-eye-off { display: block; }

.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 13px;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-icon { display: none; width: 16px; height: 16px; }
.theme-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="light"] .theme-icon-light { display: block; }
.theme-toggle-login {
  position: absolute; top: 18px; right: 18px; width: auto;
}

.main { flex: 1; min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.main-top {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex: 0 0 auto;
}
.main-top-title { font-weight: 600; }
.main-top-note { margin-left: auto; color: var(--muted); font-size: 12px; }
.sidebar-toggle {
  display: none; flex-direction: column; gap: 4px;
  background: transparent; border: 0; padding: 6px; cursor: pointer;
}
.sidebar-toggle span {
  display: block; width: 18px; height: 2px; background: var(--text);
}

.sidebar-backdrop { display: none; }

.content { width: 100%; max-width: none; margin: 0; padding: 28px 32px 40px; flex: 1; min-height: 0; overflow-y: auto; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-title { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.02em; }
.page-sub { margin: 6px 0 0; color: var(--muted); }
.page-head-meta { text-align: right; }
.section { margin-bottom: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.section-title { font-size: 16px; margin: 0; font-weight: 600; }
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); margin: 0 0 12px; }
.muted { color: var(--muted); }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 480px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.metrics-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.server-name { font-weight: 600; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.metric-label { display: block; color: var(--muted); font-size: 12px; }
.metric-value { font-size: 16px; font-weight: 600; }

.app-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.app-name { font-weight: 600; color: var(--text); text-decoration: none; }
.app-name:hover { color: var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table a { color: var(--accent); text-decoration: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px;
  font-weight: 600; border: 1px solid var(--border); background: var(--panel-2); }
.badge-healthy, .badge-success { color: var(--green); border-color: var(--green); }
.badge-warning { color: var(--yellow); border-color: var(--yellow); }
.badge-unhealthy, .badge-failure, .badge-error, .badge-denied, .badge-failed { color: var(--red); border-color: var(--red); }
.badge-stopped, .badge-unknown, .badge-cancelled { color: var(--gray); border-color: var(--gray); }

/* On/off switch for patch state */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: var(--gray); border-radius: 24px; transition: background .15s; }
.switch .slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--green); outline-offset: 2px; }
.badge-running, .badge-queued { color: var(--yellow); border-color: var(--yellow); }

.role-badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); }
.role-owner { color: var(--accent); border-color: var(--accent); }
.role-admin { color: var(--green); border-color: var(--green); }
.role-operator { color: var(--yellow); border-color: var(--yellow); }
.role-viewer { color: var(--gray); border-color: var(--gray); }

.btn { display: inline-block; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); text-decoration: none; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 10px 16px; }
.login-card .btn-primary { width: 100%; }
.login-form > .btn-primary { align-self: flex-start; width: auto; margin-top: 16px; }
.btn-ghost { background: transparent; }
.btn-ghost.is-active { color: var(--accent); border-color: var(--accent); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-disabled { opacity: .45; pointer-events: none; cursor: not-allowed; }

/* Patches */
.patch-head {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  margin: -2px 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.patch-id { min-width: 0; }
.patch-head .card-title {
  color: var(--text); text-transform: none; letter-spacing: -0.01em;
  font-size: 16px; font-weight: 650; margin: 0 0 6px;
}
.patch-tags { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin: 0; min-width: 0; }
.patch-target {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--muted);
}
.patch-actions { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.switch-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.switch-label { font-size: 12px; font-weight: 650; letter-spacing: .01em; }
.switch-label.is-on { color: var(--green); }
.switch-label.is-off { color: var(--yellow); }
.patch-actions .btn-primary { padding: 7px 14px; }
.patch-meta { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 12px 0 0; }
.patch-meta dt { color: var(--muted); font-weight: 600; }
.patch-meta dd { margin: 0; }
.patch-foot { margin-top: 12px; font-size: 12px; }
@media (max-width: 640px) {
  .patch-meta { grid-template-columns: 1fr; }
  .patch-head { flex-direction: column; align-items: stretch; }
  .patch-tags { flex-wrap: wrap; }
  .patch-actions { justify-content: flex-end; }
}
.input { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 12px; color: var(--text); width: 100%; margin: 6px 0 12px; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.event-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.event-action { flex: 1; }

.logs-head { display: flex; justify-content: space-between; align-items: center; }
.logs-controls { display: flex; gap: 8px; align-items: center; }
.logs-controls select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px; }
.logs-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.logs { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px;
  overflow: auto; max-height: 420px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px; white-space: pre-wrap; word-break: break-word; }

.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head .page-title { margin: 0 0 12px; }

.messages { margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; border: 1px solid var(--border); }
.msg-error { color: var(--red); border-color: var(--red); }
.msg-success { color: var(--green); border-color: var(--green); }
.msg-warning { color: var(--yellow); border-color: var(--yellow); }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; position: relative; overflow: auto; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 340px; box-shadow: var(--shadow); }
.login-title { text-align: center; color: var(--accent); letter-spacing: 2px; margin: 0; }
.login-sub { text-align: center; color: var(--muted); margin: 6px 0 22px; font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { color: var(--muted); font-size: 12px; margin-top: 8px; }
.login-form input, .login-form textarea { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 12px; color: var(--text); font: inherit; width: 100%; }
.login-form button { margin-top: 18px; }
.login-form .modal-actions button,
.login-form .password-toggle,
.login-form .password-copy { margin-top: 0; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .shell.sidebar-open .sidebar { transform: none; }
  .sidebar-toggle { display: flex; }
  .shell.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 15;
    background: rgba(0, 0, 0, 0.4);
  }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head-meta { text-align: left; }
  .main-top-note { display: none; }
}

/* --- Security Center --- */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: auto;
  border-radius: 10px; background: var(--red); color: #fff; font-size: 11px;
  font-weight: 700; text-align: center; line-height: 18px; }

.badge-critical { color: #fff; background: var(--red); border-color: var(--red); }
.badge-high { color: var(--red); border-color: var(--red); }
.badge-medium { color: var(--yellow); border-color: var(--yellow); }
.badge-low { color: var(--gray); border-color: var(--gray); }
.badge-info { color: var(--muted); border-color: var(--border); }
.badge-detected, .badge-blocked { color: var(--yellow); border-color: var(--yellow); }

.state-ok { color: var(--green); border-color: var(--green); }
.state-warning { color: var(--yellow); border-color: var(--yellow); }
.state-critical { color: #fff; background: var(--red); border-color: var(--red); }
.state-unknown { color: var(--gray); border-color: var(--gray); }

.sec-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; margin-top: 4px; }
.stat.is-alert .stat-value { color: var(--red); }

.sec-status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; }
.sec-status { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); }
.sec-status .label { color: var(--muted); font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: end; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.filters input, .filters select { padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.pagination .muted { color: var(--muted); }

.finding { border-left: 3px solid var(--border); padding: 12px 14px; margin-bottom: 12px;
  background: var(--panel-2); border-radius: 0 8px 8px 0; }
.finding.sev-critical { border-left-color: var(--red); }
.finding.sev-high { border-left-color: var(--red); }
.finding.sev-medium { border-left-color: var(--yellow); }
.finding.sev-low { border-left-color: var(--gray); }
.finding h4 { margin: 0 0 6px; }
.finding .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.finding .remediation { margin-top: 8px; font-size: 13px; }

.code-block { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  word-break: break-all; user-select: all; }
.qr-img { image-rendering: pixelated; width: 220px; height: 220px; background: #fff; padding: 8px;
  border-radius: 8px; }
.recovery-codes { list-style: none; padding: 0; display: grid;
  grid-template-columns: 1fr 1fr; gap: 8px; }
.recovery-codes li { font-family: ui-monospace, Menlo, monospace; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }

/* --- Analytics ------------------------------------------------------- */
.badge-live { color: var(--green, #34d399); border-color: var(--green, #34d399); }
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.analytics-filters { margin-top: 4px; }

.an-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.an-stat { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--panel-2); }
.an-stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.an-stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }
.an-stat-delta { font-size: 12px; margin-top: 6px; }
.an-stat-delta.is-up { color: var(--green, #34d399); }
.an-stat-delta.is-down { color: var(--red); }

.an-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.an-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.an-chart { width: 100%; }
.an-chart canvas { width: 100%; height: 220px; display: block; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.an-bignum { font-size: 15px; }
.an-bignum span { font-weight: 700; }

.an-visit-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 12px 0 18px; }
.an-metric { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--panel-2); text-align: center; }
.an-metric .v { display: block; font-size: 22px; font-weight: 700; }
.an-metric .l { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; margin-top: 4px; }

.table.kv th { text-align: left; color: var(--muted); font-weight: 500; width: 40%; white-space: nowrap; }

.an-timeline { list-style: none; padding: 0; margin: 0; }
.an-tl-item { display: grid; grid-template-columns: 84px 96px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-left: 3px solid var(--border); margin-bottom: 4px; background: var(--panel-2); border-radius: 0 8px 8px 0; }
.an-tl-time { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.an-tl-kind { font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.an-tl-label { font-size: 13px; }
.an-tl-detail { color: var(--muted); font-size: 12px; }
.an-tl-delta { color: var(--muted); font-size: 11px; }
.an-tl-item.kind-page { border-left-color: #5a8cff; }
.an-tl-item.kind-conversion { border-left-color: var(--green, #34d399); }
.an-tl-item.kind-form { border-left-color: var(--yellow); }
.an-tl-item.kind-download, .an-tl-item.kind-outbound { border-left-color: #b07cff; }
.an-tl-item.kind-error { border-left-color: var(--red); }

.an-code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; user-select: all; }
.an-install-status { display: flex; gap: 10px; align-items: center; margin: 10px 0; }

.an-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.an-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.an-form-grid label.wide { grid-column: 1 / -1; }
.an-form-grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.an-form-grid input, .an-form-grid select, .an-form-grid textarea { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.an-fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 16px 0; }
.an-fieldset legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
.an-form-actions { margin-top: 16px; display: flex; gap: 10px; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-danger { border-color: var(--red); color: var(--red); }
.an-install-actions { margin: 8px 0; }

/* Active-filter chips (§15) */
.an-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 14px; }
.an-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); color: var(--text); text-decoration: none; }
.an-chip:hover { border-color: var(--red); color: var(--red); }
.an-chip span { font-weight: 700; }
.an-chip-clear { border-style: dashed; color: var(--muted); }
.an-chip-clear:hover { border-color: var(--text); color: var(--text); }

/* Metric definition tooltip marker (§63) */
.an-info { display: inline-block; margin-left: 5px; width: 14px; height: 14px; line-height: 14px;
  text-align: center; font-size: 10px; border-radius: 50%; border: 1px solid var(--border);
  color: var(--muted); cursor: help; }
.an-info:focus { outline: 2px solid var(--accent, #5a8cff); outline-offset: 1px; }
