@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 750;
  font-display: swap;
  src: url('./fonts/dm-sans-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/instrument-serif-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/instrument-serif-italic.woff2') format('woff2');
}

/* ==================== WORKER THEME (ORCHARD GREEN — DEFAULT) ==================== */
:root {
  --ink: #18362c;
  --muted: #51635a;
  --brand: #153f32;
  --brand-deep: #103227;
  --brand-mid: #24583f;
  --brand-hero: linear-gradient(135deg, #143c30 0%, #1e5942 100%);
  --brand-soft: #e5efdc;
  --brand-soft-border: #c6dcb9;
  --brand-accent: #e4efa9;
  --brand-accent-hover: #d8e78c;
  --brand-accent-ink: #163324;
  --brand-eyebrow: #d9edcb;
  --brand-bar: #1e6b4a;
  --line: #dbe1d9;
  --line-strong: #c2cdc0;
  --paper: #f6f7f2;
  --white: #ffffff;
  --amber-bg: #fff6e0;
  --amber-line: #e9c97a;
  --amber-ink: #724b08;
  --red-bg: #fdf0ee;
  --red-line: #eab8b0;
  --red-ink: #992218;
  --blue-bg: #e7f0fb;
  --blue-ink: #1b4372;
  --worker-msg-bg: #f1f8ee;
  --worker-msg-border: #c8e0be;
  --worker-avatar-bg: #daf0d4;
  --worker-avatar-ink: #16593a;
  --staff-msg-bg: #f3f7fd;
  --staff-msg-border: #c7d8f0;
  --staff-avatar-bg: #dbe7fa;
  --staff-avatar-ink: #1b3b6f;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(21, 45, 50, 0.05), 0 4px 14px rgba(21, 45, 50, 0.04);
  --heading: 'Instrument Serif', Georgia, serif;
  --body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: var(--ink);
  font: 100%/1.5 var(--body);
  background: var(--paper);
  color-scheme: light;
}

/* ==================== STAFF / ADMIN THEME (DEEP NAVY SLATE) ==================== */
body.theme-staff {
  --ink: #16243d;
  --muted: #50617a;
  --brand: #1b345c;
  --brand-deep: #122442;
  --brand-mid: #274b82;
  --brand-hero: linear-gradient(135deg, #16294a 0%, #24457a 100%);
  --brand-soft: #e1ebfa;
  --brand-soft-border: #bfd3f2;
  --brand-accent: #f7d97e;
  --brand-accent-hover: #f2cc5d;
  --brand-accent-ink: #1b283f;
  --brand-eyebrow: #c8ddf8;
  --brand-bar: #254b85;
  --line: #d7e0ec;
  --line-strong: #bcc9dc;
  --paper: #f2f5fa;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

svg.ic {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.18em;
}
svg.ic-sm { width: 1em; height: 1em; }
svg.ic-lg { width: 1.35em; height: 1.35em; }

h1, h2, h3, h4, p, ul, ol {
  margin: 0;
}

h1, h2, h3 {
  line-height: 1.15;
}

a {
  color: var(--brand-mid);
  text-underline-offset: 0.2em;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #a65716;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -80px;
  z-index: 50;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 2px solid var(--brand);
  font-weight: 700;
}
.skip-link:focus {
  top: 12px;
}

.wrap {
  width: min(1140px, calc(100% - 32px));
  margin-inline: auto;
}

/* ==================== HEADER ==================== */
.site-head {
  background: var(--white);
  border-top: 4px solid var(--brand-bar);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: border-color 0.2s ease;
}

.head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding-block: 8px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-height: 44px;
}

.brand img {
  display: block;
  width: 104px;
  height: auto;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-border);
  color: var(--brand);
  font-size: 0.84rem;
  font-weight: 750;
  white-space: nowrap;
}

.head-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-btn:hover {
  background: var(--paper);
}

.nav-btn.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-btn.is-outline {
  border-color: var(--line-strong);
  background: var(--white);
}

.nav-btn.is-outline:hover {
  background: var(--paper);
}

.nav-btn.is-mode-switch {
  border-color: var(--brand-soft-border);
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-btn.is-mode-switch:hover {
  filter: brightness(0.96);
}

/* ==================== MAIN SHELL & TOAST ==================== */
.main-shell {
  flex: 1;
  padding-block: 24px 44px;
}

.loading-shell {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  background: var(--brand);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(17, 36, 58, 0.28);
  font-size: 0.92rem;
  font-weight: 550;
}

.toast.is-error {
  background: var(--red-ink);
}

/* ==================== HERO & STAFF BANNER ==================== */
.hero-card {
  background: var(--brand-hero);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 26px 26px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: 0 10px 28px rgba(17, 42, 48, 0.14);
}

.hero-card.is-compact {
  padding: 22px 24px;
}

.hero-card > div {
  min-width: 0;
  max-width: 100%;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  color: var(--brand-eyebrow);
  margin-bottom: 8px;
}

.hero-eyebrow::before {
  content: '';
  width: 20px;
  height: 2px;
  background: var(--brand-accent);
}

.hero-card h1 {
  font-family: var(--heading);
  font-weight: 400;
  font-size: clamp(2.15rem, 5vw, 3.1rem);
  letter-spacing: -0.02em;
  line-height: 1.04;
  margin-bottom: 8px;
}

.hero-card h1 em {
  color: var(--brand-accent);
}

.hero-card p {
  color: rgba(255, 255, 255, 0.9);
  max-width: 560px;
  font-size: 0.96rem;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-lime {
  background: var(--brand-accent);
  color: var(--brand-accent-ink);
}
.btn-lime:hover {
  background: var(--brand-accent-hover);
}

.btn-primary {
  background: var(--brand);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--brand-mid);
}

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover {
  background: var(--paper);
}

.btn-hero-ghost {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.28);
}
.btn-hero-ghost:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red-ink);
  border-color: var(--red-line);
}
.btn-danger:hover {
  background: #f9deda;
}

.btn-ghost {
  background: transparent;
  color: var(--brand-mid);
  padding-inline: 10px;
}
.btn-ghost:hover {
  background: var(--brand-soft);
}

.btn-sm {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.88rem;
}

/* ==================== CARDS & SURFACES ==================== */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--heading);
  font-weight: 400;
  font-size: 1.9rem;
  color: var(--ink);
}

.heading-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

/* ==================== FORM CONTROLS ==================== */
.field-grid {
  display: grid;
  gap: 14px;
}

.field-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-weight: 650;
  font-size: 0.92rem;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-hint {
  font-size: 0.84rem;
  color: var(--muted);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  font-size: 0.96rem;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27, 52, 92, 0.12);
  outline: none;
}

.textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.5;
}

.search-wrap {
  position: relative;
}
.search-wrap svg.ic {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-wrap .input {
  padding-left: 38px;
}

/* Single crisp custom chevron (never double) */
.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2318362c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}
.select::picker-icon {
  display: none;
}

.code-input {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
  min-height: 58px;
}

/* ==================== ALERTS & CALLOUTS ==================== */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: var(--paper);
}

.callout svg.ic {
  margin-top: 2px;
}

.callout-danger {
  background: var(--red-bg);
  border-color: var(--red-line);
  color: var(--red-ink);
}

.callout-warn {
  background: var(--amber-bg);
  border-color: var(--amber-line);
  color: var(--amber-ink);
}

.callout-sage {
  background: var(--brand-soft);
  border-color: var(--brand-soft-border);
  color: var(--brand-deep);
}

.callout strong {
  font-weight: 700;
}

.inline-error {
  background: var(--red-bg);
  border: 1px solid var(--red-line);
  color: var(--red-ink);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.92rem;
  font-weight: 600;
}

/* ==================== AUTH LAYOUT ==================== */
.auth-layout {
  max-width: 580px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dev-banner {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 0.88rem;
  color: var(--amber-ink);
}

.dev-code-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--amber-line);
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: 0.2em;
  color: var(--ink);
}

.demo-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-worker-quick {
  background: #e5efdc;
  border-color: #bcd6ab;
  color: #153f32;
}
.btn-worker-quick:hover { background: #d8e8cc; }

.btn-staff-quick {
  background: #e1ebfa;
  border-color: #b7cef0;
  color: #1b345c;
}
.btn-staff-quick:hover { background: #d2e2f7; }

.emergency-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.emergency-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==================== CATEGORY ICON CARDS ==================== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 9px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: var(--white);
  min-height: 132px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.cat-card:hover {
  border-color: var(--brand-mid);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.cat-card.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(21, 63, 50, 0.1);
}

.icon-tile {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-tile svg.ic {
  width: 22px;
  height: 22px;
}

.cat-tone-training { background: #dff1e8; color: #165d41; }
.cat-tone-payroll { background: #f9eccb; color: #835608; }
.cat-tone-employment { background: #e1ecfa; color: #204a7d; }
.cat-tone-wellbeing { background: #f2e2f7; color: #672d7a; }
.cat-tone-safety { background: #fce2df; color: #a32318; }
.cat-tone-other { background: #e3f1ef; color: #1d5a54; }

.cat-card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

.cat-card p {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ==================== LAYOUT HELPERS ==================== */
.narrow-shell { max-width: 780px; margin-inline: auto; }
.med-shell { max-width: 880px; margin-inline: auto; }
.empty-shell { max-width: 560px; margin-inline: auto; }
.center-actions { justify-content: center; margin-top: 14px; }
.mb-12 { margin-bottom: 12px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4 { margin-bottom: 4px; }
.sub-title { font-size: 1.55rem; }
.panel-heading { font-size: 1.1rem; }
.sub-heading { font-size: 0.98rem; }
.divider-line { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.reply-actions { align-items: center; }
.compact-select { width: auto; min-width: 210px; }
.end-field { justify-content: flex-end; }
.error-note { color: var(--red-ink); font-size: 0.84rem; }

/* ==================== LIVE PILL & PREVIEW ==================== */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 750;
  background: rgba(223, 245, 229, 0.2);
  border: 1px solid rgba(164, 232, 184, 0.45);
  color: #d6f7df;
}
.live-pill.is-offline {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #6ee799;
  box-shadow: 0 0 0 3px rgba(110, 231, 153, 0.25);
}
.live-pill.is-offline .live-dot {
  background: #b5c0cf;
  box-shadow: none;
}

.reply-preview {
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--paper);
  border-left: 3px solid var(--brand-mid);
  border-radius: 6px;
  padding: 7px 11px;
  line-height: 1.42;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.reply-preview.is-staff-reply {
  background: var(--staff-msg-bg);
  border-left-color: #244b85;
}
.reply-preview.is-worker-reply {
  background: var(--worker-msg-bg);
  border-left-color: #1f6d4a;
}
.reply-preview.is-internal-preview {
  background: var(--amber-bg);
  border-left-color: #b7791f;
  color: var(--amber-ink);
}
.flex-center {
  display: flex;
  justify-content: center;
}
.reply-preview strong {
  color: var(--ink);
}

.email-details summary {
  cursor: pointer;
  color: var(--brand-mid);
  font-weight: 600;
  font-size: 0.84rem;
  padding: 4px 0;
}
.email-preview-pre {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 440px;
}

.install-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 14px;
}
.install-step-list {
  margin-top: 10px;
  padding-inline-start: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
}

.test-mail-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.test-mail-row .input {
  flex: 1 1 240px;
}

/* ==================== PRIVACY BOX & FILE PICKER ==================== */
.privacy-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
  background: var(--paper);
  cursor: pointer;
  min-height: 54px;
}

.privacy-box:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.privacy-box input[type='checkbox'] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--brand);
}

.privacy-box-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.92rem;
}

.privacy-box-text small {
  color: var(--muted);
  font-size: 0.84rem;
}

.file-drop {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-drop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
}

.file-chip-meta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== STAT CARDS & FILTERS ==================== */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-height: 68px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--white);
  text-align: left;
  transition: border-color 0.14s ease, background-color 0.14s ease, transform 0.1s ease;
}

.stat-pill:hover {
  border-color: var(--brand-mid);
  transform: translateY(-1px);
}

.stat-pill.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 2px rgba(27, 52, 92, 0.08);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-open { background: #dff2e4; color: #156235; }
.stat-icon-waiting { background: var(--amber-bg); color: var(--amber-ink); }
.stat-icon-unassigned { background: #fce6e2; color: #a02a1d; }
.stat-icon-closed { background: #e8edf2; color: #46586e; }
.stat-icon-all { background: var(--brand-soft); color: var(--brand); }

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.stat-num {
  font-size: 1.45rem;
  font-weight: 750;
  line-height: 1.05;
  color: var(--ink);
}

.stat-label {
  font-size: 0.81rem;
  color: var(--muted);
  font-weight: 600;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* ==================== TICKET LIST CARDS ==================== */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-row {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
}

.ticket-row:hover {
  border-color: var(--brand-mid);
  box-shadow: 0 5px 18px rgba(21, 45, 70, 0.09);
  transform: translateY(-1px);
}

.ticket-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-num {
  font-weight: 750;
  font-size: 0.86rem;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.ticket-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.ticket-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-open {
  background: #dff2e4;
  color: #14532d;
}

.badge-waiting {
  background: var(--amber-bg);
  color: var(--amber-ink);
}

.badge-closed {
  background: #e9ecee;
  color: #465460;
}

.badge-worker-role {
  background: #daf0d4;
  color: #14532d;
}

.badge-staff-role {
  background: #dbe7fa;
  color: #1b3b6f;
}

.badge-internal {
  background: var(--amber-bg);
  color: var(--amber-ink);
  border: 1px solid var(--amber-line);
}

/* ==================== TICKET DETAIL & THREAD ==================== */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 18px;
  align-items: start;
}

.detail-grid.is-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 820px;
  margin-inline: auto;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.detail-header h1 {
  font-family: var(--heading);
  font-weight: 400;
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  margin-top: 6px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.fact-item strong {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 3px;
}
.fact-item span {
  display: block;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.msg {
  padding: 15px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--white);
}

/* Distinct Worker (Orchard Green) vs Staff/Admin (Navy) vs Internal Note (Amber) */
.msg-worker {
  background: var(--worker-msg-bg);
  border-color: var(--worker-msg-border);
  border-left: 4px solid #1e6b4a;
}

.msg-staff {
  background: var(--staff-msg-bg);
  border-color: var(--staff-msg-border);
  border-left: 4px solid #1f3c6e;
}

.msg-internal {
  background: var(--amber-bg);
  border-color: var(--amber-line);
  border-left: 4px solid #b7791f;
}

.msg-system {
  background: transparent;
  border: none;
  padding: 4px 10px;
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
}

.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 0.86rem;
}

.msg-author {
  font-weight: 700;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-avatar-worker { background: var(--worker-avatar-bg); color: var(--worker-avatar-ink); }
.msg-avatar-staff { background: var(--staff-avatar-bg); color: var(--staff-avatar-ink); }
.msg-avatar-internal { background: #fae4ad; color: var(--amber-ink); }

.msg-time {
  color: var(--muted);
  font-size: 0.8rem;
}

.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.96rem;
  line-height: 1.55;
}

.att-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.att-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--white);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.att-link:hover {
  border-color: var(--brand);
  background: var(--paper);
}

.att-thumb {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line);
}

.att-purged {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px dashed var(--line-strong);
  background: var(--paper);
  font-size: 0.84rem;
  color: var(--ink);
}

.att-purged-name {
  font-weight: 600;
}

.att-purged-note {
  color: var(--muted);
  font-weight: 500;
}

/* ==================== COMPOSER MODE TABS ==================== */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--white);
  font-weight: 650;
  font-size: 0.88rem;
}

.mode-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--white);
}

.mode-tab.is-active-internal {
  background: var(--amber-ink);
  border-color: var(--amber-ink);
  color: var(--white);
}

/* ==================== TABLES & EMPTY STATES ==================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--paper);
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
}

.empty-state h2,
.empty-state h3 {
  color: var(--ink);
  margin-bottom: 8px;
}

/* ==================== FOOTER ==================== */
.site-foot {
  background: var(--white);
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.foot-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-block: 14px;
  font-size: 0.88rem;
}

.foot-brand {
  font-weight: 700;
  color: var(--ink);
}

.foot-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.foot-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  font-weight: 600;
}

.foot-emergency {
  color: var(--red-ink);
  font-weight: 750;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 860px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .filter-bar {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .wrap {
    width: calc(100% - 24px);
  }
  .head-bar {
    min-height: 62px;
    gap: 8px;
  }
  .brand img {
    width: 90px;
  }
  .brand-badge {
    font-size: 0.78rem;
    padding: 5px 10px;
  }
  .hero-card {
    padding: 20px 18px;
  }
  .card {
    padding: 16px;
  }
  .field-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .category-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.filing-ref-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filing-ref-row .input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-filing {
  background: #edf2f8;
  color: #1b345c;
  border: 1px solid #d4deee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #d97706;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.badge-verified {
  background: #e2f3ea;
  color: #14533c;
  border: 1px solid #b9e2ce;
  font-weight: 600;
}

.badge-unverified {
  background: #fef3c7;
  color: #854d0e;
  border: 1px solid #fde68a;
  font-weight: 600;
}

.verified-id-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 12px;
  background: #eef7f2;
  border: 1px solid #cce6d8;
  color: #153f32;
  font-size: 0.9rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.guide-step-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border-radius: 16px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e7e2);
}

.guide-step-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  flex: 0 0 auto;
}

.guide-step-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.guide-step-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.55;
}

.guide-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.55;
}

.video-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(21, 63, 50, 0.08), rgba(27, 52, 92, 0.07));
  border: 1px dashed var(--brand-mid, #24583f);
}

.tutorial-player-card {
  display: grid;
  gap: 14px;
}

.tutorial-player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tutorial-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  background: #0f1d18;
  border: 1px solid var(--line, #dbe3de);
  box-shadow: 0 10px 28px rgba(15, 36, 28, 0.12);
  display: block;
}

.pending-list {
  display: grid;
  gap: 14px;
}

.pending-card {
  padding: 18px;
  border-radius: 14px;
  border: 1px solid #e6d5b2;
  background: #fffcf5;
  display: grid;
  gap: 12px;
}

.pending-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.match-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eaf2fc;
  border: 1px solid #c3d9f5;
  color: #16335b;
  font-size: 0.9rem;
}

.worker-approve-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto;
  gap: 8px;
  align-items: end;
}

.worker-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.csv-box {
  display: grid;
  gap: 12px;
}

.csv-summary {
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef7f2;
  border: 1px solid #c6e2d3;
  font-size: 0.9rem;
}

/* ==================== SIGNUDOC DOCUMENT ACKNOWLEDGMENTS ==================== */
.doc-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: var(--amber-ink);
}

.doc-scope-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.doc-scope-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}

.doc-scope-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.worker-picker-box {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.worker-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.worker-picker-list {
  max-height: 240px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  padding-right: 4px;
}

.worker-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.9rem;
}

.worker-picker-item:hover {
  background: var(--paper);
}

.worker-picker-item:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand-soft-border);
}

.doc-card-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.doc-card {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--white);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.doc-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.doc-card-top > div {
  min-width: 0;
  max-width: 100%;
}

.doc-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-doc-completed {
  background: #e2f3ea;
  color: #14533c;
  border: 1px solid #b9e2ce;
  font-weight: 600;
}

.badge-doc-viewed {
  background: #e7f0fb;
  color: #1b4372;
  border: 1px solid #c3d9f5;
  font-weight: 600;
}

.badge-doc-sent {
  background: #fff6e0;
  color: #724b08;
  border: 1px solid #e9c97a;
  font-weight: 600;
}

.badge-doc-queued {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

.badge-doc-attention {
  background: #fdf0ee;
  color: #992218;
  border: 1px solid #eab8b0;
  font-weight: 600;
}

.badge-doc-voided {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
  font-weight: 600;
}

.doc-card-title {
  margin-top: 8px;
}

.worker-picker-search {
  flex: 1;
  min-width: 220px;
}

.doc-resend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.doc-cat-select {
  max-width: 220px;
}

.guide-step-card-wide {
  grid-column: 1 / -1;
}

.att-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.att-delivery-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.25;
}

.att-delivery-pill.is-awaiting {
  background: #e7f0fb;
  color: #1b4372;
  border: 1px solid #c3d9f5;
}

.att-delivery-pill.is-failed {
  background: #fdf0ee;
  color: #992218;
  border: 1px solid #eab8b0;
}

.att-delivery-pill.is-pending {
  background: #fff6e0;
  color: #724b08;
  border: 1px solid #e9c97a;
}

.att-confirm-bar {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.att-confirm-copy {
  flex: 1 1 240px;
  min-width: 0;
}

/* Mobile overflow guardrails (320px / 390px viewports) */
.card,
.card-stack > *,
.callout,
.callout > div,
.msg,
.msg-body,
.ticket-card,
.ticket-main,
.stat-pill,
.stat-body,
.fact-item,
.doc-banner,
.guide-step-card,
code {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.btn {
  max-width: 100%;
  text-align: center;
}

@media (max-width: 440px) {
  .stat-pill {
    padding: 10px;
    gap: 8px;
  }
  .stat-label {
    font-size: 0.78rem;
  }
  .nav-btn {
    padding: 8px 11px;
    font-size: 0.85rem;
  }
  .brand-badge {
    max-width: 100%;
    white-space: normal;
  }
}

@media (max-width: 780px) {
  .guide-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .worker-approve-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
