/* ============================================================
   MaintHuB design tokens
   Palette locked to the brand sheet; amber and red are added
   only as status semantics (nothing else uses them).
   ============================================================ */
:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-wash: #eff4ff;
  --teal: #14b8a6;
  --teal-dark: #0b7268;   /* text-weight teal: AA on white and on --teal-wash */
  --teal-wash: #e6faf7;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #fbfcfd;      /* control strips, reply boxes */
  --input-border: #d1d5db;
  --input-border-hover: #9ca3af;
  --on-accent: #ffffff;        /* text on blue/teal fills */
  --pill-closed-bg: #f1f3f5;
  --alert-error-border: #f5c2c7;
  --alert-error-text: #991b1b;
  --alert-info-border: #c7d9fd;
  --focus-ring: rgba(37, 99, 235, 0.16);

  --amber: #b45309;
  --amber-wash: #fef4e6;
  --red: #dc2626;
  --red-wash: #fdeced;

  --display: "Sora", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(31, 41, 55, 0.06);
  --shadow-md: 0 10px 30px -18px rgba(31, 41, 55, 0.45);
  --shadow-lg: 0 24px 60px -34px rgba(31, 41, 55, 0.55);
  --edge: 1px solid var(--line);
}

*,
*::before,
*::after { box-sizing: border-box; }

/* Classes that set `display` would otherwise beat the UA rule for [hidden]. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { width: min(1180px, 100% - 3rem); margin-inline: auto; }
.wrap--narrow { width: min(880px, 100% - 3rem); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- brand lockup ---------------- */
.brand { display: inline-flex; align-items: center; gap: 0.7rem; text-decoration: none; }

/* The mark is two stacked copies of the same file: a desaturated one, and a
   full-colour one clipped to nothing. On load the clip opens upward so colour
   washes into the logo. Two <img> layers rather than an inline SVG so the
   light/dark file swap in theme.js keeps working. */
.brand__mark {
  --mark-size: 40px;
  position: relative;
  width: var(--mark-size);
  height: var(--mark-size);
  flex: 0 0 auto;
}
.brand__mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.brand__mark img:first-child {
  filter: grayscale(1) opacity(0.32);
}
.brand__mark img:last-child {
  clip-path: inset(100% 0 0 0);
  animation: markFill 900ms cubic-bezier(0.22, 0.9, 0.3, 1) 120ms forwards;
}

@keyframes markFill {
  from { clip-path: inset(100% 0 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}
.brand__word {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.035em;
  color: var(--ink);
  white-space: nowrap;
}
.brand__word b { font-weight: 700; color: var(--blue); }
.brand__word i { font-style: normal; color: var(--teal); }


/* ---------------- load splash ----------------
   A full-bleed panel in the theme's own canvas colour with the mark filling at
   dead centre, then it fades away. Three rules keep it from ever trapping the
   page: the fade is a CSS animation with `forwards`, so it completes even if
   JS never runs; it is pointer-events:none once faded; and it is skipped
   outright for repeat navigations and for reduced-motion users. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--canvas);
  animation: splashOut 480ms ease 1150ms forwards;
}
.splash .brand__mark { --mark-size: 88px; }

/* The mark inside the splash gets a slower, more deliberate sweep than the
   header copy, since it is the only thing on screen. */
.splash .brand__mark img:last-child {
  animation-duration: 1050ms;
  animation-delay: 180ms;
}

@keyframes splashOut {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

/* Second and later page loads in the same session skip it — this is a queue
   people work in all day, and replaying a splash on every click would grate. */
html[data-splash="done"] .splash { display: none; }

/* ---------------- header ---------------- */
.masthead {
  background: var(--surface);
  border-bottom: var(--edge);
  position: sticky;
  top: 0;
  z-index: 20;
}
.masthead__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 72px;
}
.nav { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.nav a {
  font-size: 0.9rem; font-weight: 500; color: var(--ink-soft);
  text-decoration: none; padding: 0.5rem 0.8rem; border-radius: var(--r-sm);
}
.nav a:hover { background: var(--canvas); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--blue); background: var(--blue-wash); }

/* ---------------- signature: the ticket stub ----------------
   Two stacked masked layers give the punched notch a dark
   keyline, mirroring the work-order card in the logo mark. */
.stub {
  --notch: 15px;
  background: var(--ink);
  padding: 2px;
  border-radius: var(--r-md);
  -webkit-mask:
    radial-gradient(var(--notch) at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(var(--notch) at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(var(--notch) at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(var(--notch) at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
}
.stub__inner {
  --notch: 13px;
  background: var(--surface);
  border-radius: 10px;
  padding: 1.4rem 1.9rem;
  text-align: center;
  -webkit-mask:
    radial-gradient(var(--notch) at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(var(--notch) at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(var(--notch) at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(var(--notch) at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
}
.stub__label {
  font-family: var(--mono);
  font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.35rem;
}
.stub__code {
  font-family: var(--mono);
  font-size: clamp(1.45rem, 5vw, 2rem);
  font-weight: 600; letter-spacing: 0.04em; color: var(--ink);
}

/* ---------------- cards & panels ---------------- */
.card {
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.card__head {
  padding: 1.4rem 1.6rem;
  border-bottom: var(--edge);
}
.card__body { padding: 1.6rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--blue); margin: 0 0 0.6rem;
}

/* ---------------- home layout ---------------- */
.intake { padding: 2.6rem 0 4rem; }
.intake__grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}
.intake__lede h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); margin-bottom: 0.7rem; }
.intake__lede p { color: var(--ink-soft); margin: 0 0 1.8rem; }

/* lifecycle rail — numbered because the stages really are a sequence */
.rail { list-style: none; margin: 0; padding: 0; }
.rail li {
  position: relative;
  padding: 0 0 1.5rem 2.6rem;
  border-left: 2px solid var(--line);
  margin-left: 0.75rem;
}
.rail li:last-child { border-left-color: transparent; padding-bottom: 0; }
.rail li::before {
  content: attr(data-step);
  position: absolute; left: -0.85rem; top: 0;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--blue);
  color: var(--blue); font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
}
.rail li:last-child::before { border-color: var(--teal); color: var(--teal); }
.rail strong { display: block; font-family: var(--display); font-size: 0.98rem; }
.rail span { font-size: 0.88rem; color: var(--muted); }

/* ---------------- forms ---------------- */
fieldset { border: 0; margin: 0 0 1.9rem; padding: 0; }
fieldset:last-of-type { margin-bottom: 1.2rem; }
legend {
  font-family: var(--display); font-weight: 600; font-size: 1.02rem;
  padding: 0 0 0.9rem; color: var(--ink);
}
.field { margin-bottom: 1.1rem; }
.field:last-child { margin-bottom: 0; }
.field label,
.field > .label {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--ink); margin-bottom: 0.4rem;
}
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }

/* Required fields are marked with an asterisk rather than labelling every
   other field "optional" — less text on every form, and the convention is
   universally understood. The mark is decorative: assistive tech gets the
   `required` attribute on the input itself, so it is hidden from the
   accessibility tree to avoid it being read out twice. */
.req-star {
  color: var(--red);
  font-style: normal;
  font-weight: 700;
  margin-left: .18rem;
}

.form-legend {
  font-size: .8rem;
  color: var(--muted);
  margin: 0 0 1.1rem;
}
.form-legend b { color: var(--red); font-weight: 700; }

input[type="text"], input[type="email"], input[type="tel"],
input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  padding: 0.62rem 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 118px; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--input-border-hover); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--red);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2.1rem;
}
.err { display: block; color: var(--red); font-size: 0.8rem; margin-top: 0.3rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }

/* priority as segmented control */
.segments { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.segments input { position: absolute; opacity: 0; pointer-events: none; }
.segments label {
  display: block; text-align: center; cursor: pointer;
  font-size: 0.85rem; font-weight: 500; margin: 0;
  padding: 0.55rem 0.3rem; border-radius: var(--r-sm);
  border: 1px solid var(--input-border); background: var(--surface); color: var(--ink-soft);
  transition: all 0.15s ease;
}
.segments label:hover { border-color: var(--blue); color: var(--blue); }
.segments input:checked + label {
  background: var(--blue); border-color: var(--blue); color: var(--on-accent);
}
.segments input:focus-visible + label { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--body); font-size: 0.92rem; font-weight: 600;
  padding: 0.68rem 1.25rem; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--blue); color: var(--on-accent); }
.btn--primary:hover:not([disabled]) { background: var(--blue-dark); color: var(--on-accent); }
.btn--teal { background: var(--teal-dark); color: var(--on-accent); }
.btn--teal:hover:not([disabled]) { background: var(--teal-dark); color: var(--on-accent); }
.btn--ghost { background: var(--surface); border-color: var(--input-border); color: var(--ink); }
.btn--ghost:hover:not([disabled]) { border-color: var(--blue); color: var(--blue); }
.btn--sm { padding: 0.42rem 0.8rem; font-size: 0.83rem; }
.btn--block { width: 100%; }

/* ---------------- status + priority pills ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.28rem 0.6rem; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--new { background: var(--blue-wash); color: var(--blue-dark); }
.pill--in_progress { background: var(--teal-wash); color: var(--teal-dark); }
.pill--waiting_on_requester { background: var(--amber-wash); color: var(--amber); }
.pill--resolved { background: var(--teal-wash); color: var(--teal-dark); }
.pill--closed { background: var(--pill-closed-bg); color: var(--muted); }

.prio { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
.prio--urgent { color: var(--red); }
.prio--high { color: var(--amber); }
.prio--normal { color: var(--muted); }
.prio--low { color: var(--muted); opacity: 0.75; }

/* ---------------- alerts ---------------- */
.alert {
  border-radius: var(--r-md); padding: 0.85rem 1rem;
  font-size: 0.9rem; margin-bottom: 1.2rem; border: 1px solid transparent;
}
.alert--error { background: var(--red-wash); border-color: var(--alert-error-border); color: var(--alert-error-text); }
.alert--info { background: var(--blue-wash); border-color: var(--alert-info-border); color: var(--blue-dark); }
.alert:empty { display: none; }

/* ---------------- conversation thread ---------------- */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.msg { border: var(--edge); border-radius: var(--r-md); padding: 0.95rem 1.1rem; background: var(--surface); }
.msg__meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; margin-bottom: 0.4rem; flex-wrap: wrap;
}
.msg__who { font-size: 0.85rem; font-weight: 600; }
.msg__when { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.msg__body { font-size: 0.93rem; color: var(--ink-soft); white-space: pre-wrap; margin: 0; }
.msg--staff { border-left: 3px solid var(--blue); background: var(--surface-alt); }
.msg--staff .msg__who { color: var(--blue-dark); }
.msg--requester { border-left: 3px solid var(--teal); }
.msg--requester .msg__who { color: var(--teal-dark); }
.msg--tech { border-left: 3px solid var(--blue); }
.msg--tech .msg__who { color: var(--blue-dark); }
.msg--internal { border-left: 3px solid var(--amber); background: var(--amber-wash); }
.msg--internal .msg__who { color: var(--amber); }
.msg--system {
  border: 0; background: transparent; padding: 0.15rem 0 0.15rem 0.2rem;
  font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
  display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap;
}

/* The management sections collapse into one menu so the bar stays readable
   as more of them are added. */
.menu-wrap { position: relative; }
.nav__tab--menu .chev { transition: transform .15s ease; opacity: .6; }
/* Also matches :hover, which is defined later in this file and would otherwise
   repaint the label the same colour as the fill. */
.nav__tab--menu[aria-expanded="true"],
.nav__tab--menu[aria-expanded="true"]:hover {
  background: var(--blue); border-color: var(--blue); color: var(--on-accent);
}
.nav__tab--menu[aria-expanded="true"] .chev { transform: rotate(180deg); opacity: 1; }
.nav__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber); display: inline-block; margin-left: .1rem;
}
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 232px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  display: grid; gap: 2px;
}
.menu .nav__tab {
  width: 100%; justify-content: flex-start;
  border: 0; border-radius: 8px; padding: .55rem .7rem;
  font-weight: 500; color: var(--ink);
}
.menu .nav__tab:hover { background: var(--canvas); color: var(--blue); }
.menu .nav__tab[aria-pressed="true"] { background: var(--blue-wash); color: var(--blue-dark); }
.menu .nav__count { margin-left: auto; }

/* Team lives in the masthead, not the filter toolbar — it's a section of the
   app, not a way to filter the queue. */
.nav__tab {
  display: inline-flex; align-items: center; gap: 0.42rem;
  font-family: var(--body); font-size: 0.9rem; font-weight: 600;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0.48rem 0.85rem; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nav__tab:hover { border-color: var(--blue); color: var(--blue); }
.nav__tab[aria-pressed="true"] {
  background: var(--blue); border-color: var(--blue); color: var(--on-accent);
}
.nav__count {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  background: var(--canvas); color: var(--ink-soft);
  border-radius: 999px; padding: 0.05rem 0.4rem; margin-left: 0.1rem;
}
.nav__tab[aria-pressed="true"] .nav__count { background: rgba(255,255,255,.22); color: var(--on-accent); }

.callout {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: var(--blue-wash); border: 1px solid #c7d9fd;
  border-radius: var(--r-md); padding: 0.95rem 1.15rem; margin-bottom: 1.2rem;
}
.callout strong { font-family: var(--display); font-size: .97rem; }
.callout p { margin: .2rem 0 0; font-size: .87rem; color: var(--ink-soft); }

/* ---------------- team board ---------------- */
.avail {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .06em;
  text-transform: uppercase; font-weight: 500;
  padding: .22rem .55rem; border-radius: 999px; white-space: nowrap;
}
.avail::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.avail--available   { background: var(--teal-wash); color: var(--teal-dark); }
.avail--on_job      { background: var(--blue-wash); color: var(--blue-dark); }
.avail--on_break    { background: var(--amber-wash); color: var(--amber); }
.avail--unavailable { background: var(--red-wash); color: var(--red); }
.avail--off_shift   { background: var(--pill-closed-bg); color: var(--muted); }

.board { display: grid; gap: .5rem; }
.board__row {
  display: flex; gap: .9rem; align-items: center; flex-wrap: wrap;
  border: var(--edge); border-left: 3px solid var(--line);
  border-radius: var(--r-md); padding: .7rem .95rem; background: var(--surface);
}
.board__row[data-avail="on_job"]   { border-left-color: var(--blue); }
.board__row[data-avail="available"]{ border-left-color: var(--teal); }
.board__row[data-avail="on_break"] { border-left-color: var(--amber); }
.board__who { flex: 1 1 200px; min-width: 0; }
.board__name { font-family: var(--display); font-weight: 600; font-size: .95rem; }
.board__doing { font-size: .82rem; color: var(--ink-soft); margin-top: .15rem; }
.board__stat { font-family: var(--mono); font-size: .74rem; color: var(--muted); white-space: nowrap; }
.board__stat b { color: var(--ink); font-weight: 600; }
.board__stat--urgent b { color: var(--red); }

/* ---------------- team directory ---------------- */
.team-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1fr auto;
  gap: 0.8rem;
  align-items: end;
}

.roster { display: grid; gap: 0.5rem; }
.roster__row {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  border: var(--edge); border-radius: var(--r-md);
  padding: 0.7rem 0.95rem; background: var(--surface);
}
.roster__row[data-active="false"] { background: var(--surface-alt); }
.roster__row[data-active="false"] .roster__name { color: var(--muted); }
.roster__id { flex: 1 1 220px; min-width: 0; }
.roster__name { font-family: var(--display); font-weight: 600; font-size: .95rem; }
.roster__mail {
  font-family: var(--mono); font-size: .76rem; color: var(--muted);
  overflow-wrap: anywhere;
}
.roster__note { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.roster__trade {
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--teal-dark); background: var(--teal-wash);
  padding: .2rem .55rem; border-radius: 999px; white-space: nowrap;
}
.roster__jobs { font-family: var(--mono); font-size: .76rem; color: var(--muted); white-space: nowrap; }

/* ---------------- admin shell ---------------- */
.console { padding: 1.6rem 0 3rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.stat {
  background: var(--surface); border: var(--edge); border-radius: var(--r-md);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.stat__n { font-family: var(--mono); font-size: 1.85rem; font-weight: 600; line-height: 1.1; }
.stat__label {
  font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-top: 0.2rem;
}
.stat--urgent .stat__n { color: var(--red); }
.stat--aging .stat__n { color: var(--amber); }
.stat--speed .stat__n { color: var(--teal-dark); }

.toolbar {
  display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: var(--edge); border-radius: var(--r-md);
  padding: 0.7rem 0.85rem; margin-bottom: 1.2rem; box-shadow: var(--shadow-sm);
}
.toolbar input[type="search"] { flex: 1 1 240px; }
.toolbar select { flex: 0 0 170px; }

.console__grid {
  display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 1.2rem; align-items: start;
}

.queue { display: grid; gap: 0.6rem; max-height: 74vh; overflow-y: auto; padding-right: 0.2rem; }
.qcard {
  width: 100%; text-align: left; cursor: pointer; font: inherit;
  background: var(--surface); border: var(--edge); border-left: 3px solid var(--line);
  border-radius: var(--r-md); padding: 0.85rem 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.qcard:hover { border-color: var(--input-border-hover); border-left-color: var(--blue); box-shadow: var(--shadow-sm); }
.qcard[aria-selected="true"] {
  border-color: var(--blue); border-left-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}
.qcard__top { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; margin-bottom: 0.35rem; }
.qcard__ref { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.qcard__title { font-family: var(--display); font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.qcard__meta { font-size: 0.79rem; color: var(--muted); display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; }

/* Keeps the sticky masthead from covering the top of the pane when
   the queue scrolls a selection into view on stacked layouts. */
#detail { scroll-margin-top: 88px; }
.detail__head { padding: 1.3rem 1.6rem; border-bottom: var(--edge); }
.detail__title { font-size: 1.25rem; margin-bottom: 0.4rem; }
.controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; padding: 1.1rem 1.6rem; border-bottom: var(--edge); background: var(--surface-alt); }
.controls label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 0.3rem; font-weight: 600; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem 1.4rem; padding: 1.2rem 1.6rem; border-bottom: var(--edge); }
.fact dt { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.15rem; }
.fact dd { margin: 0; font-size: 0.9rem; }

.reply { padding: 1.2rem 1.6rem; border-top: var(--edge); background: var(--surface-alt); }
.reply__actions { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-top: 0.7rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.86rem; color: var(--ink-soft); cursor: pointer; }
.check input { width: auto; }

.empty { padding: 3.5rem 1.5rem; text-align: center; color: var(--muted); }
.empty h3 { font-size: 1.05rem; color: var(--ink); margin-bottom: 0.35rem; }

/* ---------------- sign-in ---------------- */
.signin { min-height: calc(100vh - 72px); display: grid; place-items: center; padding: 2rem 1rem; }
.signin .card { width: min(420px, 100%); }

/* ---------------- footer ---------------- */
.foot {
  border-top: var(--edge); background: var(--surface);
  padding: 1.4rem 0; font-size: 0.83rem; color: var(--muted);
}
.foot__inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------------- responsive ---------------- */
@media (max-width: 960px) {
  .intake__grid, .console__grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .queue { max-height: none; }
  .team-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .wrap, .wrap--narrow { width: calc(100% - 2rem); }
  .row, .controls { grid-template-columns: 1fr; }
  .segments { grid-template-columns: repeat(2, 1fr); }
  .team-form { grid-template-columns: 1fr; }
  /* The nav wraps to a second row here; a sticky header would eat a
     quarter of a phone screen, so let it scroll away instead. */
  .masthead { position: static; }
  .masthead__inner { min-height: 64px; padding: 0.6rem 0; flex-wrap: wrap; }
  .nav a { padding: 0.4rem 0.55rem; }
  #detail { scroll-margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  /* Land on the finished state rather than flashing a grey logo. */
  .brand__mark img:last-child { clip-path: inset(0 0 0 0); animation: none; }
  /* No splash at all — an overlay that depends on animation to leave is the
     last thing someone with motion sensitivity should be handed. */
  .splash { display: none; }
}

/* ============================================================
   Dark theme
   The brand blue and teal are kept, but lightened: #2563EB on a
   dark surface fails contrast for text, so text-weight uses of the
   accents move up a step while filled buttons keep their weight.
   ============================================================ */
:root { color-scheme: light; }

[data-theme="dark"] {
  color-scheme: dark;

  --blue: #4f92f8;
  --blue-dark: #7cb0fb;
  --blue-wash: #17233d;
  --teal: #2dd4bf;
  --teal-dark: #5eead4;
  --teal-wash: #0f2e2b;

  --ink: #e8ecf2;
  --ink-soft: #b3bccb;
  --muted: #8b95a5;
  --line: #2a3446;
  --canvas: #0e131c;
  --surface: #161d29;
  --surface-alt: #1b2432;
  --input-border: #384357;
  --input-border-hover: #55627a;
  --on-accent: #0b1017;

  --amber: #fbbf24;
  --amber-wash: #33270d;
  --red: #f87171;
  --red-wash: #3a1a1c;

  --pill-closed-bg: #232c3b;
  --alert-error-border: #6b2a2f;
  --alert-error-text: #fca5a5;
  --alert-info-border: #2b3f66;
  --focus-ring: rgba(96, 165, 250, 0.28);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px -18px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 24px 60px -34px rgba(0, 0, 0, 0.9);
}

/* The select chevron is a baked-in SVG, so it needs its own dark version. */
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b95a5' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
}

/* Filled accent buttons keep white text — inverting to near-black there
   reads as a disabled state rather than a primary action. */
[data-theme="dark"] .btn--teal:hover:not([disabled]) { background: #8df3e0; }
[data-theme="dark"] .btn--primary,
[data-theme="dark"] .btn--teal,
[data-theme="dark"] .nav__tab[aria-pressed="true"],
[data-theme="dark"] .segments input:checked + label { color: #0b1017; }

/* The app icon is a light-background mark; on a dark surface its dark
   building blocks would disappear, so the dark variant is swapped in. */

/* ---------------- theme toggle ---------------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  background: var(--surface); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  cursor: pointer; transition: color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { color: var(--blue); border-color: var(--blue); }
.theme-toggle svg { display: block; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
