/* Metis admin. Product register: hairlines and tints, one neutral family, status colors only for state. */
:root {
  --hue: 260;
  --gray-0: oklch(100% 0 0);
  --gray-50: oklch(98.4% 0.002 var(--hue));
  --gray-100: oklch(96.5% 0.003 var(--hue));
  --gray-200: oklch(92.5% 0.004 var(--hue));
  --gray-300: oklch(87% 0.005 var(--hue));
  --gray-400: oklch(71% 0.008 var(--hue));
  --gray-500: oklch(55% 0.01 var(--hue));
  --gray-600: oklch(45% 0.01 var(--hue));
  --gray-700: oklch(35% 0.008 var(--hue));
  --gray-800: oklch(26% 0.006 var(--hue));
  --gray-900: oklch(20% 0.005 var(--hue));

  --bg: var(--gray-0);
  --sidebar-bg: var(--gray-50);
  --surface: var(--gray-0);
  --surface-sunken: var(--gray-100);
  --hover: var(--gray-100);
  --selected: var(--gray-100);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-muted: var(--gray-600);
  --text-subtle: var(--gray-500);
  --primary: var(--gray-900);
  --primary-hover: var(--gray-700);
  --on-primary: var(--gray-0);
  --focus-ring: oklch(60% 0.15 250);
  --success: oklch(62% 0.15 150);
  --success-text: oklch(45% 0.12 150);
  --warning: oklch(75% 0.15 75);
  --warning-text: oklch(50% 0.12 70);
  --danger: oklch(58% 0.19 25);
  --danger-text: oklch(50% 0.18 25);
  --danger-soft: oklch(96.5% 0.02 25);
  --info-soft: oklch(96.5% 0.02 250);

  --font-sans: "Inter", "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.625rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 999px;
  --shadow-overlay:
    0 1px 2px oklch(20% 0.01 var(--hue) / 0.06), 0 12px 32px oklch(20% 0.01 var(--hue) / 0.16);

  --control-h-sm: 30px;
  --control-h: 36px;
  --control-h-lg: 44px;
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --content-max: 1200px;

  --dur-fast: 120ms;
  --dur: 180ms;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: oklch(17% 0.005 var(--hue));
  --sidebar-bg: oklch(19.5% 0.005 var(--hue));
  --surface: oklch(19.5% 0.005 var(--hue));
  --surface-sunken: oklch(23% 0.006 var(--hue));
  --hover: oklch(25% 0.006 var(--hue));
  --selected: oklch(27% 0.006 var(--hue));
  --border: oklch(28% 0.006 var(--hue));
  --border-strong: oklch(35% 0.007 var(--hue));
  --text: oklch(95% 0.003 var(--hue));
  --text-muted: oklch(74% 0.006 var(--hue));
  --text-subtle: oklch(64% 0.008 var(--hue));
  --primary: oklch(95% 0.003 var(--hue));
  --primary-hover: oklch(85% 0.004 var(--hue));
  --on-primary: oklch(18% 0.005 var(--hue));
  --success-text: oklch(78% 0.13 150);
  --warning-text: oklch(82% 0.12 80);
  --danger-text: oklch(75% 0.15 25);
  --danger-soft: oklch(26% 0.04 25);
  --info-soft: oklch(26% 0.03 250);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font: var(--weight-regular) var(--text-base) / var(--leading-normal) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
}
code,
.mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- App shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100%;
}
.shell.collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}
.shell.collapsed .sidebar {
  visibility: hidden;
}
/* The column (background, border) spans the whole page; its content stays pinned to the viewport. */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  min-width: 0;
}
.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3) var(--space-4);
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-3);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: var(--on-primary);
}
.brand-mark .icon {
  width: 17px;
  height: 17px;
}
.brand-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}
.workspace-switch {
  margin: 0 var(--space-1) var(--space-2);
}
.workspace-switch select {
  width: 100%;
}
.nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.nav-group {
  margin: var(--space-4) var(--space-3) var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-subtle);
}
.nav-group:first-child {
  margin-top: var(--space-1);
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-md);
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.nav a:hover {
  background: var(--hover);
  color: var(--text);
}
.nav a[aria-current="page"] {
  background: var(--selected);
  color: var(--text);
  font-weight: var(--weight-medium);
}
.nav .count {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 var(--space-2);
}
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.theme-switch {
  margin: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.theme-switch button {
  display: grid;
  place-items: center;
  height: 32px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-switch button[aria-pressed="true"] {
  background: var(--surface-sunken);
  color: var(--text);
}
.user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2);
  min-width: 0;
}
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.user-text {
  min-width: 0;
}
.user-name,
.user-mail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-name {
  font-weight: var(--weight-medium);
}
.user-mail {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.sign-out {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-md);
}
.sign-out:hover {
  background: var(--hover);
  color: var(--text);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--space-7);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar .divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  color: var(--text-muted);
  min-width: 0;
}
.crumbs .current {
  color: var(--text);
  font-weight: var(--weight-medium);
}
.crumbs .icon {
  width: 14px;
  height: 14px;
}
.topbar .tag {
  margin-left: auto;
}
.content:focus {
  outline: none;
}
.content {
  width: 100%;
  max-width: var(--content-max);
  padding: var(--space-7) var(--space-7) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  line-height: var(--leading-tight);
}
.page-sub {
  margin-top: var(--space-3);
  font-size: var(--text-md);
  color: var(--text-muted);
}
.actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h-lg);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}
.btn:hover {
  background: var(--hover);
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn.danger {
  color: var(--danger-text);
}
.btn.sm {
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  font-size: var(--text-base);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.busy {
  cursor: progress;
  opacity: 0.7;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
input[type="text"],
input[type="search"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-base);
}
textarea {
  min-height: 96px;
  resize: vertical;
  line-height: var(--leading-normal);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}
input:hover,
select:hover,
textarea:hover {
  border-color: var(--gray-400);
}
label.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--weight-regular);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.form-grid .wide {
  grid-column: 1 / -1;
}
.checks {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
}
.checks label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.toolbar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.toolbar input[type="search"] {
  flex: 1 1 280px;
  min-height: var(--control-h-lg);
}
.toolbar select {
  width: auto;
  min-height: var(--control-h-lg);
}

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
a.stat:hover {
  border-color: var(--border-strong);
}
.stat-label {
  font-size: var(--text-base);
  color: var(--text-muted);
}
.stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.stat-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- Section cards ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.card-sub {
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-base);
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  min-width: 0;
  text-align: left;
}
button.tile {
  cursor: pointer;
  font: inherit;
  color: inherit;
}
button.tile:hover {
  border-color: var(--border-strong);
}
.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}
.tile-title {
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}
.tile-sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.tile-meta {
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 24px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--gray-400);
}
.pill.ok::before {
  background: var(--success);
}
.pill.ok {
  color: var(--text);
}
.pill.warn::before {
  background: var(--warning);
}
.pill.warn {
  color: var(--text);
}
.pill.bad::before {
  background: var(--danger);
}
.pill.plain::before {
  display: none;
}
.chips {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.empty {
  padding: var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}
.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--info-soft);
  font-size: var(--text-base);
}
.notice.error {
  background: var(--danger-soft);
  color: var(--danger-text);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
th,
td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  font-size: var(--text-sm);
  background: var(--surface-sunken);
}
tr:last-child td {
  border-bottom: 0;
}

/* ---------- Review ---------- */
.review {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.queue {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.queue .tile[aria-current="true"] {
  border-color: var(--text);
}
/* Two columns: each scrolls on its own, so the selected change is always in view next to its list. */
.review > .queue-col {
  position: sticky;
  top: calc(var(--topbar-h) + var(--space-4));
  max-height: calc(100vh - var(--topbar-h) - var(--space-8));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.queue-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 2px;
}
.compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
.compare > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  min-width: 0;
}
.compare h4 {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.compare .proposed {
  background: var(--surface-sunken);
}
.doc-title {
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}
pre.doc {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.list li {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
}
.list pre {
  margin: var(--space-2) 0 0;
  white-space: pre-wrap;
  font-family: var(--font-sans);
  color: var(--text-muted);
}
.section-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

/* ---------- Dialog ---------- */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
}
dialog::backdrop {
  background: oklch(20% 0.01 var(--hue) / 0.35);
}
dialog form,
dialog .dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}
dialog h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.secret {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.secret code {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  overflow-wrap: anywhere;
}

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(420px, calc(100vw - 40px));
}
.toast {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  font-size: var(--text-base);
}
.toast.error {
  border-color: var(--danger);
  color: var(--danger-text);
}

/* ---------- Auth and onboarding ---------- */
.center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--sidebar-bg);
}
.auth-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-7);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}
.auth-card .brand {
  padding: 0;
}
.auth-card form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.footer-note {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-subtle);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .review {
    grid-template-columns: 1fr;
  }
  .review > .queue-col {
    position: static;
    max-height: none;
    overflow: visible;
  }
}
@media (max-width: 860px) {
  .shell,
  .shell.collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 30;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease-out);
    visibility: hidden;
  }
  .shell.open .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-overlay);
  }
  .topbar,
  .content {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .compare,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .topbar .tag {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---------- Native controls, restyled ---------- */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}
select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6f78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  cursor: pointer;
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9adb5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
/* Chrome's customizable select: the open list follows the panel's look too; other browsers keep theirs. */
@supports (appearance: base-select) {
  select,
  ::picker(select) {
    appearance: base-select;
  }
  select::picker-icon {
    display: none;
  }
  ::picker(select) {
    margin-top: var(--space-1);
    padding: var(--space-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-overlay);
  }
  select option {
    min-height: var(--control-h);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
  }
  select option:hover,
  select option:focus-visible {
    background: var(--hover);
    outline: none;
  }
  select option:checked {
    font-weight: var(--weight-medium);
  }
  select option::checkmark {
    order: 1;
    margin-left: auto;
  }
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  text-align: center;
  font-weight: var(--weight-regular);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.dropzone:hover,
.dropzone.dragging {
  border-color: var(--text-muted);
  background: var(--hover);
}
.dropzone.has-file {
  border-style: solid;
  border-color: var(--text);
}
.dropzone:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.dropzone .icon {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
}
.dz-title {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text);
  overflow-wrap: anywhere;
}
/* The real input stays focusable and validatable, just invisible over the zone. */
.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---------- Extraction runs ---------- */
.compare.runs {
  align-items: start;
}
.run-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.run-col .list li {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.pill.about {
  font-size: var(--text-xs);
}
.review-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.review-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}
.toolbar .field {
  flex: 1 1 260px;
}

/* ---------- Spaces, directory, settings ---------- */
.parties {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-sm);
}
.parties li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}
.party-text {
  min-width: 0;
}
.btn.ghost {
  border-color: transparent;
  color: var(--text-muted);
}
.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 720px;
}

/* ---------- Date field ---------- */
.datefield {
  position: relative;
  display: flex;
  align-items: center;
}
.datefield .date-text {
  padding-right: calc(var(--control-h) + var(--space-1));
  font-variant-numeric: tabular-nums;
}
.datefield .date-text[aria-invalid="true"] {
  border-color: var(--danger);
}
.date-btn {
  position: absolute;
  right: 3px;
  display: grid;
  place-items: center;
  width: calc(var(--control-h) - 6px);
  height: calc(var(--control-h) - 6px);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.date-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.date-btn svg {
  width: 16px;
  height: 16px;
}
.date-pop {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 280px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
}
.date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.date-title {
  font-weight: var(--weight-medium);
}
.date-nav {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.date-nav:hover {
  background: var(--hover);
  color: var(--text);
}
.date-nav svg {
  width: 16px;
  height: 16px;
}
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.date-dow {
  padding: var(--space-1) 0;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  text-align: center;
}
.date-day {
  height: 34px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.date-day:hover {
  background: var(--hover);
}
.date-day.outside {
  color: var(--text-subtle);
}
.date-day.today {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.date-day[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
}
.date-day:focus-visible,
.date-nav:focus-visible,
.date-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
.date-foot {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* ---------- Review queue: one block per document ---------- */
.review {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}
.review-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.review-toolbar input[type="search"] {
  flex: 1 1 260px;
  width: auto;
}
.review-toolbar select {
  flex: 0 1 220px;
  width: auto;
}
.doclist {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.doc-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.doc-card:hover {
  border-color: var(--border-strong);
}
.doc-card.current {
  border-color: var(--text);
  box-shadow: inset 3px 0 0 var(--primary);
}
.doc-card:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.doc-card-title {
  max-width: 100%;
  overflow: hidden;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-card-meta,
.doc-card-types {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.doc-card-count {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.doc-card .flag {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
}
.doc-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.doc-panel-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.doc-bulk {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
}
.doc-bulk .check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  font-size: var(--text-sm);
}
.prow {
  display: flex;
  align-items: flex-start;
  border-top: 1px solid var(--border);
}
.prow > input[type="checkbox"] {
  flex: none;
  margin: 12px 0 0 var(--space-4);
}
.prow > .result-item {
  flex: 1;
  min-width: 0;
  border-top: 0;
}
.prow > .result-item > summary {
  padding-left: var(--space-2);
}
.prow .result-detail {
  padding-left: var(--space-5);
}
.decide-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.decide-row input {
  flex: 1;
}
.list.compact li {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.flag {
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.flag-sensitive_content,
.flag-conflicting_knowledge {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.flag-outside_project {
  background: var(--info-soft);
  color: var(--text);
}
.type-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-subtle);
}
.type-decision {
  background: oklch(60% 0.15 250);
}
.type-fact {
  background: oklch(62% 0.13 150);
}
.type-observation {
  background: oklch(72% 0.13 75);
}
.type-procedure,
.type-policy {
  background: oklch(58% 0.15 300);
}
.qrow-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---------- Run result: one block, a line per proposal, details on click ---------- */
.run-result {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.result-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.result-section + .result-section {
  border-top: 1px solid var(--border);
}
.result-section-title {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--surface-sunken);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.result-item {
  border-top: 1px solid var(--border);
}
.result-item > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  list-style: none;
  cursor: pointer;
}
.result-item > summary::-webkit-details-marker {
  display: none;
}
.result-item > summary::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-subtle);
  border-bottom: 1.5px solid var(--text-subtle);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.result-item[open] > summary::before {
  transform: rotate(45deg);
}
.result-item > summary:hover {
  background: var(--hover);
}
.result-item > summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.result-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-item[open] .result-title {
  white-space: normal;
  font-weight: var(--weight-medium);
}
.result-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-4) var(--space-4) calc(var(--space-4) + 22px);
}
.result-body {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.result-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  font-size: var(--text-xs);
}
.result-facts dt {
  color: var(--text-muted);
}
.result-facts dd {
  margin: 0;
}
.result-evidence blockquote {
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 2px solid var(--border-strong);
  background: var(--surface-sunken);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.result-evidence blockquote p {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
}
.result-detail .btn {
  align-self: flex-start;
}
.speakers > summary {
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
}
.speakers .list li {
  font-size: var(--text-sm);
}

a.btn {
  text-decoration: none;
}
