/* CaptureNow portal styles */
:root {
  color-scheme: light;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e7eaee;
  --surface: #ffffff;
  --surface-subtle: #f9fafb;
  --surface-muted: #f2f4f7;
  --surface-hover: #f9fafb;
  --canvas: #f6f7f9;
  --sidebar: #fcfcfd;
  --control: #ffffff;
  --control-border: #d0d5dd;
  --track: #eef1f4;
  --navy: #0f2a44;
  --teal: #0e9384;
  --teal-dark: #0f766e;
  --teal-label: #125d56;
  --teal-soft: #f0fdf9;
  --amber: #dc6803;
  --danger: #d92d20;
  --on-danger: #ffffff;
  --focus: #0e9384;
  --positive: #067647;
  --positive-surface: #ecfdf3;
  --positive-border: #abefc6;
  --warning-text: #b54708;
  --warning-surface: #fffaeb;
  --warning-border: #fedf89;
  --danger-surface: #fef3f2;
  --danger-border: #fecdca;
  --danger-label: #b42318;
  --danger-label-surface: #fee4e2;
  --changed-text: #b54708;
  --info-text: #175cd3;
  --info-surface: #eff8ff;
  --shadow-xs: 0 1px 2px rgba(16,24,40,.05);
  --shadow-card: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.03);
  --shadow-hero: 0 1px 3px rgba(16,24,40,.06);
  --shadow-dialog: 0 24px 64px -12px rgba(16,24,40,.28);
  --radius: 14px;
  --radius-sm: 9px;
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8edf2;
  --ink-2: #c5ced8;
  --muted: #93a1af;
  --faint: #62707d;
  --line: #222c35;
  --surface: #121920;
  --surface-subtle: #161e26;
  --surface-muted: #1b242d;
  --surface-hover: #172029;
  --canvas: #0c1116;
  --sidebar: #0e141a;
  --control: #0f161c;
  --control-border: #33414d;
  --track: #212b35;
  --navy: #0d2233;
  --teal: #2ed3b7;
  --teal-dark: #15b79e;
  --teal-label: #5fe9d0;
  --teal-soft: rgba(46,211,183,.1);
  --amber: #fdb022;
  --danger: #f97066;
  --on-danger: #1f0b09;
  --focus: #2ed3b7;
  --positive: #47cd89;
  --positive-surface: rgba(71,205,137,.1);
  --positive-border: rgba(71,205,137,.3);
  --warning-text: #fdb022;
  --warning-surface: rgba(253,176,34,.09);
  --warning-border: rgba(253,176,34,.3);
  --danger-surface: rgba(249,112,102,.09);
  --danger-border: rgba(249,112,102,.32);
  --danger-label: #fda29b;
  --danger-label-surface: rgba(249,112,102,.14);
  --changed-text: #fdb022;
  --info-text: #84caff;
  --info-surface: rgba(46,144,250,.12);
  --shadow-xs: none;
  --shadow-card: 0 0 0 1px rgba(255,255,255,.015);
  --shadow-hero: none;
  --shadow-dialog: 0 28px 80px -12px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html { color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; scroll-padding-top: 76px; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.5; transition: color 180ms ease-out, background-color 180ms ease-out; }
button, input, select, textarea { font: inherit; }
svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: color-mix(in srgb, var(--teal) 24%, transparent); }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 9px 12px; color: white; background: var(--teal-dark); border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
h1, h2, h3, h4 { color: var(--ink); }
h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
h3 { margin: 8px 0; font-size: 14px; font-weight: 650; }
.muted, .dropzone small { color: var(--muted); }
code, pre { font-family: var(--mono); }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.sidebar .brand { padding: 2px 8px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff; font-size: 15px; font-weight: 750; background: linear-gradient(145deg, #15b79e, #0f766e); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 1px 2px rgba(15,118,110,.35); }
.workspace-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 14px 10px 6px; color: var(--faint); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.nav-label:first-child { margin-top: 0; }
.workspace-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--ink-2); border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 550; text-decoration: none; transition: background-color 120ms, color 120ms; }
.workspace-nav a svg { color: var(--faint); transition: color 120ms; }
.workspace-nav a:hover { color: var(--ink); background: var(--surface-muted); }
.workspace-nav a.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-card), 0 0 0 1px var(--line); }
.workspace-nav a.active svg { color: var(--teal); }
.workspace-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.sidebar-foot { margin-top: auto; }
.app-main { min-width: 0; display: flex; flex-direction: column; }

.topbar { position: sticky; top: 0; z-index: 20; min-height: 60px; padding: 10px clamp(20px, 3vw, 40px); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--ink); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--canvas) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.session-summary { display: flex; align-items: center; gap: 12px; min-width: 0; }
.session-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.session-user > div { display: grid; min-width: 0; text-align: left; line-height: 1.3; }
.session-user strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-summary small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; color: var(--teal-label); font-size: 13px; font-weight: 700; background: var(--teal-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--teal) 25%, transparent); }
.workspace-switch { display: grid; gap: 3px; color: var(--muted); font-size: 10.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.workspace-switch select { min-width: 180px; min-height: 34px; padding-block: 5px; color: var(--ink); background: var(--control); font-size: 13px; letter-spacing: 0; text-transform: none; }
.badge.role { color: var(--teal-label); background: var(--teal-soft); text-transform: capitalize; }

/* ---------- Auth ---------- */
.auth-shell { position: relative; min-height: 100vh; padding: 24px; display: grid; place-items: center; overflow: hidden; background: var(--canvas); }
.auth-shell::before { content: ""; position: absolute; inset: -20% -10% auto; height: 70%; background: radial-gradient(600px 300px at 30% 40%, color-mix(in srgb, var(--teal) 16%, transparent), transparent 70%), radial-gradient(500px 280px at 75% 30%, color-mix(in srgb, #2e90fa 12%, transparent), transparent 70%); pointer-events: none; }
.auth-shell::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 50% 35%, #000 10%, transparent 65%); -webkit-mask-image: radial-gradient(ellipse at 50% 35%, #000 10%, transparent 65%); opacity: .6; pointer-events: none; }
.auth-card { position: relative; z-index: 1; width: min(420px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-dialog); }
.auth-brand { margin-bottom: 28px; color: var(--ink); }
.auth-card h1 { margin: 4px 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
.auth-card .stack-form { margin-top: 22px; padding-top: 0; border-top: 0; gap: 14px; }
.auth-card .button.primary { min-height: 42px; margin-top: 4px; }
.local-hint { margin: 18px 0 0; padding: 10px 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 9px; background: var(--surface-subtle); font-size: 12px; }

/* ---------- Theme toggle ---------- */
.theme-toggle { min-height: 36px; padding: 6px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-xs); transition: color 150ms, background-color 150ms, border-color 150ms, transform 80ms; }
.theme-toggle:hover { color: var(--ink); border-color: var(--control-border); background: var(--surface-subtle); }
.theme-toggle:active { transform: scale(.97); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-icon { width: 16px; font-size: 15px; line-height: 1; text-align: center; }
.auth-theme-toggle { position: absolute; top: 18px; right: 18px; }
.sidebar-theme-toggle { width: 100%; justify-content: flex-start; }

/* ---------- Page ---------- */
main { width: min(1400px, calc(100% - 2 * clamp(20px, 3vw, 40px))); margin: 0 auto 64px; }
.hero { margin: 28px 0 22px; padding: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; color: var(--ink); }
.hero h1 { margin: 2px 0 8px; font-size: clamp(24px, 2.4vw, 30px); font-weight: 700; line-height: 1.15; letter-spacing: -.03em; }
.hero p:last-child { max-width: 700px; margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: var(--teal-label); font-weight: 650; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; }
.pipeline { display: flex; flex: none; align-items: center; gap: 0; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-xs); }
.pipeline span { position: relative; padding: 5px 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.pipeline span + span::before { content: ""; position: absolute; left: -3px; top: 50%; width: 6px; height: 6px; border-top: 1.5px solid var(--faint); border-right: 1.5px solid var(--faint); transform: translateY(-50%) rotate(45deg); }
.pipeline span:first-child { color: var(--teal-label); }

.status-pill, .step-label { padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--positive); border: 1px solid var(--positive-border); background: var(--positive-surface); }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.status-pill.error { color: var(--danger-label); border-color: var(--danger-border); background: var(--danger-surface); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metrics article { position: relative; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.metrics span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.metrics strong { display: block; margin-top: 8px; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metrics:not(.compact-metrics) article:first-child::after { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--teal), #2e90fa); }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.two-columns { grid-template-columns: 1.08fr .92fr; }
.panel { padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-heading .eyebrow { font-size: 11px; }

/* Platform admin */
#platformAdminPanel { margin-bottom: 18px; }
.workspace-admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.workspace-admin-card { padding: 14px 16px; display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
.workspace-admin-card.current { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: var(--teal-soft); }
.workspace-admin-card header { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.workspace-admin-card small { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.workspace-admin-card p { margin: 0; color: var(--muted); font-size: 12.5px; }
.workspace-admin-card .button, .workspace-admin-card > .badge { justify-self: start; }
.workspace-create-form { margin-top: 18px; padding-top: 16px; display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; border-top: 1px solid var(--line); }
.workspace-create-form h3, .workspace-create-form .form-status { grid-column: 1 / -1; }
.workspace-create-form h3 { margin: 0 0 2px; }

/* ---------- Upload ---------- */
.step-label { color: var(--teal-label); background: var(--teal-soft); }
.dropzone { position: relative; min-height: 190px; padding: 28px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; border: 1.5px dashed var(--control-border); border-radius: 12px; cursor: pointer; background: var(--surface-subtle); transition: border-color 180ms, background-color 180ms; }
.dropzone:hover { border-color: var(--teal); background: var(--teal-soft); }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.dropzone strong { font-weight: 600; }
.dropzone small { font-size: 12.5px; }
.upload-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; color: var(--teal-label); border-radius: 12px; font-size: 20px; font-weight: 700; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.upload-panel .button { width: 100%; margin-top: 12px; }

/* ---------- Buttons ---------- */
.button { min-height: 38px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: transform 80ms, background-color 150ms, border-color 150ms, color 150ms, box-shadow 150ms, opacity 150ms; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { color: white; background: var(--teal-dark); box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,.14); }
.button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--teal-dark) 86%, black); }
:root[data-theme="dark"] .button.primary { color: #03201c; }
:root[data-theme="dark"] .button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--teal-dark) 85%, white); }
.button.secondary { color: var(--ink-2); border-color: var(--control-border); background: var(--control); box-shadow: var(--shadow-xs); }
.button.secondary:hover:not(:disabled) { color: var(--ink); background: var(--surface-subtle); }
.button.danger { color: var(--on-danger); background: var(--danger); }
.button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, black); }
.button.danger-outline { color: var(--danger-label); border-color: var(--danger-border); background: var(--control); }
.button.danger-outline:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-surface); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .dropzone:focus-visible, .table-wrap:focus-visible, .queue-item:focus { outline: 2px solid var(--focus); outline-offset: 2px; }

.form-status { min-height: 20px; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.form-status:empty { min-height: 0; margin: 0; }
.form-status.error { color: var(--danger-label); }
.form-status.success { color: var(--positive); font-weight: 600; }

/* ---------- Upload queue ---------- */
.upload-queue { display: grid; gap: 8px; margin-top: 12px; }
.upload-queue:empty { margin: 0; }
.queue-item { padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-size: 12.5px; box-shadow: var(--shadow-xs); }
.queue-item.processing { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: var(--teal-soft); }
.queue-item.complete { border-color: var(--positive-border); background: var(--positive-surface); }
.queue-item.failed { border-color: var(--danger-border); background: var(--danger-surface); }
.queue-copy { min-width: 0; display: grid; gap: 2px; }
.queue-copy strong, .queue-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-status { color: var(--ink); font-weight: 600; }
.queue-detail { color: var(--muted); font-variant-numeric: tabular-nums; }
.queue-state { align-self: start; padding: 3px 9px; color: var(--teal-label); border-radius: 999px; background: color-mix(in srgb, var(--teal) 14%, var(--surface)); font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-item.failed .queue-state { color: var(--danger-label); background: var(--danger-label-surface); }
.queue-item progress { grid-column: 1 / -1; width: 100%; height: 6px; appearance: none; border: 0; border-radius: 99px; overflow: hidden; background: var(--track); accent-color: var(--teal); }
.queue-item progress::-webkit-progress-bar { background: var(--track); border-radius: 99px; }
.queue-item progress::-webkit-progress-value { background: linear-gradient(90deg, var(--teal), #2e90fa); border-radius: 99px; transition: width 300ms ease; }
.queue-item progress::-moz-progress-bar { background: linear-gradient(90deg, var(--teal), #2e90fa); border-radius: 99px; }
.queue-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; }
.queue-actions .button { width: auto; margin: 0; }

/* ---------- Charts ---------- */
.category-chart { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 84px; gap: 12px; align-items: center; font-size: 13px; }
.bar-row > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); text-transform: capitalize; }
.bar-track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--track); }
.bar { height: 100%; min-width: 4px; border-radius: inherit; background: linear-gradient(90deg, var(--teal), color-mix(in srgb, var(--teal) 55%, #2e90fa)); transition: width 400ms ease; }
.bar-value { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
.filters input, .filters select { min-width: 0; width: 100%; }
.filters label, .workspace-create-form label, .report-filters label, .approval-rule-form label { display: grid; gap: 5px; color: var(--ink-2); font-size: 12.5px; font-weight: 550; }
input, select, textarea { min-height: 38px; padding: 8px 11px; color: var(--ink); border: 1px solid var(--control-border); border-radius: 8px; background: var(--control); box-shadow: var(--shadow-xs); transition: border-color 150ms, box-shadow 150ms; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input[type="checkbox"] { width: 17px; height: 17px; min-height: 0; padding: 0; accent-color: var(--teal-dark); box-shadow: none; cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; line-height: 1.5; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; padding: 10px 12px; color: var(--muted); text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--surface-subtle); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 100ms; }
tbody tr:hover { background: var(--surface-hover); }
td:first-child, th:first-child { padding-left: 16px; }
td:last-child, th:last-child { padding-right: 16px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions .button { min-height: 32px; padding: 5px 10px; font-size: 12.5px; }
.empty { padding: 40px 28px; color: var(--muted); text-align: center; }
td code { display: inline-block; max-width: 420px; overflow-wrap: anywhere; color: var(--muted); font-size: 11.5px; white-space: normal; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; color: var(--ink-2); background: var(--surface-muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.processing, .badge.queued { color: var(--info-text); background: var(--info-surface); }
.badge.processing::before, .badge.queued::before { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: currentColor; content: ""; animation: status-pulse 1.4s ease-in-out infinite; }
.badge.queued { color: var(--muted); background: var(--surface-muted); }
.badge.processed, .badge.approved { color: var(--positive); background: var(--positive-surface); }
.badge.processed::before, .badge.approved::before, .badge.review_required::before, .badge.failed::before, .badge.rejected::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge.review_required { color: var(--warning-text); background: var(--warning-surface); }
.badge.failed, .badge.rejected { color: var(--danger-label); background: var(--danger-surface); }
.confidence-cell { min-width: 112px; display: grid; gap: 3px; font-variant-numeric: tabular-nums; }
.confidence-cell span { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.confidence-cell b { min-width: 39px; display: inline-block; color: var(--ink); font-weight: 650; }

/* ---------- Members & settings ---------- */
.members { display: grid; gap: 8px; }
.member { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); }
.member small { color: var(--muted); }
.member-meta { text-align: right; }
.invitation { border-style: dashed; background: transparent; }
.optional { color: var(--faint); font-weight: 400; }
.stack-form { display: grid; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.stack-form h3 { margin: 0; }
.stack-form label { display: grid; gap: 5px; color: var(--ink-2); font-size: 12.5px; font-weight: 550; }
.settings-divider { margin-top: 8px; padding-top: 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-top: 1px solid var(--line); }
.settings-divider small { color: var(--muted); font-size: 12px; }
.provider-fields { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); }
.provider-fields p { margin: 0; font-size: 12.5px; }
.provider-fields .model-fineprint { line-height: 1.55; }
.check-row { display: flex !important; align-items: center; gap: 9px !important; color: var(--ink) !important; font-weight: 500 !important; cursor: pointer; }
.check-row input { min-height: 0; }

/* ---------- Review dialog ---------- */
dialog { width: min(1200px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-dialog); }
dialog[open] { animation: dialog-in 180ms ease-out; }
dialog::backdrop { background: rgba(10,15,22,.55); backdrop-filter: blur(4px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.review-shell { padding: 0; }
.dialog-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 18px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 20px; line-height: 1; background: var(--surface); transition: background-color 120ms, color 120ms; }
.icon-button:hover { color: var(--ink); background: var(--surface-muted); }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); gap: 24px; padding: 20px 24px 24px; }
.original-pane, .fields-pane { min-width: 0; }
.original-pane { position: sticky; top: 90px; align-self: start; }
.pane-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pane-heading h3 { margin: 0; }
.original-preview { min-height: 620px; margin-top: 12px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 16px 16px; }
.original-preview img { max-width: 100%; max-height: 72vh; object-fit: contain; box-shadow: 0 8px 24px rgba(16,24,40,.12); }
.original-preview iframe { width: 100%; min-height: 620px; border: 0; background: white; }
.review-reasons { margin: 10px 0 14px; padding: 12px 14px; color: var(--warning-text); border: 1px solid var(--warning-border); border-radius: 11px; background: var(--warning-surface); font-size: 13px; }
.review-reasons ul { margin: 6px 0 0; padding-left: 20px; }
.review-reasons.valid { color: var(--positive); border-color: var(--positive-border); background: var(--positive-surface); }
.confidence-summary { margin: 12px 0 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.confidence-metric { padding: 12px 14px; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); }
.confidence-metric span { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.confidence-metric strong { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.confidence-metric small { color: var(--muted); line-height: 1.35; }
.integrity-panel { margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); }
.integrity-panel p { margin: 3px 0 10px; color: var(--muted); font-size: 12.5px; }
.integrity-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.integrity-value { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12.5px; }
.integrity-value span { display: block; color: var(--muted); text-transform: capitalize; }
.integrity-value strong { display: inline-block; margin-top: 2px; font-variant-numeric: tabular-nums; }
.integrity-value.changed { border-left: 3px solid var(--amber); }
.integrity-value em { margin-left: 6px; color: var(--changed-text); font-size: 10.5px; font-style: normal; font-weight: 700; text-transform: uppercase; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edit-grid label, #editForm > label { display: grid; gap: 5px; color: var(--ink-2); font-size: 12.5px; font-weight: 550; }
details { margin: 14px 0; }
summary { cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 600; }
pre { max-height: 220px; padding: 12px 14px; overflow: auto; white-space: pre-wrap; color: #d7e0ea; border-radius: 10px; background: #0d141b; font-size: 11.5px; line-height: 1.6; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Integrations ---------- */
.integration-grid { display: grid; gap: 8px; }
.integration-card { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); }
.integration-card small { color: var(--muted); }
.integration-card .badge:not(.review_required) { color: var(--positive); background: var(--positive-surface); }

/* ---------- Documents / bulk ---------- */
#documentsSection, #reportsSection, #activitySection, #operationsSection, #settingsSection { margin-bottom: 18px; scroll-margin-top: 76px; }
.bulk-toolbar { margin: 0 0 12px; padding: 10px 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--ink); border: 1px solid color-mix(in srgb, var(--teal) 45%, var(--line)); border-radius: 12px; background: var(--teal-soft); }
.bulk-toolbar label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.bulk-toolbar select { min-width: 170px; }

/* ---------- Reports ---------- */
.report-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.report-filters label { min-width: 150px; }
.report-scope { margin: 0 0 14px; font-size: 12.5px; }
.compact-metrics { margin: 14px 0 18px; }
.compact-metrics article { padding: 14px 16px; background: var(--surface-subtle); box-shadow: none; }
.compact-metrics strong { font-size: 21px; }
.compact-metrics small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.subpanel { min-width: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
.subpanel h3 { margin: 0 0 12px; }
.subpanel .table-wrap { background: var(--surface); }
.rank-list, .failure-list, .rule-list { display: grid; gap: 8px; }
.rank-item { padding: 9px 4px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rank-item:last-child { border-bottom: 0; }
.rank-item b { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; color: var(--teal-label); border-radius: 6px; font-size: 11.5px; background: var(--teal-soft); }
.rank-item small { grid-column: 1 / -1; color: var(--muted); }
.rule-card, .failure-card { padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); }
.rule-card p, .failure-card p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.rule-card .row-actions { grid-column: 1 / -1; }
.rule-card.inactive { opacity: .65; }
.approval-rule-form { margin-top: 16px; padding-top: 16px; display: grid; grid-template-columns: 1.5fr repeat(4, minmax(120px, .7fr)) auto; align-items: end; gap: 10px; border-top: 1px solid var(--line); }
.approval-rule-form .form-status { grid-column: 1 / -1; }
.failure-card .button { align-self: center; }

/* ---------- Duplicates ---------- */
.duplicate-review { margin: 0 0 16px; padding: 14px; border: 1px solid var(--warning-border); border-radius: 12px; background: var(--warning-surface); }
.duplicate-comparison { margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duplicate-card { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.duplicate-card h4 { margin: 0 0 8px; font-size: 13px; }
.duplicate-preview { min-height: 150px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: var(--surface-muted); }
.duplicate-preview img { width: 100%; max-height: 240px; object-fit: contain; }
.duplicate-preview iframe { width: 100%; height: 240px; border: 0; background: white; }
.duplicate-card dl { margin: 10px 0 0; display: grid; gap: 4px; }
.duplicate-card dl div { display: grid; grid-template-columns: 72px 1fr; gap: 8px; font-size: 12px; }
.duplicate-card dt { color: var(--muted); }
.duplicate-card dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }

@keyframes status-pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) { .three-columns { grid-template-columns: 1fr 1fr; } .approval-rule-form { grid-template-columns: 1fr 1fr 1fr; } .hero { flex-direction: column; align-items: flex-start; } }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 8px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand span:last-child { display: none; }
  .workspace-nav { flex-direction: row; flex: 1; overflow-x: auto; scrollbar-width: none; }
  .nav-label { display: none; }
  .workspace-nav a { white-space: nowrap; padding: 7px 10px; }
  .sidebar-foot { margin-top: 0; }
  .sidebar-theme-toggle .theme-label { display: none; }
  .topbar { position: static; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .two-columns, .review-grid, .three-columns { grid-template-columns: 1fr; }
  .original-pane { position: static; }
  .filters { grid-template-columns: 1fr 1fr; }
  .original-preview, .original-preview iframe { min-height: 480px; }
}
@media (max-width: 680px) {
  main { width: calc(100% - 32px); }
  .workspace-nav a svg { display: none; }
  .topbar { flex-direction: column; align-items: stretch; padding: 12px 16px; }
  .session-summary { flex-wrap: wrap; }
  .pipeline { display: none; }
  .hero { margin-top: 20px; }
  .panel { padding: 18px; }
  .workspace-nav a, .button { min-height: 44px; }
  .metrics { grid-template-columns: 1fr; }
  .filters, .edit-grid, .confidence-summary, .workspace-create-form, .approval-rule-form, .duplicate-comparison, .integrity-values { grid-template-columns: 1fr; }
  .report-filters, .bulk-toolbar { align-items: stretch; flex-direction: column; }
  .report-filters label, .bulk-toolbar select { width: 100%; }
  .bar-row { grid-template-columns: 96px 1fr 70px; }
  .step-label { display: none; }
  .auth-card { padding: 26px; }
  .auth-theme-toggle { top: 14px; right: 14px; }
  .review-grid { padding: 16px; }
  .dialog-heading { padding: 14px 16px; }
  .original-preview, .original-preview iframe { min-height: 360px; }
}

/* Unified document and development modules use the existing light/dark palette. */
.unified-module { scroll-margin-top: 95px; }
.assistant-layout { display:grid; grid-template-columns:minmax(220px, .75fr) minmax(0, 2fr); gap:24px; margin-top:20px; }
.assistant-layout > * { min-width:0; }
.stack-form { display:grid; gap:14px; }
.stack-form label, .inline-form label { display:grid; gap:6px; min-width:0; }
.stack-form input, .stack-form select, .stack-form textarea, .inline-form input { width:100%; min-width:0; }
.answer-card pre { white-space:pre-wrap; overflow-wrap:anywhere; }
.library-list { display:flex; flex-direction:column; gap:8px; margin-top:16px; max-height:540px; overflow:auto; }
.library-entry { text-align:left; white-space:normal; overflow-wrap:anywhere; display:block; width:100%; }
.library-entry small { display:block; opacity:.7; margin-top:4px; }
.library-entry[aria-current=true] { outline:2px solid currentColor; outline-offset:-2px; }
.module-actions { display:flex; flex-wrap:wrap; gap:8px; margin:14px 0; }
.inline-form { display:flex; gap:8px; align-items:end; flex-wrap:wrap; margin:16px 0; }
.inline-form label { flex:1; }
.evidence-blocks { max-height:360px; overflow:auto; border:1px solid var(--border, #94a3b855); border-radius:10px; padding:12px; margin-bottom:20px; }
.evidence-block { white-space:pre-wrap; overflow-wrap:anywhere; padding:12px; border-bottom:1px solid var(--border, #94a3b855); scroll-margin-top:10px; }
.evidence-block:focus { outline:2px solid currentColor; }
.answer-card { border:1px solid var(--border, #94a3b855); border-radius:10px; padding:16px; margin:16px 0; }
.citation-button { font:inherit; cursor:pointer; border:1px solid currentColor; border-radius:5px; padding:2px 6px; color:inherit; background:transparent; margin:3px; }
.module-result { max-height:600px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; }
@media(max-width:850px) { .assistant-layout { grid-template-columns:1fr; } }
