/* Mod Studio license admin. Plain CSS, no build step.
   Themes: light tokens on :root, dark tokens on [data-theme="dark"] and on
   prefers-color-scheme dark unless the user picked light. */

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-grad: radial-gradient(1200px 600px at 0% -10%, rgba(13, 148, 136, 0.06), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eef2f6;
  --sidebar: #ffffff;
  --border: #e3e8ef;
  --border-strong: #cfd7e2;
  --text: #0f1b2a;
  --text-2: #3b4a5c;
  --muted: #6a7889;
  --accent: #0d9488;
  --accent-hover: #0b7f75;
  --accent-soft: rgba(13, 148, 136, 0.1);
  --accent-ring: rgba(13, 148, 136, 0.32);
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --bad: #c2273a;
  --bad-soft: rgba(194, 39, 58, 0.1);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.1);
  --dev: #7c3aed;
  --dev-soft: rgba(124, 58, 237, 0.11);
  --input-bg: #ffffff;
  --code-bg: #f3f5f8;
  --overlay: rgba(15, 23, 42, 0.45);
  --shadow-sm: 0 1px 2px rgba(15, 27, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 27, 42, 0.06), 0 8px 24px rgba(15, 27, 42, 0.06);
  --shadow-lg: 0 20px 60px rgba(15, 27, 42, 0.22);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 252px;
  --sidebar-rail: 72px;
  --topbar-h: 64px;
  --touch: 40px;
  --gutter: clamp(16px, 3vw, 32px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e13;
  --bg-grad: radial-gradient(1100px 560px at 0% -10%, rgba(46, 230, 197, 0.09), transparent 60%), radial-gradient(900px 500px at 100% 0%, rgba(80, 120, 255, 0.07), transparent 55%);
  --surface: #11161d;
  --surface-2: #151b23;
  --surface-3: #1b232d;
  --sidebar: #0d1218;
  --border: #212a35;
  --border-strong: #2e3a48;
  --text: #e7eef5;
  --text-2: #b4c1ce;
  --muted: #8291a1;
  --accent: #2ee6c5;
  --accent-hover: #5cf0d5;
  --accent-soft: rgba(46, 230, 197, 0.12);
  --accent-ring: rgba(46, 230, 197, 0.35);
  --on-accent: #04201b;
  --ok: #3fd69a;
  --ok-soft: rgba(63, 214, 154, 0.13);
  --warn: #ffc46b;
  --warn-soft: rgba(255, 196, 107, 0.13);
  --bad: #ff6b7a;
  --bad-soft: rgba(255, 107, 122, 0.13);
  --info: #7aa7ff;
  --info-soft: rgba(122, 167, 255, 0.13);
  --dev: #b794ff;
  --dev-soft: rgba(183, 148, 255, 0.14);
  --input-bg: #0c1117;
  --code-bg: #0c1117;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0e13;
    --bg-grad: radial-gradient(1100px 560px at 0% -10%, rgba(46, 230, 197, 0.09), transparent 60%), radial-gradient(900px 500px at 100% 0%, rgba(80, 120, 255, 0.07), transparent 55%);
    --surface: #11161d;
    --surface-2: #151b23;
    --surface-3: #1b232d;
    --sidebar: #0d1218;
    --border: #212a35;
    --border-strong: #2e3a48;
    --text: #e7eef5;
    --text-2: #b4c1ce;
    --muted: #8291a1;
    --accent: #2ee6c5;
    --accent-hover: #5cf0d5;
    --accent-soft: rgba(46, 230, 197, 0.12);
    --accent-ring: rgba(46, 230, 197, 0.35);
    --on-accent: #04201b;
    --ok: #3fd69a;
    --ok-soft: rgba(63, 214, 154, 0.13);
    --warn: #ffc46b;
    --warn-soft: rgba(255, 196, 107, 0.13);
    --bad: #ff6b7a;
    --bad-soft: rgba(255, 107, 122, 0.13);
    --info: #7aa7ff;
    --info-soft: rgba(122, 167, 255, 0.13);
    --dev: #b794ff;
    --dev-soft: rgba(183, 148, 255, 0.14);
    --input-bg: #0c1117;
    --code-bg: #0c1117;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--surface-3); border-radius: 5px; padding: 0.08em 0.38em; color: var(--text); }
kbd {
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 0.35em;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.sm { width: 15px; height: 15px; }
svg.icon.lg { width: 22px; height: 22px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.muted.center, .center { text-align: center; }
.tiny { font-size: 0.76rem; }
.small { font-size: 0.86rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; min-width: 0; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
.dev-text { color: var(--dev); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: inline-block; vertical-align: bottom; }
.eyebrow { margin: 0; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.form-error { color: var(--bad); margin: 0; font-size: 0.86rem; }
.ok { color: var(--ok); }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; font-weight: 500; color: var(--text-2); min-width: 0; }
input, select, textarea {
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.92rem;
  min-height: var(--touch);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
input[type="file"] { padding: 0.4rem; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
textarea { min-height: 6rem; resize: vertical; line-height: 1.45; }
@media (max-width: 640px) { input, select, textarea { font-size: 16px; } }
label.check, .check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--text); cursor: pointer; }
.field-hint { margin: 0.25rem 0 0; font-size: 0.78rem; color: var(--muted); font-weight: 400; }
.field-hint.ok { color: var(--ok); }
.field-hint.bad { color: var(--bad); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem 1rem; align-items: start; }
.form-grid .full, .form-grid > button, .form-grid > .form-actions { grid-column: 1 / -1; }
.form-grid > button { justify-self: start; }
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.form-section { display: grid; gap: 0.9rem; }
.form-section + .form-section { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 0.25rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 0.82rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.4rem; padding: 0; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  min-height: var(--touch);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; color: var(--btn-fg); background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn.primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bd: transparent; }
.btn.primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn.ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { --btn-fg: var(--bad); --btn-bd: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.danger.solid { --btn-bg: var(--bad); --btn-fg: #fff; --btn-bd: transparent; }
.btn.danger.solid:hover { background: color-mix(in srgb, var(--bad) 85%, black); color: #fff; }
.btn.sm { padding: 0.3rem 0.65rem; min-height: 32px; font-size: 0.8rem; border-radius: var(--radius-xs); gap: 0.35rem; }
.btn.xs { padding: 0.15rem 0.45rem; min-height: 26px; font-size: 0.74rem; border-radius: 6px; gap: 0.25rem; }
.btn.wide { width: 100%; }
.btn.icon-only { width: var(--touch); padding: 0; }
.btn.icon-only.sm { width: 32px; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.btn-group.end { justify-content: flex-end; }
.inline { display: inline; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row.stretch > input { flex: 1 1 200px; width: auto; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 1rem; }
.stack.sm { gap: 0.5rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}
.chip:hover, .chip.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.chip .x { opacity: 0.7; }

/* ---------- Badges ---------- */
.badge {
  --b-fg: var(--text-2);
  --b-bg: var(--surface-3);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--b-fg);
  background: var(--b-bg);
  vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.badge-ok, .badge-pro { --b-fg: var(--ok); --b-bg: var(--ok-soft); }
.badge-warn { --b-fg: var(--warn); --b-bg: var(--warn-soft); }
.badge-bad, .badge-revoked { --b-fg: var(--bad); --b-bg: var(--bad-soft); }
.badge-info, .badge-unlimited { --b-fg: var(--info); --b-bg: var(--info-soft); }
.badge-dev { --b-fg: var(--dev); --b-bg: var(--dev-soft); }
.badge-accent { --b-fg: var(--accent); --b-bg: var(--accent-soft); }
.badge-muted, .badge-pro-off { --b-fg: var(--muted); --b-bg: var(--surface-3); }
.nav-badge, .count {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--on-accent);
  margin-left: auto;
}
.count { background: var(--surface-3); color: var(--text-2); margin-left: 0.35rem; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(-102%);
  transition: transform 0.22s ease, width 0.2s ease;
  padding-top: var(--safe-top);
}
.sidebar.is-open, .sidebar:target { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidebar-head { display: flex; align-items: center; gap: 0.65rem; padding: 1rem 1rem 0.75rem; min-height: var(--topbar-h); }
.sidebar-head .logo { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; flex: none; }
.sidebar-head .brand-text { min-width: 0; line-height: 1.2; }
.sidebar-head .brand-name { font-weight: 700; font-size: 0.98rem; margin: 0; }
.sidebar-head .brand-sub { color: var(--muted); font-size: 0.74rem; margin: 0; }
.sidebar-close { margin-left: auto; }
.sidebar-scroll { flex: 1 1 auto; overflow-y: auto; padding: 0.25rem 0.75rem 1rem; overscroll-behavior: contain; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin-top: 0.9rem; }
.nav-group:first-child { margin-top: 0.25rem; }
.nav-group-title { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0 0.65rem 0.35rem; margin: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text-2);
  text-decoration: none;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  min-height: 38px;
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.is-active::before { content: ""; position: absolute; left: -0.75rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item .label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 0.75rem; display: grid; gap: 0.5rem; padding-bottom: calc(0.75rem + var(--safe-bottom)); }
.user-chip { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.user-chip .who { min-width: 0; font-size: 0.8rem; line-height: 1.25; }
.user-chip .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 55; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.sidebar.is-open ~ .backdrop, .sidebar:target ~ .backdrop { opacity: 1; pointer-events: auto; }

.main-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(0.5rem + var(--safe-top)) var(--gutter) 0.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs { display: flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); min-width: 0; flex: 1 1 auto; overflow: hidden; white-space: nowrap; }
.topbar .crumbs a { color: var(--muted); }
.topbar .crumbs a:hover { color: var(--text); }
.topbar .crumbs .current { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumbs svg { opacity: 0.6; }
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  min-width: 0;
  padding: 0.35rem 0.6rem 0.35rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  width: clamp(40px, 28vw, 280px);
}
.search-trigger:hover { border-color: var(--muted); color: var(--text); }
.search-trigger .label { flex: 1 1 auto; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: inline-flex; }
@media (max-width: 640px) {
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger .label, .search-trigger kbd { display: none; }
}

.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 1.25rem var(--gutter) 3rem; display: grid; gap: 1.25rem; align-content: start; flex: 1 1 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1rem; }
.page-head h1 { font-size: clamp(1.3rem, 2.4vw, 1.65rem); font-weight: 700; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.page-head .lead { color: var(--muted); margin: 0.3rem 0 0; font-size: 0.9rem; max-width: 760px; }
.page-head .btn-group { margin-left: auto; }
.footer { padding: 1rem var(--gutter) 1.5rem; color: var(--muted); font-size: 0.76rem; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.footer a { color: var(--muted); }

@media (min-width: 1024px) {
  .sidebar { transform: none; box-shadow: none; }
  .sidebar-close, .menu-btn, .backdrop { display: none !important; }
  .main-col { margin-left: var(--sidebar-w); transition: margin-left 0.2s ease; }
  html[data-sidebar="rail"] .sidebar { width: var(--sidebar-rail); }
  html[data-sidebar="rail"] .main-col { margin-left: var(--sidebar-rail); }
  html[data-sidebar="rail"] .sidebar .brand-text,
  html[data-sidebar="rail"] .sidebar .nav-group-title,
  html[data-sidebar="rail"] .sidebar .nav-item .label,
  html[data-sidebar="rail"] .sidebar .user-chip .who,
  html[data-sidebar="rail"] .sidebar .foot-label { display: none; }
  html[data-sidebar="rail"] .sidebar .nav-item { justify-content: center; padding: 0.55rem; }
  html[data-sidebar="rail"] .sidebar .nav-badge { position: absolute; top: 2px; right: 4px; min-width: 1.1rem; height: 1.1rem; font-size: 0.62rem; }
  html[data-sidebar="rail"] .sidebar .nav-group { margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
  html[data-sidebar="rail"] .sidebar .nav-group:first-child { border-top: 0; }
  html[data-sidebar="rail"] .sidebar-head { justify-content: center; padding-inline: 0.5rem; }
  html[data-sidebar="rail"] .sidebar-foot { justify-items: center; }
  html[data-sidebar="rail"] .sidebar-foot .btn .foot-label { display: none; }
}

/* ---------- Cards ---------- */
.card, .panel, .kn-card, .chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card, .panel, .kn-card, .chart-card { padding: 1.1rem 1.2rem; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 1rem 1.2rem 0.75rem; margin: 0; }
.card.flush > .card-foot { padding: 0.75rem 1.2rem; margin: 0; }
.card-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.card-head h2, .panel-head h2, .panel > h2, .kn-card > h2, .chart-card > h3 { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.panel > h2, .kn-card > h2, .chart-card > h3 { margin-bottom: 0.85rem; }
.card-head .sub { color: var(--muted); font-size: 0.8rem; font-weight: 400; margin: 0.15rem 0 0; }
.card-foot { border-top: 1px solid var(--border); margin: 1rem -1.2rem -1.1rem; padding: 0.7rem 1.2rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.84rem; }
.card.tone-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--surface); }
.card.tone-dev { border-color: color-mix(in srgb, var(--dev) 45%, var(--border)); }
.card.tone-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.card.tone-bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .grid.cols-2, .two-col, .kn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.main-side { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
  .grid.side-main { grid-template-columns: minmax(260px, 0.8fr) minmax(0, 2fr); }
}
.two-col, .kn-grid { display: grid; gap: 1.25rem; align-items: start; }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; gap: 0.85rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .kpi-grid { grid-template-columns: repeat(var(--kpi-cols, 6), minmax(0, 1fr)); } }
.kpi {
  position: relative;
  display: grid;
  gap: 0.2rem;
  align-content: start;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
a.kpi:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.kpi .kpi-label { flex: 1 1 auto; min-width: 0; font-size: 0.78rem; color: var(--muted); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .kpi-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--text-2); flex: none; }
.kpi .kpi-value { font-size: clamp(1.35rem, 2.2vw, 1.7rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .kpi-hint { font-size: 0.75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.tone-ok .kpi-icon { background: var(--ok-soft); color: var(--ok); }
.kpi.tone-warn .kpi-icon { background: var(--warn-soft); color: var(--warn); }
.kpi.tone-bad .kpi-icon { background: var(--bad-soft); color: var(--bad); }
.kpi.tone-info .kpi-icon { background: var(--info-soft); color: var(--info); }
.kpi.tone-dev .kpi-icon { background: var(--dev-soft); color: var(--dev); }
.kpi.tone-accent .kpi-icon { background: var(--accent-soft); color: var(--accent); }
.kpi.tone-warn.hot { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.kpi.tone-bad.hot { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }

/* Legacy stat tiles (kept for older views). */
.stats { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stats article { padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-link { text-decoration: none; color: inherit; }
.stat-label { margin: 0; font-size: 0.78rem; color: var(--muted); }
.stat-value { margin: 0.2rem 0 0; font-size: 1.5rem; font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
.card > .table-wrap, .panel > .table-wrap { margin: 0 -1.2rem; width: calc(100% + 2.4rem); border-radius: 0; }
.card.flush > .table-wrap { margin: 0; width: 100%; }
.card > .table-wrap:last-child, .panel > .table-wrap:last-child { margin-bottom: -1.1rem; border-radius: 0 0 var(--radius) var(--radius); }
.card.flush > .table-wrap:last-child { margin-bottom: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; }
.content > .table-wrap, .content > form > .table-wrap { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
th, td { padding: 0.65rem 0.9rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th {
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
th:first-child, td:first-child { padding-left: 1.2rem; }
th:last-child, td:last-child { padding-right: 1.2rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
tbody tr.is-selected td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
th.check-col, td.check-col { width: 1%; padding-right: 0.25rem; }
th a.sort { color: inherit; display: inline-flex; align-items: center; gap: 0.25rem; }
th a.sort:hover { color: var(--text); text-decoration: none; }
th a.sort.is-active { color: var(--accent); }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { display: block; font-size: 0.76rem; color: var(--muted); }
.key-cell { display: inline-flex; align-items: center; gap: 0.3rem; }
.key-cell code { background: transparent; padding: 0; font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.kn-row, tr[data-href] { cursor: pointer; }
.kn-row a { color: var(--text); font-weight: 600; }
.actions { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; justify-content: flex-end; }

@media (max-width: 760px) {
  .r-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .r-table, .r-table tbody, .r-table tr, .r-table td { display: block; width: 100%; }
  .r-table tr { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); position: relative; }
  .r-table tbody tr:last-child { border-bottom: 0; }
  .r-table td { border: 0; padding: 0.2rem 0; display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; text-align: right; }
  .r-table td::before { content: attr(data-label); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); text-align: left; flex: none; }
  .r-table td[data-label=""]::before, .r-table td:not([data-label])::before { content: none; }
  .r-table td.primary-cell { display: block; text-align: left; padding-right: 2.5rem; font-size: 0.95rem; }
  .r-table td.primary-cell::before { content: none; }
  .r-table td.check-col { position: absolute; top: 0.85rem; right: 0.9rem; width: auto; padding: 0; }
  .r-table td.check-col::before { content: none; }
  .r-table td.actions-cell { width: 100%; justify-content: flex-end; padding-top: 0.5rem; }
  .r-table td.actions-cell::before { content: none; }
  .r-table td:first-child, .r-table td:last-child { padding-left: 0; padding-right: 0; }
  .r-table td.primary-cell:first-child { padding-right: 2.5rem; }
  .r-table tbody tr:hover td { background: transparent; }
  .r-table tr.is-selected { background: var(--accent-soft); }
}

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.toolbar .field { flex: 1 1 160px; min-width: 0; }
.toolbar .field.search { flex: 3 1 240px; }
.toolbar .field.narrow { flex: 0 1 140px; }
.toolbar label { font-size: 0.74rem; }
.toolbar .btn-group { flex: none; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 2.2rem; }
.active-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.8rem; color: var(--muted); }

/* Tabs: underline style for page sections, pills for filters. */
.tabs, .kn-tabs { display: flex; gap: 0.25rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-bottom: 1px solid var(--border); margin: 0; padding: 0 0.1rem; }
.tab, .kn-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.8rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 550;
  white-space: nowrap;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.tab:hover, .kn-tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active, .kn-tab.is-active, .tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.kn-count { font-family: var(--mono); font-size: 0.72rem; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 0.4rem; }
.tab-panel { display: grid; gap: 1.25rem; }
.tab-panel:not(.is-active) { display: none; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border); flex-wrap: wrap; }
.seg a, .seg button { padding: 0.3rem 0.7rem; border-radius: 7px; font-size: 0.8rem; font-weight: 550; color: var(--text-2); border: 0; background: none; cursor: pointer; text-decoration: none; font-family: inherit; }
.seg a:hover, .seg button:hover { color: var(--text); text-decoration: none; }
.seg .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.pager-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.pager-links a, .pager-links span { min-width: 34px; height: 34px; padding: 0 0.55rem; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 550; text-decoration: none; }
.pager-links a:hover { border-color: var(--accent); color: var(--accent); }
.pager-links .is-active { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.pager-links .is-disabled { opacity: 0.45; }

/* ---------- Menus (details based, work without JS) ---------- */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  max-width: min(320px, 90vw);
  z-index: 70;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 1px;
  text-align: left;
}
.menu.up .menu-panel { top: auto; bottom: calc(100% + 6px); }
.menu.left .menu-panel { right: auto; left: 0; }
.menu-panel form { margin: 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad-soft); color: var(--bad); }
.menu-item svg { color: var(--muted); }
.menu-item.danger svg { color: var(--bad); }
.menu-sep { height: 1px; background: var(--border); margin: 0.3rem 0.2rem; }
.menu-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.35rem 0.65rem 0.15rem; }

/* ---------- Dialogs ---------- */
dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.dialog-body { padding: 1.25rem 1.25rem 0.5rem; display: grid; gap: 0.6rem; }
.dialog-body h2 { font-size: 1.08rem; }
.dialog-body p { margin: 0; color: var(--text-2); font-size: 0.92rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem 1.25rem; flex-wrap: wrap; }

/* Command palette */
dialog.palette { width: min(640px, calc(100vw - 24px)); margin-top: 10vh; overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.palette-input input { border: 0; box-shadow: none; padding: 0.3rem 0; font-size: 1rem; background: transparent; min-height: 36px; }
.palette-input input:focus { box-shadow: none; }
.palette-list { list-style: none; margin: 0; padding: 0.4rem; max-height: min(60vh, 460px); overflow-y: auto; }
.palette-group { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0.55rem 0.65rem 0.25rem; }
.palette-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.65rem; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.palette-item .meta { margin-left: auto; font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.palette-item small { display: block; color: var(--muted); font-size: 0.76rem; }
.palette-item.is-focused, .palette-item:hover { background: var(--accent-soft); text-decoration: none; color: var(--text); }
.palette-foot { display: flex; gap: 1rem; padding: 0.55rem 1rem; border-top: 1px solid var(--border); font-size: 0.74rem; color: var(--muted); flex-wrap: wrap; }

/* ---------- Toasts / flash ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(16px + var(--safe-bottom)); z-index: 90; display: grid; gap: 0.5rem; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: toast-in 0.2s ease;
}
.toast.ok svg { color: var(--ok); }
.toast.bad svg { color: var(--bad); }
.toast .grow { padding-top: 1px; }
.toast button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.flash { margin: 0; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 0.9rem; display: flex; gap: 0.6rem; align-items: flex-start; }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: var(--ok-soft); color: var(--text); }
.flash.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background: var(--bad-soft); color: var(--text); }
.flash.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: var(--warn-soft); color: var(--text); }
.flash.info { border-color: color-mix(in srgb, var(--info) 40%, var(--border)); background: var(--info-soft); color: var(--text); }
.flash.dev { border-color: color-mix(in srgb, var(--dev) 40%, var(--border)); background: var(--dev-soft); color: var(--text); }
.flash svg { margin-top: 2px; }
.flash.ok svg { color: var(--ok); }
.flash.bad svg { color: var(--bad); }
.flash.warn svg { color: var(--warn); }
.flash.info svg { color: var(--info); }
.flash.dev svg { color: var(--dev); }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; gap: 0.4rem; text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .empty-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); margin-bottom: 0.25rem; }
.empty strong { color: var(--text); font-size: 0.95rem; }
.empty p { margin: 0; font-size: 0.86rem; max-width: 420px; }

/* ---------- Key/value ---------- */
.kv, .verify-kv { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 0; font-size: 0.88rem; }
.kv > div, .verify-kv > div { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.kv > div:last-child, .verify-kv > div:last-child { border-bottom: 0; }
.kv dt, .verify-kv dt { color: var(--muted); font-size: 0.8rem; }
.kv dd, .verify-kv dd { margin: 0; min-width: 0; }
.verify-kv dd { font-family: var(--mono); font-size: 0.82rem; }
@media (min-width: 1100px) { .kv.two { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; } }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .bar { fill: var(--accent); opacity: 0.85; }
.chart .bar:hover { opacity: 1; }
.chart .bar.alt { fill: var(--bad); }
.chart .bar.dev { fill: var(--dev); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: var(--accent-soft); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.legend i.alt { background: var(--bad); }
.legend i.dev { background: var(--dev); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter.bad > span { background: var(--bad); }
.meter.warn > span { background: var(--warn); }
.meter.dev > span { background: var(--dev); }
.dist { display: grid; gap: 0.55rem; }
.dist-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.75rem; font-size: 0.84rem; }
.dist-row .meter { grid-column: 1 / -1; }
.sparkline { width: 100%; height: 64px; display: block; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { display: flex; gap: 0.75rem; align-items: center; padding: 0.65rem 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list .li-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.list .li-icon.warn { background: var(--warn-soft); color: var(--warn); }
.list .li-icon.bad { background: var(--bad-soft); color: var(--bad); }
.list .li-icon.ok { background: var(--ok-soft); color: var(--ok); }
.list .li-icon.info { background: var(--info-soft); color: var(--info); }
.list .li-icon.dev { background: var(--dev-soft); color: var(--dev); }
.list .li-main { min-width: 0; flex: 1 1 auto; }
.list .li-main strong, .list .li-main a { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .li-main small { display: block; color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .li-end { flex: none; display: flex; gap: 0.4rem; align-items: center; font-size: 0.8rem; color: var(--muted); }
.audit-list { list-style: none; margin: 0; padding: 0; display: grid; font-size: 0.86rem; }
.audit-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.audit-list li:last-child { border-bottom: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--border); display: grid; gap: 0.75rem; }
.timeline li { position: relative; font-size: 0.86rem; }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: 0.35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li.bad::before { border-color: var(--bad); }
.timeline li.warn::before { border-color: var(--warn); }
.timeline time { color: var(--muted); font-size: 0.76rem; }

/* ---------- Code blocks ---------- */
pre, .out {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 520px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
details.json-fold, details.fold { margin-top: 0.5rem; }
details.json-fold > summary, details.fold > summary { cursor: pointer; color: var(--text-2); font-size: 0.84rem; font-weight: 550; padding: 0.3rem 0; }
details.json-fold[open] > summary, details.fold[open] > summary { margin-bottom: 0.4rem; }

/* ---------- Type picker (radio cards) ---------- */
.type-cards { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.type-card { position: relative; display: grid; gap: 0.3rem; padding: 0.9rem 1rem 0.9rem 2.6rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; color: var(--text); font-weight: 400; }
.type-card input { position: absolute; left: 1rem; top: 1.05rem; }
.type-card strong { font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.type-card span { font-size: 0.82rem; color: var(--muted); }
.type-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.type-card.dev:has(input:checked) { border-color: var(--dev); box-shadow: 0 0 0 3px var(--dev-soft); }

/* ---------- License specific ---------- */
.key-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.key-hero code { font-size: 1rem; padding: 0.35rem 0.6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; letter-spacing: 0.02em; }
.handoff-card { padding: 1rem 1.2rem; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-soft); display: grid; gap: 0.5rem; }
.handoff-card p { margin: 0; }
.handoff-card .key-line { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.handoff-card .key-line code { font-size: 1rem; font-weight: 600; background: var(--surface); }
.preview-box { padding: 0.75rem 0.9rem; border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); background: var(--surface-2); font-size: 0.88rem; }
.device-card { display: grid; gap: 0.6rem; padding: 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.device-card h3 { margin: 0; font-size: 0.98rem; display: flex; align-items: center; gap: 0.5rem; }
.device-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; font-size: 0.82rem; color: var(--muted); }
.verify-result { padding: 1rem 1.2rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); display: grid; gap: 0.6rem; }
.verify-result.is-ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.verify-result.is-bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.verify-result h3 { margin: 0; font-size: 1rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.bulk-bar {
  position: sticky;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
}
.bulk-bar.is-visible { display: flex; }
.bulk-bar select { min-height: 34px; padding-top: 0.3rem; padding-bottom: 0.3rem; width: auto; font-size: 0.85rem; }
.bulk-bar .btn { --btn-bg: var(--surface); --btn-fg: var(--text); }
.bulk-bar .btn.primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); }
.bulk-bar .btn.danger { --btn-bg: var(--bad); --btn-fg: #fff; --btn-bd: transparent; }
.bulk-bar .row { gap: 0.4rem; }

/* ---------- Searchable select ---------- */
.search-select-wrap { min-width: 0; }
.search-select { position: relative; width: 100%; }
.search-select-trigger {
  width: 100%;
  min-height: var(--touch);
  text-align: left;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-select-panel {
  display: none;
  position: absolute;
  z-index: 70;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-select.is-open .search-select-panel { display: flex; }
.search-select.is-sheet .search-select-panel { position: fixed; top: auto; bottom: 0; left: 0; right: 0; max-height: 70vh; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: var(--safe-bottom); }
.search-select-input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none !important; }
.search-select-list { list-style: none; margin: 0; padding: 0.35rem; overflow: auto; }
.search-select-option { padding: 0.5rem 0.6rem; border-radius: 7px; cursor: pointer; display: grid; gap: 0.1rem; font-size: 0.88rem; color: var(--text); }
.search-select-option:hover, .search-select-option.is-focused { background: var(--accent-soft); }
.search-select-option small { color: var(--muted); font-size: 0.76rem; }

/* ---------- Bugs / knowledge / capabilities ---------- */
.bug-gallery { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.bug-thumb { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.bug-thumb img { display: block; width: 100%; height: 150px; object-fit: contain; background: var(--code-bg); }
.bug-thumb a { font-size: 0.8rem; padding: 0.5rem 0.6rem; display: block; }
.kn-intro { color: var(--muted); font-size: 0.88rem; max-width: 860px; margin: 0; }
.kn-kind, .kn-status { display: inline-flex; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.74rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.kn-kind-fix, .kn-status-pending { color: var(--warn); background: var(--warn-soft); }
.kn-kind-gotcha { color: var(--bad); background: var(--bad-soft); }
.kn-kind-add, .kn-status-included { color: var(--accent); background: var(--accent-soft); }
.kn-status-approved { color: var(--ok); background: var(--ok-soft); }
.kn-status-rejected { color: var(--muted); }
.kn-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; color: var(--muted); font-size: 0.84rem; }
.kn-preview { padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); line-height: 1.6; font-size: 0.9rem; overflow-x: auto; }
.kn-preview pre { margin: 0.5rem 0; }
.kn-form { display: grid; gap: 0.85rem; }
.kn-left { text-align: left; }
details.kn-existing summary { cursor: pointer; color: var(--text-2); font-size: 0.86rem; margin: 0.75rem 0 0.5rem; }
.qr-box { display: inline-grid; place-items: center; padding: 12px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.qr-box svg { display: block; width: 200px; height: 200px; }
.recovery-panel { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.recovery-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; display: grid; gap: 0.4rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.recovery-list code { font-size: 0.9rem; display: block; padding: 0.35rem 0.5rem; }

/* ---------- Auth pages ---------- */
.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card {
  width: min(400px, 100%);
  padding: 1.75rem 1.5rem;
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.auth-card h1 { margin: 0; font-size: 1.4rem; text-align: center; }
.auth-card > p { text-align: center; margin: 0; }
.brand-logo { display: block; height: auto; object-fit: contain; }
.brand-logo-login { width: min(120px, 50%); margin: 0 auto; }
.auth-theme { position: fixed; top: calc(12px + var(--safe-top)); right: 12px; }

/* ---------- Public text pages ---------- */
.privacy-page { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; line-height: 1.65; }
.privacy-page h1 { font-size: 1.6rem; margin-bottom: 1rem; }
.privacy-page h2 { font-size: 1.08rem; margin: 1.5rem 0 0.5rem; }
.privacy-lang { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

/* ---------- Misc ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.dev { background: var(--dev); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.callout { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 0.88rem; }
.callout.dev { background: var(--dev-soft); border-color: color-mix(in srgb, var(--dev) 35%, var(--border)); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.callout p { margin: 0; }
.callout svg { margin-top: 2px; flex: none; }
.callout.dev svg { color: var(--dev); }
.callout.warn svg { color: var(--warn); }
.signature { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.err-text { font-family: var(--mono); font-size: 0.8rem; color: var(--bad); white-space: pre-wrap; word-break: break-word; }
.scroll-x { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .sidebar, .topbar, .bulk-bar, .toasts, .menu, .btn { display: none !important; }
  .main-col { margin: 0 !important; }
  body { background: #fff; }
}

/* ---------- Small screens ---------- */
.filters-toggle { display: none !important; }
@media (max-width: 1023px) {
  [data-sidebar-rail] { display: none !important; }
}
@media (max-width: 640px) {
  .page-head .btn-group { margin-left: 0; width: 100%; }
  .page-head .btn-group > .btn, .page-head .btn-group > form, .page-head .btn-group > .seg { flex: 1 1 auto; }
  .page-head .btn-group > form > .btn { width: 100%; }
  .page-head .btn-group > details.menu { flex: none; }
  .toolbar[data-collapsible] .filters-toggle { display: inline-flex !important; }
  .toolbar[data-collapsible]:not(.is-open) > .field:not(.search),
  .toolbar[data-collapsible]:not(.is-open) > label.check { display: none; }
  .toolbar .field.narrow { flex: 1 1 140px; }
  .content { gap: 1rem; padding-top: 1rem; }
  .card, .panel, .kn-card, .chart-card { padding: 1rem; }
  .card > .table-wrap, .panel > .table-wrap { margin: 0 -1rem; width: calc(100% + 2rem); }
  .card > .table-wrap:last-child, .panel > .table-wrap:last-child { margin-bottom: -1rem; }
  .card-foot { margin: 1rem -1rem -1rem; padding: 0.7rem 1rem; }
  .card.flush > .card-head { padding: 0.9rem 1rem 0.6rem; }
  .card.flush > .card-foot { padding: 0.7rem 1rem; }
  .kpi { padding: 0.75rem 0.85rem; }
  .tabs { margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
  .bulk-bar { border-radius: var(--radius-sm); }
  .bulk-bar form { width: 100%; }
  .bulk-bar select { flex: 1 1 auto; }
}
