:root {
  color-scheme: dark;

  /* Text */
  --ink: #eef3f5;
  --muted: #8fa8a4;
  --subtle: #141e28;

  /* Borders */
  --line: rgba(255, 255, 255, 0.07);
  --border: rgba(20, 184, 166, 0.18);

  /* Brand */
  --brand: #14b8a6;
  --brand-dark: #5eead4;
  --brand-soft: rgba(20, 184, 166, 0.10);
  --brand-glow: rgba(20, 184, 166, 0.22);

  /* Backgrounds */
  --bg: #060a0e;
  --panel: #0d1822;
  --panel-strong: #121f2e;
  --field: #08111c;

  /* Status */
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.13);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.13);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.13);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.13);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.13);

  /* Shadows */
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 14px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.12);
  --shadow-lg: 0 2px 6px rgba(0,0,0,0.4), 0 16px 40px rgba(0,0,0,0.3);

  /* Radii */
  --radius-sm: 4px;
  --radius: 7px;
  --radius-lg: 9px;
  --radius-xl: 12px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t: 160ms var(--ease);
}

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

html {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(20, 184, 166, 0.22); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(20, 184, 166, 0.4); }

::selection { background: rgba(20, 184, 166, 0.28); color: var(--ink); }

body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(20, 184, 166, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 10%, rgba(56, 100, 120, 0.12), transparent),
    radial-gradient(ellipse 100% 60% at 50% 100%, rgba(6, 20, 30, 0.8), transparent),
    linear-gradient(180deg, #050a0d 0%, var(--bg) 50%, #050a0d 100%);
}

a {
  color: var(--brand);
  font-weight: 600;
  transition: color var(--t);
}
a:hover { color: var(--brand-dark); }

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

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(16px, 4vw, 32px);
  height: 62px;
  background: rgba(5, 10, 18, 0.85);
  border-bottom: 1px solid rgba(20, 184, 166, 0.12);
  box-shadow: 0 1px 0 rgba(20, 184, 166, 0.06), 0 8px 32px rgba(0,0,0,0.4);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

/* ─── Brand ───────────────────────────────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  transition: opacity var(--t);
}
.brand:hover { opacity: 0.85; color: var(--ink); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.22), rgba(20, 184, 166, 0.08));
  border: 1px solid rgba(20, 184, 166, 0.28);
  box-shadow: 0 0 16px rgba(20, 184, 166, 0.15), inset 0 1px 0 rgba(255,255,255,0.06);
  overflow: hidden;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-name,
.brand-subtitle { display: block; line-height: 1.05; }
.brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--ink) 60%, var(--brand-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ─── Topbar actions ──────────────────────────────────────────────────────── */
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: 1px solid rgba(20, 184, 166, 0.16);
  border-radius: var(--radius);
  background: rgba(13, 24, 34, 0.8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.user-pill strong,
.user-pill small { display: block; line-height: 1.1; }
.user-pill strong { font-size: 13px; font-weight: 700; }
.user-pill small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: capitalize;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-links a,
.link-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  padding: 8px 12px;
  color: #b8d4d0;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  transition: background var(--t), color var(--t);
}
.nav-links a:hover,
.link-button:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* ─── Page layout ─────────────────────────────────────────────────────────── */
.page {
  width: min(1140px, 100%);
  max-width: 100%;
  overflow-x: clip;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px);
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 62px);
  transition: grid-template-columns 200ms var(--ease);
}
.app-shell.is-sidebar-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar-nav {
  position: sticky;
  top: 62px;
  align-self: start;
  height: calc(100vh - 62px);
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(20, 184, 166, 0.1);
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(8px);
}

.sidebar-nav-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.sidebar-collapse-toggle {
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.sidebar-collapse-toggle::after { display: none; }
.sidebar-collapse-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.side-nav-group {
  display: grid;
  gap: 3px;
  margin-bottom: 24px;
}
.side-nav-group h2 {
  margin: 0 0 6px;
  padding: 0 10px;
  color: rgba(94, 234, 212, 0.5);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.side-nav-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  border-radius: var(--radius);
  padding: 10px 11px;
  color: #b8cec9;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  transition: background var(--t), color var(--t);
  overflow: hidden;
}
.side-nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
  transition: transform 180ms var(--ease);
}
.side-nav-link:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.side-nav-link.is-active {
  background: rgba(20, 184, 166, 0.13);
  color: var(--brand-dark);
  font-weight: 700;
}
.side-nav-link.is-active::before {
  transform: translateY(-50%) scaleY(1);
}

.side-nav-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 160ms var(--ease);
}
.side-nav-link:hover .side-nav-icon {
  transform: scale(1.08);
}

.side-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Collapsed sidebar */
.app-shell.is-sidebar-collapsed .sidebar-nav { padding-inline: 10px; }
.app-shell.is-sidebar-collapsed .sidebar-nav-tools { justify-content: center; }
.app-shell.is-sidebar-collapsed .sidebar-collapse-toggle .side-nav-icon { transform: rotate(180deg); }
.app-shell.is-sidebar-collapsed .side-nav-group { gap: 6px; margin-bottom: 18px; }
.app-shell.is-sidebar-collapsed .side-nav-group h2 {
  height: 8px; margin: 6px 0 2px; padding: 0; overflow: hidden; opacity: 0;
}
.app-shell.is-sidebar-collapsed .side-nav-link {
  justify-content: center;
  padding: 10px;
}
.app-shell.is-sidebar-collapsed .side-nav-label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.app-shell.is-sidebar-collapsed .side-nav-link::before { display: none; }

/* ─── Mobile bottom nav ───────────────────────────────────────────────────── */
.mobile-bottom-nav { display: none; }

/* ─── Wide pages ──────────────────────────────────────────────────────────── */
.page:has(.admin-claims-table),
.page:has(.user-management-table),
.page:has(.task-board) { width: min(1520px, 100%); }

/* ─── Auth ────────────────────────────────────────────────────────────────── */
.auth-shell {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-panel { width: min(420px, 100%); }

/* ─── Page header / hero ──────────────────────────────────────────────────── */
.page-header,
.hero-panel,
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.hero-panel {
  align-items: center;
  padding: clamp(24px, 5vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.1) 0%, rgba(10, 20, 32, 0.9) 52%),
    var(--panel);
  box-shadow: var(--shadow);
}

.page-header h1,
.hero-panel h1,
.auth-panel h1 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.section-header h2,
.panel h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.page-header p,
.section-header p,
.lede,
.hint {
  max-width: 62ch;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── Panel ───────────────────────────────────────────────────────────────── */
.panel,
.document {
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel {
  padding: clamp(16px, 4vw, 24px);
  margin-bottom: 20px;
}
.document {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 40px);
  line-height: 1.75;
}
.document h1,
.document h2,
.document h3 { line-height: 1.2; }
.document h1 { margin-top: 0; }
.document p,
.document li { color: #bdd0cc; }

.sop-content { overflow-wrap: anywhere; }
.sop-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.sop-table-scroll {
  width: 100%;
  margin: 18px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
.sop-table-scroll table { margin: 0; }

.sop-content-html { color: #bdd0cc; }
.sop-content-html,
.sop-content-html * { background-color: transparent !important; }
.sop-content-html * { color: inherit !important; }
.sop-content-html span,
.sop-content-html font { color: inherit !important; }
.sop-content-html a { color: var(--brand) !important; }
.sop-content-html table,
.sop-content-html th,
.sop-content-html td { border-color: var(--line) !important; }

.document table {
  width: 100%;
  table-layout: auto;
  min-width: 0;
  border: 1px solid rgba(20, 184, 166, 0.14);
  border-radius: var(--radius);
  border-collapse: collapse;
}
.document th,
.document td {
  min-width: 140px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.document th:last-child,
.document td:last-child { border-right: 0; }
.document tr:last-child td { border-bottom: 0; }

/* ─── Form layout ─────────────────────────────────────────────────────────── */
.stack,
.grid-form { display: grid; gap: 16px; }
.grid-form { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.settings-list { display: grid; gap: 12px; margin: 0; }
.settings-list div {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.settings-list div:last-child { border-bottom: 0; }
.settings-list dt { color: var(--muted); font-weight: 700; }
.settings-list dd { margin: 0; overflow-wrap: anywhere; }

.identity-list { margin-bottom: 12px; }
.settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.wide { grid-column: 1 / -1; }

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

/* ─── Labels + inputs ─────────────────────────────────────────────────────── */
label {
  display: grid;
  gap: 7px;
  color: #cdddd9;
  font-size: 13.5px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brand-dark) 50%),
    linear-gradient(135deg, var(--brand-dark) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  background-color: var(--field);
}
input:hover,
select:hover,
textarea:hover { border-color: rgba(20, 184, 166, 0.4); }
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(20, 184, 166, 0.25);
  outline-offset: 0;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  accent-color: var(--brand);
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible { outline: none; box-shadow: none; }
input[type="file"] { min-height: auto; }
textarea { min-height: 100px; resize: vertical; }

/* ─── File drop ───────────────────────────────────────────────────────────── */
.file-drop-label { margin-bottom: -4px; }
.file-drop { position: relative; }
.file-drop-input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-drop-zone {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 28px;
  border: 1.5px dashed rgba(20, 184, 166, 0.32);
  border-radius: var(--radius-lg);
  background: rgba(8, 17, 28, 0.6);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.file-drop-zone:hover,
.file-drop-zone.is-dragover,
.file-drop-input:focus-visible + .file-drop-zone {
  border-color: var(--brand);
  background: rgba(20, 184, 166, 0.07);
}

.file-drop-icon {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(20, 184, 166, 0.24);
  border-radius: var(--radius);
  background: rgba(20, 184, 166, 0.10);
  color: var(--brand-dark);
  font-size: 26px;
  line-height: 1;
}
.file-drop-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.file-drop-subtitle {
  max-width: 42ch;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
button,
.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 18px;
  background: linear-gradient(135deg, #1acfbc 0%, #0f9e8c 50%, #0c806e 100%);
  color: #042920;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: filter var(--t), box-shadow var(--t), transform var(--t);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(20,184,166,0.2);
  position: relative;
  overflow: hidden;
}
button::after,
.button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 50%);
  pointer-events: none;
  border-radius: inherit;
}
button:hover,
.button:hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 20px rgba(20, 184, 166, 0.28);
  transform: translateY(-1px);
  color: #042920;
}
button:active,
.button:active { transform: translateY(0); filter: brightness(0.97); }
button:disabled,
.button:disabled { cursor: wait; opacity: 0.65; transform: none; filter: none; }

.button-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(4, 41, 32, 0.3);
  border-top-color: #042920;
  border-radius: 999px;
  animation: spin 0.75s linear infinite;
}
.is-loading .button-spinner { display: inline-block; }

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

.secondary {
  background: rgba(20, 184, 166, 0.12);
  color: var(--brand-dark);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.22);
}
.secondary::after { display: none; }
.secondary:hover {
  background: rgba(20, 184, 166, 0.2);
  color: var(--brand-dark);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.36), 0 0 16px rgba(20, 184, 166, 0.15);
  filter: none;
  transform: translateY(-1px);
}

.danger {
  background: linear-gradient(135deg, #f87171, #dc4545);
  color: #2b0a0a;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.danger:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 16px rgba(248, 113, 113, 0.25);
  color: #2b0a0a;
}

.link-button {
  border: 0;
  background: transparent;
  box-shadow: none;
}
.link-button::after { display: none; }
.link-button:hover { filter: none; transform: none; }

.full-width { width: 100%; }
.muted { color: var(--muted); }

.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form input { min-width: 170px; }

/* ─── Toolbar / actions ───────────────────────────────────────────────────── */
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.bulk-reimbursement-summary {
  margin: -4px 0 18px;
  padding: 16px;
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.09), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow-sm);
}

.bulk-summary-header,
.bulk-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.bulk-summary-header {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.bulk-summary-header strong {
  color: var(--brand);
  font-size: 20px;
  letter-spacing: 0;
  text-transform: none;
}
.bulk-summary-list { display: grid; gap: 8px; }
.bulk-summary-row {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
}
.bulk-summary-row span { color: var(--ink); font-weight: 750; }
.bulk-summary-row strong { color: #e2fff6; }

.compact-field {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.compact-field select { min-height: 36px; padding: 7px 34px 7px 10px; }

.compact-button {
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.actions,
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.toolbar { margin-top: 0; margin-bottom: 20px; }

.chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(20, 184, 166, 0.14);
  border-radius: var(--radius);
  padding: 7px 13px;
  background: rgba(13, 24, 34, 0.7);
  color: #c2d4d0;
  text-decoration: none;
  font-size: 13.5px;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.chip:hover {
  border-color: rgba(20, 184, 166, 0.36);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* ─── Stats cards ─────────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.stats a {
  min-height: 136px;
  display: grid;
  align-content: space-between;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.stats a:hover {
  border-color: rgba(20, 184, 166, 0.3);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(20, 184, 166, 0.2);
  transform: translateY(-2px);
  color: var(--ink);
}
.stats span,
.stats small { color: var(--muted); font-weight: 700; font-size: 13px; }
.stats strong {
  display: block;
  margin: 14px 0 4px;
  color: var(--ink);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid rgba(20, 184, 166, 0.14);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.admin-claims-table-wrap {
  display: block;
  contain: inline-size;
  overflow-x: hidden;
}
.user-management-wrap { overflow-x: visible; }

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}
.user-management-table { min-width: 0; table-layout: auto; }
.user-management-table th,
.user-management-table td { overflow-wrap: anywhere; }
.user-management-table .password-reset-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 380px;
}

.admin-claims-table { width: 100%; min-width: 0; table-layout: fixed; }
.admin-mc-table { min-width: 0; }
.admin-claims-table th,
.admin-claims-table td { padding: 12px 10px; overflow-wrap: anywhere; }
.admin-claims-table th { white-space: normal; }
.admin-claims-table th:first-child,
.admin-claims-table td:first-child { width: 36px; }
.admin-claims-table th:nth-child(2),
.admin-claims-table td:nth-child(2),
.admin-claims-table th:nth-child(3),
.admin-claims-table td:nth-child(3) { width: 64px; white-space: nowrap; }
.admin-claims-table th:nth-child(5),
.admin-claims-table td:nth-child(5),
.admin-claims-table th:nth-child(6),
.admin-claims-table td:nth-child(6),
.admin-claims-table th:nth-child(9),
.admin-claims-table td:nth-child(9),
.admin-claims-table th:nth-child(10),
.admin-claims-table td:nth-child(10) { white-space: normal; }
.admin-claims-table .table-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; max-width: none; }
.admin-claims-table .table-actions .inline-form { flex: 0 0 auto; }
.admin-claims-table .table-actions .compact-button,
.admin-claims-table .table-actions .button {
  width: 100%;
  min-height: 34px;
  height: auto;
  padding-inline: 10px;
  white-space: normal;
}
.admin-claims-table .table-actions .inline-form { min-width: min(100%, 92px); }

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
td { color: #ceddda; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: rgba(20, 184, 166, 0.05); }

.clickable-row,
.selectable-row { cursor: pointer; }
.clickable-row:focus-visible,
.selectable-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.selectable-row:has([data-bulk-claim-checkbox]:checked) { background: rgba(20, 184, 166, 0.08); }
tr:last-child td { border-bottom: 0; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #ccddd9;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-pending-review { background: var(--amber-soft); color: var(--amber); border-color: rgba(251,191,36,0.2); }
.badge-needs-review { background: var(--orange-soft); color: var(--orange); border-color: rgba(251,146,60,0.2); }
.badge-approved { background: var(--green-soft); color: var(--green); border-color: rgba(52,211,153,0.2); }
.badge-pending-payment { background: var(--amber-soft); color: var(--amber); border-color: rgba(251,191,36,0.2); }
.badge-paid { background: var(--green-soft); color: var(--green); border-color: rgba(52,211,153,0.2); }
.badge-rejected { background: var(--red-soft); color: var(--red); border-color: rgba(248,113,113,0.2); }
.badge-sync-failed { background: var(--purple-soft); color: var(--purple); border-color: rgba(167,139,250,0.2); }
.badge-queued,
.badge-running,
.badge-open { background: var(--amber-soft); color: var(--amber); border-color: rgba(251,191,36,0.2); }
.badge-completed,
.badge-renamed,
.badge-done { background: var(--green-soft); color: var(--green); border-color: rgba(52,211,153,0.2); }
.badge-halted-retryable,
.badge-failed,
.badge-cancelled { background: var(--red-soft); color: var(--red); border-color: rgba(248,113,113,0.2); }

/* ─── Section heading ─────────────────────────────────────────────────────── */
.section-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-heading h2 { margin: 0 0 4px; }

/* ─── Drive renamer ───────────────────────────────────────────────────────── */
.drive-rename-meter {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}
.drive-rename-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--green));
  transition: width 200ms ease;
}
.drive-rename-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.drive-rename-stats div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.drive-rename-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.drive-rename-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}
.drive-job-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 18px;
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: rgba(20, 184, 166, 0.07);
}
.drive-job-banner div { display: grid; gap: 4px; min-width: 0; }
.drive-job-banner strong { font-size: 14px; font-weight: 700; }
.drive-job-banner span,
.drive-job-note { color: var(--muted); font-size: 13px; line-height: 1.4; }
.drive-job-note { margin: 4px 0 0; }
.drive-job-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }

.danger-button { border-color: rgba(248, 113, 113, 0.5); color: var(--red); }
.danger-button:hover { border-color: var(--red); background: var(--red-soft); }

.drive-folder-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
}
.drive-folder-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.drive-folder-tools .muted { flex-basis: 100%; margin: 0; }
.drive-folder-picker {
  flex-basis: 100%;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}
.drive-folder-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.drive-folder-row:last-child { border-bottom: 0; }
.drive-folder-name { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }

/* ─── Details list ────────────────────────────────────────────────────────── */
.details {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 0;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid rgba(20, 184, 166, 0.14);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}
dt,
dd {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
dt {
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
dd { margin: 0; color: #d2e0dc; }
dt:nth-last-of-type(1),
dd:nth-last-of-type(1) { border-bottom: 0; }

/* ─── Flash messages ──────────────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-radius: var(--radius);
  margin-bottom: 18px;
  background: rgba(20, 184, 166, 0.09);
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 14px;
}
.flash::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.2);
  font-size: 13px;
}
.flash.error {
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--red-soft);
  color: var(--red);
}
.flash.error::before { content: "✕"; background: rgba(248, 113, 113, 0.2); }

/* ─── Code / pre ──────────────────────────────────────────────────────────── */
pre {
  max-height: 420px;
  white-space: pre-wrap;
  border-radius: var(--radius);
  margin: 0;
  padding: 16px;
  overflow: auto;
  background: rgba(3, 10, 15, 0.9);
  color: #d0ede8;
  line-height: 1.55;
  font-size: 13px;
  border: 1px solid var(--line);
}

/* ─── Claim preview ───────────────────────────────────────────────────────── */
.claim-preview {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #060f18;
}
.claim-preview-image {
  display: block;
  max-height: 720px;
  object-fit: contain;
}
.claim-preview-pdf { min-height: 680px; }
.sop-pdf-preview {
  width: 100%;
  min-height: 78vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

/* ─── Danger zone ─────────────────────────────────────────────────────────── */
.danger-zone {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

/* ─── List ────────────────────────────────────────────────────────────────── */
.list { line-height: 1.9; }

/* ─── SOP grid ────────────────────────────────────────────────────────────── */
.sop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 0;
  list-style: none;
}
.sop-card {
  display: block;
  min-height: 100px;
  padding: 18px;
  color: var(--ink);
  text-decoration: none;
  transition: color var(--t), border-color var(--t), transform var(--t);
}
.sop-card:hover {
  color: var(--brand-dark);
  border-color: rgba(20, 184, 166, 0.3);
  transform: translateY(-2px);
}

/* ─── Quick create / mini form ────────────────────────────────────────────── */
.quick-create,
.mini-form { display: flex; align-items: center; gap: 8px; }
.quick-create { min-width: min(360px, 100%); }
.quick-create input,
.mini-form input { min-width: 0; }

.icon-button { width: 44px; padding: 0; font-size: 22px; line-height: 1; }

/* ─── SOP manager ─────────────────────────────────────────────────────────── */
.sop-manager { display: grid; gap: 14px; }
.sop-tree { display: grid; gap: 10px; padding-left: 28px; list-style: none; }
.root-tree { padding-left: 0; }
.sop-tree-item { position: relative; display: grid; gap: 10px; }

.sop-tree .sop-tree {
  position: relative;
  margin-left: 10px;
  padding-left: 30px;
}
.sop-tree .sop-tree::before {
  content: "";
  position: absolute;
  top: -4px; bottom: 6px; left: 10px;
  width: 1px;
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.3), rgba(20, 184, 166, 0.04));
}
.sop-tree .sop-tree > .sop-tree-item::before {
  content: "";
  position: absolute;
  top: 24px; left: -20px;
  width: 18px; height: 1px;
  background: rgba(20, 184, 166, 0.22);
}

.sop-node {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  padding: 13px 14px;
  border: 1px solid rgba(20, 184, 166, 0.12);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.sop-node:hover { border-color: rgba(20, 184, 166, 0.24); }
.sop-node-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sop-node-main a,
.sop-node-main strong { overflow-wrap: anywhere; }

.sop-toggle,
.sop-toggle-placeholder { width: 28px; height: 28px; flex: 0 0 auto; }
.sop-toggle {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
  transition: background var(--t);
}
.sop-toggle:hover { background: var(--brand-soft); }

.sop-caret {
  display: inline-block;
  width: 7px; height: 7px;
  border-right: 2px solid var(--brand-dark);
  border-bottom: 2px solid var(--brand-dark);
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 150ms var(--ease);
}
.sop-tree-item.is-collapsed > .sop-node .sop-caret { transform: rotate(-45deg) translate(-1px, 1px); }
.sop-tree-item.is-collapsed > .sop-tree { display: none; }

.sop-icon {
  position: relative;
  flex: 0 0 auto;
  width: 26px; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid rgba(20, 184, 166, 0.26);
}
.sop-icon-folder::before {
  content: "";
  position: absolute;
  left: 3px; top: -5px;
  width: 12px; height: 7px;
  border-radius: 5px 5px 0 0;
  background: rgba(20, 184, 166, 0.22);
  border: 1px solid rgba(20, 184, 166, 0.26);
  border-bottom: 0;
}
.sop-file .sop-icon {
  width: 22px; height: 26px;
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
}
.sop-icon-page::before {
  content: "";
  position: absolute;
  right: -1px; top: -1px;
  width: 8px; height: 8px;
  border-left: 1px solid rgba(167, 139, 250, 0.3);
  border-bottom: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 0 var(--radius-sm) 0 3px;
  background: rgba(167, 139, 250, 0.1);
}

.sop-node-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.sop-action-button {
  width: 36px; min-height: 36px;
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  box-shadow: none;
  letter-spacing: 0.12em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: background var(--t), color var(--t);
}
.sop-action-button:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: rgba(20, 184, 166, 0.3); }

.sop-action-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 178px;
  padding: 6px;
  border: 1px solid rgba(20, 184, 166, 0.14);
  border-radius: var(--radius);
  background: #0a1520;
  box-shadow: var(--shadow-lg);
}
.sop-action-menu a,
.sop-action-menu button {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
  color: #ceddda;
  box-shadow: none;
  font-size: 13.5px;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
  transition: background var(--t), color var(--t);
}
.sop-action-menu a:hover,
.sop-action-menu button:hover { background: var(--brand-soft); color: var(--brand-dark); }
.sop-action-menu .menu-danger { color: var(--red); }
.sop-action-menu .menu-danger:hover { background: var(--red-soft); color: var(--red); }

/* ─── Modal / dialog ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(2, 6, 10, 0.75);
  backdrop-filter: blur(6px);
}
.sop-dialog {
  width: min(480px, calc(100vw - 28px));
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: var(--radius-xl);
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.05);
}
.sop-dialog::backdrop { background: rgba(2, 6, 10, 0.75); backdrop-filter: blur(6px); }
.sop-dialog form { padding: 24px; }
.sop-dialog h2 { margin: 0; font-size: 20px; font-weight: 800; }

.dialog-copy { margin: 0; color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.sop-node.drop-target {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2), var(--shadow);
}
.sop-tree-item.dragging { opacity: 0.5; }

/* ─── Document title row ──────────────────────────────────────────────────── */
.document-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.document-title-row h1 { margin-bottom: 20px; }
.editor-textarea {
  min-height: 58vh;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  border: 1.5px dashed rgba(20, 184, 166, 0.22);
  border-radius: var(--radius-lg);
  padding: 28px;
  background: rgba(13, 24, 34, 0.5);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

/* ─── Task board ──────────────────────────────────────────────────────────── */
.task-create-panel {
  display: none;
  max-width: 1140px;
}
.task-create-panel.is-open {
  display: block;
  animation: taskCreateReveal 220ms var(--ease) both;
}
@keyframes taskCreateReveal {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task-create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.task-create-header h2 { margin: 0; }

.task-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.task-column { min-width: 0; display: grid; gap: 12px; }

.task-column-header {
  min-height: 80px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  background: rgba(10, 18, 28, 0.6);
  box-shadow: var(--shadow-sm);
}
.task-column-header h2 { margin: 0 0 4px; font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.task-column-header p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }

.task-count {
  min-width: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  border: 1px solid rgba(20, 184, 166, 0.2);
}

.task-list { display: grid; gap: 12px; min-height: 60px; }

.task-card {
  --task-accent: var(--brand);
  min-width: 0;
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--task-accent) 10%, transparent), transparent 44%),
    var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: visible;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.task-card:hover {
  border-color: rgba(20, 184, 166, 0.22);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.task-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: var(--task-accent);
}
.task-card-manage { --task-accent: var(--red); }
.task-card-prioritise { --task-accent: var(--amber); }
.task-card-reduce { --task-accent: var(--brand-dark); }
.task-card-repository { --task-accent: var(--purple); }

.task-card.is-done {
  opacity: 0.78;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--green) 10%, transparent), transparent 40%),
    rgba(13, 22, 18, 0.7);
}
.task-card.is-menu-open { z-index: 25; }

.task-card-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 30px;
  gap: 10px;
  align-items: start;
}
.task-card-content { min-width: 0; }
.task-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.task-card-head a,
.task-card-title {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: none;
}
.task-card.is-done .task-card-head a,
.task-card.is-done .task-card-title {
  color: #8faaa5;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(143, 170, 165, 0.6);
}

.task-notes,
.task-detail-notes { margin: 0; color: #aabbb7; line-height: 1.5; overflow-wrap: anywhere; }
.task-notes {
  display: -webkit-box;
  margin-top: 6px;
  overflow: hidden;
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.task-notes.is-expanded {
  display: block;
  overflow: visible;
}
.task-notes-toggle {
  all: unset;
  display: inline-block;
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-dark);
  cursor: pointer;
  transition: opacity var(--t);
}
.task-notes-toggle::after { display: none; }
.task-notes-toggle:hover { opacity: 0.75; }

/* ─── Drag and drop ──────────────────────────────────────────────────────── */
.task-card[draggable="true"] { cursor: grab; }
.task-card[draggable="true"]:active { cursor: grabbing; }
.task-card[draggable="true"] button,
.task-card[draggable="true"] a,
.task-card[draggable="true"] input,
.task-card[draggable="true"] label { cursor: pointer; }
.task-card.is-dragging { opacity: 0.3; }
.drop-placeholder {
  height: 60px;
  border: 2px dashed var(--brand-dark);
  border-radius: var(--radius);
  background: rgba(20, 184, 166, 0.05);
  pointer-events: none;
}

/* ─── Overdue ─────────────────────────────────────────────────────────────── */
.badge-overdue { background: var(--red-soft); color: var(--red); border-color: rgba(248,113,113,0.2); }
.task-due-chip.is-overdue { color: var(--red); border-color: rgba(248,113,113,0.3); }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}
.task-meta-chip,
.task-meta span { display: inline-flex; align-items: center; min-height: 22px; }
.task-meta-chip,
.task-due-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.03);
}
.task-due-chip { color: #d4c47a; }

.task-card-footer {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-left: 36px;
}

.task-card-actions,
.task-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.task-status-form { margin: 0; }

.task-status-toggle,
.task-menu-toggle {
  width: 26px; min-width: 26px;
  height: 26px; min-height: 26px;
  display: inline-grid;
  place-items: center;
  border: 1.5px solid color-mix(in srgb, var(--task-accent) 50%, var(--line));
  border-radius: 999px;
  padding: 0;
  background: rgba(10, 18, 28, 0.8);
  color: var(--task-accent);
  font-size: 13px;
  line-height: 1;
  box-shadow: none;
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}
.task-status-toggle:hover {
  border-color: var(--task-accent);
  background: color-mix(in srgb, var(--task-accent) 14%, transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--task-accent) 28%, transparent);
}
.task-card.is-done .task-status-toggle {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.task-status-toggle.is-disabled { opacity: 0.55; }

.task-card-menu-wrap { position: relative; display: flex; justify-content: flex-end; }
.task-menu-toggle {
  background: none;
  border-color: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.task-menu-toggle::after { display: none; }
.task-menu-toggle:hover,
.task-menu-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.task-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: min(210px, 78vw);
  display: grid;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: var(--shadow-lg);
}
.task-menu[hidden] { display: none; }
.task-menu-form { display: contents; }
.task-menu-item {
  min-height: 36px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
  color: #ceddda;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  box-shadow: none;
  transition: background var(--t), color var(--t);
}
.task-menu-item::after { display: none; }
.task-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}
.task-menu-label {
  padding: 7px 10px 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.task-delete-item { color: var(--red); }
.task-delete-item:hover { background: var(--red-soft); color: var(--red); }

/* ─── Avatars ─────────────────────────────────────────────────────────────── */
.avatar-stack { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.avatar-chip {
  width: 30px; height: 30px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1.5px solid rgba(20, 184, 166, 0.28);
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.1);
  color: #d2f5ed;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.personal-chip {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  width: max-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.task-empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1.5px dashed rgba(20, 184, 166, 0.18);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* ─── User picker ─────────────────────────────────────────────────────────── */
.user-picker {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.user-picker legend { padding: 0 6px; color: #cdddd9; font-size: 13.5px; font-weight: 760; }
.user-picker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.user-check {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(10, 18, 28, 0.6);
  color: #ceddda;
  font-size: 13px;
  font-weight: 700;
  transition: border-color var(--t), background var(--t);
}
.user-check:has(input:checked) {
  border-color: rgba(20, 184, 166, 0.3);
  background: rgba(20, 184, 166, 0.07);
}
.user-check span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* ─── Upload / review ─────────────────────────────────────────────────────── */
.upload-panel { max-width: 640px; }
.review-section { width: 100%; max-width: 100%; min-width: 0; margin-top: 24px; }
.review-section + .review-section { margin-top: 36px; }

/* ─── Site health check ────────────────────────────────────────────────────── */
.section-header-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-header-row h2 { margin: 0; }
.health-issues { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.health-issue {
  padding: 12px 14px;
  border-radius: var(--radius);
  border-left: 3px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.health-issue-tls,
.health-issue-server_error,
.health-issue-gemini_flag { border-left-color: rgba(248, 113, 113, 0.6); }
.health-issue-blocked,
.health-issue-bot_challenge { border-left-color: rgba(251, 191, 36, 0.6); }
.health-issue-broken_link,
.health-issue-disappeared { border-left-color: rgba(156, 163, 175, 0.5); }
.health-issue-suspicious_outbound { border-left-color: rgba(248, 113, 113, 0.6); }
.health-issue-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.health-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  white-space: nowrap;
}
.health-url { font-size: 12px; color: var(--ink); word-break: break-all; }
.health-detail { margin: 0 0 4px; font-size: 13px; }
.health-fix { margin: 0; font-size: 13px; color: var(--muted); }
.health-ok { color: var(--green); font-weight: 600; margin-top: 12px; }
.code-block {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-family: monospace;
  font-size: 13px;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink);
}

/* ─── Task edit drawer ────────────────────────────────────────────────────── */
.task-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}
.task-drawer[hidden] { display: none; }

.task-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms var(--ease);
  cursor: pointer;
}
.task-drawer.is-open .task-drawer-backdrop { opacity: 1; pointer-events: auto; }

.task-drawer-panel {
  position: relative;
  width: min(440px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 240ms var(--ease);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.task-drawer.is-open .task-drawer-panel { transform: translateX(0); }

.task-drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.task-drawer-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.task-drawer-close-btn {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.task-drawer-close-btn::after { display: none; }
.task-drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.task-drawer-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.task-drawer-danger {
  padding-top: 16px;
  border-top: 1px solid rgba(248, 113, 113, 0.18);
}

/* ─── Task tabs (mobile pill switcher) ───────────────────────────────────── */
.task-tab-bar { display: none; }

/* ─── Responsive: 1180px ──────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .task-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ─── Responsive: 900px ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { display: block; min-height: auto; }
  .sidebar-nav { display: none; }

  .mobile-bottom-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(20, 184, 166, 0.18);
    border-radius: var(--radius-xl);
    background: rgba(6, 12, 22, 0.96);
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav summary {
    min-height: 52px;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--radius);
    padding: 6px 4px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
    transition: background var(--t), color var(--t);
  }
  .mobile-bottom-nav a svg,
  .mobile-bottom-nav summary svg {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .mobile-bottom-nav summary::-webkit-details-marker { display: none; }
  .mobile-bottom-nav a:hover,
  .mobile-bottom-nav summary:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
  }
  .mobile-bottom-nav .is-active {
    background: rgba(20, 184, 166, 0.14);
    color: var(--brand-dark);
  }

  .mobile-more { position: relative; flex: 1 1 0; min-width: 0; }
  .mobile-more > summary { width: 100%; }

  .mobile-more-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: min(220px, calc(100vw - 28px));
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(20, 184, 166, 0.18);
    border-radius: var(--radius-lg);
    background: #090f1a;
    box-shadow: var(--shadow-lg);
  }
  .mobile-more:not([open]) .mobile-more-panel { display: none; }
  .mobile-more-panel a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    color: #ceddda;
  }
}

/* ─── Responsive: 760px ───────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .topbar { flex-direction: row; align-items: center; }
  .nav-links { width: 100%; justify-content: flex-start; }
  .nav-links a,
  .link-button { flex: 1 1 auto; justify-content: center; }

  .page { padding: 18px 14px 110px; }

  .brand-subtitle,
  .user-pill small { display: none; }
  .topbar-actions { gap: 6px; }
  .user-pill { padding-right: 5px; }
  .user-pill strong { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .page-header,
  .hero-panel,
  .section-header { align-items: stretch; flex-direction: column; }

  .actions .button,
  .page-header .button,
  .hero-panel .button { width: 100%; }

  .stats { grid-template-columns: 1fr 1fr; }
  .task-board { grid-template-columns: 1fr; }
  .task-column-header { min-height: auto; }

  /* Tab bar — underline style */
  .task-tab-bar {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
  }
  .task-tab-bar::-webkit-scrollbar { display: none; }

  .task-tab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: -1px;
    box-shadow: none;
    transition: color var(--t), border-color var(--t);
  }
  .task-tab:hover {
    color: var(--ink);
    background: none;
    transform: none;
    filter: none;
    border-bottom-color: rgba(20, 184, 166, 0.35);
  }
  .task-tab.is-active {
    color: var(--ink);
    border-bottom-color: var(--brand);
  }

  .task-tab-count {
    font-size: 11.5px;
    font-weight: 500;
    color: inherit;
    opacity: 0.6;
    background: none;
    padding: 0;
    min-width: auto;
    height: auto;
    border-radius: 0;
  }
  .task-tab.is-active .task-tab-count {
    background: none;
    color: inherit;
    opacity: 0.7;
  }

  /* Hide non-active quadrant columns; JS sets .is-tab-active on the visible one */
  [data-task-board] [data-task-column]:not(.is-tab-active) { display: none; }
  .task-card-actions,
  .task-detail-actions { align-items: stretch; flex-direction: column; }
  .task-card-actions .inline-form,
  .task-card-actions button,
  .task-card-actions select,
  .task-detail-actions .inline-form,
  .task-detail-actions .button,
  .task-detail-actions button { width: 100%; }

  .details { grid-template-columns: 1fr; }
  dt { border-bottom: 0; padding-bottom: 4px; }
  dd { padding-top: 4px; }

  .grid-form { grid-template-columns: 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }

  .responsive-table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .responsive-table { min-width: 0; }
  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table th,
  .responsive-table td { display: block; width: 100%; }
  .responsive-table thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .responsive-table tbody { display: grid; gap: 14px; }
  .responsive-table tr {
    padding: 14px;
    border: 1px solid rgba(20, 184, 166, 0.14);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
  }
  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(104px, 38%) 1fr;
    gap: 12px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
  }
  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .responsive-table td:first-child { padding-top: 0; }
  .responsive-table td:last-child { padding-bottom: 0; border-bottom: 0; }
  .responsive-table td[data-label="ID"],
  .responsive-table td[data-label="Status"],
  .responsive-table td[data-label="Amount"] { align-items: center; }
  .responsive-table td[data-label="Actions"] {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 12px;
  }
  .responsive-table td[data-label="Actions"]::before { display: none; }
  .responsive-table .table-actions { width: 100%; display: grid; grid-template-columns: 1fr; gap: 8px; }
  .responsive-table .table-actions .inline-form,
  .responsive-table .table-actions .button,
  .responsive-table .table-actions button,
  .responsive-table .table-actions a { width: 100%; }

  .admin-claims-table th:first-child,
  .admin-claims-table td:first-child,
  .admin-claims-table th:nth-child(2),
  .admin-claims-table td:nth-child(2),
  .admin-claims-table th:nth-child(3),
  .admin-claims-table td:nth-child(3) { width: 100%; white-space: normal; }
  .admin-claims-table .table-actions { min-width: 0; max-width: none; }

  .quick-create,
  .mini-form,
  .sop-node,
  .document-title-row { align-items: stretch; flex-direction: column; }
  .sop-node-actions { position: static; align-self: flex-end; }
  .sop-action-menu { right: 0; }
  .sop-node { display: flex; }
  .sop-tree { padding-left: 12px; }
  .sop-tree .sop-tree { margin-left: 2px; padding-left: 20px; }
  .sop-tree .sop-tree::before { left: 7px; }
  .sop-tree .sop-tree > .sop-tree-item::before { left: -13px; width: 12px; }

  .document { padding: 16px; }
  .sop-table-scroll { margin-right: -8px; margin-left: -8px; padding: 0 8px 6px; }

  .document table:not(.sop-table-cardable) {
    width: max-content;
    min-width: 100%;
    max-width: none;
    font-size: 13px;
  }
  .document table:not(.sop-table-cardable) th,
  .document table:not(.sop-table-cardable) td { min-width: 110px; padding: 9px; }

  .document table.sop-table-compact { width: 100%; min-width: 100%; }
  .document table.sop-table-has-media th,
  .document table.sop-table-has-media td { min-width: 160px; }
  .document table.sop-table-has-media img { max-width: min(260px, 72vw); height: auto; }

  .document table.sop-table-cardable,
  .document table.sop-table-cardable thead,
  .document table.sop-table-cardable tbody,
  .document table.sop-table-cardable tr,
  .document table.sop-table-cardable th,
  .document table.sop-table-cardable td { display: block; }
  .document table.sop-table-cardable { border: 0; background: transparent; }
  .document table.sop-table-cardable thead {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .document table.sop-table-cardable tbody { display: grid; gap: 14px; }
  .document table.sop-table-cardable tr {
    border: 1px solid rgba(20, 184, 166, 0.14);
    border-radius: var(--radius-lg);
    background: rgba(13, 24, 34, 0.82);
    overflow: hidden;
  }
  .document table.sop-table-cardable td {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(110px, 38%) 1fr;
    gap: 12px;
    border-right: 0;
    padding: 12px;
  }
  .document table.sop-table-cardable td::before {
    content: attr(data-label);
    color: var(--brand);
    font-size: 11.5px;
    font-weight: 800;
    line-height: 1.35;
    text-transform: uppercase;
  }
  .document table.sop-table-cardable tr:last-child td { border-bottom: 1px solid var(--line); }
  .document table.sop-table-cardable tr td:last-child { border-bottom: 0; }

  .mini-form button,
  .quick-create button,
  .dialog-actions button { width: 100%; }

  .stats { grid-template-columns: 1fr; }
}

/* ─── Safe area insets (notched phones) ───────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav {
    bottom: max(10px, calc(env(safe-area-inset-bottom) + 6px));
  }
  @media (max-width: 760px) {
    .page { padding-bottom: max(110px, calc(env(safe-area-inset-bottom) + 100px)); }
  }
}

/* ─── AI Editor ───────────────────────────────────────────────────────────── */
.ai-mode-toggle-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.ai-mode-toggle {
  all: unset;
  box-sizing: border-box;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px;
  width: 132px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  isolation: isolate;
  transition: border-color var(--t), opacity var(--t);
}
.ai-mode-toggle::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 2);
  border-radius: 999px;
  background: var(--brand);
  transform: translateX(0);
  transition: transform 220ms var(--ease), background 220ms var(--ease);
}
.ai-mode-toggle::after { display: none; }
.ai-mode-toggle .ai-mode-review,
.ai-mode-toggle .ai-mode-auto {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 3px 0;
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
  transition: color 180ms var(--ease);
}
.ai-mode-toggle:not(.is-auto) .ai-mode-review { color: #000; }
.ai-mode-toggle.is-auto::before { background: var(--amber); transform: translateX(100%); }
.ai-mode-toggle.is-auto .ai-mode-auto { color: #000; }
.ai-mode-toggle:hover { border-color: var(--brand); }
.ai-mode-toggle:disabled { cursor: wait; opacity: .72; }

/* Layout */
.ai-editor-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 4px;
}
@media (max-width: 900px) {
  .ai-editor-layout { grid-template-columns: 1fr; }
}

/* Sources panel */
.ai-sources-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: sticky;
  top: 80px;
}
.ai-sources-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ai-sources-header h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-source-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--brand-soft, rgba(96,165,250,.15));
  color: var(--brand, #60a5fa);
  font-size: 10px;
  font-weight: 700;
}
.ai-source-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.ai-source-cb {
  appearance: checkbox;
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--brand);
  margin: 0;
  flex-shrink: 0;
  align-self: center;
}
.ai-source-item {
  display: grid;
  grid-template-columns: 16px 18px 1fr auto 20px;
  gap: 5px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12.5px;
  transition: background var(--t);
}
.ai-source-item:has(.ai-source-cb:checked) { background: var(--brand-soft, rgba(96,165,250,.06)); }
.ai-source-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-source-ocr { display: flex; align-items: center; justify-content: center; }
.ai-source-ocr[hidden] { display: none; }
.ocr-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: .02em;
  line-height: 1;
}
.ocr-badge.is-done    { background: rgba(52,211,153,.2);  color: var(--green); }
.ocr-badge.is-failed  { background: rgba(248,113,113,.2); color: var(--red); }
.ocr-badge.is-pending {
  background: rgba(251,191,36,.2);
  color: #92610a;
  animation: ocr-pulse 1s ease-in-out infinite;
}
@keyframes ocr-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.ai-source-remove {
  all: unset;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t), background var(--t);
}
.ai-source-remove::after { display: none; }
.ai-source-remove:hover { color: var(--red); background: var(--red-soft); }
.ai-source-picker { margin-bottom: 10px; }
.ai-source-picker[hidden] { display: none; }
/* Selection bar — 2×2 grid so buttons never get cut off */
.ai-source-selbar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2, rgba(255,255,255,.05));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
}
.ai-source-selbar[hidden] { display: none; }
.ai-selbar-selectall { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.ai-selbar-selectall input { accent-color: var(--brand); margin: 0; }
.ai-selbar-count { grid-column: 2; grid-row: 1; color: var(--muted); align-self: center; text-align: right; }
#ai-remove-selected { grid-column: 1; grid-row: 2; }
#ai-remove-all     { grid-column: 2; grid-row: 2; }
.button.small { font-size: 11px; padding: 4px 10px; }
.button.danger { background: rgba(248,113,113,.15); color: var(--red); border-color: rgba(248,113,113,.3); }
.button.danger:hover { background: rgba(248,113,113,.25); }
/* Clickable row cursor */
.ai-source-item { cursor: pointer; }
.ai-source-remove, button.ocr-badge { cursor: pointer; }
/* Reset native button styles on OCR retry badge */
button.ocr-badge {
  appearance: none;
  border: none;
  font-family: inherit;
  line-height: inherit;
}
button.ocr-badge.is-failed:hover { filter: brightness(1.2); }
/* OCR progress bar above chat */
.ai-ocr-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(251,191,36,.1);
  border-top: 1px solid rgba(251,191,36,.25);
  font-size: 12px;
  color: #92610a;
}
.ai-ocr-progress[hidden] { display: none; }
.ai-ocr-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(146,97,10,.3);
  border-top-color: #92610a;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Chat panel */
.ai-chat-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 500px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ai-chat-history {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  min-height: 340px;
}

/* Messages */
.ai-message { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.ai-message-meta { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ai-message.is-user .ai-message-meta { text-align: right; color: var(--brand-dark); }
.ai-message-content {
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-message.is-user .ai-message-content {
  background: rgba(20, 184, 166, 0.08);
  border-color: rgba(20, 184, 166, 0.2);
  align-self: flex-end;
  max-width: 86%;
}
.ai-message.is-assistant .ai-message-content { max-width: 96%; }

/* Diff panel */
.ai-diff-panel {
  margin-top: 8px;
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ai-diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(20, 184, 166, 0.07);
  border-bottom: 1px solid rgba(20, 184, 166, 0.15);
  font-size: 12.5px;
  font-weight: 700;
  gap: 8px;
}
.ai-diff-actions { display: flex; gap: 8px; }
.ai-diff-actions .button,
.ai-diff-actions .secondary {
  font-size: 12px;
  padding: 5px 12px;
  min-height: 28px;
}
.ai-changes-list { list-style: none; margin: 0; padding: 8px; display: grid; gap: 6px; }
.ai-change {
  padding: 9px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12.5px;
  display: grid;
  gap: 6px;
}
.ai-change-desc { font-weight: 700; color: var(--ink); }
.ai-change-diff {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-family: monospace;
}
.ai-diff-del {
  background: rgba(248,113,113,.15);
  color: var(--red);
  text-decoration: line-through;
  padding: 1px 4px;
  border-radius: 3px;
  word-break: break-all;
}
.ai-diff-ins {
  background: rgba(52,211,153,.15);
  color: var(--green);
  padding: 1px 4px;
  border-radius: 3px;
  word-break: break-all;
}
.ai-diff-arrow { color: var(--muted); flex-shrink: 0; }
.ai-cell-ref {
  font-family: monospace;
  font-size: 11px;
  background: rgba(167,139,250,.12);
  color: var(--purple);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.ai-row-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.ai-row-cell {
  background: rgba(52,211,153,.12);
  color: var(--green);
  border: 1px solid rgba(52,211,153,.25);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11.5px;
}
.ai-highlight-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,.1);
}
.ai-highlight-chip[data-color="yellow"] { background: rgba(251,191,36,.25); color: #92610a; }
.ai-highlight-chip[data-color="green"]  { background: rgba(52,211,153,.2);  color: var(--green); }
.ai-highlight-chip[data-color="red"]    { background: rgba(248,113,113,.2); color: var(--red); }
.ai-highlight-chip[data-color="blue"]   { background: rgba(96,165,250,.2);  color: #2563eb; }
.ai-highlight-chip[data-color="orange"] { background: rgba(251,146,60,.2);  color: #c2410c; }
.ai-highlight-chip[data-color="purple"] { background: rgba(167,139,250,.2); color: var(--purple); }
.ai-highlight-chip[data-color="clear"]  { background: rgba(255,255,255,.1); color: var(--muted); }
.ai-applied-badge {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(52,211,153,.25);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 700;
}

/* Chat input */
.ai-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  resize: none;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  padding: 9px 13px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color var(--t);
}
.ai-chat-input:focus { outline: none; border-color: var(--brand); }
.ai-chat-send {
  all: unset;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #000;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--t), transform var(--t);
}
.ai-chat-send::after { display: none; }
.ai-chat-send:hover { opacity: .85; transform: scale(1.05); }
.ai-chat-send:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* AI file picker rows (used in AI editor and drive renamer) */
.ai-file-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t);
  font-size: 13.5px;
}
.ai-file-row.has-action { grid-template-columns: 20px 1fr auto; }
.ai-file-row.is-selectable-source { grid-template-columns: 18px 20px 1fr; }
.ai-file-row:last-child { border-bottom: 0; }
.ai-file-row:hover { background: rgba(255,255,255,.04); }
.ai-file-row.is-selected {
  background: rgba(20,184,166,.08);
  box-shadow: inset 3px 0 0 var(--brand);
}
.ai-file-row.is-folder { cursor: default; }
.ai-file-row.is-folder:hover { background: rgba(255,255,255,.02); }
.ai-file-icon { font-size: 14px; line-height: 1; }
.ai-file-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.ai-file-row.is-folder .ai-file-name { font-weight: 400; color: var(--muted); }
.ai-source-check {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.ai-source-batch-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(20,184,166,.15);
  background: rgba(20,184,166,.04);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}
.ai-source-batch-bar[hidden] { display: none; }
.ai-source-batch-add {
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  box-shadow: none;
  white-space: nowrap;
}
.ai-file-nav-arrow { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.ai-file-folder-add {
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  box-shadow: none;
  white-space: nowrap;
}
.drive-select-current {
  background: rgba(20,184,166,.04);
  border-bottom: 1px solid rgba(20,184,166,.15);
  font-weight: 700;
}
.drive-select-current:hover { background: rgba(20,184,166,.08); }

/* Loading indicator in chat */
.ai-message-loading .ai-message-content {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 16px;
}
.ai-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: aiDotBounce 1.2s infinite ease-in-out;
}
.ai-loading-dot:nth-child(1) { animation-delay: 0s; }
.ai-loading-dot:nth-child(2) { animation-delay: .2s; }
.ai-loading-dot:nth-child(3) { animation-delay: .4s; }
@keyframes aiDotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Context meter */
.ai-context-meter {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--t);
}
.ai-context-meter.is-warn { color: var(--amber); }
.ai-context-meter.is-over { color: var(--red); }
.ai-context-label { font-weight: 400; }

.ai-context-warn-banner {
  padding: 8px 16px;
  background: rgba(251,191,36,.08);
  border-top: 1px solid rgba(251,191,36,.22);
  color: var(--amber);
  font-size: 12.5px;
  font-weight: 600;
}
.ai-context-warn-banner.is-over {
  background: var(--red-soft);
  border-color: rgba(248,113,113,.22);
  color: var(--red);
}
