/* Playflow app shell, layered on site.css. Load AFTER site.css.
   The tenant workspace: ink sidebar for structure, sand content, shell cards.
   Everything here is app chrome, site.css still owns type, buttons, fields,
   badges, callouts, the player and every token. */

/* React UI wrappers deliberately emit the package primitives. These are
   app-only state/surface rules; the shared site stylesheet owns their base
   geometry and typography. */
.field [aria-invalid="true"] { border-color: var(--coral-deep); }
.field-select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: var(--r-md); background: var(--shell); color: var(--ink); font: inherit; font-size: 15px; }
.field-select:focus-visible { outline: none; border-color: var(--deep-teal); box-shadow: var(--focus-ring); }
.field--inline { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.field--inline input { width: auto; min-width: 142px; }
.callout--ok { background: var(--success-subtle); color: var(--success-text); border: 1px solid color-mix(in srgb, var(--seagrass) 35%, transparent); }
.callout--warn { background: var(--warning-subtle); color: var(--warning-text); border: 1px solid color-mix(in srgb, var(--sunlit) 35%, transparent); }
.callout--bad { background: var(--destructive-subtle); color: var(--destructive-text); border: 1px solid color-mix(in srgb, var(--coral-deep) 35%, transparent); }
.skeleton { background: var(--dune); background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--shell) 55%, transparent), transparent); background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease-in-out infinite; }
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- auth and onboarding ---------- */
.auth-hero-copy { max-width: 480px; }
.auth-hero-ticks { margin-top: 8px; }
.auth-hero-ticks li { color: var(--sand); }
.auth-hero-ticks li > span:first-child { width: 17px; height: 17px; flex: none; margin-top: 4px; color: var(--seafoam); font-weight: 700; line-height: 17px; }
.auth-google { justify-content: center; }
.auth-status { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 96px; color: var(--text-muted); }
.auth-next { justify-content: center; }
.auth-forgot-row { justify-content: space-between; }
.onboarding-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--surface-page); color: var(--text); }
.onboarding-header { width: 100%; max-width: var(--max); margin: 0 auto; padding: 16px var(--pad); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.onboarding-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.onboarding-brand__mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--deep-teal) 12%, transparent); color: var(--deep-teal); }
.onboarding-header__actions { display: flex; align-items: center; gap: 8px; }
.onboarding-main { flex: 1; display: grid; place-items: center; padding: 24px var(--pad); }
.onboarding-card { width: 100%; max-width: 520px; padding: 32px; }
.onboarding-state { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 24px 0; text-align: center; }
.onboarding-state h1, .onboarding-state h2 { font-family: var(--font-display); }
.onboarding-state__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: color-mix(in srgb, var(--deep-teal) 12%, transparent); color: var(--deep-teal); }
.onboarding-state__icon--bad { background: var(--destructive-subtle); color: var(--destructive-text); }
.onboarding-action { width: 100%; }

/* The React chrome keeps the static marketing header's DOM contract while
   using the package's mobile panel behavior. */
.site-nav-panel { display: contents; }
.site-header__backdrop { display: none; }
.site-header .mobile-only { display: none; }
.desktop-only { display: flex; }
@media (max-width: 900px) {
  .site-header .mobile-only { display: inline-flex; }
  .desktop-only { display: none; }
  .site-nav-panel {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 72px;
    z-index: 1;
    padding: 12px 20px 20px;
    background: var(--ink);
    border-bottom: 1px solid rgba(159,189,188,.22);
  }
  .site-header[data-open="true"] .site-nav-panel { display: block; }
  .site-header__backdrop {
    position: fixed;
    inset: 72px 0 0;
    z-index: 0;
    background: var(--scrim);
  }
  .site-header[data-open="true"] .site-header__backdrop { display: block; }
  .site-header .brand, .site-header .mobile-header-controls {
    position: relative;
    z-index: 2;
  }
  body.nav-open { overflow: hidden; }
  .site-nav-panel .site-nav { display: flex; position: static; flex-direction: column; padding: 0; border: 0; }
  .site-nav-panel .site-nav a { min-height: 44px; }
  .panel-footer { display: block; padding-top: 18px; }
  .panel-ctas { display: grid; gap: 10px; }
  .panel-signin { display: flex; justify-content: center; gap: 6px; padding: 20px 0; color: rgba(236,224,217,.78); font-size: 14px; }
  .panel-signin a { color: var(--seafoam); }
}
@media (max-width: 560px) {
  .auth-card .form-grid { grid-template-columns: 1fr; }
  .onboarding-card { padding: 24px; }
}

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0,1fr); align-items: start; min-height: 100vh; }

.app-side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--ink); color: var(--sand); border-right: 1px solid rgba(159,189,188,.22);
}
.app-side__top { padding: 14px 16px; border-bottom: 1px solid rgba(159,189,188,.18); }

/* Workspace switcher. A real button, so it is reachable without JS. */
.ws {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 52px;
  padding: 7px 10px; border: 1px solid transparent; border-radius: var(--r-lg);
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.ws:hover { background: rgba(159,189,188,.12); border-color: rgba(159,189,188,.28); }
.ws__tile {
  width: 36px; height: 36px; flex: none; border-radius: var(--r-md);
  background: var(--deep-teal); color: #fff; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 17px; font-weight: 700; line-height: 1;
}
.ws__body { min-width: 0; flex: 1; }
.ws__name { display: block; font-weight: 600; font-size: 15px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Seafoam, not alpha-muted sand: 7.4:1 on ink and it reads as a distinct rank. */
.ws__plan { display: block; font-size: 12.5px; color: var(--seafoam); line-height: 1.3; }
.ws .i { width: 16px; height: 16px; flex: none; color: var(--seafoam); }

.app-nav { padding: 16px 12px; overflow-y: auto; flex: 1; }
.app-nav__label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--seafoam); padding: 0 10px 10px; display: block; font-weight: 500;
}
.app-nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-lg); font-size: 15px; font-weight: 500;
  /* Full sand, never alpha. An inactive item is still a primary destination. */
  color: var(--sand); text-decoration: none; margin-bottom: 2px;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.app-nav a:hover { background: rgba(159,189,188,.13); text-decoration: none; color: var(--sand); }
.app-nav a .i { width: 18px; height: 18px; flex: none; }
/* Solid seafoam + ink text: 9.4:1, and the fill alone carries the state so the
   label does not need a weight change that would shift the row. */
.app-nav a[aria-current="page"] { background: var(--seafoam); color: var(--ink); font-weight: 600; }
.app-nav a[aria-current="page"]:hover { background: #AFC9C8; color: var(--ink); }

.app-side__foot { padding: 16px; border-top: 1px solid rgba(159,189,188,.18); }
.meter__label { font-size: 12px; color: var(--seafoam); font-family: var(--font-mono);
  letter-spacing: .04em; text-transform: uppercase; }
.meter__value { font-size: 14px; font-weight: 600; margin: 3px 0 8px; font-family: var(--font-mono); }
.meter__track { height: 6px; border-radius: 999px; background: rgba(236,224,217,.2); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 999px; background: var(--seafoam); }
.meter__fill[data-warn] { background: var(--sunlit); }
.meter__fill[data-over] { background: var(--coral); }
.meter__fill--ok { background: var(--seagrass); }
.meter__fill--warn { background: var(--sunlit); }
.usage__fill[data-warn] { background: var(--sunlit); }
.usage__fill[data-over] { background: var(--coral); }

/* ---------- mobile top bar + drawer ---------- */
.app-top { display: none; }
.app-scrim { display: none; }

/* ---------- main ---------- */
.app-main { min-width: 0; background: var(--sand); }
.app-wrap { max-width: 1240px; margin: 0 auto; padding: 34px 32px 96px; }

.page-head { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head__body { min-width: 0; flex: 1 1 320px; }
.page-head h1 {
  font-family: var(--font-display); font-size: clamp(30px, 3.2vw, 40px); line-height: 1.06;
  letter-spacing: -.025em; font-weight: 700; display: flex; align-items: center; gap: 11px;
}
.page-head__title {
  font-family: var(--font-display); font-size: clamp(26px, 3.2vw, 40px); line-height: 1.06;
  letter-spacing: -.025em; font-weight: 700; display: flex; align-items: center; gap: 11px;
}
.page-head h1 .i { width: 26px; height: 26px; flex: none; color: var(--deep-teal); }
.page-head .caption { margin-top: 7px; font-size: 15px; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.section-title { font-family: var(--font-display); font-size: 22px; letter-spacing: -.015em;
  font-weight: 700; margin: 40px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--driftwood); }
.section-title:first-child { margin-top: 0; }

/* ---------- panels ---------- */
/* Tighter than the marketing .card: app density, same surface and border. */
.panel { background: var(--shell); border: 1px solid var(--driftwood); border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm); }
.panel__head { padding: 20px 22px 0; }
.panel__head--row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.panel__title { font-family: var(--font-display); font-size: 18px; font-weight: 600;
  letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.panel__title .i { width: 19px; height: 19px; flex: none; color: var(--deep-teal); }
.panel__head .caption { margin-top: 5px; }
.panel__body { padding: 20px 22px; }
.panel__body--flush { padding: 0; }
.panel__foot { padding: 15px 22px; border-top: 1px solid var(--driftwood);
  background: rgba(27,47,56,.025); border-radius: 0 0 var(--r-xl) var(--r-xl);
  display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.panel__foot--split { justify-content: space-between; }
.panel--seam { border-top: 1px solid var(--driftwood); }

/* ---------- metric cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat { background: var(--shell); border: 1px solid var(--driftwood); border-radius: var(--r-xl);
  padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat__label { font-size: 14px; color: var(--slate-teal); font-weight: 500; }
.stat__top .i { width: 17px; height: 17px; flex: none; color: var(--slate-teal); }
.stat__value { font-family: var(--font-display); font-size: 32px; font-weight: 700;
  letter-spacing: -.025em; line-height: 1.1; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat__delta { font-size: 13px; margin-top: 6px; display: flex; align-items: center; gap: 5px; color: var(--slate-teal); }
.stat__delta .i { width: 14px; height: 14px; flex: none; }
.stat__delta[data-dir="up"] { color: var(--success-text); }
.stat__delta[data-dir="down"] { color: var(--coral-text); }

/* ---------- two-column page layouts ---------- */
.app-split { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(0,1fr); gap: 20px; align-items: start; }
.app-split--detail { grid-template-columns: minmax(0,1fr) 360px; }
.app-split--even { grid-template-columns: repeat(auto-fit, minmax(320px,1fr)); }

/* ---------- data tables ---------- */
.dtable-wrap { background: var(--shell); border: 1px solid var(--driftwood);
  border-radius: var(--r-xl); box-shadow: var(--shadow-sm); overflow: hidden; }
.dtable-scroll { overflow-x: auto; }
.dtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
/* Ink on Dune, not slate-teal. Slate Teal on Dune is 4.45:1 at this size, the
   same trap as the chips, the docs cards and the sidebar badge. Fourth time. */
.dtable th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ink);
  padding: 13px 16px; background: var(--dune); border-bottom: 1px solid var(--driftwood); white-space: nowrap;
}
.dtable td { padding: 13px 16px; border-bottom: 1px solid var(--driftwood); vertical-align: middle; }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr { transition: background-color 140ms var(--ease); }
.dtable tbody tr:hover { background: rgba(27,47,56,.035); }
.dtable .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.dtable .nowrap { white-space: nowrap; }
.dtable__title { font-weight: 600; }
.dtable__sub { font-size: 12.5px; color: var(--slate-teal); margin-top: 3px; }
.dtable__cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dtable__foot { padding: 13px 16px; border-top: 1px solid var(--driftwood);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 13px; color: var(--slate-teal); background: rgba(27,47,56,.025); }

/* Row actions reveal on hover but stay reachable by keyboard and on touch. */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity 140ms var(--ease); }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* ---------- thumbs ---------- */
.thumb { width: 84px; height: 52px; flex: none; border-radius: var(--r-md); overflow: hidden;
  background: repeating-linear-gradient(135deg, #1B2F38 0 7px, #22404b 7px 14px);
  position: relative; display: grid; place-items: center; color: rgba(236,224,217,.75); }
.thumb .i { width: 17px; height: 17px; }
.thumb--tall { width: 44px; height: 64px; }
.thumb--library { width: 80px; height: 48px; color: var(--shell); }
.thumb--mobile { width: 112px; height: 64px; }
.folder-icon { background: var(--info-subtle); color: var(--info-text); }
.color-dot { border-radius: 50%; box-shadow: 0 0 0 1px var(--control-border); }
.preview-frame { border-radius: var(--r-xl); box-shadow: var(--shadow-lg); background: var(--canvas); }
.audit-before { background: var(--destructive-subtle); color: var(--destructive-text); }
.audit-after { background: var(--success-subtle); color: var(--success-text); }
.video-progress-overlay { background: color-mix(in srgb, var(--canvas) 78%, transparent); color: var(--sand); }
.thumb__dur { position: absolute; right: 4px; bottom: 4px; font-family: var(--font-mono);
  font-size: 10.5px; background: rgba(19,34,41,.78); color: #fff; padding: 1px 5px; border-radius: 3px; }

/* ---------- tabs ---------- */
/* Real anchors/buttons. Without JS every panel below stays visible, so the page
   is complete; app.js only collapses the inactive ones. */
.app-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--driftwood);
  overflow-x: auto; scrollbar-width: none; }
.app-tabs::-webkit-scrollbar { display: none; }
.app-tabs button, .app-tabs a {
  appearance: none; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; padding: 13px 15px; min-height: 46px; font: inherit; font-size: 15px;
  font-weight: 500; color: var(--slate-teal); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.app-tabs button:hover, .app-tabs a:hover { color: var(--ink); text-decoration: none; }
.app-tabs [aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--deep-teal); }

/* Segmented switch, for two peer views (Members / Permission Groups). */
.segset { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-lg);
  background: var(--shell); border: 1px solid var(--driftwood); }
.segset .btn { min-height: 38px; border-radius: var(--r-md); }
.segset .btn[aria-pressed="false"] { background: transparent; border-color: transparent;
  color: var(--slate-teal); box-shadow: none; }
.segset .btn[aria-pressed="false"]:hover { background: var(--dune); color: var(--ink); }

/* ---------- definition list (video details rail) ---------- */
.dl { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 0; font-size: 13.5px; }
.dl dt { color: var(--slate-teal); padding: 10px 0; border-bottom: 1px solid var(--driftwood); }
.dl dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--driftwood);
  text-align: right; font-family: var(--font-mono); font-size: 13px;
  overflow-wrap: anywhere; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.dl > :nth-last-child(-n+2) { border-bottom: none; }
.dl__eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--slate-teal); font-weight: 500; }

/* ---------- copy control ---------- */
.copy-btn { width: 32px; height: 32px; flex: none; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-md); background: transparent;
  color: var(--slate-teal); cursor: pointer; transition: background-color 140ms var(--ease), color 140ms; }
.copy-btn:hover { background: var(--dune); color: var(--ink); }
.copy-btn[data-copied] { color: var(--success-text); }
.copy-btn .i { width: 15px; height: 15px; }
.copy-row { display: flex; gap: 10px; align-items: stretch; }
.copy-row input, .copy-row textarea { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 13px; }
.copy-row .btn { flex: none; }

/* ---------- status tags ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--dune); color: var(--ink); }
.tag--ok { background: var(--success-subtle); color: var(--success-text); }
.tag--warn { background: var(--warning-subtle); color: var(--warning-text); }
.tag--info { background: var(--info-subtle); color: var(--info-text); }
.tag--bad { background: var(--destructive-subtle); color: var(--coral-text); }
/* Mono tags (resolutions, action names, PROTECTED) keep their own case: the
   product writes "1440p Vertical" and "Content:Video.Updated", and
   text-transform would mangle both. */
.tag--mono { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  border-radius: var(--r-sm); padding: 3px 7px; letter-spacing: .01em; }
.tag--outline { background: transparent; border: 1px solid var(--control-border); color: var(--slate-teal); }
.tag__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- inline code chip ---------- */
.idchip { font-family: var(--font-mono); font-size: 12.5px; background: var(--dune);
  color: var(--ink); padding: 3px 7px; border-radius: var(--r-sm); }

/* ---------- bar list (timeline / referrers / devices) ---------- */
.barlist { display: grid; gap: 11px; }
.barrow { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 14px; align-items: center; }
.barrow__label { font-family: var(--font-mono); font-size: 13px; color: var(--slate-teal); }
.barrow__track { height: 9px; border-radius: 999px; background: var(--dune); overflow: hidden; }
.barrow__fill { height: 100%; border-radius: 999px; background: var(--deep-teal); }
.barrow__value { font-family: var(--font-mono); font-size: 13.5px; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.keyrow { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--driftwood); font-size: 14.5px; }
.keyrow:last-child { border-bottom: none; }
.keyrow__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- engagement histogram ---------- */
.histo { display: flex; align-items: flex-end; gap: 2px; height: 168px; }
.histo span { flex: 1; background: var(--seafoam); border-radius: 2px 2px 0 0; min-height: 3px; }
.histo span[data-hot] { background: var(--deep-teal); }
.histo-axis { display: flex; justify-content: space-between; margin-top: 8px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--slate-teal); }

/* ---------- activity feed ---------- */
.feed { display: grid; gap: 0; }
.feed li { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--driftwood); align-items: start; }
.feed li:last-child { border-bottom: none; }
.feed__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--seafoam);
  box-shadow: 0 0 0 3px rgba(159,189,188,.26); margin-top: 6px; }
.feed__action { font-weight: 600; font-size: 14px; color: var(--deep-teal); }
.feed__meta { font-size: 13px; color: var(--slate-teal); margin-top: 2px; }
.feed__time { font-family: var(--font-mono); font-size: 11.5px; color: var(--slate-teal); white-space: nowrap; }
.feed-scroll { max-height: 560px; overflow-y: auto; }

/* ---------- ranked rows (top content) ---------- */
.ranked { display: grid; gap: 8px; }
.ranked__row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 14px;
  align-items: center; padding: 12px 14px; border: 1px solid var(--driftwood);
  border-radius: var(--r-lg); background: var(--shell); text-decoration: none; color: inherit;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease); }
.ranked__row:hover { border-color: var(--deep-teal); background: rgba(60,104,118,.04); text-decoration: none; }
.ranked__rank { font-family: var(--font-mono); font-size: 12.5px; color: var(--slate-teal); }
.ranked__name { font-weight: 600; }
.ranked__stats { display: flex; gap: 16px; font-size: 13.5px; color: var(--slate-teal);
  font-family: var(--font-mono); white-space: nowrap; }

/* ---------- swatch + hex pair ---------- */
.hexfield { display: flex; gap: 10px; align-items: center; }
.hexfield__chip { width: 44px; height: 44px; flex: none; border-radius: var(--r-md);
  border: 1px solid var(--control-border); }
.hexfield input { font-family: var(--font-mono); }
.dots { display: flex; gap: 10px; flex-wrap: wrap; }
.dots button { width: 34px; height: 34px; border-radius: 50%; border: none; padding: 0;
  cursor: pointer; box-shadow: 0 0 0 1px var(--control-border);
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease); }
.dots button:hover { transform: scale(1.08); }
.dots button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--shell), 0 0 0 4px var(--deep-teal); }

/* ---------- empty slot ---------- */
.slot { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px;
  border: 1px dashed var(--control-border); border-radius: var(--r-md);
  background: var(--dune); color: var(--slate-teal); font-size: 14px; }
.initials-box { width: 60px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--control-border); border-radius: var(--r-md); background: var(--shell);
  font-family: var(--font-display); font-weight: 700; font-size: 19px; }

/* ---------- prefix field (slug) ---------- */
.prefix { display: flex; align-items: stretch; border: 1px solid var(--control-border);
  border-radius: var(--r-md); background: var(--shell); overflow: hidden; }
.prefix__label { display: flex; align-items: center; padding: 0 12px; background: var(--dune);
  border-right: 1px solid var(--control-border); font-size: 14px; color: var(--slate-teal); white-space: nowrap; }
.prefix input { border: none; background: transparent; min-height: 44px; padding: 10px 12px;
  font: inherit; font-family: var(--font-mono); font-size: 14px; color: var(--ink); flex: 1; min-width: 0; }
.prefix input:focus { outline: none; }
.prefix:focus-within { border-color: var(--deep-teal); box-shadow: 0 0 0 3px rgba(60,104,118,.22); }

/* ---------- usage block ---------- */
.usage { border: 1px solid var(--driftwood); border-radius: var(--r-lg);
  background: rgba(27,47,56,.025); padding: 18px 20px; }
.usage__value { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -.025em; }
.usage__track { height: 9px; border-radius: 999px; background: var(--dune); overflow: hidden; margin-top: 16px; }
.usage__fill { height: 100%; border-radius: 999px; background: var(--seafoam); }

/* ---------- avatar ---------- */
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who__av { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--deep-teal);
  color: #fff; display: grid; place-items: center; font-family: var(--font-display);
  font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.who__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who__mail { font-size: 13px; color: var(--slate-teal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- breadcrumb ---------- */
.crumb { display: flex; align-items: center; gap: 7px; font-size: 14px;
  color: var(--slate-teal); flex-wrap: wrap; margin-bottom: 14px; }
.crumb .i { width: 15px; height: 15px; flex: none; }
.crumb a { color: var(--slate-teal); }
.crumb [aria-current] { color: var(--ink); font-weight: 600; }
.admin-theme .crumb, .admin-theme .crumb a { color: var(--seafoam); }
.admin-theme .crumb [aria-current] { color: var(--sand); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app-split, .app-split--detail { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 960px) {
  /* Sidebar becomes an off-canvas drawer. It is still the same element and the
     same markup order, so with JS off it simply renders above the content. */
  .app { grid-template-columns: minmax(0,1fr); }
  .app-top {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40;
    min-height: var(--app-top); padding: 0 16px; background: var(--ink); color: var(--sand);
    border-bottom: 1px solid rgba(159,189,188,.22);
  }
  .app-top .brand .word { font-size: 20px; }
  .app-top__spacer { flex: 1; }
  .app-burger {
    width: 44px; height: 44px; margin-left: -10px; display: grid; place-items: center;
    background: transparent; border: none; border-radius: var(--r-md); color: var(--sand); cursor: pointer;
  }
  .app-burger:hover { background: rgba(159,189,188,.14); }
  .app-burger .i { width: 22px; height: 22px; }

  .app-side {
    position: fixed; inset: 0 auto 0 0; width: 288px; max-width: 86vw; height: 100vh;
    z-index: 60; transform: translateX(-100%); transition: transform 220ms var(--ease);
    box-shadow: 0 24px 60px rgba(0,0,0,.45);
  }
  .app-side[data-open] { transform: translateX(0); }
  .app-scrim { display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(19,34,41,.6); opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease); }
  .app-scrim[data-open] { opacity: 1; pointer-events: auto; }
  /* The no-JS variant of this lives in each page's <noscript><style>, so the
     stacked fallback needs no class on <html> and cannot flash. */

  .app-wrap { padding: 24px 20px 80px; }
  .page-head h1 { font-size: clamp(26px, 6vw, 32px); }
  .section-title { font-size: 20px; margin-top: 32px; }
}
@media (max-width: 700px) {
  .app-wrap { padding: 20px 16px 72px; }
  .page-head { gap: 14px; margin-bottom: 22px; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1 1 auto; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(144px,1fr)); gap: 12px; }
  .stat { padding: 15px 16px; }
  .stat__value { font-size: 27px; }
  .panel__head { padding: 17px 16px 0; }
  .panel__body { padding: 17px 16px; }
  .panel__foot { padding: 13px 16px; }
  .panel__foot .btn, .segset { width: 100%; }
  .segset .btn { flex: 1; }

  /* Tables reflow to stacked cards. Each cell keeps its column name via
     data-label, so nothing depends on a visible header row. */
  .dtable-wrap { background: transparent; border: none; box-shadow: none; border-radius: 0; }
  .dtable-scroll { overflow: visible; }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; width: 100%; }
  .dtable thead { display: none; }
  .dtable tr {
    background: var(--shell); border: 1px solid var(--driftwood); border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 12px;
  }
  .dtable tr:hover { background: var(--shell); }
  .dtable td { padding: 5px 0; border-bottom: none; display: flex; align-items: center;
    justify-content: space-between; gap: 14px; text-align: left; }
  .dtable td::before {
    content: attr(data-label); font-size: 12.5px; font-weight: 600; color: var(--slate-teal);
    flex: none;
  }
  .dtable td[data-label=""]::before, .dtable td:not([data-label])::before { content: none; }
  /* The primary cell spans the card, so the title is not squeezed against a label. */
  .dtable td[data-primary] { display: block; padding-bottom: 11px; margin-bottom: 7px;
    border-bottom: 1px solid var(--driftwood); }
  .dtable td[data-primary]::before { content: none; }
  .dtable .num { text-align: left; }
  .dtable__foot { background: var(--shell); border: 1px solid var(--driftwood);
    border-radius: var(--r-xl); }
  .row-actions { opacity: 1; }
  .dl { grid-template-columns: minmax(0,1fr) auto; }
  .histo { height: 128px; }
  .vid-stage { padding: 0 !important; }
  .ranked__row { grid-template-columns: auto minmax(0,1fr); }
  .ranked__stats { grid-column: 2; }
  .barrow { grid-template-columns: minmax(0,1fr) auto; }
  .barrow__track { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- authenticated application chrome ---------- */
/* These are the authoritative shell hooks used by both tenant and operator
   routes. Keep their geometry here rather than in component utility classes. */
.app-shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
  background: var(--surface-page);
  color: var(--text);
}
.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 60;
  width: var(--side);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--sand);
  border-right: 1px solid rgba(159,189,188,.22);
}
.app-sidebar__inner { min-height: 100%; display: flex; flex-direction: column; }
.app-sidebar__top { padding: 14px 16px; border-bottom: 1px solid rgba(159,189,188,.18); }
.app-sidebar__foot { padding: 16px; border-top: 1px solid rgba(159,189,188,.18); }
.app-sidebar .app-nav { min-height: 0; }
.app-sidebar .app-nav a.is-active { background: var(--seafoam); color: var(--ink); font-weight: 600; }
.app-sidebar__admin-entry { color: var(--seafoam); }
.app-sidebar__admin-entry:hover { background: var(--canvas); color: var(--sand); }
.panel-wordmark { display: flex; align-items: center; gap: 7px; margin-bottom: 18px; color: var(--seafoam); font-family: var(--font-display); font-size: 14px; font-weight: 600; }
.panel-wordmark__mark { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 5px; background: var(--seafoam); color: var(--ink); font-size: 12px; }
.app-main { min-width: 0; min-height: 100vh; background: var(--surface-page); }
.app-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--app-top);
  padding: 0 24px;
  background: var(--ink);
  color: var(--sand);
  border-bottom: 1px solid rgba(159,189,188,.22);
}
.app-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--sand); text-decoration: none; }
.app-brand:hover { color: var(--sand); text-decoration: none; }
.app-brand img { width: 30px; height: 30px; }
.app-brand .word { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.app-burger { width: 44px; height: 44px; display: grid; place-items: center; background: transparent; border: 0; border-radius: var(--r-md); color: var(--sand); cursor: pointer; }
.app-burger:hover { background: rgba(159,189,188,.14); }
.app-burger .i { width: 22px; height: 22px; }
.app-top__admin { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 1; margin-left: auto; }
.app-admin-search { position: relative; width: min(100%, 384px); }
.app-admin-search input { width: 100%; }
.app-admin-exit { flex: none; }
.app-scrim { display: none; }
.app-wrap { width: min(100%, var(--max)); margin: 0 auto; padding: 28px var(--pad) 96px; }
.app-breadcrumb { margin-bottom: 20px; }

/* ---------- operator console ---------- */
/* The operator surface is intentionally dark, but it still uses the same
   primitives as the tenant workspace.  Keep these aliases scoped here rather
   than teaching individual admin pages about a second palette. */
.admin-theme {
  --surface-page: var(--ink);
  --surface-raised: var(--canvas);
  --surface-sunken: var(--operator-surface-sunken);
  --text: var(--sand);
  --text-muted: var(--seafoam);
  --text-on-ink: var(--sand);
  --divider: var(--operator-divider);
  --shell: var(--canvas);
  --dune: var(--operator-surface-sunken);
  --driftwood: var(--operator-divider);
  --control-border: var(--operator-control-border);
  --deep-teal: var(--lagoon);
  --deep-teal-hover: var(--lagoon-bright);
}
.admin-theme .app-shell { background: var(--ink); color: var(--sand); }
.admin-theme .app-main { background: var(--ink); color: var(--sand); }
.admin-theme .app-wrap { background: var(--ink); }
.admin-theme .app-top { background: var(--ink); color: var(--sand); border-color: var(--divider); }
.admin-theme .app-sidebar { background: var(--ink); color: var(--sand); border-color: var(--divider); }
.admin-theme .app-sidebar__top,
.admin-theme .app-sidebar__foot { border-color: var(--divider); }
.admin-theme .app-sidebar .app-nav__label,
.admin-theme .caption,
.admin-theme .text-muted-foreground { color: var(--seafoam); }
.admin-theme .panel,
.admin-theme .stat,
.admin-theme .dtable-wrap { background: var(--canvas); border-color: var(--divider); }
.admin-theme .panel__head,
.admin-theme .dtable th { background: var(--operator-surface-sunken); border-color: var(--divider); color: var(--sand); }
.admin-theme .panel__foot,
.admin-theme .dtable__foot { background: var(--operator-surface-foot); border-color: var(--divider); }
.admin-theme .text-primary { color: var(--seafoam); }
.admin-theme .border-primary { border-color: var(--seafoam); }
.admin-theme .dtable td,
.admin-theme .dtable tbody tr { border-color: var(--divider); }
.admin-theme .dtable tbody tr:hover { background: var(--operator-surface-sunken); }
.admin-theme .field input,
.admin-theme .field textarea,
.admin-theme .field-select,
.admin-theme input:not([type="checkbox"]):not([type="radio"]),
.admin-theme textarea,
.admin-theme [data-radix-select-trigger] {
  background: var(--canvas);
  border-color: var(--control-border);
  color: var(--sand);
}
.admin-theme .btn--outline {
  --btn-bg: transparent;
  --btn-hover-bg: var(--operator-surface-hover);
  --btn-fg: var(--sand);
  --btn-border: var(--seafoam);
  --btn-hover-border: var(--sand);
}
.admin-theme .btn--ghost {
  --btn-fg: var(--sand);
  --btn-hover-bg: var(--operator-surface-hover);
}
/* Every operator button keeps a measurable foreground/background pair on both
   states. Do not inherit .on-ink gradients here: gradients are hard to audit
   and the darker edge of a hover fill can silently fail text contrast. */
.admin-theme .btn--accent,
.admin-theme .btn:not([class*="btn--"]) {
  --btn-bg: var(--lagoon);
  --btn-hover-bg: var(--lagoon-bright);
  --btn-fg: var(--ink);
  --btn-border: var(--lagoon-deep);
  --btn-hover-border: var(--lagoon-bright);
}
.admin-theme .btn--danger,
.admin-theme .btn--coral {
  --btn-bg: var(--coral-deep);
  --btn-hover-bg: var(--coral-deeper);
  --btn-fg: #fff;
  --btn-border: var(--coral-deep);
  --btn-hover-border: var(--coral-deeper);
}
.admin-theme .btn--seafoam {
  --btn-bg: var(--seafoam);
  --btn-hover-bg: #8FB1B0;
  --btn-fg: var(--ink);
  --btn-border: var(--seafoam);
  --btn-hover-border: #8FB1B0;
}
.admin-theme .btn--text {
  --btn-bg: transparent;
  --btn-hover-bg: transparent;
  --btn-fg: var(--lagoon-bright);
  --btn-border: transparent;
  --btn-hover-border: transparent;
}
.admin-theme .app-admin-search input { background: var(--canvas); border-color: var(--operator-control-border); }
.admin-theme .tag,
.admin-theme .badge { background: var(--operator-surface-hover); color: var(--sand); border-color: var(--divider); }
.admin-theme .tag--ok { background: var(--success-subtle); color: var(--success-text); }
.admin-theme .tag--warn { background: var(--warning-subtle); color: var(--warning-text); }
.admin-theme .tag--bad { background: var(--destructive-subtle); color: var(--destructive-text); }
.admin-theme .callout--bad { background: var(--destructive-subtle); color: var(--destructive-text); }
.admin-theme .admin-capacity-ok { background: var(--seagrass); }
.admin-theme .admin-capacity-warn { background: var(--sunlit); }
.admin-theme .admin-capacity-critical { background: var(--coral); }
.admin-theme .admin-status-ok { color: var(--seafoam); }
.admin-theme .admin-status-warn { color: var(--sunlit); }
.admin-theme .admin-status-critical { color: var(--coral); }
.admin-theme .admin-status-icon { color: var(--seafoam); }
.admin-theme .admin-status-icon--critical { color: var(--coral); }
.admin-theme .spinner { border-color: var(--seafoam); border-inline-end-color: transparent; }
.admin-theme .app-nav a[aria-current="page"],
.admin-theme .app-sidebar .app-nav a.is-active { background: var(--seafoam); color: var(--ink); }
.admin-theme .app-nav a:hover { background: var(--operator-surface-hover); color: var(--sand); }
.impersonation-banner {
  background: var(--warning-subtle); color: var(--warning-text);
  border-bottom: 1px solid color-mix(in srgb, var(--sunlit) 35%, transparent);
}
.impersonation-banner__muted { color: color-mix(in srgb, var(--warning-text) 78%, transparent); }
.impersonation-banner__chip { background: color-mix(in srgb, var(--warning-text) 12%, transparent); }
.impersonation-banner__error { background: color-mix(in srgb, var(--warning-text) 12%, transparent); border-color: color-mix(in srgb, var(--warning-text) 40%, transparent); }
.impersonation-banner .btn--outline {
  --btn-bg: transparent; --btn-hover-bg: var(--warning-text);
  --btn-fg: var(--warning-text); --btn-hover-fg: var(--warning-subtle);
  --btn-border: var(--warning-text); --btn-hover-border: var(--warning-text);
}
.impersonation-banner .btn--outline:hover { color: var(--warning-subtle); }

@media (min-width: 1024px) {
  .app-burger { display: none; }
  /* Tenant desktop chrome is the fixed sidebar; the top bar is the mobile
     header. The operator keeps its desktop search/actions in the same hook. */
  .app-shell--tenant .app-top { display: none; }
}
@media (max-width: 1023px) {
  .app-shell { display: block; }
  .app-top { padding: 0 16px; }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(288px, 86vw);
    max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: 0 24px 60px rgba(0,0,0,.45);
  }
  .app-sidebar[data-open] { transform: translateX(0); }
  .app-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    border: 0;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms var(--ease);
  }
  .app-scrim[data-open] { opacity: 1; pointer-events: auto; }
  .app-wrap { padding: 24px 20px 80px; }
  .app-top__admin { justify-content: flex-end; }
  .app-admin-search, .app-admin-exit { display: none; }
}
@media (max-width: 700px) {
  .app-wrap { padding: 20px 16px 72px; }
  .app-brand .word { font-size: 19px; }
}
