/* DNK Support System — mobile-first, responsive, light/dark */
:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #ededf0;
  --text: #111111;
  --muted: #5c5c63;
  --border: #d8d8dc;
  --primary: #111111;
  --primary-ink: #ffffff;
  --danger: #c93434;
  --warning: #b77b00;
  --success: #1f8a4c;
  --info: #2a7bb8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c;
    --surface: #161618;
    --surface-2: #1f1f22;
    --text: #f2f2f2;
    --muted: #a3a3a8;
    --border: #2c2c31;
    --primary: #f2f2f2;
    --primary-ink: #0b0b0c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0c; --surface: #161618; --surface-2: #1f1f22; --text: #f2f2f2;
  --muted: #a3a3a8; --border: #2c2c31; --primary: #f2f2f2; --primary-ink: #0b0b0c; --shadow: none;
}
/* Content boxes in dark mode: the original dark surface, 25% lighter. Text keeps the original light colours. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card { --surface: #1c1c1e; background: #1c1c1e; }
}
:root[data-theme="dark"] .card { --surface: #1c1c1e; background: #1c1c1e; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.55 var(--font); color: var(--text); background: var(--bg);
  min-height: 100vh; display: flex; flex-direction: column;
}
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h2.h4 { font-size: .95rem; margin: 0 0 .3rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 50%, transparent); outline-offset: 2px;
}
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.h4 { font-size: .95rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .9rem; }
.pre-wrap { white-space: normal; }
.small-caps { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .5rem; }
.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; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--primary-ink); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-ink); font-size: .75rem; font-weight: 800; }
.brand-logo { height: 32px; width: auto; flex: none; }
.nav-toggle { margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; color: var(--text); font-size: 1.1rem; cursor: pointer; min-height: 40px; min-width: 44px; }
.primary-nav { display: none; width: 100%; flex-direction: column; gap: 4px; }
.primary-nav.is-open { display: flex; }
.primary-nav a { padding: 10px 12px; border-radius: 8px; color: var(--text); min-height: 44px; display: flex; align-items: center; }
.primary-nav a:hover { background: var(--surface-2); text-decoration: none; }
.primary-nav a.is-active { background: var(--surface-2); font-weight: 600; color: var(--primary); }
.nav-user { padding: 8px 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }

/* The header never breaks a word: when everything does not fit on one line (a long app name, user name or an
   extra menu), app.js adds .is-compact and the header switches to the menu button, as on a narrow screen. */
.brand { flex: none; white-space: nowrap; }
@media (min-width: 1000px) {
  .topbar:not(.is-compact) .nav-toggle { display: none; }
  .topbar:not(.is-compact) .primary-nav { display: flex; width: auto; flex-direction: row; align-items: center; margin-left: auto; gap: 2px; overflow-wrap: normal; }
  .topbar:not(.is-compact) .primary-nav > * { flex: none; }
  .topbar:not(.is-compact) .primary-nav a { min-height: 36px; padding: 6px 10px; white-space: nowrap; }
  .topbar:not(.is-compact) .primary-nav .btn { white-space: nowrap; min-height: 36px; padding: 6px 10px; }
  /* On one line the theme button shows only its icon; the label stays for screen readers and in the menu. */
  .topbar:not(.is-compact) .theme-toggle [data-theme-label] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .topbar:not(.is-compact) .topbar-inner { flex-wrap: nowrap; }
}

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.05); background: var(--primary); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 42px;
}
textarea { min-height: 96px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.checkbox input { width: auto; min-height: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin-bottom: 0; }
.task-form input, .task-form select { min-height: 40px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Cards, alerts, badges ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.empty-state { text-align: center; padding: 32px 16px; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: color-mix(in srgb, var(--success) 12%, transparent); border-color: var(--success); }
.alert-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); }
.alert-warning { background: color-mix(in srgb, var(--warning) 14%, transparent); border-color: var(--warning); }
.alert-info { background: color-mix(in srgb, var(--info) 12%, transparent); border-color: var(--info); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); text-transform: capitalize; white-space: nowrap; }
.badge-open, .badge-new { color: var(--info); }
.badge-pending, .badge-triaged, .badge-normal, .badge-minor { color: var(--muted); }
.badge-high, .badge-major, .badge-in_review { color: var(--warning); }
.badge-urgent, .badge-critical, .badge-blocker, .badge-overdue { color: var(--danger); }
.badge-resolved, .badge-closed, .badge-done, .badge-low { color: var(--success); }
.badge-in_progress, .badge-doing { color: var(--primary); }
.badge-warning { color: var(--warning); }
.badge-internal { color: var(--warning); }
.badge-role { color: var(--primary); }

/* ---------- Tables (cards on small screens) ---------- */
.table-wrap { overflow-x: auto; padding: 0; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.hide-sm { display: none; }
@media (min-width: 720px) { .hide-sm { display: table-cell; } }

/* ---------- Tabs / lists ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 12px; border-radius: 8px 8px 0 0; color: var(--muted); white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; background: none; border: 0; font: inherit; cursor: pointer; }
.tab.is-active { color: var(--primary); font-weight: 700; box-shadow: inset 0 -2px 0 var(--primary); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.list li:last-child { border-bottom: 0; }
.breadcrumbs { margin-bottom: 4px; }
.actions-row .btn { flex: 0 0 auto; }

/* ---------- Ticket threads ---------- */
.split { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.split-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.split-side { position: static; }
@media (min-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr) 300px; }
  .split-side { position: sticky; top: 76px; }
}
.entry { padding: 14px 16px; }
.entry-note { background: color-mix(in srgb, var(--warning) 8%, var(--surface)); border-style: dashed; }
.entry-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.entry-body { overflow-wrap: anywhere; }
.system-note { text-align: center; padding: 4px 0; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 14px 0 0; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { text-align: left; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.actions-row + .card, .actions-row { margin-bottom: 14px; }

/* ---------- Knowledge base ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }
.space-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 640px) { .space-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .space-grid { grid-template-columns: repeat(3, 1fr); } }
.space-card { display: flex; gap: 12px; color: var(--text); }
.space-card:hover { text-decoration: none; border-color: var(--primary); }
.space-avatar { flex: 0 0 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: 1.1rem; }
.result-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.excerpt { margin: 6px 0 0; color: var(--muted); }
.kb-layout { display: grid; gap: 16px; grid-template-columns: 1fr; }
.kb-sidebar { max-height: none; overflow: auto; }
.kb-tree, .kb-tree ul { list-style: none; padding-left: 12px; margin: 0; }
.kb-tree > li { padding-left: 0; }
.kb-tree li { margin: 3px 0; }
.kb-tree a { display: block; padding: 6px 8px; border-radius: 6px; color: var(--text); font-size: .92rem; }
.kb-tree a:hover { background: var(--surface-2); text-decoration: none; }
.kb-tree a.is-active { background: var(--surface-2); color: var(--primary); font-weight: 700; }
.kb-tree a.is-draft { font-style: italic; color: var(--muted); }
@media (min-width: 900px) { .kb-layout { grid-template-columns: 260px minmax(0, 1fr); align-items: start; } .kb-sidebar { position: sticky; top: 76px; max-height: calc(100vh - 100px); } }

.prose { line-height: 1.7; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.2em; }
.prose h1 { font-size: 1.4rem; } .prose h2 { font-size: 1.2rem; } .prose h3 { font-size: 1.05rem; }
.prose code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.prose ul { padding-left: 1.3em; }
.prose p { margin: .7em 0; }
.page-editor .tab { min-height: 40px; }
.editor-tabs { display: flex; gap: 6px; }
#page-body { font-family: var(--mono); font-size: .92rem; }
#page-preview { padding: 14px; min-height: 180px; }
.kb-article { min-height: 240px; }

/* ---------- Bugs & tracker ---------- */
.task-list { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.task { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.task-main { display: flex; flex-direction: column; }
.task-main .done { text-decoration: line-through; color: var(--muted); }
.task-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.task-todo { border-left: 4px solid var(--muted); }
.task-doing { border-left: 4px solid var(--primary); }
.task-done { border-left: 4px solid var(--success); }
.kanban { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .kanban { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; } }
.kanban-col { background: var(--surface-2); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.kanban-head { display: flex; justify-content: space-between; align-items: center; }
.kanban-head h2 { margin: 0; }
.kanban-card { padding: 12px; display: flex; flex-direction: column; gap: 4px; border-left: 4px solid var(--border); }
.kanban-card.priority-urgent { border-left-color: var(--danger); }
.kanban-card.priority-high { border-left-color: var(--warning); }
.kanban-card.priority-normal { border-left-color: var(--primary); }
.kanban-title { overflow-wrap: anywhere; }
.kanban-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); flex-wrap: wrap; }
.kanban-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.empty-col { margin: 0; }

/* ---------- Auth & footer ---------- */
.guest { background: var(--bg); }
.guest-main { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.guest-main > .alert { position: fixed; top: 12px; left: 12px; right: 12px; max-width: 420px; margin: 0 auto; }
.auth-card { width: 100%; max-width: 400px; }
.brand-title { display: flex; gap: 10px; align-items: center; font-size: 1.3rem; }
.footer { border-top: 1px solid var(--border); padding: 14px 0; color: var(--muted); font-size: .85rem; background: var(--surface); }
.footer .container { padding-top: 0; padding-bottom: 0; }

@media (max-width: 480px) {
  .container { padding: 12px; }
  .btn { width: auto; }
  .page-head .btn { width: 100%; }
}
@media print {
  .topbar, .footer, .split-side, .actions-row, form, .kanban-actions, .task-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}
/* ---------- Settings forms ---------- */
.check-list { display: grid; gap: 10px; }
.check-list.two-col { grid-template-columns: 1fr; }
@media (min-width: 640px) { .check-list.two-col { grid-template-columns: 1fr 1fr; } }
label.checkbox { align-items: flex-start; }
label.checkbox > span { font-weight: 500; line-height: 1.4; }
label.checkbox.is-disabled { opacity: .6; }
label.checkbox input[type="checkbox"] { margin-top: 3px; }
.fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0; display: grid; gap: 10px; min-width: 0; }
.fieldset legend { font-weight: 700; padding: 0 6px; }
.fieldset > p { margin: 0; }
.grow { flex: 1 1 220px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone h2 { color: var(--danger); }
/* Two-factor setup. The QR code keeps a white background so phones can read it in dark mode too. */
.qr-code { background: #fff; padding: 12px; border-radius: 8px; width: 220px; height: 220px; }
.setup-key { letter-spacing: 0.08em; word-break: break-all; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

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

/* Theme picker (between the user name and Sign out) */
.icon { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.theme-menu { position: relative; }
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.theme-icon { display: inline-flex; }
.theme-options {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 260px; white-space: nowrap;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.theme-options li { margin: 0; }
.theme-options button {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.theme-options button:hover, .theme-options button:focus-visible { background: var(--surface-2); outline: none; }
.theme-options button[aria-checked="true"] { color: var(--primary); font-weight: 600; }
.theme-options button[aria-checked="true"]::after { content: "✓"; margin-left: auto; }

/* User menu (the signed-in name): User Settings, and Security with its pages beneath it */
.user-menu { position: relative; }
.user-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; color: var(--text); }
.icon-sm { width: 14px; height: 14px; }
.user-options {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 260px; white-space: nowrap;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.user-options li { margin: 0; }
.user-options a { display: flex; align-items: center; min-height: 44px; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.user-options a:hover, .user-options a:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.user-options .menu-sub { list-style: none; margin: 0; padding: 0 0 0 16px; }
.user-options .menu-sub a { color: var(--muted); }
@media (max-width: 999px) { .user-options { left: 0; right: auto; } }
.topbar.is-compact .user-options { left: 0; right: auto; }

/* Account pages */
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.badge-on { color: var(--success); }
.badge-off { color: var(--muted); }

/* Administration overview */
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; margin: 0; }
.kv dt { color: var(--muted, #6b7280); }
.kv dd { margin: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.input-narrow { width: 6.5rem; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 0.4rem; } }

/* API documentation page (CONFIDENTIAL) */
.api-docs-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; padding: 16px; }
.api-docs-head h1 { margin: 0; }
.api-docs #swagger { padding: 0 16px 32px; }
.api-docs .swagger-ui .topbar { display: none; }

/* Sign-in: username with a small "Remember" check beside it, and the password show/hide button */
.username-row { display: flex; align-items: flex-end; gap: 10px; }
.username-row > label.grow { flex: 1; min-width: 0; }
.remember-check { flex-shrink: 0; flex-direction: row; align-items: center; gap: 6px; font-size: .85rem; font-weight: 500; white-space: nowrap; margin-bottom: 10px; }
.remember-check input[type="checkbox"] { width: auto; min-height: 0; margin: 0; }
.password-field { display: flex; align-items: center; gap: .5rem; }
.password-field input { flex: 1; min-width: 0; }
.pw-eye { padding: 6px 8px; line-height: 0; }
.pw-rules { list-style: none; margin: .4rem 0 0; padding: 0; color: var(--muted); }
.pw-rules li.met { color: var(--success); }

/* ---------- Administration menu: grouped, no scroll bar ----------
   Wide screens: a bar of group menus. Narrow screens: one button that opens the groups as a list.
   Without JavaScript every group simply shows as an open list. */
.admin-nav { margin-bottom: 16px; border-bottom: 1px solid var(--border); position: relative; }
.admin-nav-toggle { display: none; }
.admin-nav-list, .admin-group-menu { list-style: none; margin: 0; padding: 0; }
.admin-nav-list { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.admin-link, .admin-group-toggle {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px; border-radius: 8px 8px 0 0;
  color: var(--muted); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.admin-link:hover, .admin-group-toggle:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin-link.is-active { color: var(--primary); font-weight: 700; }
.admin-nav-list > li > .admin-link.is-active, .admin-group.has-active > .admin-group-toggle { color: var(--primary); font-weight: 700; box-shadow: inset 0 -2px 0 var(--primary); }
.admin-group { position: relative; }
.admin-nav-js .admin-group-menu {
  display: none; position: absolute; left: 0; top: 100%; z-index: 40; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.admin-nav-js .admin-group.is-open .admin-group-menu { display: block; }
.admin-nav-js .admin-group-menu .admin-link { border-radius: 8px; color: var(--text); }
.admin-nav-js .admin-group-menu .admin-link.is-active { background: var(--surface-2); box-shadow: none; }
.admin-group-toggle .icon-sm { transition: transform .15s; }
.admin-group.is-open .admin-group-toggle .icon-sm { transform: rotate(180deg); }
@media (max-width: 859px) {
  .admin-nav { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  .admin-nav-js .admin-nav-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 8px 14px;
    background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: left;
  }
  .admin-nav-toggle .icon-sm { margin-left: auto; }
  .admin-nav.is-open .admin-nav-toggle .icon-sm { transform: rotate(180deg); }
  .admin-nav-js .admin-nav-list { display: none; }
  .admin-nav-js.is-open .admin-nav-list { display: block; padding: 0 8px 8px; border-top: 1px solid var(--border); }
  .admin-nav-list > li > .admin-link, .admin-group-menu .admin-link { border-radius: 8px; }
  .admin-nav-list > li > .admin-link.is-active, .admin-group.has-active > .admin-group-toggle { box-shadow: none; }
  .admin-group-toggle { pointer-events: none; width: 100%; padding-bottom: 2px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; cursor: default; }
  .admin-group-toggle .icon { display: none; }
  .admin-nav-js .admin-group-menu { display: block; position: static; min-width: 0; padding: 0 0 4px 8px; border: 0; box-shadow: none; background: none; }
}

/* ---------- Responsive polish ---------- */
.btn, .card, .primary-nav a, .space-card { transition: background-color .15s, border-color .15s, box-shadow .15s, transform .15s; }
a.card:hover, .space-card:hover { box-shadow: 0 4px 14px rgba(16, 24, 40, .12); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.container { padding: 20px 16px 28px; }
@media (min-width: 1000px) { .container { padding: 28px 24px 40px; } }
.page-head { align-items: center; margin-bottom: 18px; }
.page-head > div > .muted.small { margin: 0; }
.card-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card-grid + .card, .card + .card { margin-top: 12px; }
.primary-nav { overflow-wrap: anywhere; }
@media (max-width: 999px) {
  .primary-nav.is-open { padding: 8px 0 4px; border-top: 1px solid var(--border); }
  .primary-nav .user-menu, .primary-nav .theme-menu { width: 100%; }
  .primary-nav .user-toggle, .primary-nav .theme-toggle { width: 100%; justify-content: flex-start; min-height: 44px; }
  .primary-nav .inline-form, .primary-nav .inline-form .btn { width: 100%; justify-content: flex-start; min-height: 44px; }
  .user-options, .theme-options { min-width: 0; width: 100%; position: static; box-shadow: none; margin-top: 4px; white-space: normal; }
}
.topbar.is-compact .primary-nav.is-open { padding: 8px 0 4px; border-top: 1px solid var(--border); }
.topbar.is-compact .primary-nav .user-menu, .topbar.is-compact .primary-nav .theme-menu { width: 100%; }
.topbar.is-compact .primary-nav .user-toggle, .topbar.is-compact .primary-nav .theme-toggle { width: 100%; justify-content: flex-start; min-height: 44px; }
.topbar.is-compact .primary-nav .inline-form, .topbar.is-compact .primary-nav .inline-form .btn { width: 100%; justify-content: flex-start; min-height: 44px; }
.topbar.is-compact .user-options, .topbar.is-compact .theme-options { min-width: 0; width: 100%; position: static; box-shadow: none; margin-top: 4px; white-space: normal; }
@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  .stat-value { font-size: 1.5rem; }
  .table th, .table td { padding: 8px 10px; }
  .actions-row > .btn, .actions-row > form { flex: 1 1 auto; }
}

/* Public help forms (/help) */
.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--primary); }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
code.break { word-break: break-all; }
.crash-report summary { cursor: pointer; }
.crash-report pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; max-height: 320px; overflow: auto; }
