/*
 * Portal DataCorpore — editorial operations console.
 *
 * Warm porcelain paper, aubergine ink and a berry/magenta brand. Both themes
 * share one token contract; [data-theme="dark"] only swaps values. theme.js
 * applies the stored preference before the first paint. No external fonts or
 * imagery, no inline styles. Server-rendered and printable.
 */

:root {
  color-scheme: light;

  /* Surfaces */
  --canvas: #f6f1f2;
  --surface: #fffcfc;
  --surface-2: #faf5f6;
  --surface-3: #f3eaee;
  --line: #e5d9df;
  --line-strong: #d4c3cb;
  --field-line: #a38795;
  --field-line-strong: #8f7382;

  /* Ink */
  --ink: #201820;
  --ink-soft: #433640;
  --muted: #6b5d66;
  --muted-2: #7a6b75;

  /* Aubergine shell */
  --sidebar: #171219;
  --sidebar-raised: #211923;
  --sidebar-ink: #f6edf3;
  --sidebar-nav: #cfc2ca;
  --sidebar-muted: #b9a6b2;
  --sidebar-line: rgba(255, 255, 255, .09);
  --sidebar-hover: rgba(255, 255, 255, .055);
  --sidebar-icon: #b49fab;
  --sidebar-icon-active: #f0a0c8;
  --sidebar-active-bg: rgba(210, 59, 144, .13);
  --sidebar-active-ink: #fff7fa;
  --sidebar-avatar-bg: #3a1b2c;
  --sidebar-avatar-ink: #f3b6d4;
  --sidebar-border: #0e0a10;

  /* Brand + links. --brand is the action surface; --brand-text is the
     readable accent on paper (brighter in dark, where the button stays deep). */
  --brand: #a31366;
  --brand-hover: #7c0c4c;
  --brand-ink: #fffcfc;
  --brand-text: #a31366;
  --brand-text-strong: #7c0c4c;
  --brand-bright: #d23b90;
  --brand-on-ink: #ef7fba;
  --brand-soft: #fae7f1;
  --brand-line: #f2cfe1;

  /* Semantics */
  --attention: #a4580a;
  --attention-soft: #fdf1e1;
  --attention-line: #ecd6b6;
  --danger: #b3261e;
  --danger-solid: #b3261e;
  --danger-solid-hover: #8f1d17;
  --danger-soft: #fbecea;
  --danger-line: #efd1cd;
  --success: #1e6b46;
  --success-soft: #e8f2ec;
  --success-line: #c8e0d3;
  --blue: #2d5f87;
  --blue-soft: #eaf1f7;
  --blue-line: #cfdeeb;
  --plum: #7c3f63;
  --plum-soft: #f6ecf2;
  --plum-line: #e8d3df;

  /* Feedback, overlays, media */
  --focus-shadow: 0 0 0 3px rgba(163, 19, 102, .15);
  --shadow-brand: 0 1px 1px rgba(60, 4, 35, .18);
  --shadow-1: 0 1px 2px rgba(32, 24, 32, .05);
  --shadow-2: 0 24px 48px -28px rgba(32, 24, 32, .38);
  --menu-overlay: rgba(23, 18, 25, .48);
  --preview-backdrop: rgba(13, 10, 14, .58);
  --image-surface: #fff;
  --message-staff: #fdf3f8;
  --auth-orbit: rgba(210, 59, 144, .16);

  /* Theme switch */
  --switch-track: #f3eaee;
  --switch-thumb: #fffcfc;
  --switch-line: #d4c3cb;
  --switch-icon: #8b7783;
  --switch-icon-active: #a31366;

  /* Shape and depth */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;

  /* Layout */
  --sidebar-w: 244px;
  --topbar-h: 60px;
  --content-w: 1380px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

  --canvas: #131013;
  --surface: #1c171c;
  --surface-2: #241d23;
  --surface-3: #2d242c;
  --line: #3b3039;
  --line-strong: #4d3e49;
  --field-line: #7a6673;
  --field-line-strong: #957e8c;

  --ink: #f7eef3;
  --ink-soft: #d9ccd4;
  --muted: #b09ea9;
  --muted-2: #9c8994;

  --sidebar: #0d0a0e;
  --sidebar-raised: #18121a;
  --sidebar-ink: #f9eff5;
  --sidebar-nav: #d3c3cd;
  --sidebar-muted: #bcaab6;
  --sidebar-line: rgba(255, 255, 255, .1);
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-icon: #b7a3af;
  --sidebar-icon-active: #f4a6cd;
  --sidebar-active-bg: rgba(239, 127, 186, .12);
  --sidebar-active-ink: #fff;
  --sidebar-avatar-bg: #3b1c2d;
  --sidebar-avatar-ink: #f6bcd8;
  --sidebar-border: #050306;

  --brand: #b51c70;
  --brand-hover: #cc237f;
  --brand-ink: #fff;
  --brand-text: #ef7fba;
  --brand-text-strong: #f7a8d0;
  --brand-bright: #ef7fba;
  --brand-on-ink: #ef7fba;
  --brand-soft: #35182a;
  --brand-line: #52253c;

  --attention: #e2a04c;
  --attention-soft: #352718;
  --attention-line: #5c4328;
  --danger: #f08a80;
  --danger-solid: #a32a24;
  --danger-solid-hover: #bd352d;
  --danger-soft: #3b1d1c;
  --danger-line: #60302c;
  --success: #7ecfa6;
  --success-soft: #162d23;
  --success-line: #2f5341;
  --blue: #8db8d8;
  --blue-soft: #182b38;
  --blue-line: #2c465a;
  --plum: #d9a1c2;
  --plum-soft: #2f1f29;
  --plum-line: #513247;

  --focus-shadow: 0 0 0 3px rgba(239, 127, 186, .22);
  --shadow-brand: 0 1px 1px rgba(0, 0, 0, .4);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 28px 60px -28px rgba(0, 0, 0, .8);
  --menu-overlay: rgba(5, 3, 6, .64);
  --preview-backdrop: rgba(3, 2, 4, .74);
  --message-staff: #251a22;
  --auth-orbit: rgba(239, 127, 186, .14);

  --switch-track: #2d242c;
  --switch-thumb: #b51c70;
  --switch-line: #4d3e49;
  --switch-icon: #9c8994;
  --switch-icon-active: #fff;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.menu-open { overflow: hidden; }

h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
h1 { font-size: 30px; line-height: 1.16; letter-spacing: -.028em; font-weight: 730; }
h2 { font-size: 17px; line-height: 1.3; letter-spacing: -.014em; font-weight: 680; }
h3 { font-size: 15px; line-height: 1.35; letter-spacing: -.01em; font-weight: 660; }
p { text-wrap: pretty; }

img, svg { max-width: 100%; }
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .88em; }
::selection { background: var(--brand-soft); color: var(--brand-text-strong); }

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 10px;
  z-index: 200;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.skip-link:focus { left: 10px; }
.sidebar :focus-visible,
.auth-brand-panel :focus-visible { outline-color: var(--brand-bright); }

.noscript-note {
  padding: 12px 16px;
  background: var(--attention-soft);
  color: var(--ink-soft);
  border-bottom: 1px solid var(--attention-line);
  font-size: 13px;
}

/* ---------- Shared helpers ---------- */

.muted { color: var(--muted); }
.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;
}
.nowrap { white-space: nowrap; }
.hint { margin-top: 7px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.cell-clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-form { display: inline; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-text);
  font: inherit;
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
  text-align: left;
}
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.link svg { width: 14px; height: 14px; }
.link-danger { color: var(--danger); }

/* ---------- Staff shell ---------- */

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  padding: 18px 14px 16px;
  overflow-y: auto;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-border);
  transition: transform .22s ease;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .13); border-radius: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 2px 6px;
  color: var(--ink);
  border-radius: var(--radius-sm);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: block;
  flex: none;
  width: 30px;
  height: 40px;
  object-fit: contain;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-text strong,
.brand-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text strong { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: 10.5px; color: var(--muted); }

.sidebar .brand { flex: 1; color: var(--sidebar-ink); }
.sidebar .brand:hover { background: var(--sidebar-hover); }
.sidebar .brand-text small { color: var(--sidebar-muted); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.icon-button.sidebar-close {
  display: none;
  flex: none;
  width: 36px;
  height: 36px;
  background: var(--sidebar-hover);
  border-color: var(--sidebar-line);
  color: var(--sidebar-nav);
}
.sidebar-close:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .18); }

/* Light/dark switch: 44x24 track inside a larger hit area. */
.theme-switch {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  cursor: pointer;
}
.theme-switch-track {
  position: relative;
  display: block;
  width: 44px;
  height: 24px;
  border: 1px solid var(--switch-line);
  border-radius: 999px;
  background: var(--switch-track);
  transition: background .18s ease, border-color .18s ease;
}
.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--switch-thumb);
  box-shadow: 0 1px 2px rgba(20, 10, 16, .22);
  transition: transform .2s ease, background .18s ease;
}
.theme-switch-icon {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  color: var(--switch-icon);
  transform: translateY(-50%);
  pointer-events: none;
  transition: color .18s ease;
}
.theme-switch-icon svg { width: 12px; height: 12px; stroke-width: 2; }
.theme-switch-icon-sun { left: 5px; }
.theme-switch-icon-moon { right: 5px; }
.theme-switch:hover .theme-switch-track { border-color: var(--brand-bright); }
.theme-switch:focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 3px; border-radius: 999px; }
.sidebar .theme-switch-track { background: var(--sidebar-raised); border-color: var(--sidebar-line); }
.sidebar .theme-switch-icon { color: var(--sidebar-muted); }
[data-theme="dark"] .theme-switch-thumb { transform: translateX(20px); }
[data-theme="dark"] .theme-switch-icon-moon { color: var(--switch-icon-active); }
:root:not([data-theme="dark"]) .theme-switch-icon-sun { color: var(--switch-icon-active); }

.nav { display: flex; flex: 1; flex-direction: column; gap: 3px; margin-top: 24px; }
.nav-label {
  margin: 18px 10px 7px;
  color: var(--sidebar-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .13em;
  opacity: .74;
  text-transform: uppercase;
}
.nav-label:first-child { margin-top: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-nav);
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.3;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 17px; height: 17px; color: var(--sidebar-icon); transition: color .15s ease; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-ink); text-decoration: none; }
.nav-item:hover svg { color: var(--sidebar-ink); }
.nav-item.is-active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-ink);
  box-shadow: inset 2px 0 0 var(--brand-bright);
}
.nav-item.is-active svg { color: var(--sidebar-icon-active); }
.nav-button { width: 100%; border: 0; background: none; font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 8px 12px;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-meta strong { overflow: hidden; color: inherit; font-size: 12.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { overflow: hidden; color: var(--sidebar-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .avatar { background: var(--sidebar-avatar-bg); color: var(--sidebar-avatar-ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07); }
.nav-item-sub { min-height: 36px; padding: 7px 10px; color: var(--sidebar-muted); font-size: 12.5px; }
.nav-item-sub svg { width: 15px; height: 15px; }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 720;
  letter-spacing: .02em;
}
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-icon {
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-text);
  box-shadow: inset 0 0 0 1px var(--brand-line);
}
.avatar-icon svg { width: 14px; height: 14px; }
.avatar-lg { width: 52px; height: 52px; border-radius: 15px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; border-radius: 17px; font-size: 19px; }

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--sidebar-w);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 10px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.global-search { position: relative; flex: 1; max-width: 540px; }
.global-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.global-search input::placeholder { color: var(--muted-2); }
.global-search input:hover { background: var(--surface-3); }
.global-search input:focus { outline: none; background: var(--surface); border-color: var(--brand-text); box-shadow: var(--focus-shadow); }
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  transform: translateY(-50%);
  pointer-events: none;
}
.search-icon svg { width: 16px; height: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.topbar-note::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-bright);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.topbar-portal { min-height: 36px; }
.topbar-portal svg { width: 14px; height: 14px; }
/* The sidebar carries the switch on desktop; below 980 the sidebar is
   off-canvas, so the topbar gets its own copy of the same control. */
.topbar-theme { display: none; }

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 30px 32px 64px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.icon-button:hover { background: var(--surface-2); border-color: var(--line-strong); }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.menu-button { display: none; }

/* ---------- Client shell ---------- */

.shell-client {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--canvas);
}
.client-header {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 10px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand-client { padding: 0; }
.brand-client .brand-mark { width: 27px; height: 36px; }
.brand-client .brand-text strong { font-size: 13.5px; }
.client-header .theme-switch { margin-left: -4px; }
.client-nav { display: flex; flex: 1; gap: 2px; min-width: 0; margin-left: 6px; }
.client-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 570;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.client-nav-item svg { width: 16px; height: 16px; color: var(--muted); }
.client-nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.client-nav-item.is-active { background: var(--brand-soft); color: var(--brand-text-strong); }
.client-nav-item.is-active svg { color: var(--brand-text); }
.client-user { display: flex; align-items: center; gap: 9px; min-width: 0; margin-left: auto; }
.client-user .user-meta strong { color: var(--ink); }
.client-user .user-meta small { color: var(--muted); }
.client-user .button { min-height: 36px; }
.content-client { flex: 1; max-width: 1150px; padding-top: 32px; }
.client-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1150px;
  margin: 0 auto;
  padding: 20px 32px 30px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.client-foot a { color: var(--brand-text); }

/* ---------- Page heading ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.page-head h1 { margin-bottom: 4px; }
.page-head .subtitle { max-width: 740px; }
.subtitle { color: var(--muted); font-size: 14px; line-height: 1.5; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--brand-text);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-bright); box-shadow: 0 0 0 3px var(--brand-soft); }
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 12.5px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand-text); }
.breadcrumb span:last-child { color: var(--ink-soft); }
.breadcrumb svg { width: 13px; height: 13px; color: var(--muted-2); }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.page-actions-center { justify-content: center; margin-top: 20px; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 640;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .06s ease;
}
.button:hover { text-decoration: none; }
.button:active { transform: translateY(1px); }
.button svg { width: 16px; height: 16px; }
.button-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-brand);
}
.button-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.button-secondary {
  background: var(--surface);
  border-color: var(--field-line);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.button-secondary:hover { background: var(--surface-2); border-color: var(--field-line-strong); }
.button-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.button-ghost:hover { background: var(--surface-2); color: var(--ink); }
.button-danger { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--brand-ink); }
.button-danger:hover { background: var(--danger-solid-hover); border-color: var(--danger-solid-hover); }
.button-block { width: 100%; }
.button-sm { min-height: 34px; padding: 6px 11px; border-radius: 8px; font-size: 12.5px; }
.button-sm svg { width: 14px; height: 14px; }
.button[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Badges / pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  line-height: 1.45;
  white-space: nowrap;
}
.badge::before {
  content: "";
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-line); }
.badge-green { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.badge-amber { background: var(--attention-soft); color: var(--attention); border-color: var(--attention-line); }
.badge-red { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-purple { background: var(--plum-soft); color: var(--plum); border-color: var(--plum-line); }
.badge-gray { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Cards ---------- */

.card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card-flush { padding: 0; overflow: hidden; }
.card-compact { padding: 17px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.card-flush > .card-head { margin-bottom: 0; }
.card-head-pad { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15.5px; }
.card-head .muted { font-size: 12px; }
.card-head-icon { display: inline-flex; align-items: center; gap: 9px; }
.card-head-icon svg { width: 16px; height: 16px; color: var(--brand-text); }

.grid-1 { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.section-note { color: var(--muted); font-size: 12.5px; }

/* ---------- Metric strip ---------- */

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.metric-strip-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  min-width: 0;
  padding: 18px 20px;
  color: var(--ink);
}
.metric + .metric { border-left: 1px solid var(--line); }
a.metric { transition: background .15s ease; }
a.metric:hover { background: var(--surface-2); text-decoration: none; }
.metric-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--brand-line);
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.metric-icon svg { width: 18px; height: 18px; }
.metric-icon-attention { background: var(--attention-soft); border-color: var(--attention-line); color: var(--attention); }
.metric-icon-plum { background: var(--plum-soft); border-color: var(--plum-line); color: var(--plum); }
.metric-body { display: flex; flex-direction: column; min-width: 0; }
.metric-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 720;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.metric-value {
  margin-top: 2px;
  font-size: 30px;
  font-weight: 730;
  letter-spacing: -.035em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric-hint { margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.metric-go { margin-left: auto; align-self: center; color: var(--muted-2); opacity: 0; transition: opacity .15s ease, transform .15s ease; }
a.metric:hover .metric-go { opacity: 1; transform: translateX(2px); }
.metric-go svg { width: 16px; height: 16px; }

/* ---------- Dashboard queue board ---------- */

.queue-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
  margin-bottom: 22px;
}
.queue-card { padding: 0; overflow: hidden; }
.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.queue-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.queue-title h2 { font-size: 14.5px; }
.queue-mark { width: 8px; height: 8px; border-radius: 2px; background: var(--brand-bright); flex: none; }
.queue-mark-attention { background: var(--attention); }
.queue-mark-plum { background: var(--plum); }
.queue-head .link { flex: none; }
.queue-list { display: flex; flex-direction: column; }
.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 14px;
  align-items: center;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  transition: background .12s ease;
}
.queue-row:first-child { border-top: 0; }
.queue-row:hover { background: var(--surface-2); text-decoration: none; }
.queue-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.queue-subject {
  overflow: hidden;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-context {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-context .dot { color: var(--line-strong); }
.queue-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.queue-age {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.queue-age svg { width: 12px; height: 12px; }

.dash-lower {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 322px;
  gap: 20px;
  align-items: start;
}
.dash-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.review-callout {
  padding: 20px;
  border: 1px solid var(--attention-line);
  border-left: 3px solid var(--attention);
  border-radius: var(--radius);
  background: var(--attention-soft);
}
.review-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  border: 1px solid var(--attention-line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--attention);
}
.review-icon svg { width: 17px; height: 17px; }
.review-eyebrow {
  color: var(--attention);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.review-callout h2 { margin: 3px 0 5px; color: var(--ink); font-size: 19px; letter-spacing: -.02em; }
.review-callout p { color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.review-callout .button-secondary { background: var(--surface); border-color: var(--attention-line); color: var(--ink); }
.review-callout .button-secondary:hover { background: var(--surface-2); border-color: var(--attention); }

.fact-list { display: flex; flex-direction: column; margin: 0; }
.fact-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.fact-list > div:last-child { border-bottom: 0; }
.fact-list dt { color: var(--muted); font-size: 12px; }
.fact-list dd { color: var(--ink); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.directory-card .card-head { margin-bottom: 8px; }
.directory-card .link { margin-top: 12px; }

/* ---------- Tables ---------- */

.table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  line-height: 1.4;
}
.table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table th.num { text-align: right; }
.table td {
  min-height: 52px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  vertical-align: middle;
}
.table tbody tr { height: 52px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table-hover tbody tr:focus-within { background: var(--surface-2); }
.table-primary {
  display: block;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 630;
  line-height: 1.35;
}
a.table-primary:hover { color: var(--brand-text); text-decoration: none; }
.table-secondary {
  display: block;
  max-width: 320px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-title { max-width: 440px; }
.cell-title a { color: var(--ink); font-weight: 620; }
.cell-title a:hover { color: var(--brand-text); }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-person-copy { min-width: 0; }
.cell-person-copy .table-primary,
.cell-person-copy .table-secondary { max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-age {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-age svg { width: 13px; height: 13px; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .inline-form + .inline-form { margin-left: 12px; }
.col-go { width: 38px; padding-right: 14px !important; text-align: right; color: var(--muted-2) !important; }
.col-go svg { width: 15px; height: 15px; opacity: 0; transition: opacity .12s ease; }
tr:hover .col-go svg { opacity: 1; }
.cell-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; vertical-align: 1px; }
.ticket-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ticket-line > a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-line .cell-badges { flex: none; margin-left: 0; }
.table-recent { table-layout: fixed; }
.table-recent th:nth-child(1) { width: 64px; }
.table-recent th:nth-child(2) { width: 27%; }
.table-recent th:nth-child(4) { width: 112px; }
.table-recent th:nth-child(5) { width: 112px; }
.table-recent .cell-title { max-width: none; }
.table-recent .cell-title a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-recent .cell-person-copy .table-primary { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Ticket rows have fixed, predictable columns; the subject absorbs the rest
   so the updated column is visible at 1440 instead of forcing a table scroll. */
.table-tickets { table-layout: fixed; }
.table-tickets th:nth-child(1) { width: 72px; }
.table-tickets th:nth-child(3) { width: 18%; }
.table-tickets th:nth-child(4) { width: 12%; }
.table-tickets th:nth-child(5) { width: 18%; }
.table-tickets th:nth-child(6) { width: 14%; }
.table-tickets .cell-title { max-width: none; }

/* ---------- Filters ---------- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.filter-bar-wrap { flex-wrap: wrap; }
.filter-search { position: relative; flex: 1 1 260px; min-width: 190px; }
.filter-search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.filter-search input::placeholder { color: var(--muted-2); }
.filter-search input:focus { outline: none; background: var(--surface); border-color: var(--brand-text); box-shadow: var(--focus-shadow); }
.filter-bar select {
  flex: 0 1 auto;
  min-width: 132px;
  max-width: 220px;
  height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.filter-bar .button { min-height: 44px; }
.filter-bar .button-ghost { color: var(--muted); }
.filter-bar .button-ghost:hover { color: var(--ink); }
/* Submit feedback: keep controls usable while the GET navigation starts. */
.filter-bar.is-filtering,
.filter-bar.is-filtering input,
.filter-bar.is-filtering select,
.filter-bar.is-filtering .button { cursor: progress; }

.filter-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -6px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.form-wide { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span,
.field-label {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 640;
  letter-spacing: .005em;
}
.field-span-2 { grid-column: span 2; }
.field-row { display: flex; align-items: flex-end; gap: 10px; }
.field-row .field { flex: 1; }
.field-error { color: var(--danger); font-size: 12px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: var(--field-line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-text);
  box-shadow: var(--focus-shadow);
}
input:not([type="checkbox"]):not([type="radio"]):focus-visible,
select:focus-visible,
textarea:focus-visible { outline: none; }
textarea { min-height: 122px; resize: vertical; line-height: 1.6; }
input[type="file"] { padding: 8px 10px; font-size: 13px; }
input[type="file"]::file-selector-button {
  margin-right: 11px;
  padding: 6px 11px;
  border: 1px solid var(--field-line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-3); }
.check-row { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 16px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--brand-text); }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; padding-top: 4px; }
.form-section { padding: 0; overflow: hidden; }
.form-section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.form-section-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-text);
}
.form-section-icon svg { width: 16px; height: 16px; }
.form-section-head h2 { font-size: 14px; }
.form-section-head p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.form-section-body { padding: 20px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.form-aside { position: sticky; top: 82px; }
.form-aside .card-head { margin-bottom: 10px; }
.tip-list { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.tip {
  display: flex;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.5;
}
.tip-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.tip-icon svg { width: 14px; height: 14px; }
.tip strong { display: block; margin-bottom: 1px; color: var(--ink); font-size: 12.5px; }
.side-form { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.side-form:last-child { margin-bottom: 0; }
.side-form .field > span { font-size: 11.5px; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 22px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-bottom: -1px;
  padding: 10px 13px 11px;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.tab.is-active { border-bottom-color: var(--brand-text); color: var(--brand-text-strong); }
.tab-count {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab-count { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-text); }

/* ---------- Detail lists ---------- */

.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; margin: 0; }
.detail-list > div { min-width: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-list dt {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.detail-list dd { margin-top: 3px; color: var(--ink-soft); font-size: 13px; overflow-wrap: anywhere; }
.detail-list-sm { grid-template-columns: 1fr; }
.detail-list-sm > div { padding: 7px 0; }

/* ---------- Company identity ---------- */

.company-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.company-identity { display: flex; align-items: center; gap: 18px; min-width: 0; }
.company-identity-copy { min-width: 0; }
.company-identity h1 { overflow-wrap: anywhere; }
.company-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 9px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
}
.company-meta .mono { color: var(--ink-soft); }
.meta-sep { color: var(--line-strong); }
.company-columns { display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  padding: 18px;
}
.document-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.document-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.document-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 48px;
  border: 1px solid var(--brand-line);
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.document-icon svg { width: 19px; height: 19px; }
.document-body { flex: 1; min-width: 0; }
.document-body h3 { font-size: 13px; font-weight: 620; overflow-wrap: anywhere; }
.document-meta { margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.document-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.document-download {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  color: var(--muted);
}
.document-download:hover { background: var(--surface-3); color: var(--ink); }
.document-download svg { width: 15px; height: 15px; }

/* ---------- Lists ---------- */

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.list-row:last-child { border-bottom: 0; }
a.list-row { border-radius: 7px; padding-right: 6px; padding-left: 6px; margin: 0 -6px; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-main { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.list-title { overflow: hidden; font-size: 13px; font-weight: 620; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { overflow: hidden; color: var(--muted); font-size: 11.5px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.list-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.list-scroll {
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.list-scroll:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.list-scroll .list-row { align-items: flex-start; }
.list-scroll .list-title {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.list-scroll .list-row > .badge { margin-top: 2px; }
.list-more { margin-top: 10px; color: var(--muted); font-size: 11px; }

/* ---------- Timeline ---------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item { position: relative; display: flex; gap: 12px; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 11px;
  height: 11px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--brand-text);
  box-shadow: 0 0 0 3px var(--brand-soft);
  flex: none;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.timeline-head strong { color: var(--ink); font-size: 12.5px; }
.timeline-head span { color: var(--muted); font-size: 11px; }

/* ---------- Alerts / notices / toast ---------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 16px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}
.alert-error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.alert-success { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-text-strong); }
.alert-info { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue); }
.alert-warning { background: var(--attention-soft); border-color: var(--attention-line); color: var(--attention); }
.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 18px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.5;
}
.notice-review { border-color: var(--attention-line); border-left-color: var(--attention); background: var(--attention-soft); color: var(--attention); }
.notice svg { width: 15px; height: 15px; margin-top: 1px; flex: none; }
.toast {
  position: fixed;
  top: 76px;
  right: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  padding: 11px 12px 11px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--brand);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  animation: toast-in .18s ease-out;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-text); flex: none; }
.toast-success .toast-dot { background: var(--success); }
.toast-error .toast-dot { background: var(--danger); }
.toast-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.toast-close:hover { background: var(--surface-2); color: var(--ink); }
.toast-close svg { width: 15px; height: 15px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* ---------- Empty states ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 38px 24px;
  margin: 0;
  color: var(--muted);
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty-state h3 { color: var(--ink); font-size: 14px; }
.empty-state p { max-width: 400px; font-size: 12.5px; line-height: 1.55; }
.empty-state .button { margin-top: 9px; }
.empty-state-sm { padding: 24px 18px; }
.empty-large { padding: 52px 24px; }
.empty-large .empty-icon { width: 50px; height: 50px; }

/* ---------- Pagination ---------- */

.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.pagination-info { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 36px;
  min-height: 36px;
  padding: 5px 9px;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page-link:hover { border-color: var(--field-line); background: var(--surface-2); text-decoration: none; }
.page-link.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.page-link.is-disabled { color: var(--muted); opacity: .72; }
.page-link svg { width: 13px; height: 13px; }

/* ---------- Auth split screen ---------- */

.auth-body { min-height: 100vh; background: var(--canvas); }
.auth-split {
  display: grid;
  grid-template-columns: minmax(380px, 44%) minmax(0, 1fr);
  min-height: 100vh;
}
.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 38px 44px 30px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
}
.auth-brand-panel::before,
.auth-brand-panel::after {
  content: "";
  position: absolute;
  border: 1px solid var(--auth-orbit);
  border-radius: 50%;
  pointer-events: none;
}
.auth-brand-panel::before { right: -170px; bottom: -180px; width: 520px; height: 520px; }
.auth-brand-panel::after { right: -70px; bottom: -80px; width: 300px; height: 300px; }
.auth-brand-panel .brand { position: relative; z-index: 1; padding: 0; color: var(--sidebar-ink); }
.auth-brand-panel .brand-text small { color: var(--sidebar-muted); }
.auth-brand-panel .brand-mark { width: 32px; height: 42px; }
.auth-brand-copy { position: relative; z-index: 1; max-width: 470px; margin: auto 0; padding: 42px 0 30px; }
.auth-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
  color: var(--brand-on-ink);
  font-size: 10px;
  font-weight: 740;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.auth-kicker::before { content: ""; width: 22px; height: 1px; background: var(--brand-on-ink); }
.auth-brand-title {
  max-width: 430px;
  color: var(--sidebar-ink);
  font-size: 38px;
  font-weight: 710;
  letter-spacing: -.035em;
  line-height: 1.1;
}
.auth-brand-copy > p:not(.auth-brand-title):not(.auth-kicker) {
  max-width: 410px;
  margin-top: 16px;
  color: var(--sidebar-muted);
  font-size: 14.5px;
  line-height: 1.6;
}
.auth-trust {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--sidebar-line);
}
.auth-trust-item { display: flex; align-items: flex-start; gap: 11px; }
.auth-trust-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  color: var(--brand-on-ink);
}
.auth-trust-icon svg { width: 15px; height: 15px; }
.auth-trust-item strong { display: block; color: var(--sidebar-ink); font-size: 12.5px; font-weight: 620; line-height: 1.4; }
.auth-trust-item span { display: block; margin-top: 1px; color: var(--sidebar-muted); font-size: 11.5px; line-height: 1.5; }
.auth-brand-foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--sidebar-line);
  color: var(--sidebar-muted);
  font-size: 11px;
}
.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 38px 32px;
  overflow-y: auto;
}
.auth-panel { width: 100%; max-width: 460px; margin: auto 0; }
.auth-panel-wide { max-width: 610px; }
.auth-mobile-brand { display: none; margin-bottom: 24px; }
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.auth-back:hover { color: var(--brand-text); text-decoration: none; }
.auth-back svg { width: 14px; height: 14px; }
.auth-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; line-height: 1.5; text-align: center; }

.auth-head { margin-bottom: 22px; }
.auth-head h1 { margin-bottom: 6px; font-size: 27px; }
.auth-head p { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.auth-note { margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 18px; text-align: center; font-size: 13px; }
.auth-links .muted { font-size: 12px; }
.auth-hero { margin-bottom: 24px; }
.auth-hero h1 { margin-bottom: 8px; font-size: 31px; }
.auth-lede { max-width: 540px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.auth-block {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.auth-block-head { margin-bottom: 15px; }
.auth-block-head h2 { margin-bottom: 2px; font-size: 16px; }
.auth-block-head p { color: var(--muted); font-size: 12.5px; }
.auth-block .alert { margin-bottom: 14px; }
.auth-block .form { gap: 14px; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.magic-form { display: flex; flex-direction: row; align-items: flex-end; gap: 10px; }
.magic-form .field { flex: 1; }
.auth-block-note { margin-top: 12px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.landing-note {
  margin-top: 20px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

/* Magic confirmation / recovery / TOTP */

.totp-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.qr {
  display: block;
  width: 190px;
  height: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--image-surface);
}
.totp-copy { min-width: 0; }
.steps { margin: 0 0 12px; padding-left: 18px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.55; }
.steps li { margin-bottom: 6px; }
.steps li::marker { color: var(--brand-text); font-weight: 700; }
.secret-box { padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.secret-box span { display: block; color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.secret-box code { display: block; margin-top: 3px; color: var(--ink); font-size: 12px; overflow-wrap: anywhere; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.recovery-codes code {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  letter-spacing: .05em;
  text-align: center;
}

/* ---------- Client portal ---------- */

.client-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 26px 28px;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  background: var(--brand-soft);
}
.client-hero h1 { font-size: 30px; }
.client-hero .subtitle { color: var(--ink-soft); }
.client-hero .eyebrow { color: var(--brand-text-strong); }
.client-hero-side { display: flex; align-items: center; gap: 12px; flex: none; }
.hero-company {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 7px;
  border: 1px solid var(--brand-line);
  border-radius: 11px;
  background: var(--surface);
}
.hero-company .avatar { background: var(--brand); color: var(--brand-ink); }
.hero-company strong { display: block; max-width: 210px; overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.meta-label { display: block; color: var(--muted); font-size: 9.5px; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; }

.client-ticket-list { display: flex; flex-direction: column; }
.client-ticket {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.client-ticket:first-child { border-top: 0; }
.client-ticket:hover { text-decoration: none; }
.client-ticket:hover .client-ticket-subject { color: var(--brand-text); }
.client-ticket-main { flex: 1; min-width: 0; }
.client-ticket-subject { display: block; overflow: hidden; color: var(--ink); font-size: 13.5px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.ticket-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 7px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}
.client-ticket-side { display: flex; align-items: center; gap: 8px; flex: none; }
.contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.contact-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.contact-card > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.contact-card strong { color: var(--ink); font-size: 12.5px; }
.contact-card .muted { font-size: 11.5px; }
.contact-card a { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.policy-list { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.55; }
.policy-list li { margin-bottom: 7px; }
.policy-list li::marker { color: var(--brand-text); }

/* ---------- Search ---------- */

.search-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 26px;
  align-items: center;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.search-guide h2 { margin-bottom: 6px; font-size: 19px; }
.search-guide p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.search-guide-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.search-guide-list li { display: flex; gap: 9px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; }
.search-guide-list svg { width: 16px; height: 16px; margin-top: 1px; color: var(--brand-text); }
.search-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.search-example {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.result-head h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.result-head svg { width: 15px; height: 15px; color: var(--brand-text); }
.result-head .count-pill { margin-left: 2px; }
.search-summary { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.search-summary strong { color: var(--ink); }

/* ---------- Ticket page contract ---------- */

.ticket-page { min-width: 0; }
.ticket-header {
  margin-bottom: 20px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.ticket-eyebrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 720;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.ticket-title { font-size: 28px; line-height: 1.2; letter-spacing: -.025em; overflow-wrap: anywhere; }
.ticket-header-copy { flex: 1; min-width: 0; }
.ticket-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 11px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.ticket-meta a { color: var(--ink-soft); }
.ticket-meta a:hover { color: var(--brand-text); }
.ticket-meta .mono { color: var(--ink-soft); }
.ticket-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.ticket-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.ticket-rail { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.thread {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.message {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.message:last-child { border-bottom: 0; }
.message-contact { background: var(--surface); }
.message-staff { background: var(--message-staff); }
.message-internal {
  background: var(--attention-soft);
  box-shadow: inset 3px 0 0 var(--attention);
}
.message-internal .message-meta strong { color: var(--attention); }
.message-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.message-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 720;
  object-fit: cover;
  overflow: hidden;
}
.message-staff .message-avatar { background: var(--brand-soft); color: var(--brand-text-strong); }
.message-internal .message-avatar { background: var(--surface); color: var(--attention); box-shadow: inset 0 0 0 1px var(--attention-line); }
.message-meta { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.message-meta strong { color: var(--ink); font-size: 13px; font-weight: 640; }
.message-meta a { color: var(--muted); }
.message-body { max-width: 74ch; color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; }
.message-body p { margin: 0 0 12px; }
.message-body p:last-child { margin-bottom: 0; }
.message-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

/* Plain-text e-mail: preserve every newline, indent and quoted reply. */
.email-text {
  max-width: 72ch;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.68;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.email-text img { max-width: 100%; height: auto; vertical-align: middle; }
.email-html figcaption { margin-top: 5px; color: var(--muted); font-size: 11.5px; }
.email-text a { color: var(--brand-text); text-decoration: underline; }

/* Sanitised inbound HTML. Never assume Markdown list semantics. */
.email-html {
  max-width: 74ch;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}
.email-html > :first-child { margin-top: 0; }
.email-html > :last-child { margin-bottom: 0; }
.email-html p { margin: 0 0 12px; }
.email-html h1, .email-html h2, .email-html h3, .email-html h4 { margin: 18px 0 8px; color: var(--ink); line-height: 1.3; }
.email-html h1 { font-size: 22px; }
.email-html h2 { font-size: 19px; }
.email-html h3 { font-size: 16px; }
.email-html ul, .email-html ol { margin: 0 0 12px; padding-left: 22px; }
.email-html li { margin-bottom: 4px; }
.email-html a { color: var(--brand-text); text-decoration: underline; }
.email-html blockquote { margin: 12px 0; padding: 6px 0 6px 14px; border-left: 2px solid var(--line-strong); color: var(--muted); }
.email-html pre { overflow-x: auto; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; }
.email-html code { padding: 1px 4px; border-radius: 4px; background: var(--surface-3); font-size: .9em; }
.email-html pre code { padding: 0; background: none; }
.email-html img { max-width: 100%; height: auto; border-radius: 8px; }
.email-html figure { margin: 14px 0; }
.email-html table { max-width: 100%; margin: 0 0 12px; border-collapse: collapse; font-size: 13px; }
.email-html th, .email-html td { padding: 6px 9px; border: 1px solid var(--line); text-align: left; }
.email-html th { background: var(--surface-2); font-weight: 650; }
.email-html hr { margin: 18px 0; border: 0; border-top: 1px solid var(--line); }
.email-text .mail-inline-image,
.email-html .mail-inline-image {
  display: inline-block;
  max-width: 100%;
  height: auto;
  margin: 0;
  vertical-align: middle;
}

/* Attachment list: one compact section at the end of every message. */
.message-attachments {
  max-width: 74ch;
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.message-attachments-title {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 720;
  letter-spacing: .1em;
  line-height: 1.4;
  text-transform: uppercase;
}
.message-attachment-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.message-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 0;
}
.message-attachment + .message-attachment { border-top: 1px dashed var(--line); }
.message-attachment-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
}
.message-attachment-icon svg { width: 14px; height: 14px; }
.message-attachment-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.message-attachment-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 620;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-attachment-info { color: var(--muted); font-size: 11px; line-height: 1.35; }
.message-attachment-actions {
  display: flex;
  align-items: center;
  flex: none;
  gap: 2px;
  margin-left: auto;
}

.attachments { margin-top: 16px; }
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 9px;
}
.attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}
.attachment-card:hover { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; }
.attachment-thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-thumb svg { width: 17px; height: 17px; }
.attachment-file {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--brand-line);
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.attachment-file svg { width: 17px; height: 17px; }
.attachment-meta { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.attachment-meta strong { overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.attachment-meta span { color: var(--muted); font-size: 10.5px; }
.attachment-actions { display: flex; align-items: center; gap: 1px; flex: none; }
.attachment-preview {
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--brand-text);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.attachment-preview:hover { background: var(--brand-soft); text-decoration: none; }
.attachment-download { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; color: var(--muted); }
.attachment-download:hover { background: var(--surface-3); color: var(--ink); }
.attachment-download svg { width: 14px; height: 14px; }
/* Legacy inline attachment chip used by older markup. */
.attachment {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
}
.attachment:hover { border-color: var(--brand-text); color: var(--brand-text); text-decoration: none; }
.attachment small { color: var(--muted); }
.attachment svg { width: 14px; height: 14px; }

.composer {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.composer-head h2 { font-size: 14.5px; }
.composer-head p { color: var(--muted); font-size: 11.5px; }
.composer-body { padding: 18px; }
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.composer-tabs { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.composer-tabs button,
.composer-tabs a {
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 620;
  cursor: pointer;
}
.composer-tabs .is-active { background: var(--brand-soft); color: var(--brand-text-strong); }
.reply-mode { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.composer.is-internal { border-color: var(--attention-line); background: var(--attention-soft); }
.composer.is-internal .reply-mode { color: var(--attention); font-weight: 700; }
.composer.is-internal .composer-head h2 { color: var(--attention); }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 18px;
  border: 1.5px dashed var(--field-line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--brand-text); background: var(--brand-soft); }
.dropzone-title { color: var(--ink); font-size: 13px; font-weight: 650; }
.dropzone input[type="file"] { max-width: 420px; margin-top: 8px; text-align: left; }
.composer-status { min-width: 200px; }
.composer-status select { min-height: 40px; }

.recipient-disclosure { margin-top: 6px; font-size: 11.5px; }
.recipient-disclosure summary { color: var(--brand-text); cursor: pointer; }
.recipient-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
}
.recipient-list li { display: flex; gap: 7px; overflow-wrap: anywhere; }
.recipient-role { flex: none; min-width: 44px; color: var(--muted); font-weight: 600; }

.context-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.context-card h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.context-list { display: flex; flex-direction: column; margin: 0; }
.context-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.context-list > div:last-child { border-bottom: 0; }
.context-list dt { color: var(--muted); font-size: 11px; font-weight: 600; }
.context-list dd { color: var(--ink-soft); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.props-form { display: flex; flex-direction: column; gap: 13px; }
.props-form .field > span { font-size: 11px; }

/* Legacy ticket layout aliases (kept while pages migrate to the contract). */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.ticket-head { margin-bottom: 20px; }
.ticket-side { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side-title { margin-bottom: 12px; color: var(--muted); font-size: 10px; font-weight: 720; letter-spacing: .1em; text-transform: uppercase; }
.side-company { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.side-company:hover { text-decoration: none; }
.side-company span:last-child { display: flex; flex-direction: column; min-width: 0; }
.side-company strong { font-size: 12.5px; }
.side-company small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.tag { padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); font-size: 11px; }
.participant-list { display: flex; flex-direction: column; gap: 2px; margin: 0 0 10px; padding: 0; list-style: none; }
.participant-list li { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.participant-list li:last-child { border-bottom: 0; }
.participant-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.participant-copy strong { overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.participant-copy small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.participant-role { flex: none; }
.inline-add { display: flex; gap: 6px; }
.inline-add input { height: 36px; min-height: 36px; font-size: 12px; }

/* Attachment preview dialog (native <dialog>) */
.preview-dialog {
  width: min(920px, 92vw);
  max-width: 920px;
  max-height: 88vh;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
.preview-dialog::backdrop { background: var(--preview-backdrop); }
.preview-dialog-inner { display: flex; flex-direction: column; max-height: 88vh; }
.preview-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.preview-dialog-head h2 { overflow-wrap: anywhere; font-size: 14px; }
.preview-dialog-close { width: 36px; min-height: 36px; padding: 0; }
.preview-dialog-body {
  flex: 1;
  min-height: 200px;
  overflow: auto;
  padding: 18px;
  background: var(--surface-2);
}
.preview-dialog-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  background: var(--image-surface);
}
.preview-dialog-body iframe {
  display: block;
  width: 100%;
  height: 68vh;
  border: 0;
  border-radius: 8px;
  background: var(--image-surface);
}
.preview-dialog-body pre {
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.preview-dialog-foot {
  display: flex;
  justify-content: flex-end;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* Prose (internal notes, legacy ticket bodies) */
.prose { max-width: 74ch; color: var(--ink-soft); font-size: 13.5px; line-height: 1.65; overflow-wrap: anywhere; }
.prose p { margin: 0 0 10px; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 10px; padding-left: 22px; }
.prose pre { overflow-x: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.prose code { padding: 1px 5px; border-radius: 5px; background: var(--surface-3); }
.prose pre code { padding: 0; background: none; }
.prose blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 2px solid var(--line-strong); color: var(--muted); }
.prose table { width: 100%; margin-bottom: 10px; border-collapse: collapse; }
.prose th, .prose td { padding: 6px 8px; border: 1px solid var(--line); text-align: left; }
.prose a { text-decoration: underline; }

/* ---------- Error panel ---------- */

.error-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 560px;
  margin: 32px auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.error-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  border: 1px solid var(--danger-line);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
}
.error-mark svg { width: 21px; height: 21px; }
.error-code {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.error-panel h1 { margin: 5px 0 7px; font-size: 26px; }
.error-message { max-width: 440px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.error-panel .page-actions { margin-top: 20px; }

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
  .content { padding-right: 28px; padding-left: 28px; }
  .dash-lower { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 1200px) {
  /* The client name is long; below the wide layout the avatar and exit action
     carry the identity without crowding the primary navigation. */
  .client-user .user-meta { display: none; }
}

@media (max-width: 1120px) {
  .ticket-grid, .ticket-layout { grid-template-columns: minmax(0, 1fr); }
  .ticket-rail, .ticket-side { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-lower { grid-template-columns: minmax(0, 1fr); }
  .dash-rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company-columns { grid-template-columns: 1fr; }
  .form-layout { grid-template-columns: minmax(0, 1fr); }
  .form-aside { position: static; }
  .hide-md { display: none; }
  .metric { gap: 10px; padding: 16px; }
  .metric-icon { width: 34px; height: 34px; border-radius: 9px; }
  .metric-icon svg { width: 16px; height: 16px; }
  .metric-label { font-size: 9.5px; letter-spacing: .055em; }
}

@media (max-width: 980px) {
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: var(--shadow-2);
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  .shell.is-menu-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition: transform .22s ease, visibility 0s;
  }
  .shell.is-menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--menu-overlay);
  }
  .main { margin-left: 0; }
  .icon-button.menu-button { display: inline-grid; }
  .icon-button.sidebar-close { display: inline-grid; width: 44px; height: 44px; }
  .icon-button { width: 44px; height: 44px; }
  .theme-switch { width: 52px; height: 44px; }
  .topbar-theme { display: inline-flex; align-items: center; margin-left: -8px; }
  .shell.is-menu-open .topbar-theme { visibility: hidden; }
  .sidebar-head { gap: 4px; }
  .sidebar .brand { padding-left: 2px; }
  .nav-item { min-height: 44px; }
  .topbar-portal { min-height: 44px; }
  .client-user .button { min-height: 44px; }
  .page-link { min-width: 40px; min-height: 40px; }
  .topbar { padding: 10px 20px; }
  .content { padding: 24px 20px 56px; }
  .client-header { flex-wrap: wrap; gap: 12px; padding: 10px 20px; }
  .client-nav { display: none; order: 4; flex-basis: 100%; flex-direction: column; gap: 2px; }
  .shell.is-menu-open .client-nav { display: flex; }
  .shell-client.is-menu-open .client-header { z-index: 60; }
  .shell-client.is-menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--menu-overlay);
  }
  .client-nav-item { min-height: 44px; }
  .client-user { margin-left: auto; }
  .client-user .user-meta { display: none; }
  .grid-2, .grid-3, .contact-grid { grid-template-columns: 1fr; }
  .form-grid, .detail-list { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .page-head .page-actions { width: auto; }
  .company-hero { align-items: flex-start; flex-direction: column; }
  .client-hero { align-items: flex-start; flex-direction: column; }
  .client-hero-side { width: 100%; flex-wrap: wrap; justify-content: space-between; }
  .client-foot { flex-direction: column; padding: 18px 20px 28px; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .auth-main { min-height: 100vh; padding: 30px 24px; }
  .auth-mobile-brand { display: block; }
  .auth-back { margin-bottom: 18px; }
  .search-guide { grid-template-columns: 1fr; gap: 18px; padding: 24px; }
}

@media (min-width: 821px) and (max-width: 1120px) {
  /* The directory keeps useful columns instead of an awkward clipped table. */
  .table-directory .hide-sm { display: none; }
  .table-directory th,
  .table-directory td { padding-right: 12px; padding-left: 12px; }

  /* Hide the least useful ticket columns and give status room for the full
     "Aguardando cliente" pill. */
  .table-tickets th:nth-child(1),
  .table-tickets td:nth-child(1),
  .table-tickets th:nth-child(4),
  .table-tickets td:nth-child(4) { display: none; }
  .table-tickets th:nth-child(3) { width: 16%; }
  .table-tickets th:nth-child(5) { width: 20%; }
  .table-tickets th:nth-child(6) { width: 15%; }
  .table-tickets th,
  .table-tickets td { padding-right: 12px; padding-left: 12px; }
  .table-tickets .badge { padding: 2px 6px; font-size: 10.5px; }
  .tab { padding-right: 11px; padding-left: 11px; }
}

@media (max-width: 820px) {
  .queue-board { grid-template-columns: 1fr; }
  .metric-strip-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip-4 .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metric-strip-4 .metric:nth-child(4) { border-top: 1px solid var(--line); }
  .topbar-note { display: none; }
  .documents-grid { grid-template-columns: 1fr; }
  .totp-grid { grid-template-columns: 150px minmax(0, 1fr); }
  .qr { width: 150px; height: 150px; }
  .table-wrap .table { min-width: 640px; }
  .table-wrap .table-tickets,
  .table-wrap .table-directory,
  .table-wrap .table-recent,
  .table-wrap .table-portal { min-width: 0; }
  .table-tickets thead,
  .table-directory thead,
  .table-recent thead,
  .table-portal thead { display: none; }
  .table-tickets tbody,
  .table-directory tbody,
  .table-recent tbody,
  .table-portal tbody { display: flex; flex-direction: column; }
  .table-tickets tr,
  .table-directory tr,
  .table-recent tr,
  .table-portal tr {
    display: grid;
    height: auto;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    gap: 3px 12px;
  }
  .table.table-tickets tbody tr,
  .table.table-directory tbody tr,
  .table.table-recent tbody tr,
  .table.table-portal tbody tr { height: auto; }
  .table-tickets tr:last-child,
  .table-directory tr:last-child,
  .table-recent tr:last-child,
  .table-portal tr:last-child { border-bottom: 0; }
  .table-tickets td,
  .table-directory td,
  .table-recent td,
  .table-portal td {
    display: block;
    min-height: 0;
    padding: 0;
    border: 0;
  }
  .table-tickets tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "subject subject" "client status" "client age"; }
  .table-tickets td:nth-child(1),
  .table-tickets td:nth-child(4) { display: none; }
  .table-tickets td.cell-title { grid-area: subject; max-width: none; }
  .table-tickets td:nth-child(3) { grid-area: client; align-self: start; }
  .table-tickets td:nth-child(5) { grid-area: status; text-align: right; }
  .table-tickets td:nth-child(6) { grid-area: age; text-align: right; }
  .table-tickets .ticket-line { flex-wrap: wrap; }
  .table-tickets .ticket-line > a { overflow: visible; font-weight: 620; text-overflow: clip; white-space: normal; }
  .table-tickets .cell-badges { margin-top: 2px; }
  .table-directory tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client status" "doc open"; }
  .table-directory td:nth-child(1) { grid-area: client; align-self: start; }
  .table-directory td:nth-child(2) { grid-area: doc; }
  .table-directory td:nth-child(3),
  .table-directory td:nth-child(4),
  .table-directory td:nth-child(5),
  .table-directory td:nth-child(8) { display: none; }
  .table-directory td:nth-child(6) { grid-area: open; text-align: right; }
  .table-directory td:nth-child(7) { grid-area: status; text-align: right; }
  .table-recent tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "subject subject" "client status" "client updated"; }
  .table-recent td:nth-child(1) { display: none; }
  .table-recent td:nth-child(2) { grid-area: client; align-self: start; }
  .table-recent td:nth-child(3) { grid-area: subject; max-width: none; }
  .table-recent td:nth-child(4) { grid-area: status; text-align: right; }
  .table-recent td:nth-child(5) { grid-area: updated; text-align: right; }
  .table-recent td.cell-title a { white-space: normal; }
  .table-portal tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "subject subject" "updated status"; }
  .table-portal td:nth-child(1),
  .table-portal td:nth-child(3) { display: none; }
  .table-portal td:nth-child(2) { grid-area: subject; max-width: none; }
  .table-portal td:nth-child(4) { grid-area: status; text-align: right; }
  .table-portal td:nth-child(5) { grid-area: updated; align-self: center; }
  .table-portal td.cell-title a { white-space: normal; }
  .table-directory td:nth-child(6)::before {
    content: "Abertos: ";
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }
  .tabs { flex-wrap: wrap; overflow: visible; }
}

@media (max-width: 720px) {
  h1 { font-size: 27px; }
  .dash-rail { grid-template-columns: 1fr; }
  .company-hero { padding: 20px; }
  .company-identity { align-items: flex-start; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric + .metric { border-top: 1px solid var(--line); border-left: 0; }
  .metric { align-items: center; padding: 14px 16px; }
  .metric-value { font-size: 26px; }
  .metric-label { font-size: 10.5px; letter-spacing: .09em; }
  .metric-go { opacity: 1; }
  .metric-strip-4 { grid-template-columns: 1fr; }
  .metric-strip-4 .metric:nth-child(2),
  .metric-strip-4 .metric:nth-child(3),
  .metric-strip-4 .metric:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .topbar { flex-wrap: wrap; }
  .global-search { order: 3; flex-basis: 100%; max-width: none; }
  .topbar-actions { margin-left: auto; }
  .topbar-portal-label { display: none; }
  .topbar-portal { width: 44px; min-height: 44px; padding: 0; }
  .icon-button { width: 44px; height: 44px; }
  .nav-item { min-height: 44px; }
  .client-user .button { min-height: 44px; }
  .button-sm { min-height: 44px; }
  .filter-search { flex-basis: 100%; }
  .filter-bar select { flex: 1 1 44%; min-width: 0; max-width: none; }
  .filter-bar .button { flex: 0 1 auto; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .card { padding: 18px; }
  .card-flush { padding: 0; }
  .client-hero { padding: 22px; }
  .client-hero h1 { font-size: 26px; }
  .hero-company strong { max-width: 150px; }
  .auth-hero h1 { font-size: 28px; }
  .magic-form { flex-direction: column; align-items: stretch; }
  .magic-form .button { width: 100%; }
  .form-actions .button { flex: 1; }
  .table th, .table td { padding-right: 12px; padding-left: 12px; }
  .hide-sm { display: none; }

  .error-panel { margin: 16px auto; padding: 24px; }
  .error-panel h1 { font-size: 23px; }
}

@media (max-width: 560px) {
  .content { padding: 20px 16px 48px; }
  .client-header .client-user .avatar { display: none; }
  .topbar { padding: 9px 16px; }
  .client-header { padding: 9px 16px; }
  .client-foot { padding: 16px 16px 26px; }
  h1 { font-size: 25px; }
  .subtitle { font-size: 13px; }
  .card { padding: 16px; }
  .card-flush { padding: 0; }
  .card-head-pad { padding: 13px 15px; }
  .queue-head { padding: 12px 15px; }
  .queue-row { padding: 12px 15px; }
  .queue-side .badge { font-size: 10px; }
  .company-meta { font-size: 11.5px; }
  .avatar-xl { width: 54px; height: 54px; border-radius: 14px; font-size: 16px; }
  .hide-xs { display: none; }
  .table th, .table td { padding: 10px; }
  .cell-person-copy .table-primary { max-width: 168px; }
  .cell-title { max-width: 230px; }
  .documents-grid { padding: 12px; gap: 9px; }
  .document-card { padding: 12px; }
  .form-section-body { padding: 16px; }
  .form-grid { gap: 14px; }
  .recovery-codes { grid-template-columns: 1fr; }
  .totp-grid { grid-template-columns: 1fr; justify-items: center; text-align: left; }
  .totp-copy { width: 100%; }
  .qr { width: 170px; height: 170px; }
  .auth-main { padding: 24px 18px; }
  .auth-head h1 { font-size: 24px; }
  .auth-block { padding: 16px; }
  .auth-brand-foot { flex-direction: column; gap: 4px; }
  .auth-panel-wide { max-width: 100%; }
  .pagination-wrap { justify-content: center; }
  .review-callout { padding: 17px; }
  .search-guide { padding: 20px; }
  .ticket-header { padding: 18px; }
  .ticket-title { font-size: 23px; }
  .message { padding: 17px; }
  .ticket-rail, .ticket-side { grid-template-columns: minmax(0, 1fr); }
  .ticket-rail > *, .ticket-side > * { min-width: 0; max-width: 100%; }
  .participant-list li { align-items: flex-start; }
  .participant-copy strong, .participant-copy small {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .client-hero-side { align-items: flex-start; }
  .hero-company { flex: 1; min-width: 0; }
  .client-ticket { align-items: flex-start; }
  .client-ticket-side { flex-direction: column; align-items: flex-end; gap: 4px; }
  .search-example { font-size: 10px; }
  .toast { left: 16px; right: 16px; max-width: none; }
  .auth-body .toast { top: 16px; }
  .page-link { min-width: 44px; min-height: 44px; }
  .document-download { width: 44px; height: 44px; }
  .toast-close { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Mail reading + ticket interactions ---------- */

.ticket-header-copy { min-width: 0; }
.attachment-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.attachment-actions { gap: 2px; }
.attachment-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--brand-text);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  appearance: none;
}
.attachment-preview:hover { background: var(--brand-soft); }
.attachment-preview svg { width: 13px; height: 13px; }
.attachment-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  height: auto;
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  line-height: 1.2;
  white-space: nowrap;
}
.attachment-download:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.attachment-download svg { width: 13px; height: 13px; }
.attachment-meta strong { font-size: 12.5px; }
.attachment-meta span { font-size: 10.5px; }
.message-meta strong { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.context-card > .props-form { margin-top: 12px; }
.context-card > .props-form + .hint { margin-top: 10px; }

/* The email composer label is the picker surface, so the native control is
   transparent and covers it; focus-within still gives a visible ring. */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.dropzone-title { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-weight: 650; }
.dropzone .hint { margin-top: 0; }
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone:focus-within {
  border-color: var(--brand-text);
  box-shadow: var(--focus-shadow);
}
.composer-status { flex: 0 1 230px; }

/* Auth magic form: keep the field and button on one line on desktop. */
.auth-block .magic-form { flex-direction: row; align-items: flex-end; }
.auth-block .magic-form .button { flex: 0 0 auto; }

/* Preview dialog */
.preview-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
.preview-dialog::backdrop { background: var(--preview-backdrop); }
.preview-dialog-inner { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.preview-dialog-head,
.preview-dialog-foot { flex: none; }
.preview-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.preview-dialog-head h2 { min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.preview-dialog-close { flex: none; }
.preview-dialog-body {
  display: grid;
  place-items: center;
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
  padding: 20px;
  background: var(--surface-2);
}
.preview-dialog-body img { max-width: 100%; max-height: calc(100vh - 230px); border-radius: 8px; object-fit: contain; }
.preview-dialog-body pre {
  width: 100%;
  max-height: calc(100vh - 250px);
  margin: 0;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-dialog-foot { display: flex; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); }
body.preview-open { overflow: hidden; }

@media (max-width: 720px) {
  .auth-block .magic-form { flex-direction: column; align-items: stretch; }
  .auth-block .magic-form .button { width: 100%; }
  .attachment-grid { grid-template-columns: 1fr; }
}

/* Keep the leading icon clear of the search placeholder. */
.global-search input { padding-left: 40px; }

/* ---------- Print ----------
   Paper is always the light theme, even when the screen is dark. */
@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
    --canvas: #fff;
    --surface: #fff;
    --surface-2: #f7f3f5;
    --surface-3: #f1ebee;
    --line: #d8ccd3;
    --line-strong: #c4b5be;
    --field-line: #a38795;
    --field-line-strong: #8f7382;
    --ink: #1a141a;
    --ink-soft: #3d323a;
    --muted: #5e525b;
    --muted-2: #6b5d66;
    --brand: #a31366;
    --brand-text: #a31366;
    --brand-text-strong: #7c0c4c;
    --brand-ink: #fff;
    --brand-on-ink: #a31366;
    --brand-soft: #fae7f1;
    --brand-line: #f2cfe1;
    --attention: #a4580a;
    --attention-soft: #fdf1e1;
    --attention-line: #ecd6b6;
    --danger: #b3261e;
    --danger-solid: #b3261e;
    --danger-soft: #fbecea;
    --danger-line: #efd1cd;
    --success: #1e6b46;
    --success-soft: #e8f2ec;
    --success-line: #c8e0d3;
    --blue: #2d5f87;
    --blue-soft: #eaf1f7;
    --blue-line: #cfdeeb;
    --plum: #7c3f63;
    --plum-soft: #f6ecf2;
    --plum-line: #e8d3df;
    --message-staff: #fff;
    --image-surface: #fff;
  }
  body { background: #fff; color: #1a141a; }
  .sidebar, .topbar, .client-header, .client-foot, .theme-switch, .toast, .composer, .skip-link,
  .auth-brand-panel, .auth-mobile-brand { display: none !important; }
  .main { margin-left: 0; }
  .content, .content-client { max-width: none; padding: 0; }
  .auth-split { display: block; min-height: auto; }
  .auth-main { min-height: auto; padding: 0; }
  .auth-panel { max-width: none; margin: 0; }
  .card, .thread, .ticket-header, .message, .metric-strip, .company-hero, .client-hero, .auth-block { box-shadow: none; break-inside: avoid; }
  a { color: inherit; text-decoration: underline; }
}
