/* ---------- Admin panel ----------
   Staff console on the current brand (logstrata_docs/brand/logstrata.html,
   mobile src/lib/theme.ts): Paper and Night, one green accent, Manrope for
   type and JetBrains Mono for numerals and identifiers. Both themes follow the
   system by default; the rail's toggle pins one (html[data-theme]).

   Tokens are scoped to `.admin-body` ON PURPOSE: the print stickers share
   variable names with the shared stylesheet and must stay as they were.
   Role names mirror the app's theme roles. The accent marks the active place and
   links; the primary action is ink (Paper) / paper (Night), as in the app.
   Gold is records only; red is destructive. */

.admin-body {
  --bg-app: #FAF8F1;
  --surface: #FFFFFF;
  --surface-2: #F0EEE4;
  --surface-3: #E2E6D9;
  --rail: #F0EEE4;
  --border: #DDE1D3;
  --border-strong: #C9D0C1;
  --text: #192820;
  --text-muted: #536357;
  --text-faint: #59695C;
  --accent: #17694E;
  --accent-wash: #DCECDF;
  --on-accent: #FAF8F1;
  --primary: #192820;
  --on-primary: #FAF8F1;
  --gold: #805810;
  --gold-wash: rgba(128, 88, 16, 0.12);
  --danger: #A83E32;
  --danger-wash: rgba(168, 62, 50, 0.1);
  --shadow: 0 1px 2px rgba(25, 40, 32, 0.05);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --side-width: 244px;
  /* Names older rules and shared components still read. */
  --signal: var(--accent);
  --signal-wash: var(--accent-wash);
  --verdigris: var(--accent);
  --verified: var(--accent);

  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .admin-body { /* Night */
    --bg-app: #111917;
    --surface: #1B2822;
    --surface-2: #20302A;
    --surface-3: #24372C;
    --rail: #15201B;
    --border: #2A3A31;
    --border-strong: #2E4035;
    --text: #FAF9F2;
    --text-muted: #A0AEA4;
    --text-faint: #91A095;
    --accent: #83B99E;
    --accent-wash: #20362B;
    --on-accent: #111917;
    --primary: #FAF9F2;
    --on-primary: #111917;
    --gold: #ECC878;
    --gold-wash: rgba(236, 200, 120, 0.14);
    --danger: #F3ADA3;
    --danger-wash: rgba(243, 173, 163, 0.12);
    --shadow: none;
    color-scheme: dark;
  }
}
html[data-theme="dark"] .admin-body {
  --bg-app: #111917;
  --surface: #1B2822;
  --surface-2: #20302A;
  --surface-3: #24372C;
  --rail: #15201B;
  --border: #2A3A31;
  --border-strong: #2E4035;
  --text: #FAF9F2;
  --text-muted: #A0AEA4;
  --text-faint: #91A095;
  --accent: #83B99E;
  --accent-wash: #20362B;
  --on-accent: #111917;
  --primary: #FAF9F2;
  --on-primary: #111917;
  --gold: #ECC878;
  --gold-wash: rgba(236, 200, 120, 0.14);
  --danger: #F3ADA3;
  --danger-wash: rgba(243, 173, 163, 0.12);
  --shadow: none;
  color-scheme: dark;
}

.admin-body a { color: inherit; }
.admin-body :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.admin-shell { display: flex; min-height: 100vh; align-items: stretch; }

/* The brand lockup ships in ink and reverse; the theme picks one. */
.admin-brand-art { display: block; height: 22px; width: auto; }
.admin-brand-art.is-reverse { display: none; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .admin-brand-art.is-ink { display: none; }
  html:not([data-theme="light"]) .admin-brand-art.is-reverse { display: block; }
}
html[data-theme="dark"] .admin-brand-art.is-ink { display: none; }
html[data-theme="dark"] .admin-brand-art.is-reverse { display: block; }

/* ---- Rail ---- */

.admin-side {
  position: sticky;
  top: 0;
  flex: 0 0 var(--side-width);
  width: var(--side-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--border);
  background: var(--rail);
  overflow-y: auto;
}
.admin-brand { display: flex; align-items: center; gap: 8px; padding: 0 10px; text-decoration: none; }
.admin-brand-tag {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-muted);
  font: 700 9px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.admin-menu { display: flex; flex-direction: column; gap: 2px; }
.admin-menu-label {
  margin: 18px 10px 6px;
  color: var(--text-faint);
  font: 700 9px var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.admin-menu-label:first-child { margin-top: 0; }
.admin-menu-link {
  display: block;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-muted) !important;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.admin-menu-link:hover { background: var(--surface-3); color: var(--text) !important; }
.admin-menu-link.active {
  background: var(--accent-wash);
  color: var(--accent) !important;
  font-weight: 700;
}
.admin-menu-sub { margin: 0 0 0 10px; padding-left: 8px; border-left: 1px solid var(--border-strong); }
.admin-menu-sub .admin-menu-link { padding: 6px 10px; font-size: 13px; font-weight: 550; }

.admin-side-foot {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid var(--border);
}
.admin-side-user { font-size: 13px; font-weight: 700; }
.admin-side-role { margin-top: 2px; color: var(--text-faint); font: 700 9px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.admin-side-zone { margin-top: 8px; color: var(--text-faint); font: 500 11px var(--mono); }
.admin-side-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.admin-side-signout, .admin-theme-toggle {
  padding: 0;
  background: none;
  border: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.admin-side-signout:hover { color: var(--danger); }
.admin-theme-toggle:hover { color: var(--text); }
.admin-side form { margin: 0; }

/* ---- Main column ---- */

.admin-main { flex: 1 1 auto; min-width: 0; }
.admin-content { max-width: 1280px; padding: 8px 36px 96px; }

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 36px;
  background: color-mix(in srgb, var(--bg-app) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.admin-crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-faint); font-size: 13px; font-weight: 600; }
.admin-crumbs a { color: var(--text-muted); text-decoration: none; }
.admin-crumbs a:hover { color: var(--text); }
.admin-crumbs .sep { color: var(--border-strong); }
.admin-crumbs .here { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-gsearch { display: flex; margin: 0; }
.admin-gsearch input {
  width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.admin-gsearch input::placeholder { color: var(--text-faint); }

.admin-main h1 {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.admin-main h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }

.admin-body .flash { max-width: none; margin: 18px 0 0; border: 1px solid transparent; }
.admin-body .flash-notice { background: var(--accent-wash); color: var(--accent); border-color: var(--accent-wash); }
.admin-body .flash-alert { background: var(--danger-wash); color: var(--danger); }

.admin-eyebrow {
  color: var(--text-faint);
  font: 700 10px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.admin-sub { margin-top: 6px; color: var(--text-muted); font-size: 13px; }
.admin-back {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.admin-back:hover { color: var(--text); }

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 22px;
}
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.admin-section { margin-top: 30px; }
.admin-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 10px;
}
.admin-section-head h2 { flex: 0 0 auto; }
.admin-section-head .admin-sub { margin-top: 0; }
.admin-note { max-width: 74ch; margin-bottom: 12px; }

/* ---- Tabs (server-side: a link per tab, the current one marked) ---- */

.admin-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.admin-tab {
  position: relative;
  padding: 10px 12px;
  color: var(--text-muted) !important;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.admin-tab:hover { color: var(--text) !important; }
.admin-tab.active { color: var(--text) !important; font-weight: 700; }
.admin-tab.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.admin-tab .count { margin-left: 6px; color: var(--text-faint); font: 600 11px var(--mono); }
.admin-tab-danger.active::after { background: var(--danger); }

/* ---- Stat tiles ---- */

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.admin-stat {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
}
a.admin-stat:hover { border-color: var(--border-strong); }
.admin-stat strong { display: block; font: 700 28px var(--mono); letter-spacing: -0.03em; }
.admin-stat span { display: block; margin-top: 4px; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.admin-stat em { display: block; margin-top: 2px; color: var(--text-faint); font: normal 500 12px var(--font); }

.admin-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; }

/* ---- Facts (label / value rows on a detail page) ---- */

.admin-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1px; border: 1px solid var(--border); border-radius: 14px; background: var(--border); overflow: hidden; }
.admin-fact { padding: 12px 16px; background: var(--surface); }
.admin-fact dt { color: var(--text-faint); font: 700 9px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.admin-fact dd { margin: 4px 0 0; font-size: 14px; font-weight: 600; word-break: break-word; }

/* ---- Danger zone ---- */

.admin-danger {
  margin-top: 8px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.admin-danger-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 16px 18px; }
.admin-danger-row + .admin-danger-row { border-top: 1px solid var(--border); }
.admin-danger-row strong { display: block; font-weight: 700; }
.admin-danger-row p { margin-top: 2px; max-width: 60ch; color: var(--text-muted); font-size: 13px; }
.admin-danger-row .adm-inline-form { margin: 0; }

/* ---- Buttons ---- */

.admin-body .btn-primary {
  display: inline-block;
  width: auto;
  margin-top: 0;
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
}
.admin-body .btn-primary:hover { opacity: 0.88; }
.admin-btn { width: auto; margin-top: 0; }

.btn-ghost-admin {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost-admin:hover { border-color: var(--text-faint); color: var(--text); }
.link-danger { color: var(--danger) !important; }
.link-danger:hover { border-color: var(--danger) !important; }
.admin-delete { margin-top: 24px; }

/* ---- Filters ---- */

.admin-filter-form {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.admin-search { display: flex; gap: 10px; }
.admin-search input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
.admin-filter-row,
.adm-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.admin-filter-row:first-child,
.adm-filter-row:first-child { margin-top: 0; }
.admin-filter-row select,
.adm-filter-row select,
.adm-filter-row input[type="date"] {
  flex: 1 1 170px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
.adm-filter-row input[type="date"] { flex: 0 1 160px; }
.adm-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}
.adm-check input { accent-color: var(--signal); }

.admin-results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}
.admin-empty {
  padding: 28px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--text-faint);
  font-size: 14px;
  text-align: center;
}
.admin-pagination { display: flex; gap: 10px; margin-top: 18px; }

/* ---- Lists and cards ---- */

.admin-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.admin-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.admin-row strong { display: block; font-size: 15px; font-weight: 650; }
.admin-row span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 13px; }
.admin-chevron { color: var(--text-faint); font-size: 20px; }

.admin-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.admin-card-head { display: flex; justify-content: space-between; gap: 12px; }
.admin-card-head strong { display: block; font-weight: 650; }
.admin-card-head span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 13px; }
.admin-card-actions { display: flex; gap: 14px; align-items: flex-start; }
.admin-card-actions a,
.admin-card-actions button {
  padding: 0;
  border: none;
  background: none;
  color: var(--signal);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.admin-slugs { margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.slug-primary { color: var(--signal); font-weight: 700; }
.slug-alt { color: var(--text-muted); }
.admin-exercise-thumb {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
}
.tracking-mode { font-style: normal; }
.tracking-mode-per_side,
.tracking-mode-per_hand,
.tracking-mode-alternating_total { color: var(--gold); }

/* ---- Forms ---- */

.admin-form { max-width: 620px; margin-top: 18px; }
.admin-form-wide { max-width: 820px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.admin-form label,
.field label {
  display: block;
  margin: 16px 0 6px;
  color: var(--text-faint);
  font: 650 9px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}
.admin-form textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.admin-form input[readonly] { color: var(--text-faint); cursor: not-allowed; }
.field-hint { margin-top: 5px; color: var(--text-faint); font-size: 12px; }
.error-messages {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 13px;
}

/* ---- Data tables (athlete browser) ----
   Wide content scrolls inside its own box; the page itself never scrolls
   sideways. */

.adm-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.adm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.adm-table th,
.adm-table td {
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.adm-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-faint);
  font: 650 9px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tbody tr:hover { background: var(--surface-2); }
.adm-table tbody th { width: 170px; color: var(--text-faint); font-weight: 600; }
.adm-num { text-align: right !important; }
.adm-mono { font-family: var(--mono); font-size: 12px; }
.adm-faint { color: var(--text-faint); }
.adm-link { color: var(--signal); font-weight: 650; text-decoration: none; }
.adm-link:hover { text-decoration: underline; }
.adm-submit { padding: 0; border: none; background: none; font: inherit; cursor: pointer; }

/* Tombstones stay visible: deleted_at is load-bearing for offline reconcile,
   and hiding them would hide the bugs worth seeing. */
.adm-row-deleted td { opacity: 0.42; text-decoration: line-through; }
.adm-row-deleted td:last-child { opacity: 1; text-decoration: none; }

.adm-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-muted);
  font: 650 10px var(--mono);
  letter-spacing: 0.04em;
}
.adm-badge-logstrata { background: var(--signal-wash); color: var(--signal); }
.adm-badge-hevy,
.adm-badge-strong { background: var(--surface-3); color: var(--text-faint); }
.adm-badge-pr { background: var(--gold-wash); color: var(--gold); }
.adm-badge-warmup { background: var(--surface-3); color: var(--text-faint); }
.adm-badge-dropset { background: var(--signal-wash); color: var(--signal); }
.adm-badge-failure,
.adm-badge-mode { background: var(--danger-wash); color: var(--danger); }

.adm-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}
.adm-inline-actions form { margin: 0; }

/* ---- Narrow screens: the sidebar becomes a top bar (CSS only, no JS) ---- */

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-side {
    position: static;
    flex: none;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .admin-menu { flex-direction: row; align-items: center; gap: 4px; }
  .admin-menu-label { display: none; }
  .admin-menu-link { white-space: nowrap; }
  .admin-side-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 0 auto;
    padding: 0;
    border-top: none;
  }
  .admin-side-role,
  .admin-side-zone { display: none; }
  .admin-side-signout { margin-top: 0; }
  .admin-content { padding: 4px 16px 70px; }
  .admin-topbar { position: static; padding: 10px 16px; }
  .admin-gsearch input { width: 100%; }
  .admin-menu-sub { display: none; }
  .admin-header { flex-direction: column; }
  .admin-form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Tom Select (exercise picker) — themed to match the forms ---------- */

.admin-form .ts-wrapper { margin: 0; }
.admin-form .ts-control {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 12px;
  gap: 6px;
  box-shadow: none;
}
.admin-form .ts-wrapper.focus .ts-control {
  border-color: var(--accent);
  box-shadow: none;
}
.admin-form .ts-control input { color: var(--text); font-size: 15px; }
.admin-form .ts-control input::placeholder { color: var(--text-faint); }
.admin-form .ts-control .item {
  background: var(--surface-3);
  color: var(--text);
  border-radius: 8px;
  padding: 3px 8px;
}
/* The first pick is the sticker's default — give it the volt edge. */
.admin-form .ts-control .item:first-child { outline: 1px solid var(--accent); }
.admin-form .ts-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}
.admin-form .ts-dropdown .option { padding: 10px 14px; }
.admin-form .ts-dropdown .active { background: var(--accent-wash); color: var(--accent); }
.admin-form .ts-dropdown .highlight {
  background: var(--accent-wash);
  color: inherit;
  border-radius: 3px;
}

/* ---------- The exercise form (7 Sep 2026): sections, the contributions grid ---------- */
.adm-fieldset {
  margin: 18px 0 0;
  padding: 4px 18px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  min-inline-size: 0;
}
.adm-fieldset legend {
  padding: 0 8px;
  margin-left: -8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.adm-fieldset .field { margin-top: 0; }
.adm-fieldset .admin-form-grid { gap: 0 16px; }
.admin-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.adm-more { margin-top: 8px; font-size: 12px; color: var(--text-faint); }
.adm-more summary { cursor: pointer; color: var(--text-muted); font-weight: 600; list-style: none; }
.adm-more summary::before { content: "▸ "; }
.adm-more[open] summary::before { content: "▾ "; }
.adm-more p { margin: 6px 0 0; line-height: 1.5; max-width: 62ch; }
.adm-form-actions { margin-top: 20px; }
/* A checkbox row inside the form stays a row — `.admin-form label` makes every
   other label a block heading. */
.admin-form .adm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  font: 500 13px var(--font);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  white-space: normal;
}
.admin-form .adm-check input { width: auto; padding: 0; margin: 0; accent-color: var(--signal); }
.adm-contrib-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 6px 16px; }
.adm-contrib-head > label:first-child { margin-bottom: 0; }
.admin-form .adm-contrib-head .adm-check { margin: 0; color: var(--text-muted); }
.adm-contrib-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 24px;
  margin-top: 12px;
  transition: opacity 120ms;
}
.adm-contrib-grid.is-derived { opacity: 0.55; }
.adm-contrib-region h4 {
  margin: 6px 0 2px;
  font: 650 9px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.adm-contrib-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  border-top: 1px solid var(--border);
}
.adm-contrib-name { font-size: 13px; color: var(--text); }
.adm-contrib-opts { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.admin-form .adm-radio {
  position: relative;
  display: block;
  min-width: 34px;
  margin: 0;
  padding: 5px 0;
  text-align: center;
  font: 700 12px var(--font);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-faint);
  cursor: pointer;
  user-select: none;
}
.adm-radio + .adm-radio { border-left: 1px solid var(--border-strong); }
.admin-form .adm-radio input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.adm-radio.is-on { background: var(--surface-3); color: var(--text); }
.adm-radio-prime.is-on { background: var(--signal-wash); color: var(--signal); }
.adm-contrib-grid.is-derived .adm-radio,
.adm-contrib-grid.is-derived .adm-radio input { cursor: not-allowed; }
.adm-badge-missing { background: var(--gold-wash); color: var(--gold); }

/* ---------- Lists: denser rows, quiet secondary actions ---------- */
.adm-listrow .admin-row { padding: 10px 14px; }
.adm-listrow .admin-row strong { font-size: 14px; }
.adm-listrow .admin-row span { margin-top: 2px; font-size: 12.5px; }
.adm-meta-sep { color: var(--text-faint); }

@media (max-width: 720px) {
  .admin-header { flex-direction: column; }
  .admin-form-grid,
  .admin-form-grid-3,
  .admin-form-grid-4,
  .adm-contrib-grid { grid-template-columns: minmax(0, 1fr); }
}
/* `.admin-row span` is a block line; anything nested inside it stays inline. */
.admin-row span span,
.admin-row span em { display: inline; margin: 0; }
/* Archive is a quiet action on a list of 400; it turns red only under the pointer. */
.adm-listrow .btn-ghost-admin.link-danger { color: var(--text-faint) !important; border-color: var(--border); }
.adm-listrow .btn-ghost-admin.link-danger:hover { color: var(--danger) !important; border-color: var(--danger) !important; }


/* ---------- 2026-10 console pass: surfaces, inline forms, sign-in ---------- */

.admin-row, .admin-card, .adm-table-scroll, .admin-filter-form, .adm-fieldset { box-shadow: var(--shadow); }
.admin-filter-form { background: var(--surface); }
.admin-body .adm-table thead th { background: var(--surface-2); }
.admin-body .adm-table tbody tr:hover { background: var(--surface-2); }
.admin-body input[type="search"],
.admin-body .admin-filter-row select,
.admin-body .adm-filter-row select,
.admin-body .adm-filter-row input[type="date"],
/* Never a submit: at 0,2,1 this outranks `.admin-body .btn-primary` (0,2,0) and
   painted "Save flag"/"Save settings" on-primary text over the field ground —
   invisible on both Paper and Night (found 8 Oct 2026). */
.admin-body .admin-form input:not([type="submit"]),
.admin-body .admin-form select,
.admin-body .admin-form textarea,
.admin-body .adm-inline-form input:not([type="submit"]),
.admin-body .adm-inline-form select { background: var(--surface); }

.adm-inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 14px; }
.adm-inline-form input[type="text"],
.adm-inline-form input[type="number"],
.adm-inline-form select {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.adm-inline-form input[type="number"] { width: 90px; }
.adm-inline-form input:focus, .adm-inline-form select:focus { outline: none; border-color: var(--accent); }

.admin-body .adm-link, .admin-body .slug-primary { color: var(--accent); }
.admin-body .admin-card-actions a, .admin-body .admin-card-actions button { color: var(--accent); }
.admin-body .adm-badge-logstrata, .admin-body .adm-badge-dropset { background: var(--accent-wash); color: var(--accent); }
.admin-body .adm-radio-prime.is-on { background: var(--accent-wash); color: var(--accent); }
.admin-body .adm-check input, .admin-body .admin-form .adm-check input { accent-color: var(--accent); }

.admin-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-muted); font: 700 10px var(--mono); letter-spacing: 0.04em; }
.admin-chip-on { background: var(--accent-wash); color: var(--accent); }
.admin-chip-warn { background: var(--gold-wash); color: var(--gold); }

/* Sign-in: the same Paper / Night ground as the console. */
.admin-auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.admin-auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 30px 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.admin-auth-card .admin-brand-art { height: 24px; margin-bottom: 28px; }
.admin-auth-card h1 { font-size: 24px; }
.admin-auth-card .field { margin-top: 16px; }
.admin-auth-card .field label { display: block; margin-bottom: 6px; color: var(--text-faint); font: 700 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.admin-auth-card .field input[type="email"],
.admin-auth-card .field input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-app);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.admin-auth-card .field input:focus { outline: none; border-color: var(--accent); }
.admin-auth-card .btn-primary { width: 100%; margin-top: 22px; padding: 12px; }
.admin-auth-card .remember { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--text-muted); font-size: 13px; }
.admin-auth-card .remember input { accent-color: var(--accent); }
.admin-body .error-messages { margin: 0 0 16px; padding: 12px 14px; border: none; border-radius: 10px; background: var(--danger-wash); color: var(--danger); font-size: 13px; }
.admin-body .field label { color: var(--text-faint); }
/* application.css loads after this file and styles `.admin-search input` for the sign-in era;
   these win on specificity so filters stay compact. */
.admin-body .admin-search input[type="search"] { padding: 9px 12px; border-radius: 10px; font-size: 14px; background: var(--surface); }
.admin-body .admin-filter-row select, .admin-body .adm-filter-row select { padding: 9px 10px; font-size: 13px; }

/* ---- Feature flags (M6) ---- */

.admin-body .adm-badge-flag-on { background: var(--accent-wash); color: var(--accent); }
.admin-body .adm-badge-flag-rollout { background: var(--surface-3); color: var(--text); }
.admin-body .adm-badge-flag-killed { background: var(--danger-wash); color: var(--danger); }
.admin-body .adm-badge-flag-env { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* ---- Insights → Funnel (M6): aggregates only ---- */

.adm-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.adm-funnel-defs { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: 14px; background: var(--border); overflow: hidden; box-shadow: var(--shadow); }
.adm-funnel-defs > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 11px 16px; background: var(--surface); }
.adm-funnel-defs dt { color: var(--text-faint); font: 700 9px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; padding-top: 3px; }
.adm-funnel-defs dd { margin: 0; color: var(--text); font-size: 13px; max-width: 80ch; }
.adm-funnel-table td strong { font-weight: 650; color: var(--text); }
.adm-funnel-table tbody th { width: auto; min-width: 128px; white-space: normal; color: var(--text); font-weight: 600; }
.adm-funnel-rate { display: block; margin-top: 1px; color: var(--text-faint); font-size: 11px; }
.adm-funnel-region th { padding-left: 28px !important; color: var(--text-muted) !important; font-weight: 500 !important; }
.admin-body .adm-badge-open { background: transparent; color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border-strong); }
.adm-funnel-read p + p { margin-top: 10px; }

@media (max-width: 720px) {
  .adm-funnel-defs > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
