/* ═══════════════════════════════════════════════════════════════
   stocktake. — Manage (phone-first)
   Self-contained Industrial token set + mg-* primitives ported
   from the 2026-06-12 design handoff. Responsive: full-viewport
   on phones, a centred narrow column on desktop. NO fixed-size
   "phone preview" frame — this view IS the phone view.
   ═══════════════════════════════════════════════════════════════ */

/* Token scope: standalone manage.html (body.mg) AND the embedded Manage tab
   inside the operator app (#page-manage). NOT :root — index.html loads this
   stylesheet alongside sf.css, whose :root/theme tokens must win everywhere
   outside the manage view. Custom properties inherit down from these hosts. */
body.mg, #page-manage {
  --brand-50:#2a2118; --brand-100:#3b2c1c; --brand-200:#5a3f1f;
  --brand-300:#b07820; --brand-400:#d99325; --brand-500:#ffae00;
  --brand-600:#e09600; --brand-700:#b87600; --brand-800:#7e5000; --brand-900:#4a2f00;

  --ink-25:#1b2228; --ink-50:#161c22; --ink-100:#1f272f; --ink-150:#252e38;
  --ink-200:#2d3845; --ink-300:#475363; --ink-400:#6a7787; --ink-500:#8b97a6;
  --ink-600:#b3bdc9; --ink-700:#d2d9e2; --ink-800:#e8ecf1; --ink-900:#f5f7fa;

  --amber-soft:#3a2a0a; --amber-deep:#ffd166;
  --ok:#6ee7b7; --ok-soft:rgba(52,211,153,.14);
  --warn:#ffd166; --warn-soft:rgba(255,174,0,.14);
  --danger:#ff8b8b; --danger-soft:rgba(248,113,113,.14);

  --surface:#1a232c;
  --surface-2:#131a21;
  --line:#2d3845;
  --line-soft:#232f3a;

  --font-sans:'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono:'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
}

body.mg *, #page-manage * { box-sizing: border-box; }
/* Page chrome for standalone manage.html only — embedded, the operator app
   owns html/body and this must not touch them. */
body.mg {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
#page-manage {
  font-family: var(--font-sans);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
body.mg {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(255,174,0,.07) 0%, transparent 60%),
    #0a0e12;
  display: flex;
  justify-content: center;
}

/* Phone shell — fills the viewport on phones; centred narrow column on desktop. */
.mg-phone {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  /* Clear the status bar / notch on phones. env() expands past the 47px floor
     on notched devices; the floor covers iOS WebView contexts that report 0.
     (box-sizing:border-box keeps the shell at 100dvh — no overflow.) */
  padding-top: max(env(safe-area-inset-top), 47px);
  background: linear-gradient(180deg, #161c22 0%, #0e1318 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 600px) {
  body.mg { padding: 24px 16px; align-items: flex-start; }
  .mg-phone {
    min-height: min(900px, calc(100dvh - 48px));
    max-height: calc(100dvh - 48px);
    padding-top: 0;            /* centred desktop card has no status bar to clear */
    border-radius: 28px;
    box-shadow:
      0 0 0 1.5px rgba(255,255,255,.06),
      0 2px 0 2px #05080b,
      0 40px 90px -30px rgba(0,0,0,.85);
  }
}

/* viewport holds the stacked screens */
.mg-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── A screen ────────────────────────────────────────────────── */
.mg-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #161c22 0%, #0e1318 100%);
}
.mg-screen.is-pushed { box-shadow: -16px 0 40px rgba(0,0,0,.4); }

/* header */
.mg-head {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
}
.mg-head.is-home { grid-template-columns: 1fr auto; padding: 16px 18px 12px; }
.mg-iconbtn {
  width: 40px; height: 40px;
  border-radius: 999px; border: 0;
  background: rgba(255,255,255,.05);
  color: var(--ink-700);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.mg-iconbtn:hover { background: rgba(255,255,255,.10); color: var(--ink-900); }
.mg-iconbtn svg { width: 19px; height: 19px; }
.mg-acct { border: 0; background: transparent; padding: 0; cursor: pointer; display: grid; place-items: center; border-radius: 999px; }
.mg-acct:active { transform: scale(.95); }
.mg-head-title {
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--ink-900);
}
.mg-head-title small {
  display: block;
  font-size: 11px; font-weight: 500;
  color: var(--ink-500);
  letter-spacing: 0;
  margin-top: 1px;
}

/* home brand lockup */
.mg-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mg-brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: #1a1208;
  color: var(--brand-500);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,174,0,.30), 0 6px 16px -8px rgba(255,174,0,.5);
  flex-shrink: 0;
}
.mg-brand-mark svg { width: 21px; height: 21px; }
.mg-brand-name {
  font-size: 19px; font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink-900);
  line-height: 1;
}
.mg-brand-name .dot { color: var(--brand-500); }
.mg-brand-sub {
  font-size: 11px; font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 3px;
}

/* body scroll */
.mg-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}
.mg-body.has-nav { padding-bottom: 96px; }
.mg-body > * { flex-shrink: 0; }
.mg-body::-webkit-scrollbar { width: 0; }

/* ── Hero (site context) ─────────────────────────────────────── */
.mg-hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 18px 18px 16px;
  background: linear-gradient(160deg, #1f272f 0%, #0e1318 100%);
  box-shadow:
    0 12px 32px -12px rgba(0,0,0,.7),
    inset 0 1px 0 rgba(255,174,0,.16),
    inset 0 0 0 1px rgba(255,174,0,.13);
}
.mg-hero::after {
  content: '';
  position: absolute;
  top: -45%; right: -20%;
  width: 230px; height: 230px;
  background: radial-gradient(circle, rgba(255,174,0,.18), transparent 65%);
  pointer-events: none;
}
.mg-hero-top {
  position: relative; z-index: 1;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.mg-hero-eyebrow {
  font-size: 10px; font-weight: 700;
  color: var(--brand-500);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.mg-hero-titlebtn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 0; padding: 0; margin-top: 3px;
  font-family: var(--font-sans);
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink-900);
  cursor: pointer;
  text-align: left;
}
.mg-hero-titlebtn svg { width: 18px; height: 18px; color: var(--ink-500); flex-shrink: 0; }
.mg-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.mg-pill-live { background: rgba(255,174,0,.14); color: var(--brand-500); }
.mg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); }
.mg-dot-live { box-shadow: 0 0 0 3px rgba(255,174,0,.22); animation: mg-pulse 2.4s ease-in-out infinite; }
@keyframes mg-pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.mg-hero-stats {
  position: relative; z-index: 1;
  display: flex; align-items: stretch; gap: 0;
  margin: 16px 0 16px;
}
.mg-hero-stat { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mg-hero-num {
  font-family: var(--font-mono);
  font-size: 23px; font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.03em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.mg-hero-num[data-warn="1"] { color: var(--amber-deep); }
.mg-hero-lbl {
  font-size: 10px; font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.mg-hero-vr { width: 1px; background: rgba(255,255,255,.10); margin: 2px 12px; }
.mg-hero-actions {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.mg-btn {
  height: 44px;
  border-radius: 12px; border: 0;
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 100ms, box-shadow 120ms, background 120ms;
  white-space: nowrap;
}
.mg-btn:active { transform: translateY(1px); }
.mg-btn svg { width: 17px; height: 17px; }
.mg-btn-primary {
  background: linear-gradient(180deg, #ffae00, #b87600);
  color: #1a1208;
  box-shadow: 0 4px 14px rgba(255,174,0,.30), inset 0 1px 0 rgba(255,255,255,.3);
}
.mg-btn-primary:hover { box-shadow: 0 6px 18px rgba(255,174,0,.40), inset 0 1px 0 rgba(255,255,255,.3); }
.mg-btn-ghost {
  background: rgba(255,255,255,.06);
  color: var(--ink-900);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
}
.mg-btn-ghost:hover { background: rgba(255,255,255,.10); }
.mg-btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(248,113,113,.30);
}
.mg-btn-danger:hover { background: rgba(248,113,113,.20); }
.mg-btn-block { width: 100%; height: 50px; font-size: 15px; border-radius: 14px; }
.mg-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── Section group / cards / rows ────────────────────────────── */
.mg-group { display: flex; flex-direction: column; gap: 7px; }
.mg-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 4px;
}
.mg-group-title {
  font-size: 11px; font-weight: 700;
  color: var(--ink-500);
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
}
.mg-group-link {
  background: none; border: 0;
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 600;
  color: var(--brand-500);
  cursor: pointer; padding: 2px 4px; border-radius: 6px;
  letter-spacing: -0.005em;
}
.mg-group-link:hover { background: rgba(255,174,0,.10); }
.mg-hint {
  font-size: 11.5px; color: var(--ink-500);
  padding: 1px 4px 0; line-height: 1.4;
}
.mg-card {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
}

/* generic nav row */
.mg-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 0; background: transparent;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  transition: background 120ms;
}
.mg-card > .mg-row:last-child { border-bottom: 0; }
.mg-row:hover { background: rgba(255,255,255,.03); }
.mg-row-static { cursor: default; }
.mg-row-static:hover { background: transparent; }
.mg-row-ico {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--brand-500);
  flex-shrink: 0;
}
.mg-row-ico svg { width: 19px; height: 19px; }
.mg-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mg-row-title {
  font-size: 14.5px; font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}
.mg-row-sub {
  font-size: 12px; color: var(--ink-500);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-row-right { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.mg-row-chev { color: var(--ink-400); display: grid; place-items: center; }
.mg-row-chev svg { width: 18px; height: 18px; }
.mg-count-chip {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  color: var(--ink-600);
  background: var(--surface-2);
  border-radius: 7px;
  padding: 3px 8px;
}

/* simple label/value row */
.mg-kv {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 46px;
}
.mg-card > .mg-kv:last-child { border-bottom: 0; }
.mg-kv-lbl { font-size: 13px; font-weight: 500; color: var(--ink-500); flex-shrink: 0; white-space: nowrap; }
.mg-kv-val {
  font-size: 13px; font-weight: 600; color: var(--ink-900);
  letter-spacing: -0.01em; text-align: right;
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-kv-val.mono { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }

/* action row (chevron, tappable) */
.mg-action {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: 0; border-bottom: 1px solid var(--line-soft);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13.5px; font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 120ms;
}
.mg-card > .mg-action:last-child { border-bottom: 0; }
.mg-action:hover { background: rgba(255,255,255,.04); }
.mg-action-primary { color: var(--brand-500); }
.mg-action-quiet { color: var(--ink-700); }
.mg-action-danger { color: var(--danger); }
.mg-action-chev { color: var(--ink-400); }
.mg-action-chev svg { width: 15px; height: 15px; display: block; }

/* toggle switch */
.mg-switch {
  position: relative; width: 42px; height: 25px;
  border-radius: 999px; border: 0;
  background: var(--line);
  cursor: pointer; padding: 0; flex-shrink: 0;
  transition: background 160ms;
}
.mg-switch[data-on="1"] { background: var(--brand-500); }
.mg-switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform 160ms cubic-bezier(.34,1.4,.64,1);
}
.mg-switch[data-on="1"] .mg-switch-thumb { transform: translateX(17px); }

/* ── Pills / badges ──────────────────────────────────────────── */
.mg-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.mg-badge svg { width: 11px; height: 11px; }
.mg-badge-ok { background: var(--ok-soft); color: var(--ok); }
.mg-badge-warn { background: var(--warn-soft); color: var(--warn); }
.mg-badge-danger { background: var(--danger-soft); color: var(--danger); }
.mg-badge-neutral { background: var(--surface-2); color: var(--ink-600); }
.mg-badge-amber { background: rgba(255,174,0,.14); color: var(--brand-500); }
.mg-badge-dot { width: 7px; height: 7px; border-radius: 50%; }
.mg-badge-dot.ok { background: var(--ok); }
.mg-badge-dot.warn { background: var(--warn); }
.mg-badge-dot.danger { background: var(--danger); }
.mg-badge-dot.neutral { background: var(--ink-400); }

/* ── Avatar ──────────────────────────────────────────────────── */
.mg-avatar {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  color: #1a1208;
}
.mg-avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
.mg-avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 19px; }

/* ── Segmented control ───────────────────────────────────────── */
.mg-seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
}
.mg-seg-btn {
  flex: 1;
  padding: 8px 6px;
  border: 0; background: transparent;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12.5px; font-weight: 600;
  color: var(--ink-500);
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 120ms;
  white-space: nowrap;
}
.mg-seg-btn.active {
  background: var(--surface);
  color: var(--ink-900);
  box-shadow: 0 1px 2px rgba(0,0,0,.4), inset 0 0 0 1px var(--line);
}
.mg-seg-btn .mg-seg-count { color: var(--ink-400); font-family: var(--font-mono); font-size: 11px; }
.mg-seg-btn.active .mg-seg-count { color: var(--brand-500); }

/* Section switcher for Manage's own areas (Home/Team/Operations/Setup) when
   embedded in the operator app. Manage used to swap in a second bottom bar;
   its sections now live here so the app's single bottom bar never changes. */
.mg-seg-sections {
  flex: 0 0 auto;
  margin: 12px 14px 0;
}

/* ── Person / list rows ──────────────────────────────────────── */
.mg-person {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0; background: transparent;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer; text-align: left;
  font-family: var(--font-sans);
  transition: background 120ms;
}
.mg-card > .mg-person:last-child { border-bottom: 0; }
.mg-person:hover { background: rgba(255,255,255,.03); }
.mg-person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mg-person-name {
  font-size: 14.5px; font-weight: 600; color: var(--ink-900);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-person-meta {
  display: flex; align-items: center; gap: 7px;
  margin-top: 3px;
  font-size: 12px; color: var(--ink-500);
}
.mg-person-email {
  font-family: var(--font-mono); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* live feed row */
.mg-feed { display: flex; flex-direction: column; }
.mg-feed-row {
  display: grid; grid-template-columns: 46px 1fr auto;
  align-items: center; gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.mg-card > .mg-feed-row:last-child { border-bottom: 0; }
.mg-feed-time {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-500); font-weight: 500;
}
.mg-feed-main { min-width: 0; }
.mg-feed-desc {
  font-size: 13px; font-weight: 600; color: var(--ink-900);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-feed-sub {
  display: flex; align-items: center; gap: 7px;
  margin-top: 2px;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-500);
}
.mg-feed-qty {
  font-family: var(--font-mono); font-size: 17px; font-weight: 600;
  color: var(--ink-900); letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* session / generic detail rows */
.mg-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.mg-tile-num {
  font-family: var(--font-mono); font-size: 21px; font-weight: 600;
  color: var(--ink-900); letter-spacing: -0.03em; line-height: 1;
}
.mg-tile-num[data-warn="1"] { color: var(--amber-deep); }
.mg-tile-lbl {
  font-size: 10.5px; font-weight: 600; color: var(--ink-500);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.mg-tilegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mg-tile-btn { font-family: var(--font-sans); text-align: left; cursor: pointer; transition: border-color 120ms, background 120ms; }
.mg-tile-btn:hover { border-color: var(--ink-300); background: var(--surface-2); }
.mg-tile-btn:active { transform: translateY(1px); }

/* unlisted item card */
.mg-unlisted {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0; border-bottom: 1px solid var(--line-soft);
  background: transparent;
  font-family: var(--font-sans);
  text-align: left; cursor: pointer;
  transition: background 120ms;
}
.mg-unlisted:hover { background: rgba(255,255,255,.03); }
.mg-card > .mg-unlisted:last-child { border-bottom: 0; }
.mg-unlisted-thumb {
  width: 48px; height: 48px; border-radius: 10px;
  background: repeating-linear-gradient(135deg, #1f272f 0 6px, #232f3a 6px 12px);
  display: grid; place-items: center;
  color: var(--ink-400);
  flex-shrink: 0;
  overflow: hidden;
}
.mg-unlisted-thumb svg { width: 18px; height: 18px; }
.mg-unlisted-main { flex: 1; min-width: 0; }

/* category health row */
.mg-cat {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.mg-card > .mg-cat:last-child { border-bottom: 0; }
.mg-cat-bar {
  width: 4px; align-self: stretch; border-radius: 2px; flex-shrink: 0;
  min-height: 30px;
}
.mg-cat-bar.ok { background: var(--ok); }
.mg-cat-bar.warn { background: var(--warn); }
.mg-cat-bar.danger { background: var(--danger); }
.mg-cat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mg-cat-name { font-size: 14px; font-weight: 600; color: var(--ink-900); letter-spacing: -0.01em; }
.mg-cat-meta { font-size: 12px; color: var(--ink-500); }
.mg-cat-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.mg-cat-last { font-size: 11px; color: var(--ink-500); font-weight: 500; white-space: nowrap; }

/* ── Bottom nav ──────────────────────────────────────────────── */
.mg-nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: grid;
  /* Standalone manage.html has 4 nav items (Home/Team/Operations/Settings);
     embedded in the operator app there's a 5th leading "Scan" exit item. A
     fixed 4-column grid wrapped that 5th button onto a second row at phone
     width — auto-flow equal-width columns fit whatever count is present. */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom));
  background: rgba(14,19,24,.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.mg-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 4px;
  border: 0; background: transparent;
  color: var(--ink-400);
  font-family: var(--font-sans);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: color 120ms;
  min-height: 44px;
}
/* Match the operator bar exactly (sf.css uses --brand-700 for the lit tab).
   These differed, so the same app lit its active tab a different shade
   depending which bar you were looking at. */
.mg-nav-btn.active { color: var(--brand-700); }
.mg-nav-btn svg { width: 22px; height: 22px; }

/* ── Sheets ──────────────────────────────────────────────────── */
.mg-sheet-back {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 40;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.mg-sheet {
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -16px 40px rgba(0,0,0,.6);
  max-height: 92%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.mg-sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--line);
  margin: 9px auto 0;
}
.mg-sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 18px 6px;
}
.mg-sheet-title {
  font-size: 19px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink-900);
}
.mg-sheet-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 3px; line-height: 1.4; }
.mg-sheet-close {
  width: 32px; height: 32px; border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--ink-500);
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.mg-sheet-close:hover { background: var(--line); color: var(--ink-800); }
.mg-sheet-close svg { width: 16px; height: 16px; }
.mg-sheet-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 8px 18px 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.mg-sheet-body::-webkit-scrollbar { width: 0; }
.mg-sheet-foot {
  padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
}

/* ── Fields ──────────────────────────────────────────────────── */
.mg-field { display: flex; flex-direction: column; gap: 7px; }
.mg-field-lbl {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.10em; text-transform: uppercase;
}
/* Host-scoped (#page-manage / body.mg prefix) so these win over the operator
   app's global `input[type=text], select, textarea { … }` rules in styles.css
   (specificity 0,1,1) that otherwise leak IN and repaint Manage's fields with
   the operator padding/border/green focus ring. Prefixing lifts these to
   (0,2,0) and keeps Manage's amber styling authoritative in the shared DOM. */
#page-manage .mg-input, #page-manage .mg-select,
body.mg .mg-input, body.mg .mg-select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 16px; font-weight: 500;
  color: var(--ink-900);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition: all 120ms;
  min-height: 48px;
}
#page-manage .mg-input.mono, body.mg .mg-input.mono { font-family: var(--font-mono); font-size: 14px; }
#page-manage .mg-input::placeholder, body.mg .mg-input::placeholder { color: var(--ink-400); }
#page-manage .mg-input:focus, #page-manage .mg-select:focus,
body.mg .mg-input:focus, body.mg .mg-select:focus {
  border-color: var(--brand-500);
  background: #0e1318;
  box-shadow: 0 0 0 3px rgba(255,174,0,.16);
}
.mg-field-hint { font-size: 11.5px; color: var(--ink-500); line-height: 1.4; padding: 0 2px; }
.mg-field-error { font-size: 12px; color: var(--danger); font-weight: 600; line-height: 1.4; padding: 0 2px; }

/* choice cards (site / role pickers) */
.mg-choices { display: flex; flex-direction: column; gap: 8px; }
.mg-choice {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  cursor: pointer; text-align: left;
  font-family: var(--font-sans);
  transition: all 120ms;
}
.mg-choice:hover { border-color: var(--ink-300); }
.mg-choice.selected {
  border-color: var(--brand-500);
  background: rgba(255,174,0,.07);
  box-shadow: inset 0 0 0 1px var(--brand-500);
}
.mg-choice-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mg-choice-title { font-size: 14.5px; font-weight: 600; color: var(--ink-900); letter-spacing: -0.01em; }
.mg-choice-sub { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.mg-choice-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid; place-items: center; flex-shrink: 0;
  color: transparent;
  transition: all 120ms;
}
.mg-choice.selected .mg-choice-check {
  border-color: var(--brand-500); background: var(--brand-500); color: #1a1208;
}
.mg-choice-check svg { width: 13px; height: 13px; }

/* progress dots */
.mg-steps { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.mg-step-dot {
  height: 4px; border-radius: 2px;
  background: var(--line);
  flex: 1;
  transition: background 200ms;
}
.mg-step-dot.done { background: var(--brand-500); }

/* ── Notice / callout ────────────────────────────────────────── */
.mg-notice {
  display: flex; gap: 11px;
  padding: 13px 14px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.mg-notice-ico { color: var(--brand-500); flex-shrink: 0; margin-top: 1px; }
.mg-notice-ico svg { width: 18px; height: 18px; }
.mg-notice-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.mg-notice-title { font-size: 13.5px; font-weight: 600; color: var(--ink-900); letter-spacing: -0.01em; }
.mg-notice-text { font-size: 12.5px; color: var(--ink-500); margin-top: 3px; line-height: 1.45; }
.mg-notice.amber { border-color: rgba(255,174,0,.3); background: rgba(255,174,0,.06); }
.mg-notice.danger { border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.07); }
.mg-notice.danger .mg-notice-ico { color: var(--danger); }

/* ── QR ──────────────────────────────────────────────────────── */
.mg-qr-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 4px 0;
}
.mg-qr {
  width: 192px; height: 192px;
  padding: 14px;
  background: #f5f7fa;
  border-radius: 18px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,174,0,.4);
}
.mg-qr svg, .mg-qr img { width: 100%; height: 100%; display: block; }
.mg-qr-link {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--brand-500);
  word-break: break-all; text-align: center;
}

/* success state */
.mg-success { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 8px 8px; text-align: center; }
.mg-success-ico {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center;
}
.mg-success-ico svg { width: 30px; height: 30px; }
.mg-success-title { font-size: 19px; font-weight: 700; color: var(--ink-900); letter-spacing: -0.02em; }
.mg-success-text { font-size: 13.5px; color: var(--ink-500); line-height: 1.45; max-width: 280px; }

/* foot text */
.mg-foot {
  text-align: center; font-size: 11px; color: var(--ink-400);
  padding: 4px 0 2px; letter-spacing: 0.005em;
}

/* toast */
.mg-toast {
  position: absolute;
  left: 16px; right: 16px;
  bottom: 84px;
  z-index: 60;
  padding: 12px 15px;
  border-radius: 13px;
  background: #0f2a1f;
  color: var(--ok);
  font-size: 13px; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(52,211,153,.35), 0 12px 30px rgba(0,0,0,.5);
  display: flex; align-items: center; gap: 9px;
}
.mg-toast svg { width: 17px; height: 17px; flex-shrink: 0; }
.mg-toast.is-error { background: #2a0f12; color: var(--danger); box-shadow: inset 0 0 0 1px rgba(248,113,113,.35), 0 12px 30px rgba(0,0,0,.5); }

.mg-readout {
  font-size: 14px; color: var(--ink-800); line-height: 1.45;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.mg-unlisted-photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  height: 150px;
  border-radius: 14px;
  background: repeating-linear-gradient(135deg, #1f272f 0 8px, #232f3a 8px 16px);
  color: var(--ink-400);
}
.mg-unlisted-photo-lbl {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-500);
  letter-spacing: 0.04em;
}

/* misc helpers */
.mg-spacer { flex: 1; }
.mg-divider { height: 1px; background: var(--line); margin: 2px 0; }
.mg-empty { padding: 24px 16px; text-align: center; color: var(--ink-500); font-size: 13px; }
.mg-loading { display: flex; justify-content: center; padding: 32px 16px; color: var(--ink-500); font-size: 13px; }

/* ── Auth gate (sign-in screen reuses .mg-screen) ─────────── */
.mg-auth { padding: 32px 24px; display: flex; flex-direction: column; gap: 18px; }
.mg-auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 0 6px; }
.mg-auth-brand .mg-brand-mark { width: 56px; height: 56px; border-radius: 16px; }
.mg-auth-brand .mg-brand-mark svg { width: 30px; height: 30px; }
.mg-auth-brand-name { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.mg-auth-brand-name .dot { color: var(--brand-500); }
.mg-auth-sub { font-size: 12px; color: var(--ink-500); letter-spacing: 0.08em; text-transform: uppercase; }

/* ── Embedded Manage tab (inside the operator app) ──────────────
   #page-manage is a top-level tab section in index.html. Phone: plain
   full-height block (the .mg-phone shell handles safe areas). Desktop:
   centre the phone shell like standalone body.mg does. The [hidden]
   guard must beat the desktop display:flex. */
#page-manage[hidden] { display: none !important; }
@media (min-width: 600px) {
  #page-manage {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 16px;
  }
}
