/* ============================================================
   Entirely Helpdesk — app styles
   ------------------------------------------------------------
   Every value here comes from the Entirely design system tokens
   (web/tokens/*.css) or from the v1 design handoff. Flat fills,
   1px hairlines, capsule CTAs, no gradients, no shadows.
   ============================================================ */

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-black);
  background: var(--color-sand);
  transition: background var(--dur-base) var(--ease-standard);
}
body.ground-white { background: var(--color-white); }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
a { color: var(--color-moss); text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------ screen shell */
.screen {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 62px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.screen.tight { gap: 20px; padding-left: 18px; padding-right: 18px; }

/* ------------------------------------------------------------ type roles */
.eyebrow {
  font-size: 11px; font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-cta); text-transform: uppercase;
  color: var(--color-slate);
}
.eyebrow.muted { color: var(--color-cement); }
.screen-title {
  font-family: var(--font-display); font-weight: var(--weight-light);
  font-size: 34px; line-height: var(--lh-display); margin-top: 6px;
  text-wrap: balance;
}
.screen-title.md { font-size: 32px; }
.screen-title.sm { font-size: 30px; }
.meta-line { font-size: 13px; color: var(--color-slate); }

/* ------------------------------------------------------------ header */
.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.avatar {
  border-radius: var(--radius-capsule);
  background: var(--color-black); color: var(--color-white);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--weight-semibold); flex-shrink: 0;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.dot { width: 22px; height: 22px; font-size: 0; }
.avatar.hue-teal   { background: var(--color-aqua);   color: var(--color-black); }
.avatar.hue-moss   { background: var(--color-sage);   color: var(--color-black); }
.avatar.hue-azalea { background: var(--color-petal);  color: var(--color-black); }
.avatar.hue-orange { background: var(--color-cream);  color: var(--color-black); }

/* ------------------------------------------------------------ top bar (sub-screens) */
.top-bar { display: flex; align-items: center; justify-content: space-between; font-size: 14px; min-height: 44px; }
.top-bar .back { color: var(--color-slate); padding: 10px 10px 10px 0; }
.top-bar .step {
  font-size: 12px; font-weight: var(--weight-semibold);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-cement);
}
.top-bar .bar-action { font-size: 13px; color: var(--color-moss); font-weight: var(--weight-medium); padding: 10px 0; }

/* ------------------------------------------------------------ CTA block (home) */
.cta-block {
  background: var(--color-neon); border-radius: 16px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px; align-items: flex-start;
}
.cta-block .headline { font-family: var(--font-display); font-size: 24px; font-weight: var(--weight-medium); line-height: var(--lh-tight); }
.cta-block .sub { font-size: 14px; line-height: 1.45; color: var(--color-slate); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 13px 22px;
  border-radius: var(--radius-capsule);
  font-size: 13px; font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-cta); text-transform: uppercase;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--color-black); color: var(--color-white); }
.btn.accent  { background: var(--color-neon);  color: var(--color-black); }
.btn.outline { border: 1px solid var(--color-black); background: transparent; }
.btn.ghost   { border: 1px solid rgba(0,0,0,0.2); color: var(--color-slate); background: transparent; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ------------------------------------------------------------ section label rows */
.label-row { display: flex; align-items: baseline; justify-content: space-between; }
.label-row .eyebrow { letter-spacing: 0.06em; font-size: 13px; color: var(--color-black); }
.label-row .link { font-size: 13px; color: var(--color-slate); text-decoration: none; padding: 6px 0; }

/* ------------------------------------------------------------ ticket cards */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.ticket-card {
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px; width: 100%;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.ticket-card:active { transform: scale(0.97); }
.ticket-card .meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ticket-card .ref { font-size: 12px; font-weight: var(--weight-semibold); letter-spacing: 0.06em; color: var(--color-cement); }
.ticket-card .subject { font-size: 17px; font-weight: var(--weight-medium); line-height: 1.3; }
.ticket-card .activity { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--color-slate); }

/* compact rows ("Then", lists) */
.row-card {
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 14px; padding: 14px; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.row-card .subject { font-size: 15px; font-weight: var(--weight-medium); line-height: 1.3; }
.row-card .age { font-size: 12px; color: var(--color-slate); white-space: nowrap; }

/* ------------------------------------------------------------ status badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 6px 10px; border-radius: var(--radius-capsule);
  font-size: 11px; font-weight: var(--weight-semibold);
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.badge.st-open        { background: var(--color-sand);  color: var(--color-slate); }
.badge.st-in_progress { background: var(--color-aqua);  color: var(--color-teal); }
.badge.st-waiting     { background: var(--color-cream); color: var(--color-bark); }
.badge.st-resolved    { background: var(--color-sage);  color: var(--color-moss); }
.badge.st-closed      { background: var(--color-sand);  color: var(--color-cement); }
.badge.priority       { background: var(--color-white); color: var(--color-slate); border: 1px solid var(--border-subtle); }
.badge.pr-high, .badge.pr-urgent { background: var(--color-cream); color: var(--color-bark); border: 0; }
.badge.neutral        { background: var(--color-sand); color: var(--color-slate); }

/* on white grounds the neutral badges need the hairline to hold */
body.ground-white .badge.st-open, body.ground-white .badge.st-closed, body.ground-white .badge.neutral { border: 1px solid var(--border-subtle); }

/* ------------------------------------------------------------ category tiles */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cat-tile {
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 16px; padding: 18px; min-height: 148px;
  display: flex; flex-direction: column; align-items: flex-start;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.cat-tile:active { transform: scale(0.97); }
.cat-tile .label { font-size: 16px; font-weight: var(--weight-medium); line-height: 1.25; margin-top: auto; }
/* Category icons: Lucide outlines inlined by app.js, drawn in the category
   hue with the brand's stroke treatment (rounded cap & corner). */
.cat-icon { width: 40px; height: 40px; display: inline-flex; color: var(--color-cement); }
.cat-icon svg { width: 100%; height: 100%; }
.hue-teal   .cat-icon, .cat-icon.hue-teal   { color: var(--color-teal); }
.hue-moss   .cat-icon, .cat-icon.hue-moss   { color: var(--color-moss); }
.hue-azalea .cat-icon, .cat-icon.hue-azalea { color: var(--color-azalea); }
.hue-orange .cat-icon, .cat-icon.hue-orange { color: var(--color-orange); }

.capsule-tag {
  display: inline-flex; padding: 9px 14px; border-radius: var(--radius-capsule);
  background: var(--color-white); border: 1px solid rgba(0,0,0,0.16); font-size: 13px;
}
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ dark info card */
.dark-card {
  background: var(--color-black); color: var(--color-white);
  border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.dark-card .eyebrow { color: var(--color-neon); font-size: 12px; }
.dark-card .body { font-size: 15px; line-height: 1.45; color: rgba(255,255,255,0.82); }

/* ------------------------------------------------------------ form */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; font-weight: var(--weight-medium); color: var(--color-slate); }
.field input, .field textarea {
  font: inherit; color: var(--color-black);
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 14px; font-size: 15px; line-height: 1.5;
  width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--color-cement); }
.field .error { font-size: 12px; color: var(--color-rowan); }

.attach-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--color-white); border: 1px dashed rgba(0,0,0,0.3);
  border-radius: 12px; padding: 14px; width: 100%;
}
.attach-row .ring { width: 22px; height: 22px; border-radius: var(--radius-capsule); border: 5px solid var(--color-black); flex-shrink: 0; }
.attach-row .txt { font-size: 14px; line-height: 1.4; }
.attach-row .txt .sub { font-size: 12px; color: var(--color-slate); }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; padding: 6px 12px; border-radius: var(--radius-capsule);
  background: var(--color-white); border: 1px solid var(--border-subtle);
}

/* auto-attached profile panel */
.profile-panel {
  background: var(--color-heather); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.profile-panel .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; font-size: 14px; }
.profile-panel .grid .k { color: var(--color-slate); font-size: 12px; }
.profile-panel .grid .v { font-weight: var(--weight-medium); }
.profile-panel .foot { font-size: 12px; color: var(--color-slate); line-height: 1.4; }

/* ------------------------------------------------------------ view band
   Which hat you are wearing, stated rather than implied. Only rendered for
   people who have more than one view; a requester never sees it. Each view
   gets its own fill so the difference reads before any text does. */
.view-band {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  border-radius: var(--radius-capsule);
  padding: 8px 10px 8px 16px;
  margin-bottom: 4px;
}
.view-band .vb-what {
  font-size: 12px; font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-cta); text-transform: uppercase;
}
.view-band .vb-switch {
  display: flex; gap: 4px; padding: 3px;
  background: rgba(255, 255, 255, 0.55); border-radius: var(--radius-capsule);
}
.view-band .vb-opt {
  font-size: 12px; font-weight: var(--weight-medium);
  padding: 7px 14px; min-height: 34px; border-radius: var(--radius-capsule);
  color: var(--color-slate); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard);
}
.view-band .vb-opt.active {
  background: var(--color-black); color: var(--color-white);
  font-weight: var(--weight-semibold);
}
/* user: quiet. It is the default, so it announces the switch, not itself. */
.view-band.vb-user   { background: var(--color-heather); }
.view-band.vb-user .vb-what { color: var(--color-slate); }
/* agent: Marmind aqua - you are looking at other people's tickets. */
.view-band.vb-agent  { background: var(--color-aqua); }
.view-band.vb-agent .vb-what { color: var(--color-teal); }
.view-band.vb-agent .vb-opt.active { background: var(--color-teal); }
/* admin: moss - you are changing configuration. */
.view-band.vb-admin  { background: var(--color-moss); }
.view-band.vb-admin .vb-what { color: var(--color-neon); }
.view-band.vb-admin .vb-switch { background: rgba(255, 255, 255, 0.16); }
.view-band.vb-admin .vb-opt { color: rgba(255, 255, 255, 0.82); }
.view-band.vb-admin .vb-opt.active { background: var(--color-neon); color: var(--color-black); }

.capsule-tag.on { border-color: var(--color-black); font-weight: var(--weight-semibold); }

/* ------------------------------------------------------------ filters
   Status and type are chip rows that scroll sideways rather than wrapping
   into four lines on a phone; the free-text box takes subject, number or
   submitter. Each row scrolls in its own container, never the page. */
.filters { display: flex; flex-direction: column; gap: 10px; }
.chip-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .capsule-tag { flex: 0 0 auto; }
.filters input[type="search"] {
  font: inherit; width: 100%; font-size: 15px;
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 12px 14px; color: var(--color-black);
  -webkit-appearance: none; appearance: none;
}
.filters input[type="search"]::placeholder { color: var(--color-cement); }

/* ------------------------------------------------------------ assistant
   AI output is always labelled and always cites what it drew on. It is a
   suggestion the reader checks, not an answer they are handed. */
.ai-tag {
  font-size: 10px; font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-cta); text-transform: uppercase;
  padding: 4px 9px; border-radius: var(--radius-capsule);
  background: var(--color-moss); color: var(--color-neon); white-space: nowrap;
}
.kb-answer {
  background: var(--color-sage); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.kb-answer.none { background: var(--color-heather); }
.kb-answer .body { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.kb-answer .foot { font-size: 12px; color: var(--color-slate); line-height: 1.4; }
/* Proposed articles: each one is a thing to read and edit before it becomes
   handbook, so it gets a card rather than a row. */
.gap-list { display: flex; flex-direction: column; gap: 14px; }
.gap-card {
  background: var(--color-sage); border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.gap-card .hint { font-size: 13px; color: var(--color-slate); line-height: 1.45; }
.gap-card input[type="text"], .gap-card textarea {
  font: inherit; width: 100%; font-size: 14px; line-height: 1.5;
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 12px; color: var(--color-black); resize: vertical;
}
.gap-card .field label { font-size: 12px; }

.draft-note:empty { display: none; }
.draft-note {
  font-size: 12px; color: var(--color-slate); line-height: 1.4;
  background: var(--color-cream); border-radius: 10px; padding: 8px 12px;
}
.panel > header .ai-tag { align-self: center; }
.panel textarea {
  font: inherit; font-size: 14px; line-height: 1.5; padding: 14px;
  border: 1px solid var(--border-subtle); border-radius: 12px;
  background: var(--color-white); color: var(--color-black); resize: vertical;
}

.footer-note { font-size: 13px; color: var(--color-slate); text-align: center; line-height: 1.4; }
.push-down { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }

/* ------------------------------------------------------------ triage stack */
.triage-stack { position: relative; padding-bottom: 14px; }
.triage-stack .peek {
  position: absolute; left: 14px; right: 14px; top: 14px; bottom: 0;
  background: var(--color-white); border: 1px solid var(--border-subtle); border-radius: 18px;
}
.triage-card {
  position: relative;
  background: var(--color-white); border: 1px solid var(--color-black);
  border-radius: 18px; padding: 22px;
  display: flex; flex-direction: column; gap: 16px;
}
@media (prefers-reduced-motion: no-preference) {
  .triage-card.leaving {
    transition: transform var(--dur-base) var(--ease-standard), opacity var(--dur-base) var(--ease-standard);
    transform: translateX(60px) rotate(2deg); opacity: 0;
  }
}
.triage-card .meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.triage-card .ref { font-size: 11px; font-weight: var(--weight-semibold); letter-spacing: 0.06em; color: var(--color-cement); }
.triage-card .age { font-size: 12px; font-weight: var(--weight-semibold); color: var(--color-slate); }
.triage-card .subject { font-family: var(--font-display); font-weight: var(--weight-regular); font-size: 24px; line-height: var(--lh-heading); }
.triage-card .quote { font-size: 14px; line-height: 1.5; color: var(--color-slate); }
.triage-card .requester { display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border-subtle); font-size: 13px; color: var(--color-slate); line-height: 1.4; }

/* ------------------------------------------------------------ ticket detail */
.detail-head .ref { font-size: 11px; font-weight: var(--weight-semibold); letter-spacing: 0.06em; color: var(--color-cement); }
.detail-head .subject { font-family: var(--font-display); font-weight: var(--weight-light); font-size: 28px; line-height: 1.18; margin-top: 6px; text-wrap: balance; }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }

.requester-panel { background: var(--color-sand); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.requester-panel .who { display: flex; align-items: center; gap: 12px; }
.requester-panel .who .name { font-size: 15px; font-weight: var(--weight-medium); }
.requester-panel .who .sub { font-size: 12px; color: var(--color-slate); }
.requester-panel .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.requester-panel .chip {
  font-size: 11px; font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 9px; border-radius: var(--radius-capsule);
  background: var(--color-white); border: 1px solid var(--border-subtle);
}
.requester-panel .foot { font-size: 12px; color: var(--color-slate); }

.thread { display: flex; flex-direction: column; gap: 12px; }
.bubble { border-radius: 14px; padding: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.bubble .who { font-size: 12px; font-weight: var(--weight-semibold); color: var(--color-slate); margin-bottom: 6px; }
.bubble.requester { background: var(--color-heather); }
.bubble.agent { background: var(--color-sand); }
.bubble.internal { background: var(--color-cream); }
.bubble.internal .who {
  letter-spacing: var(--tracking-cta); text-transform: uppercase;
  color: var(--color-bark); font-size: 11px;
}
.thread .system { font-size: 12px; color: var(--color-cement); text-align: center; }

/* composer */
.composer { display: flex; flex-direction: column; gap: 12px; }
.composer .segs { display: flex; gap: 6px; background: var(--color-sand); border-radius: var(--radius-capsule); padding: 4px; }
.composer .segs .seg { flex: 1; text-align: center; padding: 9px; border-radius: var(--radius-capsule); font-size: 13px; color: var(--color-slate); min-height: 38px; }
.composer .segs .seg.active { background: var(--color-black); color: var(--color-white); font-weight: var(--weight-semibold); }
.composer.internal-mode .segs { background: var(--color-cream); }
.composer.internal-mode .segs .seg.active { background: var(--color-bark); }
.composer textarea {
  font: inherit; width: 100%;
  border: 1px solid rgba(0,0,0,0.2); border-radius: 12px; padding: 14px;
  font-size: 15px; line-height: 1.45; min-height: 52px; resize: vertical;
  background: var(--color-white); color: var(--color-black);
}
.composer textarea::placeholder { color: var(--color-cement); }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-actions .qa {
  font-size: 12px; padding: 8px 12px; min-height: 36px;
  border-radius: var(--radius-capsule); border: 1px solid rgba(0,0,0,0.2);
}

/* ------------------------------------------------------------ insights */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-tile { background: var(--color-sand); border-radius: 16px; padding: 18px; }
.stat-tile.hero { background: var(--color-neon); }
.stat-tile .value { font-family: var(--font-display); font-size: 44px; font-weight: var(--weight-regular); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-tile .label { font-size: 13px; margin-top: 6px; line-height: 1.35; }

.cat-bars { display: flex; flex-direction: column; gap: 12px; }
.cat-bar .head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.cat-bar .head .n { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.cat-bar .track { height: 10px; background: var(--color-sand); border-radius: var(--radius-capsule); }
.cat-bar .fill { height: 100%; border-radius: var(--radius-capsule); background: var(--color-cement); }
.cat-bar .fill.hue-teal { background: var(--color-teal); }
.cat-bar .fill.hue-moss { background: var(--color-moss); }
.cat-bar .fill.hue-azalea { background: var(--color-azalea); }
.cat-bar .fill.hue-orange { background: var(--color-orange); }

/* ------------------------------------------------------------ tab bar */
.tab-bar {
  margin-top: auto; display: flex; gap: 10px;
  border-top: 1px solid var(--border-subtle); padding: 16px 8px 0;
}
.tab-bar .tab { flex: 1; text-align: center; font-size: 12px; color: var(--color-cement); padding: 6px 0; min-height: 36px; }
.tab-bar .tab.active { color: var(--color-black); font-weight: var(--weight-semibold); letter-spacing: 0.04em; }

/* ============================================================
   Desktop (>= 900px)
   ------------------------------------------------------------
   The screens above are mobile-first, which is right for raising a
   ticket on a phone. At a desk the same markup gets a real desktop
   layout rather than a 480px column stranded in the middle of a
   monitor: the tab bar becomes a top nav, lists go multi-column, and
   the two agent screens split in two. Structure is unchanged - this
   is all layout, so there is one code path, not two.
   ============================================================ */
@media (min-width: 900px) {
  .screen, .screen.tight {
    max-width: 1080px;
    padding: 28px 40px 48px;
    gap: 28px;
  }

  /* The bottom tab bar becomes a top nav. It is the last child in the
     DOM (correct for a thumb), so it is hoisted with order. */
  .view-band { order: -2; }
  .tab-bar {
    order: -1; margin-top: 0;
    border-top: 0; border-bottom: 1px solid var(--border-subtle);
    padding: 0 0 14px; gap: 28px; justify-content: flex-start;
  }
  .tab-bar .tab { flex: 0 0 auto; font-size: 14px; text-align: left; }
  .tab-bar .tab.active { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }

  /* Headline block and hero CTA sit side by side. */
  .screen-title { font-size: 44px; }
  .screen-title.sm, .screen-title.md { font-size: 36px; }
  .cta-block { flex-direction: row; align-items: center; gap: 24px; padding: 26px 28px; }
  .cta-block .headline { font-size: 26px; flex: 0 0 auto; }
  .cta-block .sub { flex: 1; }

  /* Ticket lists read as a grid; the eye scans a wide screen in columns. */
  .card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }

  /* Triage: the decision on the left, the queue behind it on the right. */
  .triage-body {
    display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 1fr);
    gap: 28px; align-items: start;
  }
  .triage-body .triage-stack { grid-column: 1; }
  .triage-body .triage-actions { grid-column: 1; }
  .triage-body .triage-then { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }

  /* Ticket detail: conversation left, composer beside it rather than below. */
  .detail-body {
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
    gap: 28px; align-items: start;
  }
  .detail-side { position: sticky; top: 28px; }
  .bubble { max-width: 62ch; }

  /* Category picker's footer card should not stretch the full width. */
  .dark-card { max-width: 62ch; }
  .push-down { margin-top: 32px; }
}

/* Wide phones and tablets: two columns of tiles is already right, but the
   4-up desktop grid would be cramped. */
@media (min-width: 620px) and (max-width: 899px) {
  .screen, .screen.tight { max-width: 640px; padding-left: 28px; padding-right: 28px; }
  .card-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ------------------------------------------------------------ admin (desktop-first)
   The staff-facing screens are mobile-first by design; administration is
   desktop-first on purpose - it is table work (queues x categories x agents)
   done at a desk, and squeezing it into 402px would make it worse. It stays
   usable narrow, but the layout is built for width. */
.admin {
  max-width: 1100px; margin: 0 auto;
  padding: 40px 32px 64px;
  display: flex; flex-direction: column; gap: 28px;
}
.admin > .view-band { margin-bottom: 4px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.admin-head .screen-title { font-size: 40px; margin-top: 4px; }
.admin-cols { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
/* minmax(0, 1fr), not 1fr: a bare 1fr track cannot shrink below its content's
   min-content width, so one wide child (the agent form's inputs) inflated the
   column past the viewport and the whole page scrolled sideways. The tables
   inside scroll on their own. */
@media (max-width: 720px) {
  .admin-cols { grid-template-columns: minmax(0, 1fr); }
  .admin { padding: 32px 18px 48px; }
}
.admin-cols > * { min-width: 0; }
.admin { width: 100%; }
.inline-form .grow { min-width: 0; }

.admin-rail { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 24px; }
.admin-rail .q {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 12px 14px; font-size: 14px; width: 100%;
}
.admin-rail .q.active { border-color: var(--color-black); font-weight: var(--weight-semibold); }
.admin-rail .q .n { font-size: 12px; color: var(--color-cement); font-variant-numeric: tabular-nums; }
.admin-rail .q .lock { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-bark); }

.panel {
  background: var(--color-white); border: 1px solid var(--border-subtle);
  border-radius: 16px; padding: 22px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.panel h2 {
  font-family: var(--font-display); font-weight: var(--weight-medium);
  font-size: 22px; margin: 0;
}
.panel .hint { font-size: 13px; color: var(--color-slate); line-height: 1.5; max-width: 62ch; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left; font-size: 11px; font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-cta); text-transform: uppercase; color: var(--color-slate);
  padding: 0 14px 8px 0; border-bottom: 1px solid var(--color-black); white-space: nowrap;
}
.admin-table td { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.admin-table td:last-child, .admin-table th:last-child { padding-right: 0; text-align: right; }
.admin-table .muted { color: var(--color-slate); font-size: 13px; }
.admin-table tr.gone td { opacity: 0.45; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { gap: 6px; }
.inline-form .field label { font-size: 12px; }
.inline-form input, .inline-form select {
  font: inherit; font-size: 14px; padding: 10px 12px; min-height: 42px;
  border: 1px solid var(--border-subtle); border-radius: 10px;
  background: var(--color-white); color: var(--color-black);
}
.inline-form .grow { flex: 1; min-width: 180px; }
.btn.sm { min-height: 42px; padding: 10px 18px; font-size: 12px; }

/* ------------------------------------------------------------ states */
.skeleton { border-radius: 16px; background: var(--color-sand); min-height: 84px; }
body.ground-white .skeleton { background: var(--color-sand); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: pulse 1.2s var(--ease-standard) infinite alternate; }
  @keyframes pulse { from { opacity: 1; } to { opacity: 0.55; } }
}

.banner {
  background: var(--color-sand); color: var(--color-black);
  border: 1px solid var(--border-subtle); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; line-height: 1.4;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
body.ground-white .banner { background: var(--color-sand); }
.banner .retry {
  font-size: 12px; font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 8px 14px; border-radius: var(--radius-capsule); border: 1px solid var(--color-black);
  white-space: nowrap;
}

.empty-line { font-size: 14px; color: var(--color-slate); }

/* gate: the full-screen reason when sign-in cannot proceed. Never a redirect. */
#gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--color-sand);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#gate[hidden] { display: none; }
#gate .inner { max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
#gate h1 { font-family: var(--font-display); font-weight: var(--weight-light); font-size: 30px; line-height: 1.15; margin: 0; }
#gate p { font-size: 15px; line-height: 1.5; color: var(--color-slate); margin: 0; }
