/* VeLens Cloud — web app styles. Self-contained, no external fonts/CDN.
 *
 * Colors/spacing/radii come from the shared design system
 * (vendor/tokens.css + vendor/button.css, vendored from lib/ui/ via
 * `npm run sync-studio`) — same --mc-* tokens as the extension. Only
 * Studio-specific values (the navy sidebar) are defined locally.
 */

:root {
  /* Studio-only: sidebar identity — not part of the shared token sheet. */
  --sidebar: #0f2744;
  --sidebar-ink: #cdd8e6;
  /* Height of the mobile top bar (44px tap target + 6px padding each side).
     chat.css subtracts it from the viewport to size the chat card, so the two
     sheets can't drift. Zero above the mobile breakpoint — the bar is hidden. */
  --topbar-h: 0px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--mc-surface-2);
  color: var(--mc-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--mc-text-lg);
  line-height: 1.55;
}

a { color: var(--mc-primary); }

/* ── Sign-in ── */
.signin-wrap {
  min-height: 100vh;
  min-height: 100dvh; /* iOS: 100vh sits under the collapsing URL bar */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--mc-space-6);
  background: linear-gradient(135deg, var(--sidebar), #1a56a8);
}
.signin-card {
  background: var(--mc-surface);
  border-radius: var(--mc-radius-modal);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
  padding: 40px 38px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.signin-logo {
  width: 54px; height: 54px; border-radius: var(--mc-radius-xl); overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.signin-logo img { width: 100%; height: 100%; display: block; }
.signin-card h1 { font-size: var(--mc-text-3xl); margin: 0 0 6px; letter-spacing: -.02em; }
.signin-card .sub { color: var(--mc-text-muted); margin: 0 0 26px; font-size: var(--mc-text-lg); }
.signin-card .advanced { margin-top: 18px; text-align: left; }
.signin-card summary { cursor: pointer; color: var(--mc-text-muted); font-size: var(--mc-text-md); }
.signin-card input[type=text] {
  width: 100%; margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius-md);
  font-size: var(--mc-text-lg);
  background: var(--mc-surface); color: var(--mc-text);
  outline: none;
  transition: border-color var(--mc-duration) var(--mc-ease), box-shadow var(--mc-duration) var(--mc-ease);
}
.signin-card input[type=text]:focus {
  border-color: var(--mc-primary);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, .15);
}
.hint { font-size: var(--mc-text-sm); color: var(--mc-text-muted); margin-top: 6px; }
/* Sits below the Advanced disclosure, so it must clear the expanded state too
   — hence the border rather than relying on the collapsed card's spacing. */
.signin-card .signin-legal {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--mc-border);
  font-size: var(--mc-text-sm);
  color: var(--mc-text-muted);
  text-align: center;
  line-height: 1.5;
}
/* nowrap so the line breaks between phrases, never mid-title ("Privacy" on one
   line and "Policy." on the next) — the card is only ~344px of content wide. */
.signin-card .signin-legal a {
  color: var(--mc-text-muted);
  text-decoration: underline;
  white-space: nowrap;
}
.signin-card .signin-legal a:hover { color: var(--mc-primary); }

/* ── App shell ── */
.shell { display: flex; min-height: 100vh; }

/* Mobile-only chrome, inert on desktop: a compact bar carrying the brand and
   the hamburger, plus the scrim that dims the page behind the open drawer.
   Both are display:none until the mobile breakpoint, so the desktop shell is
   byte-identical to what it was before. */
.topbar { display: none; }
.nav-scrim { display: none; }

.sidebar {
  width: 234px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 20px 14px;
  /* Pin to the viewport: an explicit height stops the flex-stretch that made
     the sidebar grow with tall pages (footer ended up at the DOCUMENT bottom,
     below the fold). Only the white content area scrolls past it now. */
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px;
  color: #fff; font-weight: 700; font-size: var(--mc-text-xl); letter-spacing: -.01em;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: var(--mc-radius-lg); overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand .mark img { width: 100%; height: 100%; display: block; }
.brand .brand-sub {
  margin-left: 7px; padding: 2px 7px; border-radius: var(--mc-radius-pill);
  background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .65);
  font-size: var(--mc-text-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
}
.nav { display: flex; flex-direction: column; }
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section + .nav-section { margin-top: 18px; }
/* .55, not .38 — 10px bold at .38 over the navy is ~3.4:1, under WCAG AA for
   small text. .55 lands at ~5.5:1 and still reads as a quiet section label. */
.nav-label {
  padding: 0 12px 6px; font-size: var(--mc-text-2xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: rgba(255, 255, 255, .55);
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--mc-radius-lg);
  color: var(--sidebar-ink); text-decoration: none; font-size: var(--mc-text-lg); font-weight: 500;
  transition: background var(--mc-duration) var(--mc-ease), color var(--mc-duration) var(--mc-ease);
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: var(--mc-primary); color: #fff; }
.nav a:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.nav .ico {
  width: 16px; height: 16px; flex-shrink: 0; opacity: .85;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav .ico svg { display: block; }
.nav a.active .ico, .nav a:hover .ico { opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 12px 4px 2px; font-size: var(--mc-text-sm); min-width: 0; border-top: 1px solid rgba(255, 255, 255, .08); }
/* The identity block is the link to #/account. Its "active" treatment is a
   subtle wash rather than the nav's solid --mc-primary: the footer sits apart
   from the nav list, and a full blue slab there reads as a fourth nav item —
   the exact thing moving Account out of the nav was meant to stop. */
.foot-id {
  display: flex; align-items: center; gap: 9px; padding: 6px 4px; min-width: 0;
  border-radius: var(--mc-radius-lg); text-decoration: none; color: inherit;
  transition: background var(--mc-duration) var(--mc-ease);
}
.foot-id:hover { background: rgba(255, 255, 255, .06); }
.foot-id.active { background: rgba(255, 255, 255, .1); }
.foot-id:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.foot-id:hover .foot-user, .foot-id.active .foot-user { color: #fff; }
.foot-avatar {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--mc-text-sm); font-weight: 700;
}
.foot-meta { min-width: 0; }
.sidebar-foot .foot-user {
  color: rgba(255, 255, 255, .88); font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* .58, not .45 — 11px at .45 is ~4.2:1 over the navy, just under AA. */
.sidebar-foot .foot-email {
  font-size: var(--mc-text-xs); color: rgba(255, 255, 255, .58); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-foot button {
  display: block; width: 100%; margin-top: 8px; text-align: left;
  background: none; border: none; border-radius: var(--mc-radius-md);
  color: rgba(255, 255, 255, .55);
  cursor: pointer; font-size: var(--mc-text-sm); padding: 6px 4px;
  transition: color var(--mc-duration) var(--mc-ease), background var(--mc-duration) var(--mc-ease);
}
.sidebar-foot button:hover { color: #fff; background: rgba(255, 255, 255, .06); }

/* Embedded in Marketing Cloud's app iframe — MC owns the session, so hide the
   in-app Sign out control (see applyEmbeddedFlag in app.js). */
.is-embedded .sidebar-foot #signout { display: none; }

.main { flex: 1; min-width: 0; padding: 34px 40px; }
.page { max-width: 860px; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--mc-text-muted); font-size: var(--mc-text-lg); }

/* ── Cards ── */
.card {
  background: var(--mc-surface); border: 1px solid var(--mc-border-subtle);
  border-radius: var(--mc-radius-xl); box-shadow: var(--mc-shadow-sm); padding: 22px 24px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: var(--mc-text-xl); }

/* org meta grid */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px 24px; }
.meta .lbl { font-size: var(--mc-text-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--mc-text-muted); }
.meta .val { font-size: var(--mc-text-xl); font-weight: 600; margin-top: 2px; word-break: break-word; }

/* Connection strip — the old Connection card compressed to one line under the
   page head. Wraps at narrow widths; the separators are drawn by CSS so the
   markup stays a plain list of spans. */
.conn-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: -10px 0 18px;
  font-size: var(--mc-text-md); color: var(--mc-text-muted);
}
/* TRAILING separator, not leading: when the strip wraps on a narrow screen a
   hanging dot at the end of a line reads as a continuation, while a dot at the
   START of the next line reads as a bullet point. */
.conn-strip .conn-item:not(:last-child)::after {
  content: '·'; margin-left: 10px; color: var(--mc-text-subtle);
}

/* badges — fg/bg pairs from the design system's status-badge card */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: var(--mc-radius-pill);
  font-size: var(--mc-text-sm); font-weight: 600; text-transform: capitalize;
  background: var(--mc-success-tint); color: var(--mc-success);
}
.badge.role { background: var(--mc-primary-tint); color: var(--mc-primary-hover); }
.badge.tier-pro { background: #f3e8fd; color: #6b21a8; }
.badge.tier-free { background: #f1f3f4; color: #5f6368; }

/* feature rows */
.feature-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 2px; border-top: 1px solid var(--mc-border-subtle);
}
.feature-row:first-of-type { border-top: none; }
.feature-row .txt { flex: 1; min-width: 0; }
/* flex-wrap: a long feature label must push its tier badge to the next line
   rather than squeezing it into an unreadable sliver. */
.feature-row .name { font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.feature-row .desc { color: var(--mc-text-muted); font-size: var(--mc-text-md); margin-top: 2px; }

/* per-role availability pills under each feature (roles = VeLens roles) */
.role-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.role-strip.muted { opacity: .45; }
.role-strip-label { color: var(--mc-text-muted); font-size: var(--mc-text-sm); margin-right: 2px; }
.role-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border: 1px solid var(--mc-border-subtle); border-radius: var(--mc-radius-pill);
  font-size: var(--mc-text-sm); text-transform: capitalize; cursor: pointer;
  color: var(--mc-text-muted); background: transparent;
}
.role-pill:has(input:checked) {
  background: var(--mc-primary-tint); color: var(--mc-primary-hover);
  border-color: transparent;
}
.role-pill input { accent-color: var(--mc-primary); margin: 0; }
.role-pill input:disabled { cursor: default; }
.role-pill:has(input:disabled) { cursor: default; }

/* AI Chat Tools: the same .feature-row rows, bucketed under a group heading.
   The <h4> is not a <div>, so .feature-row:first-of-type still matches the
   first row in each group and drops its top border. */
.tool-group { margin-top: 18px; }
.tool-group-label {
  margin: 0; font-size: var(--mc-text-sm); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--mc-text-muted);
}

/* toggle switch — 34×18 per the design system's form-controls card */
.switch { position: relative; width: 34px; height: 18px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--mc-radius-pill); background: var(--mc-border-strong);
  transition: background var(--mc-duration-md) var(--mc-ease); cursor: pointer;
}
.switch .track::before {
  content: ''; position: absolute; height: 14px; width: 14px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform var(--mc-duration-md) var(--mc-ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.switch input:checked + .track { background: var(--mc-primary); }
.switch input:checked + .track::before { transform: translateX(16px); }
.switch input:disabled + .track { opacity: .5; cursor: default; }
.switch input:focus-visible + .track { outline: 2px solid var(--mc-primary); outline-offset: 2px; }

/* table — the wrapper is the scroll jail. A roster with long email addresses
   is wider than a phone; it must scroll INSIDE its card, never widen the page.
   Inert on desktop, where the table already fits. */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--mc-text-lg); }
table.tbl th {
  text-align: left; font-size: var(--mc-text-sm); text-transform: uppercase; letter-spacing: .04em;
  color: var(--mc-text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--mc-border-subtle);
}
table.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--mc-border-subtle); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
select.role-select {
  padding: 6px 8px; border: 1px solid var(--mc-border); border-radius: var(--mc-radius-md);
  background: var(--mc-surface); color: var(--mc-text); font-size: var(--mc-text-md);
}
select.role-select:disabled { opacity: .7; }
select.role-select:focus-visible { outline: 2px solid var(--mc-primary); outline-offset: 1px; }
.you-tag { font-size: var(--mc-text-xs); color: var(--mc-text-muted); margin-left: 6px; }

/* ── Team: invites + removal ── */
td.row-actions { text-align: right; white-space: nowrap; }
.btn-icon {
  background: none; border: 1px solid transparent; border-radius: var(--mc-radius-md);
  color: var(--mc-text-secondary); font-size: var(--mc-text-sm); font-family: inherit;
  padding: 5px 9px; cursor: pointer; margin-left: 4px;
}
.btn-icon:hover { background: var(--mc-surface-alt); border-color: var(--mc-border-subtle); }
.btn-icon:focus-visible { outline: 2px solid var(--mc-primary); outline-offset: 1px; }
.btn-icon:disabled { opacity: .5; cursor: default; }
.btn-icon.danger:hover { background: var(--mc-danger-tint); color: var(--mc-danger-strong); border-color: var(--mc-danger); }
/* Armed = one click from destructive. Reads as a warning, not a hover state. */
.btn-icon.danger.armed {
  background: var(--mc-danger); color: #fff; border-color: var(--mc-danger); font-weight: 600;
}

/* The address that actually redeemed differs from the one invited. */
.invited-as {
  display: block; font-size: var(--mc-text-xs); color: var(--mc-text-muted); margin-top: 2px;
}

tr.pending td { background: var(--mc-surface-alt); }
.pending-tag {
  display: inline-block; font-size: var(--mc-text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--mc-text-muted);
  border: 1px dashed var(--mc-border); border-radius: var(--mc-radius-sm); padding: 1px 6px;
}
.muted { color: var(--mc-text-muted); font-size: var(--mc-text-sm); }

.invite-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.invite-row input[type="email"] {
  flex: 1 1 240px; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius-md);
  background: var(--mc-surface); color: var(--mc-text); font-size: var(--mc-text-md); font-family: inherit;
}
.invite-row select {
  padding: 8px 10px; border: 1px solid var(--mc-border); border-radius: var(--mc-radius-md);
  background: var(--mc-surface); color: var(--mc-text); font-size: var(--mc-text-md);
}
/* These two had no focus treatment at all — keyboard users lost the caret ring
   the other Studio inputs get. */
.invite-row input[type="email"]:focus {
  border-color: var(--mc-primary); outline: none;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, .15);
}
.invite-row select:focus-visible { outline: 2px solid var(--mc-primary); outline-offset: 1px; }
.invite-result {
  margin-top: 14px; padding: 12px 14px;
  background: var(--mc-primary-tint); border-radius: var(--mc-radius-md);
  font-size: var(--mc-text-md);
}
.invite-link { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
/* The link is long and must never widen the page — it scrolls inside itself. */
.invite-link code {
  flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap;
  background: var(--mc-surface); border: 1px solid var(--mc-border-subtle);
  border-radius: var(--mc-radius-sm); padding: 6px 8px; font-size: var(--mc-text-sm);
}
.gate-toggle { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: var(--mc-text-lg); }

/* misc states */
.note {
  font-size: var(--mc-text-md); color: var(--mc-text-secondary); background: var(--mc-warn-tint);
  border-left: 3px solid var(--mc-warn);
  border-radius: var(--mc-radius-md); padding: 10px 14px; margin-bottom: 16px;
}
.loading, .empty { color: var(--mc-text-muted); padding: 40px 0; text-align: center; }
/* max-width + safe-area: an unbounded toast (a long server error) was wider
   than a phone and gave the whole document a horizontal scrollbar. z-index 70
   keeps it above the mobile nav drawer (60) that can be open behind it. */
.toast {
  position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--mc-text); color: var(--mc-text-on-primary); padding: 10px 18px;
  border-radius: var(--mc-radius-xl); text-align: center;
  font-size: var(--mc-text-lg); box-shadow: var(--mc-shadow-card); z-index: 70;
  opacity: 0; transition: opacity var(--mc-duration-md) var(--mc-ease); pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--mc-danger); color: #fff; }
.blurb { color: var(--mc-text-secondary); font-size: var(--mc-text-lg); }
.blurb ul { margin: 10px 0 0; padding-left: 20px; }
.blurb li { margin: 4px 0; }

/* ── Org Health (Home) ── */
.health-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; }
.health-head h3 { margin: 0; font-size: var(--mc-text-xl); }
.health-fresh { font-size: var(--mc-text-sm); color: var(--mc-text-muted); white-space: nowrap; }
.health-empty { color: var(--mc-text-muted); font-size: var(--mc-text-lg); padding: 8px 0 4px; }

.health-banner {
  font-size: var(--mc-text-md); border-radius: var(--mc-radius-lg);
  padding: 10px 12px; margin-bottom: 14px;
}
.health-banner.warn { background: var(--mc-warn-tint); color: var(--mc-text-secondary); }
.health-banner.err { background: var(--mc-danger-tint); color: var(--mc-danger-strong); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.metric-tile {
  border: 1px solid var(--mc-border-subtle); border-radius: var(--mc-radius-lg);
  background: var(--mc-surface-1); padding: 14px 16px; min-width: 0;
}
.metric-label {
  font-size: var(--mc-text-sm); text-transform: uppercase; letter-spacing: .04em;
  color: var(--mc-text-muted); font-weight: 600;
}
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.metric-value.good { color: var(--mc-success); }
.metric-value.bad { color: var(--mc-danger); }
.metric-value .ok-mark { color: var(--mc-success); font-weight: 700; }
.metric-value .metric-of { font-size: var(--mc-text-md); font-weight: 600; color: var(--mc-text-muted); }
.metric-sub { font-size: var(--mc-text-sm); color: var(--mc-text-tertiary); margin-top: 6px; }
.metric-hint { color: var(--mc-text-muted); }

/* Week-over-week deltas under a tile. Muted by default — only metrics with a
   clear direction (open/click rate) get a color, so green never implies that
   "more sends" or "more contacts" is good news. */
.metric-delta {
  display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px;
  font-size: var(--mc-text-sm); color: var(--mc-text-muted);
}
.delta.up { color: var(--mc-success); }
.delta.down { color: var(--mc-danger); }
.delta-since { color: var(--mc-text-subtle); }

/* Ask VeLens — suggested prompts that deep-link into AI Chat (#/workspace)
   with the composer prefilled. Chips wrap; they never scroll sideways. */
.ask-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-chip {
  display: inline-flex; align-items: center; padding: 7px 14px;
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius-pill);
  background: var(--mc-surface-1); color: var(--mc-text-secondary);
  font-size: var(--mc-text-md); text-decoration: none;
}
.ask-chip:hover { border-color: var(--mc-primary); color: var(--mc-primary-hover); }
.ask-hint { margin-top: 10px; font-size: var(--mc-text-sm); color: var(--mc-text-muted); }
/* Same destination from the Automation-failures tile, at tile-sub scale. */
.ask-link { display: inline-block; margin-top: 4px; font-size: var(--mc-text-sm); }

.rate-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.rate-stat { display: inline-flex; flex-direction: column; line-height: 1.2; }
.rate-name { font-size: var(--mc-text-2xs); text-transform: uppercase; letter-spacing: .03em; color: var(--mc-text-subtle); }
.rate-val { font-size: var(--mc-text-md); font-weight: 600; color: var(--mc-text-strong); }

/* utilization bars */
.util-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--mc-border-subtle); }
.util-title { font-size: var(--mc-text-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--mc-text-muted); font-weight: 600; margin-bottom: 10px; }
.util-row { margin-bottom: 14px; }
.util-row:last-child { margin-bottom: 0; }
.util-label { font-size: var(--mc-text-md); font-weight: 600; color: var(--mc-text-strong); }
.util-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 3px 0 5px; }
.util-count { font-size: var(--mc-text-sm); color: var(--mc-text-tertiary); }
.util-pct { font-size: var(--mc-text-md); font-weight: 700; color: var(--mc-primary); }
.util-pct.warn { color: var(--mc-warn); }
.util-pct.critical { color: var(--mc-danger); }
.util-track { height: 8px; border-radius: var(--mc-radius-pill); background: var(--mc-border-subtle); overflow: hidden; }
.util-fill { height: 100%; border-radius: var(--mc-radius-pill); background: var(--mc-primary); transition: width var(--mc-duration-md) var(--mc-ease); }
.util-fill.warn { background: var(--mc-warn); }
.util-fill.critical { background: var(--mc-danger); }
.util-unset { font-size: var(--mc-text-sm); color: var(--mc-text-muted); margin-top: 4px; }

/* ── Setup (entitlements editor) ── */
.setup-field { margin-bottom: 18px; }
.setup-field:last-of-type { margin-bottom: 8px; }
.setup-field label { display: block; font-weight: 600; font-size: var(--mc-text-lg); margin-bottom: 6px; }
.setup-field input[type=number], .setup-field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius-md);
  font-size: var(--mc-text-lg); font-family: inherit;
  background: var(--mc-surface); color: var(--mc-text); outline: none;
  transition: border-color var(--mc-duration) var(--mc-ease), box-shadow var(--mc-duration) var(--mc-ease);
}
.setup-field textarea { resize: vertical; }
.setup-field input[type=number]:focus, .setup-field textarea:focus {
  border-color: var(--mc-primary); box-shadow: 0 0 0 2px rgba(26, 115, 232, .15);
}
.setup-hint { font-size: var(--mc-text-sm); color: var(--mc-text-muted); margin-top: 6px; }
.setup-actions { margin-top: 8px; }

/* ── Account (profile + danger zone) ── */
.prefs-soon, .del-loading { color: var(--mc-text-muted); font-size: var(--mc-text-md); }
.card--danger { border-color: var(--mc-danger); }
.card--danger h3 { color: var(--mc-danger-strong); }
#account-delete-card { margin-bottom: 12px; }
.del-warn {
  background: var(--mc-danger-tint); color: var(--mc-danger-strong);
  border: 1px solid var(--mc-danger); border-radius: var(--mc-radius-md);
  padding: 10px 12px; font-size: var(--mc-text-md); margin-bottom: 12px;
}
.del-counts {
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius-lg);
  margin-bottom: 14px; overflow: hidden;
}
.del-count-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; font-size: var(--mc-text-md); }
.del-count-row + .del-count-row { border-top: 1px solid var(--mc-border-subtle); }
.del-count-row span:last-child { font-weight: 600; }
.del-type-label { display: block; font-weight: 600; font-size: var(--mc-text-md); margin: 4px 0 6px; }
.del-input {
  width: 220px; max-width: 100%; padding: 8px 12px;
  border: 1px solid var(--mc-border); border-radius: var(--mc-radius-md);
  font-size: var(--mc-text-lg); font-family: inherit;
  background: var(--mc-surface); color: var(--mc-text); outline: none;
}
.del-input:focus { border-color: var(--mc-danger); box-shadow: 0 0 0 2px rgba(217, 48, 37, .15); }
.del-input--wide { width: 320px; }
.del-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile (≤768px)

   The old layout turned the sidebar into a horizontally SCROLLING strip: nav
   items ran off the right edge with no affordance, and the more routes an
   owner had the worse it got. Replaced with the conventional pattern: a fixed
   top bar (brand + hamburger) and the SAME sidebar re-used verbatim as an
   off-canvas drawer. Nothing about the sidebar's markup or the mountShell()
   architecture changes — only where the box sits.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }

  .shell { flex-direction: column; min-height: 100vh; min-height: 100dvh; }

  /* ── Top bar ── */
  .topbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 60;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: 6px 10px;
    padding-top: calc(6px + env(safe-area-inset-top));
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
    background: var(--sidebar); color: #fff;
  }
  .topbar-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex-shrink: 0; padding: 0;
    border: none; border-radius: var(--mc-radius-lg);
    background: none; color: #fff; cursor: pointer;
  }
  .topbar-toggle:hover { background: rgba(255, 255, 255, .1); }
  .topbar-toggle:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
  /* The one button is both open and close: the drawer opens BELOW the bar, so
     the hamburger stays visible and swaps to an ✕ rather than being buried
     under the panel it opened. */
  .topbar-toggle .ico-close { display: none; }
  .shell.nav-open .topbar-toggle .ico-open { display: none; }
  .shell.nav-open .topbar-toggle .ico-close { display: block; }
  .topbar-brand {
    display: flex; align-items: center; gap: 9px; min-width: 0;
    font-weight: 700; font-size: var(--mc-text-xl); letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar-brand .mark {
    width: 26px; height: 26px; flex-shrink: 0;
    border-radius: var(--mc-radius-lg); overflow: hidden; display: inline-flex;
  }
  .topbar-brand .mark img { width: 100%; height: 100%; display: block; }

  /* ── The sidebar, as a drawer ──
     Sits BELOW the top bar (not under it) so the hamburger stays reachable.
     Same markup as desktop; only the box moves. */
  .sidebar {
    position: fixed; left: 0; bottom: 0; z-index: 50;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    width: 264px; max-width: 84vw; height: auto;
    padding: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    /* visibility keeps the closed drawer out of the tab order; it flips only
       after the slide finishes so the exit animation is still visible. */
    visibility: hidden;
    transition: transform var(--mc-duration-md) var(--mc-ease),
                visibility 0s linear var(--mc-duration-md);
  }
  .shell.nav-open .sidebar {
    transform: none; visibility: visible;
    box-shadow: 0 0 30px rgba(0, 0, 0, .38);
    transition: transform var(--mc-duration-md) var(--mc-ease);
  }
  /* The brand is already in the top bar — repeating it in the drawer just eats
     a fifth of the panel. */
  .sidebar .brand { display: none; }
  .nav-scrim {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    background: rgba(0, 0, 0, .42);
  }
  .nav-scrim[hidden] { display: none; }

  /* Thumb-sized rows inside the drawer (the desktop 36px rows are mouse-sized). */
  .nav a { padding: 11px 12px; min-height: 44px; }
  .nav-section + .nav-section { margin-top: 20px; }
  .foot-id { padding: 8px 4px; min-height: 44px; }
  .sidebar-foot button { min-height: 40px; }

  /* ── Content ── */
  .main {
    padding: 20px 16px;
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .page-head { margin-bottom: 16px; }
  .page-head h2 { font-size: 21px; }
  .card { padding: 16px 14px; margin-bottom: 14px; }

  /* Two readable columns of short values instead of one tall stack. */
  .meta { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px 18px; }

  .invite-row input[type="email"] { flex: 1 1 100%; }

  /* The toggle belongs beside the feature NAME, not floating next to the
     middle of a three-line description. */
  .feature-row { align-items: flex-start; }
  .feature-row .switch { margin-top: 3px; }

  /* 16px is the threshold below which iOS Safari zooms the page on focus —
     it never zooms back out, so every focusable control needs to clear it. */
  .signin-card input[type=text],
  .setup-field input[type=number],
  .setup-field textarea,
  .invite-row input[type="email"],
  .invite-row select,
  select.role-select,
  .del-input { font-size: 16px; }

  /* Touch targets. The .switch pseudo-element grows the label's hit area to
     44px without changing a single painted pixel — five 44px-tall role pills
     in a row would, so those settle at 40px.
     :not(.mc-btn--icon) — that variant is a fixed square and min-height would
     turn it into a rectangle. */
  .main .mc-btn:not(.mc-btn--icon) { min-height: 40px; }
  .btn-icon { min-height: 40px; padding: 8px 12px; }
  .role-pill { min-height: 40px; padding: 5px 11px; }
  .ask-chip { min-height: 40px; }
  .gate-toggle { min-height: 44px; }
  select.role-select { min-height: 40px; }
  .switch::after { content: ''; position: absolute; top: -13px; bottom: -13px; left: -6px; right: -6px; }
}

/* Roster: below ~560px a four-column table can only be read by scrolling it
   sideways, which buries the Role dropdown and Remove — the two controls the
   page exists for. Each row becomes a stacked block instead. No markup or
   class changes: the <table> is still a <table>, only its display is swapped.
   .tbl-wrap keeps its overflow-x above this width as a safety net. */
@media (max-width: 560px) {
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl thead { display: none; }
  table.tbl tr {
    padding: 12px 0; border-bottom: 1px solid var(--mc-border-subtle);
  }
  table.tbl tr:last-child { border-bottom: none; }
  table.tbl tr:first-child { padding-top: 2px; }
  table.tbl td { border-bottom: none; padding: 3px 0; }
  table.tbl td:first-child { font-weight: 600; }
  /* Backgrounds move to the row: per-cell they'd leave gutters between blocks. */
  tr.pending td { background: none; }
  table.tbl tr.pending {
    background: var(--mc-surface-alt); border-radius: var(--mc-radius-md);
    padding: 12px 10px; margin: 6px 0;
  }
  td.row-actions { text-align: left; padding-top: 8px; }
  td.row-actions .btn-icon:first-child { margin-left: 0; }
  select.role-select { width: 100%; }
}

@media (max-width: 480px) {
  .main { padding: 16px 14px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .card { padding: 14px 13px; }
  .signin-wrap { padding: 16px; }
  .signin-card { padding: 28px 20px; }
  .signin-card h1 { font-size: var(--mc-text-2xl); }
  /* Single column everywhere — 2-up tiles at this width are unreadable. */
  .metric-grid { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; gap: 12px; }
  .feature-row { gap: 12px; }
  .del-input, .del-input--wide { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .shell.nav-open .sidebar { transition: none; }
}
