/* Director's Dashboard — Indigen West Brand System
   Typography: IM Fell English SC (headings), DM Sans (UI)
   Palette: Terracotta #983C29 primary, Near-white #FCF9F3 surfaces
   No em dashes, no en dashes, no "AI" language in UI */

/* ─── Fonts ───────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IM+Fell+English+SC&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ─── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  text-size-adjust: none;
}

/* ─── Design Tokens ───────────────────────────────────────────────── */
:root, [data-theme="light"] {
  --font-display: 'IM Fell English SC', Georgia, serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'DM Mono', 'Consolas', monospace;

  /* Type scale (capped at --text-xl for web app) */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.8125rem);
  --text-sm:   clamp(0.8125rem, 0.78rem + 0.2vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-lg:   clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  --text-xl:   clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);

  /* 4px spacing system */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Indigen palette — Light */
  --color-bg:              #FCF9F3;
  --color-surface:         #FFFFFF;
  --color-surface-2:       #F8F5EF;
  --color-surface-offset:  #F2EDE4;
  --color-border:          #E0D8CC;
  --color-divider:         #EAE4DA;

  --color-text:            #2C2417;
  --color-text-muted:      #7A7168;
  --color-text-faint:      #B0A89D;

  --color-primary:         #983C29;
  --color-primary-hover:   #7D3122;
  --color-primary-active:  #62261A;
  --color-primary-bg:      rgba(152, 60, 41, 0.08);

  --color-success:         #3D7A3E;
  --color-success-bg:      rgba(61, 122, 62, 0.08);
  --color-warning:         #B8860B;
  --color-warning-bg:      rgba(184, 134, 11, 0.08);
  --color-error:           #B33A3A;
  --color-error-bg:        rgba(179, 58, 58, 0.08);
  --color-info:            #2E6B8A;
  --color-info-bg:         rgba(46, 107, 138, 0.08);

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(44, 36, 23, 0.06);
  --shadow-md: 0 2px 8px rgba(44, 36, 23, 0.08);
  --shadow-lg: 0 8px 24px rgba(44, 36, 23, 0.1);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --color-bg:              #1A1816;
  --color-surface:         #222019;
  --color-surface-2:       #2A2720;
  --color-surface-offset:  #1E1C18;
  --color-border:          #3D3930;
  --color-divider:         #332F28;

  --color-text:            #D9D2C8;
  --color-text-muted:      #8E867C;
  --color-text-faint:      #5E574E;

  --color-primary:         #C9694F;
  --color-primary-hover:   #D88068;
  --color-primary-active:  #A75740;
  --color-primary-bg:      rgba(201, 105, 79, 0.12);

  --color-success:         #5FAA60;
  --color-success-bg:      rgba(95, 170, 96, 0.12);
  --color-warning:         #D4A017;
  --color-warning-bg:      rgba(212, 160, 23, 0.12);
  --color-error:           #D05555;
  --color-error-bg:        rgba(208, 85, 85, 0.12);
  --color-info:            #5A9CBF;
  --color-info-bg:         rgba(90, 156, 191, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:              #1A1816;
    --color-surface:         #222019;
    --color-surface-2:       #2A2720;
    --color-surface-offset:  #1E1C18;
    --color-border:          #3D3930;
    --color-divider:         #332F28;
    --color-text:            #D9D2C8;
    --color-text-muted:      #8E867C;
    --color-text-faint:      #5E574E;
    --color-primary:         #C9694F;
    --color-primary-hover:   #D88068;
    --color-primary-active:  #A75740;
    --color-primary-bg:      rgba(201, 105, 79, 0.12);
    --color-success:         #5FAA60;
    --color-success-bg:      rgba(95, 170, 96, 0.12);
    --color-warning:         #D4A017;
    --color-warning-bg:      rgba(212, 160, 23, 0.12);
    --color-error:           #D05555;
    --color-error-bg:        rgba(208, 85, 85, 0.12);
    --color-info:            #5A9CBF;
    --color-info-bg:         rgba(90, 156, 191, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* ─── Base ─────────────────────────────────────────────────────────── */
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
input, textarea, select { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }

::selection {
  background: var(--color-primary-bg);
  color: var(--color-text);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Shell ────────────────────────────────────────────────────────── */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ─── Top Bar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-brand h1 {
  font-size: var(--text-lg);
  color: var(--color-text);
  white-space: nowrap;
}

.topbar-brand .brand-mark {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

.client-selector {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  min-width: 160px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

/* ─── Navigation Tabs ──────────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.nav-tab:hover {
  color: var(--color-text);
}
.nav-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ─── Main Content ─────────────────────────────────────────────────── */
.main {
  flex: 1;
  padding: var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.section {
  display: none;
}
.section.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.section-header h2 {
  font-size: var(--text-xl);
  color: var(--color-text);
}

/* ─── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  transition: box-shadow var(--transition-fast);
}
.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.card-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.card-body p {
  max-width: 72ch;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

/* ─── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  line-height: 1;
  white-space: nowrap;
}

.badge-active, .badge-new   { background: var(--color-info-bg);    color: var(--color-info); }
.badge-reviewed              { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-approved              { background: var(--color-success-bg); color: var(--color-success); }
.badge-dismissed             { background: var(--color-error-bg);   color: var(--color-error); }
.badge-draft                 { background: var(--color-info-bg);    color: var(--color-info); }
.badge-edited                { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-sent                  { background: var(--color-success-bg); color: var(--color-success); }
.badge-archived              { background: var(--color-surface-2);  color: var(--color-text-faint); }
.badge-paused                { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-score {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* ─── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-active); }

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-offset); }

.btn-ghost {
  color: var(--color-text-muted);
}
.btn-ghost:hover { color: var(--color-text); background: var(--color-surface-2); }

.btn-danger {
  color: var(--color-error);
}
.btn-danger:hover { background: var(--color-error-bg); }

.btn-success {
  color: var(--color-success);
}
.btn-success:hover { background: var(--color-success-bg); }

.btn-sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* ─── Filter Bar ───────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.filter-bar select,
.filter-bar input {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  min-width: 100px;
}

.filter-bar input[type="range"] {
  width: 100px;
  min-width: auto;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── Tables ───────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

.data-table thead {
  background: var(--color-surface-2);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--color-surface-2);
}

/* ─── Forms / Inputs ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

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

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.4;
  margin-bottom: var(--space-2);
  max-width: 60ch;
}

/* ─── Field visibility indicators ─────────────────────────────────── */
.field-visibility {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  line-height: 1;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  margin-left: var(--space-2);
  vertical-align: middle;
}

.field-visibility--dispatch {
  color: var(--color-primary);
  background: var(--color-primary-bg);
}

.field-visibility--private {
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
}

.field-visibility--private svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Private notes field styling */
.form-textarea--private {
  background: var(--color-surface-2);
  border-style: dashed;
}

.form-textarea--private:focus {
  border-style: solid;
}

/* ─── URL auto-fill ───────────────────────────────────────────────── */
.url-autofill-group {
  position: relative;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.url-autofill-group .form-input {
  padding-right: 3rem;
}

.url-autofill-status {
  font-size: var(--text-xs);
  margin-top: var(--space-2);
  line-height: 1.4;
}

.url-autofill-status--loading {
  color: var(--color-primary);
}

.url-autofill-status--error {
  color: var(--color-danger);
}

.url-autofill-status--success {
  color: var(--color-success, #3D8B37);
}

@keyframes spin-subtle {
  to { transform: rotate(360deg); }
}

.url-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin-subtle 0.8s linear infinite;
  vertical-align: middle;
  margin-right: var(--space-1);
}

/* ─── Status Indicators ────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.ok      { background: var(--color-success); }
.status-dot.warning { background: var(--color-warning); }
.status-dot.error   { background: var(--color-error); }

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.stat-card .stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text);
}

.stat-card .stat-sub {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* ─── Empty State ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-faint);
}

.empty-state p {
  max-width: 40ch;
  margin: 0 auto;
}

/* ─── Score bar ────────────────────────────────────────────────────── */
.score-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.score-fill {
  width: 40px;
  height: 4px;
  background: var(--color-surface-offset);
  border-radius: 2px;
  overflow: hidden;
}

.score-fill-inner {
  height: 100%;
  border-radius: 2px;
  background: var(--color-primary);
}

/* ─── Expandable / Accordion ───────────────────────────────────────── */
.expandable-content {
  display: none;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-4);
}
.expandable-content.open {
  display: block;
}

/* ─── Modal / Dialog ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: calc(100% - var(--space-8));
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto;
  padding: var(--space-6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.modal-header h3 {
  font-size: var(--text-lg);
}

/* ─── Toast ────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  max-width: 320px;
  animation: toast-in 200ms ease-out;
}

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-error); }
.toast.info    { border-left: 3px solid var(--color-info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Skeleton loader ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--color-surface-2) 25%,
    var(--color-surface-offset) 50%,
    var(--color-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-2);
}
.skeleton-line:last-child { width: 60%; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Tabs (inline, for sub-sections) ──────────────────────────────── */
.sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: var(--space-5);
}

.sub-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.sub-tab:hover { color: var(--color-text); }
.sub-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.sub-panel {
  display: none;
}
.sub-panel.active {
  display: block;
}

/* ─── Diff View ────────────────────────────────────────────────────── */
.diff-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.diff-pane {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-pane-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

/* ─── Annotation input ─────────────────────────────────────────────── */
.annotation-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.annotation-row input {
  flex: 1;
}

/* ─── Bulk action bar ──────────────────────────────────────────────── */
.bulk-bar {
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}
.bulk-bar.visible {
  display: flex;
}
.bulk-bar .count {
  font-weight: 600;
  color: var(--color-primary);
}

/* ─── Footer ───────────────────────────────────────────────────────── */
.site-footer {
  padding: var(--space-4) var(--space-6);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-divider);
}
.site-footer a {
  color: var(--color-text-faint);
}
.site-footer a:hover {
  color: var(--color-text-muted);
}

/* ─── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar {
    padding: var(--space-2) var(--space-4);
  }
  .topbar-brand h1 {
    font-size: var(--text-base);
  }
  .nav-tabs {
    padding: 0 var(--space-4);
  }
  .nav-tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }
  .main {
    padding: var(--space-4);
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    flex-wrap: wrap;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .diff-view {
    grid-template-columns: 1fr;
  }
  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .card-actions .btn {
    justify-content: center;
  }
}

/* ─── Legend (collapsible help) ─────────────────────────────────────── */
.legend {
  margin-bottom: var(--space-5);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.legend summary {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
}

.legend summary::-webkit-details-marker { display: none; }

.legend summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--color-text-faint);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
}

.legend[open] summary::before {
  transform: rotate(90deg);
}

.legend summary:hover {
  color: var(--color-text);
}

.legend-body {
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-divider);
}

.legend-body dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.legend-body dt {
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  padding-top: var(--space-1);
}

.legend-body dd {
  color: var(--color-text-muted);
  padding-top: var(--space-1);
  max-width: 60ch;
}

@media (max-width: 768px) {
  .legend-body dl {
    grid-template-columns: 1fr;
    gap: var(--space-1) 0;
  }
  .legend-body dt {
    margin-top: var(--space-2);
  }
}

/* ─── Utility ──────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.hidden { display: none; }
