/* ============================================================
   FeedBacko.me — admin.css
   Shared chrome + page layout for the platform-admin console
   (views #34 login/MFA, #35 overview, #36-37 settings, #38 flags).
   Prefix: adm-. Shell chrome stays fbk-, DS-ported stays fb-.
   Tokens only — no raw hex, no px-magic beyond structural layout.
   ============================================================ */

/* ---- Content well inside the admin shell main column ---- */
.adm-wrap {
  max-width: 1080px;
  padding-bottom: var(--space-11);
}

/* AdminShell's 230px sidebar is fixed-width with no mobile affordance;
   hide it on narrow viewports (matches the business shell rule). */
@media (max-width: 900px) {
  .fbk-shell-admin .fbk-sidenav { display: none; }
}

/* ============================================================
   Admin top strip: identity + env switch + logout.
   Env is session-global and scopes every write — kept prominent
   and persistent on every authenticated admin page.
   ============================================================ */
.adm-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) 0 var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-5);
}
.adm-ident { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.adm-ident-mark {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
}
.adm-ident-who { min-width: 0; }
.adm-ident-role {
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.adm-ident-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-topbar-spacer { flex: 1 1 auto; }

/* Env segmented control — the single most consequential control here. */
.adm-env { display: flex; align-items: center; gap: var(--space-2); }
.adm-env-label {
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.adm-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-pill);
  background: var(--gray-100);
  border: 1px solid var(--border-subtle);
}
.adm-seg-btn {
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.adm-seg-btn:disabled { cursor: default; }
.adm-seg-dot { width: 7px; height: 7px; border-radius: var(--radius-circle); background: currentColor; }
.adm-seg-btn--test.is-on { background: var(--green-500); color: var(--text-inverse); }
.adm-seg-btn--prod.is-on { background: var(--red-600); color: var(--text-inverse); }
.adm-seg-btn:not(.is-on):hover { color: var(--text-primary); }

.adm-logout {
  border: 1px solid var(--border-default);
  background: var(--white);
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: var(--weight-semibold);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.adm-logout:hover { border-color: var(--gray-400); background: var(--surface-subtle); }

/* Live-env warning ribbon (prod only). */
.adm-envnote {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  padding: 9px 13px;
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-5);
}
.adm-envnote--prod {
  background: color-mix(in srgb, var(--red-600) 8%, var(--white));
  color: var(--red-600);
  border: 1px solid color-mix(in srgb, var(--red-600) 30%, var(--white));
}
.adm-envnote--test { background: var(--surface-brand-tint); color: var(--green-900); border: 1px solid var(--green-200); }

/* Inline env tag beside a write control ("this write hits <env>"). */
.adm-envtag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
}
.adm-envtag--prod { background: color-mix(in srgb, var(--red-600) 8%, var(--white)); color: var(--red-600); }
.adm-envtag--test { background: var(--green-50); color: var(--green-900); }

/* ---- Page head ---- */
.adm-head { margin-bottom: var(--space-5); }
.adm-eyebrow {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
}
.adm-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  letter-spacing: var(--tracking-tight);
  margin: var(--space-1) 0 var(--space-2);
}
.adm-sub {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: 0;
  line-height: var(--leading-normal);
  max-width: 60ch;
}

/* ============================================================
   Centered auth gate (login / MFA, #34)
   ============================================================ */
.adm-authpage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: var(--surface-subtle);
}
.adm-auth {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-7);
  box-shadow: var(--shadow-sm);
}
.adm-auth-brand { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-6); }
.adm-auth-tag {
  font-size: 10.5px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}
.adm-auth-title { font-size: var(--text-2xl); font-weight: var(--weight-black); margin: 0 0 var(--space-1); }
.adm-auth-body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--space-6);
}
.adm-field { margin-bottom: var(--space-4); }
.adm-label {
  display: block;
  font-size: 12.5px;
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.adm-input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--control-bg);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard);
}
.adm-input:focus-visible { border-color: var(--color-brand); box-shadow: var(--shadow-focus); }
.adm-input--code {
  font-size: var(--text-2xl);
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-bold);
}
.adm-authbtn {
  width: 100%;
  border: none;
  background: var(--ink);
  color: var(--text-inverse);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  cursor: pointer;
  font-family: inherit;
  margin-top: var(--space-2);
}
.adm-authbtn:hover { background: var(--button-primary-bg-hover); }
.adm-authbtn:disabled { opacity: 0.5; cursor: not-allowed; }
.adm-devhint {
  margin: var(--space-5) 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: var(--leading-normal);
}
.adm-devhint code {
  font-family: var(--font-mono, monospace);
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  color: var(--text-secondary);
}
.adm-backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.adm-backlink:hover { color: var(--text-primary); }

/* Inline form error (401/403/422) — rendered next to the control, never console-only. */
.adm-formerr {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: color-mix(in srgb, var(--red-600) 8%, var(--white));
  border: 1px solid color-mix(in srgb, var(--red-600) 30%, var(--white));
  color: var(--red-600);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}
.adm-formerr-icon { flex: none; margin-top: 1px; }

/* ============================================================
   Overview (#35)
   ============================================================ */
.adm-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.adm-toolbar-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
}
.adm-chipset { display: inline-flex; gap: var(--space-2); }
.adm-chip {
  border-radius: var(--radius-pill);
  padding: 6px 13px;
  font-size: 13px;
  font-weight: var(--weight-semibold);
  border: 1px solid var(--border-subtle);
  background: var(--white);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease-standard),
              background var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.adm-chip:hover { border-color: var(--gray-400); }
.adm-chip.is-on, .adm-chip.is-on:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--text-inverse);
}

.adm-grid { display: grid; gap: var(--space-3); }
.adm-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.adm-grid--2 { grid-template-columns: 1fr 1fr; margin-top: var(--space-3); }

.adm-card {
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
  min-width: 0;
}
.adm-card-title { font-size: var(--text-base); font-weight: var(--weight-bold); margin: 0 0 var(--space-4); }

/* Queue-bucket tiles link into the case queue. */
.adm-bucket {
  display: block;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--duration-base) var(--ease-standard),
              border-color var(--duration-base) var(--ease-standard);
}
.adm-bucket:hover { text-decoration: none; border-color: var(--gray-300); box-shadow: var(--shadow-md); }
.adm-bucket:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-color: var(--color-brand); }
.adm-bucket-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.adm-metric-v {
  font-size: var(--text-4xl);
  font-weight: var(--weight-black);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.adm-metric-v--warn { color: var(--amber-500); }
.adm-metric-v--danger { color: var(--red-600); }
.adm-metric-l { font-size: 12.5px; color: var(--text-tertiary); font-weight: var(--weight-semibold); margin-top: 6px; }
.adm-bucket-go { font-size: 12px; font-weight: var(--weight-bold); color: var(--text-secondary); display: inline-flex; align-items: center; gap: 4px; }

/* Small stat cells inside a grouped card. */
.adm-statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.adm-stat-v { font-size: 22px; font-weight: var(--weight-black); letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }
.adm-stat-v--warn { color: var(--amber-500); }
.adm-stat-v--danger { color: var(--red-600); }
.adm-stat-l { font-size: 12px; color: var(--text-tertiary); font-weight: var(--weight-semibold); margin-top: 4px; }

/* Verdict-mix bars. */
.adm-vrow { display: flex; align-items: center; gap: var(--space-3); }
.adm-vrow + .adm-vrow { margin-top: 9px; }
.adm-vlabel { flex: none; width: 96px; font-size: 12.5px; color: var(--text-secondary); font-weight: var(--weight-semibold); }
.adm-vtrack { flex: 1; height: 9px; background: var(--gray-100); border-radius: var(--radius-pill); overflow: hidden; }
.adm-vfill { display: block; height: 100%; border-radius: var(--radius-pill); }
.adm-vfill--genuine { background: var(--green-500); }
.adm-vfill--fabricated { background: var(--red-600); }
.adm-vfill--inconclusive { background: var(--amber-500); }
.adm-vcount { flex: none; width: 30px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
.adm-vconf { font-size: 12px; color: var(--text-tertiary); margin-top: var(--space-4); }

/* Cases-by-state chips. */
.adm-states { display: flex; flex-wrap: wrap; gap: 9px; }
.adm-statechip {
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
}
.adm-statechip b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Recent changes feed. */
.adm-feed { display: flex; flex-direction: column; }
.adm-feed-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: 11px 0;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.adm-feed-row:first-child { border-top: none; }
.adm-feed-key { font-size: 13px; font-weight: var(--weight-bold); color: var(--text-primary); font-family: var(--font-mono, monospace); }
.adm-feed-change { font-size: 12.5px; color: var(--text-secondary); }
.adm-feed-change code { color: var(--text-primary); }
.adm-feed-arrow { color: var(--text-tertiary); margin: 0 4px; }
.adm-feed-meta { margin-left: auto; font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; }

/* ============================================================
   Settings (#36 / #37)
   ============================================================ */
.adm-filters {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}
.adm-filter { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.adm-filter--grow { flex: 1 1 200px; }
.adm-group { margin-bottom: var(--space-6); }
.adm-group-head {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.adm-setting {
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.adm-setting + .adm-setting { margin-top: var(--space-3); }
.adm-setting-top { display: flex; align-items: flex-start; gap: var(--space-3); flex-wrap: wrap; }
.adm-setting-id { min-width: 0; flex: 1 1 260px; }
.adm-setting-key { font-size: var(--text-base); font-weight: var(--weight-bold); font-family: var(--font-mono, monospace); word-break: break-word; }
.adm-setting-desc { font-size: 13px; color: var(--text-secondary); line-height: var(--leading-normal); margin: 4px 0 0; }
.adm-setting-tags { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.adm-guard {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: var(--space-2) 0 0;
}
.adm-guard b { color: var(--text-secondary); }
.adm-default { font-size: 12px; color: var(--text-tertiary); }
.adm-default code { color: var(--text-secondary); }

.adm-editrow {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.adm-editctrl { flex: 1 1 280px; min-width: 0; }
.adm-num, .adm-text, .adm-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--control-bg);
  outline: none;
}
.adm-textarea { min-height: 88px; resize: vertical; line-height: var(--leading-normal); }
.adm-num { max-width: 160px; font-variant-numeric: tabular-nums; }
.adm-num:focus-visible, .adm-text:focus-visible, .adm-textarea:focus-visible {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-focus);
}
.adm-json-note { font-size: 11.5px; color: var(--text-tertiary); margin: 6px 0 0; }

.adm-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.adm-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: var(--space-3); }
.adm-meta code { color: var(--text-secondary); }
.adm-saved {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  color: var(--green-700);
}

/* Guardrail-violation / error surface, inline under the editor. */
.adm-inlineerr {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: color-mix(in srgb, var(--red-600) 8%, var(--white));
  border: 1px solid color-mix(in srgb, var(--red-600) 30%, var(--white));
  color: var(--red-600);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: var(--leading-normal);
  margin-top: var(--space-3);
}
.adm-inlineerr-icon { flex: none; margin-top: 1px; }

/* History disclosure. */
.adm-histbtn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.adm-histbtn:hover { color: var(--text-primary); }
.adm-history {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--border-default);
}
.adm-hist-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.adm-hist-row:first-child { border-top: none; }
.adm-hist-ver {
  flex: none;
  font-size: 12px;
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
}
.adm-hist-change { font-size: 12.5px; color: var(--text-secondary); min-width: 0; }
.adm-hist-change code { color: var(--text-primary); word-break: break-word; }
.adm-hist-meta { font-size: 11.5px; color: var(--text-tertiary); }
.adm-hist-aside { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

/* ============================================================
   Feature flags (#38)
   ============================================================ */
.adm-flag {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.adm-flag + .adm-flag { margin-top: var(--space-3); }
.adm-flag-main { min-width: 0; flex: 1; }
.adm-flag-key { font-size: var(--text-base); font-weight: var(--weight-bold); font-family: var(--font-mono, monospace); word-break: break-word; }
.adm-flag-desc { font-size: 13px; color: var(--text-secondary); line-height: var(--leading-normal); margin: 4px 0 0; }
.adm-flag-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: 6px; }
.adm-flag-aside { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.adm-flag-default { font-size: 11px; color: var(--text-tertiary); font-weight: var(--weight-semibold); }

/* ============================================================
   Label-first control headers (settings #36-37 + flags #38).
   The human label titles each control; the underlying setting/
   flag key stays a quiet mono sub-line (every filter/update/
   toggle call is keyed on it). Help is the plain-language
   paragraph — readable but secondary (tertiary, small, relaxed).
   ============================================================ */
.adm-setting-label,
.adm-flag-label {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: var(--leading-snug);
  word-break: break-word;
}
.adm-setting-keyline,
.adm-flag-keyline {
  font-size: var(--text-xs);
  font-family: var(--font-mono, monospace);
  color: var(--text-tertiary);
  margin-top: 2px;
  word-break: break-word;
}
.adm-setting-help,
.adm-flag-help {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: var(--leading-relaxed);
  margin: var(--space-3) 0 0;
  max-width: 74ch;
}
/* Pin the flag toggle column to the top so it stays beside the
   label once the help paragraph gives the row real height. */
.adm-flag-aside { align-self: flex-start; padding-top: 2px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  .adm-grid--3 { grid-template-columns: 1fr; }
  .adm-grid--2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .fbk-shell-main { padding: var(--space-4); }
  .adm-topbar { align-items: flex-start; }
  .adm-topbar-spacer { flex-basis: 100%; height: 0; }
  .adm-statgrid { grid-template-columns: 1fr; }
  .adm-flag { flex-wrap: wrap; }
  .adm-feed-meta { margin-left: 0; }
}
