:root {
  --nav-width: 236px;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbfe;
  --surface-3: #eef5fb;
  --text: #071a35;
  --muted: #60738d;
  --border: #d5e1ec;
  --border-strong: #bdcedd;
  --nav-bg: #052844;
  --nav-bg-2: #031d34;
  --nav-text: #edf8ff;
  --nav-muted: #a9c6da;
  --primary: #0878d1;
  --primary-2: #00a7f5;
  --primary-soft: #e7f4ff;
  --success: #009b62;
  --success-soft: #e8f8f1;
  --warning: #d38400;
  --warning-soft: #fff4dc;
  --danger: #d73648;
  --danger-soft: #ffecef;
  --purple: #7c4ce0;
  --purple-soft: #f1ebff;
  --shadow: 0 10px 30px rgba(16, 54, 88, .08);
  --radius: 14px;
  --radius-sm: 9px;
  --focus: 0 0 0 3px rgba(8, 120, 209, .22);
  --font: Inter, Aptos, "Segoe UI", Arial, sans-serif;
}

html[data-af-theme="dark"] {
  --bg: #061525;
  --surface: #0d2032;
  --surface-2: #10263a;
  --surface-3: #142d43;
  --text: #f2f8fd;
  --muted: #9ab5cb;
  --border: #29445a;
  --border-strong: #3d5e75;
  --nav-bg: #031b31;
  --nav-bg-2: #021426;
  --nav-text: #f4fbff;
  --nav-muted: #98b8cf;
  --primary: #27a4f2;
  --primary-2: #22c5ff;
  --primary-soft: #113653;
  --success: #28c98a;
  --success-soft: #0c3b31;
  --warning: #ffb82d;
  --warning-soft: #3d3012;
  --danger: #ff6576;
  --danger-soft: #421d29;
  --purple: #a980ff;
  --purple-soft: #2d2450;
  --shadow: 0 14px 36px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-boot { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.boot-card { display: grid; justify-items: center; gap: 14px; color: var(--muted); }
.boot-mark { width: 58px; height: 58px; border-radius: 16px; background: linear-gradient(145deg, var(--primary-2), #0056da); display: grid; place-items: center; color: white; font-size: 30px; font-weight: 800; box-shadow: var(--shadow); }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 46%) 1fr; background: var(--bg); }
.login-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 50px; color: white; background: radial-gradient(circle at 15% 15%, rgba(0,174,255,.35), transparent 35%), linear-gradient(145deg, #03172b, #073b61); }
.login-brand::after { content:""; position:absolute; width:520px; height:520px; border-radius:50%; border:1px solid rgba(102,211,255,.2); right:-180px; bottom:-210px; box-shadow: 0 0 0 70px rgba(57,189,255,.04), 0 0 0 140px rgba(57,189,255,.03); }
.login-logo { width: 310px; max-width: 90%; position: relative; z-index: 1; }
.login-copy { position: relative; z-index: 1; max-width: 580px; }
.login-copy h1 { margin: 0 0 18px; font-size: clamp(38px, 5vw, 68px); line-height: 1.02; letter-spacing: -.04em; }
.login-copy p { font-size: 18px; line-height: 1.7; color: #c8e9fb; }
.login-points { display: grid; gap: 12px; margin-top: 26px; }
.login-point { display: flex; align-items: center; gap: 12px; color: #e6f6ff; }
.login-point span:first-child { width: 30px; height: 30px; border-radius: 9px; display:grid; place-items:center; background:rgba(80,201,255,.16); }
.login-form-wrap { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(450px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 36px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 6px; font-size: 30px; }
.login-card > p { margin: 0 0 28px; color: var(--muted); }
.form-stack { display: grid; gap: 18px; }
.form-group { display: grid; gap: 7px; }
.form-group label { font-weight: 700; font-size: 13px; }
.login-error { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: 9px; padding: 11px 12px; }
.login-footer { margin-top: 22px; color: var(--muted); font-size: 12px; text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; min-height: 680px; display: flex; flex-direction: column; padding: 16px 13px 12px; background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg-2)); color: var(--nav-text); z-index: 20; }
.brand-box { padding: 0 4px 14px; border-bottom: 1px solid rgba(185,222,243,.18); }
.brand-box img { display: block; width: 100%; max-width: 194px; margin: auto; border-radius: 12px; }
.business-picker { display: grid; gap: 6px; margin: 13px 0 7px; }
.business-picker label { font-size: 11px; font-weight: 800; color: #dff3ff; }
.business-picker select { width: 100%; background: white; color: #14263a; border: 0; border-radius: 8px; padding: 10px 11px; }
.nav-list { display: grid; gap: 2px; margin-top: 5px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 11px; border-radius: 9px; color: var(--nav-text); font-weight: 700; font-size: 13px; transition: .18s ease; }
.nav-link:hover { background: rgba(117,196,238,.12); }
.nav-link.active { background: rgba(144,203,237,.2); box-shadow: inset 3px 0 0 #35c7ff; }
.nav-icon { width: 19px; height: 19px; display: inline-grid; place-items:center; flex: 0 0 19px; color: #bfe6fb; }
.nav-icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-spacer { flex: 1; min-height: 18px; }
.user-panel { border-top: 1px solid rgba(185,222,243,.18); padding: 14px 8px 4px; display: grid; gap: 12px; }
.user-name { font-weight: 800; }
.user-role { color: var(--nav-muted); font-size: 11px; margin-top: 2px; }
.sidebar-action { display:flex; align-items:center; gap:10px; background:transparent; color:var(--nav-text); border:0; padding:4px 0; cursor:pointer; font-weight:700; text-align:left; }
.theme-row { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.switch { width: 36px; height: 20px; border: 1px solid rgba(183,219,239,.45); border-radius: 999px; background: #43647b; padding: 2px; cursor:pointer; transition:.2s; }
.switch::after { content:""; display:block; width:14px; height:14px; border-radius:50%; background:white; transition:.2s; }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(16px); }
.copyright { color: #789bb3; font-size: 9px; line-height: 1.5; text-align:center; padding-top:6px; }

.main { min-width: 0; padding: 20px 24px 34px; }
.page { max-width: 1550px; margin: 0 auto; }
.page-header { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding-bottom: 17px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.eyebrow { color: #0063a4; font-size: 11px; letter-spacing: .11em; font-weight: 900; text-transform: uppercase; margin-bottom: 7px; }
html[data-af-theme="dark"] .eyebrow { color: #3ebeff; }
.page-title { margin: 0; font-size: 29px; line-height: 1.05; letter-spacing: -.025em; }
.page-subtitle { margin: 7px 0 0; color: var(--muted); }
.header-actions { display:flex; align-items:center; flex-wrap:wrap; justify-content:flex-end; gap:9px; }

.btn { appearance:none; border:1px solid var(--border-strong); background:var(--surface); color:var(--text); border-radius:9px; min-height:38px; padding:8px 14px; display:inline-flex; align-items:center; justify-content:center; gap:8px; cursor:pointer; font-weight:750; transition:.16s ease; }
.btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline:none; box-shadow:var(--focus); border-color:var(--primary); }
.btn.primary { background:var(--primary); border-color:var(--primary); color:white; }
.btn.success { background:var(--success); border-color:var(--success); color:white; }
.btn.danger { color:var(--danger); border-color:color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.ghost { background:transparent; border-color:transparent; }
.btn.small { min-height:32px; padding:5px 10px; font-size:12px; }
.btn[disabled] { opacity:.5; cursor:not-allowed; transform:none; }

.input, .select, .textarea { width:100%; border:1px solid var(--border-strong); background:var(--surface); color:var(--text); border-radius:9px; min-height:40px; padding:9px 12px; }
.textarea { min-height:100px; resize:vertical; }
.search-wrap { position:relative; }
.search-wrap .input { padding-left:38px; }
.search-wrap::before { content:"⌕"; position:absolute; left:13px; top:8px; font-size:22px; color:var(--muted); z-index:1; }

.grid { display:grid; gap:14px; }
.kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom:14px; }
.kpi { min-height:118px; padding:16px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); position:relative; overflow:hidden; }
.kpi::before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:var(--accent, var(--primary)); }
.kpi-top { display:flex; align-items:center; gap:11px; }
.kpi-icon { width:40px; height:40px; border-radius:11px; display:grid; place-items:center; background:var(--soft, var(--primary-soft)); color:var(--accent, var(--primary)); font-size:20px; }
.kpi-label { color:var(--muted); font-size:12px; }
.kpi-value { font-size:26px; font-weight:850; line-height:1; margin-top:9px; }
.kpi-note { color:var(--muted); font-size:11px; margin-top:7px; }
.kpi.blue { --accent:var(--primary); --soft:var(--primary-soft); }
.kpi.green { --accent:var(--success); --soft:var(--success-soft); }
.kpi.amber { --accent:var(--warning); --soft:var(--warning-soft); }
.kpi.red { --accent:var(--danger); --soft:var(--danger-soft); }
.kpi.purple { --accent:var(--purple); --soft:var(--purple-soft); }

.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); }
.card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:16px 17px 12px; }
.card-head h2, .card-head h3 { margin:0; font-size:17px; }
.card-head p { margin:4px 0 0; color:var(--muted); font-size:12px; }
.card-body { padding: 0 17px 17px; }
.section-title { margin:0; font-size:17px; }
.section-kicker { margin:0 0 5px; color:#0471b6; font-size:10px; letter-spacing:.1em; font-weight:900; text-transform:uppercase; }
html[data-af-theme="dark"] .section-kicker { color:#47c4ff; }

.badge { display:inline-flex; align-items:center; gap:5px; border-radius:999px; padding:4px 8px; font-size:11px; font-weight:800; white-space:nowrap; background:var(--surface-3); color:var(--muted); }
.badge.green { background:var(--success-soft); color:var(--success); }
.badge.amber { background:var(--warning-soft); color:var(--warning); }
.badge.red { background:var(--danger-soft); color:var(--danger); }
.badge.blue { background:var(--primary-soft); color:var(--primary); }
.badge.purple { background:var(--purple-soft); color:var(--purple); }

.tabs { display:flex; gap:6px; align-items:center; flex-wrap:wrap; border-bottom:1px solid var(--border); padding:0 14px; }
.tab { border:0; background:transparent; color:var(--muted); padding:13px 12px; cursor:pointer; font-weight:800; border-bottom:2px solid transparent; }
.tab.active { color:var(--primary); border-bottom-color:var(--primary); }
.chips { display:flex; flex-wrap:wrap; gap:7px; }
.chip { border:1px solid var(--border); background:var(--surface-2); color:var(--text); border-radius:8px; padding:7px 11px; cursor:pointer; font-weight:700; font-size:12px; }
.chip.active { background:var(--primary); color:white; border-color:var(--primary); }

.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; }
th { background:var(--surface-3); color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-size:10px; text-align:left; padding:11px 12px; border-bottom:1px solid var(--border); }
td { padding:12px; border-bottom:1px solid var(--border); vertical-align:middle; }
tr:last-child td { border-bottom:0; }
tbody tr { transition:.15s; }
tbody tr:hover { background:color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.cell-primary { font-weight:800; }
.cell-secondary { color:var(--muted); font-size:11px; margin-top:4px; }
.status-strip { border-left:3px solid var(--row-accent, var(--border)); }
.progress { height:6px; border-radius:999px; background:var(--surface-3); overflow:hidden; }
.progress > span { display:block; height:100%; border-radius:inherit; background:var(--progress, var(--primary)); }

.dashboard-layout { grid-template-columns: minmax(0, 1.7fr) minmax(290px, .8fr); }
.performance-stack { display:grid; gap:12px; }
.performance-row { padding:13px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.performance-row-top { display:flex; justify-content:space-between; gap:10px; margin-bottom:8px; }
.performance-row strong { font-size:20px; }
.pipeline-chart { display:flex; align-items:flex-end; gap:10px; height:180px; padding:20px 8px 0; border-bottom:1px solid var(--border); }
.chart-day { flex:1; min-width:24px; display:flex; justify-content:center; align-items:flex-end; gap:3px; height:100%; position:relative; }
.chart-bar { width:9px; border-radius:4px 4px 0 0; min-height:2px; }
.chart-bar.intake { background:#4db8ef; }
.chart-bar.processed { background:var(--success); }
.chart-backlog { position:absolute; bottom:0; width:100%; border-top:2px solid var(--warning); }
.chart-labels { display:grid; grid-template-columns:repeat(7,1fr); gap:10px; color:var(--muted); font-size:10px; text-align:center; margin-top:8px; }
.activity-list { display:grid; gap:8px; }
.activity-row { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:11px; padding:11px 12px; border:1px solid var(--border); border-left:3px solid var(--row-accent,var(--primary)); border-radius:9px; background:var(--surface-2); }
.activity-icon { width:34px; height:34px; border-radius:9px; display:grid; place-items:center; background:var(--primary-soft); color:var(--primary); }
.activity-title { font-weight:800; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.activity-sub { color:var(--muted); font-size:11px; margin-top:3px; }

.capture-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
.capture-card { padding:20px; min-height:280px; display:flex; flex-direction:column; align-items:center; text-align:center; gap:10px; }
.capture-card .capture-icon { width:52px; height:52px; border-radius:14px; display:grid; place-items:center; font-size:25px; background:var(--primary-soft); color:var(--primary); }
.capture-card.mobile .capture-icon { background:var(--success-soft); color:var(--success); }
.capture-card.email .capture-icon { background:var(--purple-soft); color:var(--purple); }
.drop-zone { border:1.5px dashed var(--primary); }
.drop-zone.dragging { background:var(--primary-soft); }
.capture-card h2 { margin:4px 0 0; font-size:22px; }
.capture-card p { color:var(--muted); line-height:1.5; margin:0; }
.upload-queue { width:100%; display:grid; gap:6px; margin-top:8px; text-align:left; }
.upload-item { display:flex; justify-content:space-between; gap:10px; font-size:11px; padding:7px 9px; background:var(--surface-3); border-radius:7px; }
.lifecycle { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; padding:13px; }
.life-step { display:flex; align-items:center; gap:9px; padding:10px; background:var(--surface-2); border-radius:9px; }
.life-step-icon { width:28px; height:28px; display:grid; place-items:center; border-radius:8px; background:var(--primary-soft); color:var(--primary); }

.queue-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; padding:13px; border-bottom:1px solid var(--border); }
.queue-table { min-width: 980px; table-layout:fixed; }
.queue-table th:nth-child(1) { width:12%; }
.queue-table th:nth-child(2) { width:23%; }
.queue-table th:nth-child(3) { width:9%; }
.queue-table th:nth-child(4) { width:12%; }
.queue-table th:nth-child(5) { width:15%; }
.queue-table th:nth-child(6) { width:13%; }
.queue-table th:nth-child(7) { width:10%; }
.queue-table th:nth-child(8) { width:6%; }

.validation-shell { display:grid; grid-template-columns:280px minmax(420px,1fr) 340px; gap:14px; align-items:start; }
.validation-side { display:grid; gap:12px; position:sticky; top:20px; }
.document-frame { width:100%; height:780px; border:0; background:white; border-radius:10px; }
.validation-fields { display:grid; gap:10px; max-height:780px; overflow:auto; padding-right:3px; }
.field-card { padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.field-card-top { display:flex; justify-content:space-between; gap:10px; margin-bottom:7px; }
.check-list { display:grid; gap:7px; }
.check-row { padding:9px; border-radius:8px; background:var(--surface-2); border-left:3px solid var(--row-accent,var(--border)); }

.workspace-split { display:grid; grid-template-columns:minmax(300px,.82fr) minmax(500px,1.25fr); gap:14px; min-height:680px; }
.directory-card { display:flex; flex-direction:column; min-height:680px; }
.directory-controls { padding:0 14px 12px; display:grid; gap:9px; }
.directory-list { flex:1; overflow:auto; padding:0 8px 8px; }
.directory-item { width:100%; border:0; border-bottom:1px solid var(--border); background:transparent; color:var(--text); padding:12px 10px; display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:10px; text-align:left; cursor:pointer; }
.directory-item:hover { background:var(--surface-2); }
.directory-item.active { background:var(--primary-soft); box-shadow:inset 3px 0 0 var(--primary); }
.avatar { width:42px; height:42px; border-radius:50%; display:grid; place-items:center; background:linear-gradient(145deg,var(--primary),var(--purple)); color:white; font-weight:850; }
.directory-footer { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:10px 14px; border-top:1px solid var(--border); color:var(--muted); font-size:11px; }
.detail-card { min-height:680px; display:flex; flex-direction:column; }
.detail-header { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:17px; border-bottom:1px solid var(--border); }
.detail-title { display:flex; align-items:center; gap:12px; }
.detail-content { padding:15px; flex:1; }
.detail-grid { display:grid; grid-template-columns:1.15fr .85fr; gap:12px; }
.info-panel { border:1px solid var(--border); border-radius:11px; background:var(--surface-2); padding:14px; }
.info-panel h3 { margin:0 0 12px; font-size:15px; }
.definition-list { display:grid; gap:9px; }
.definition-row { display:grid; grid-template-columns:1fr 1.2fr; gap:12px; font-size:12px; }
.definition-row span:first-child { color:var(--muted); }
.alias-box { margin-top:12px; border:1px solid var(--border); border-radius:11px; padding:14px; background:var(--surface-2); }
.alias-chip { display:inline-flex; align-items:center; gap:8px; padding:7px 10px; border-radius:8px; background:var(--surface-3); border:1px solid var(--border); margin:0 6px 6px 0; }
.alias-chip button { border:0; background:transparent; color:var(--muted); cursor:pointer; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px; }
.form-grid .span-2 { grid-column:span 2; }
.toggle-row { min-height:40px; display:flex; align-items:center; gap:10px; }
.action-footer { display:flex; gap:9px; padding:14px 15px; border-top:1px solid var(--border); }

.admin-layout { grid-template-columns:280px minmax(0,1fr); }
.admin-menu { padding:8px; }
.admin-menu-item { width:100%; border:0; background:transparent; color:var(--text); padding:11px; border-radius:9px; display:flex; align-items:center; gap:11px; text-align:left; cursor:pointer; font-weight:750; }
.admin-menu-item:hover { background:var(--surface-2); }
.admin-menu-item.active { background:var(--primary-soft); color:var(--primary); }
.admin-detail { min-height:670px; }
.config-health { display:grid; gap:8px; }
.health-row { display:grid; grid-template-columns:minmax(140px,1fr) 110px 3fr; align-items:center; gap:10px; }
.health-bar { height:7px; border-radius:999px; background:var(--surface-3); overflow:hidden; }
.health-bar span { display:block; height:100%; background:var(--success); }
.collection-layout { display:grid; grid-template-columns:minmax(260px,.75fr) minmax(420px,1.25fr); gap:12px; }
.collection-list { max-height:570px; overflow:auto; border:1px solid var(--border); border-radius:10px; }
.collection-item { width:100%; border:0; border-bottom:1px solid var(--border); background:transparent; color:var(--text); padding:11px; text-align:left; cursor:pointer; }
.collection-item:last-child { border-bottom:0; }
.collection-item.active { background:var(--primary-soft); }
.collection-item strong { display:block; }
.collection-item small { display:block; color:var(--muted); margin-top:3px; }
.empty-state { padding:35px 18px; text-align:center; color:var(--muted); }

.toast-region { position:fixed; top:16px; right:16px; z-index:100; display:grid; gap:8px; width:min(360px,calc(100vw - 32px)); }
.toast { background:var(--surface); color:var(--text); border:1px solid var(--border); border-left:4px solid var(--primary); border-radius:10px; padding:12px 14px; box-shadow:var(--shadow); animation:toast-in .2s ease; }
.toast.success { border-left-color:var(--success); }
.toast.danger { border-left-color:var(--danger); }
@keyframes toast-in { from { opacity:0; transform:translateY(-8px); } }
.modal-backdrop { position:fixed; inset:0; z-index:90; display:grid; place-items:center; background:rgba(0,12,24,.58); padding:20px; }
.modal { width:min(540px,100%); background:var(--surface); border:1px solid var(--border); border-radius:16px; box-shadow:var(--shadow); }
.modal-head { padding:17px; border-bottom:1px solid var(--border); }
.modal-body { padding:17px; }
.modal-actions { padding:14px 17px; display:flex; justify-content:flex-end; gap:8px; border-top:1px solid var(--border); }

@media (max-width: 1250px) {
  :root { --nav-width: 210px; }
  .kpi-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .capture-grid { grid-template-columns:1fr 1fr; }
  .capture-card.email { grid-column:span 2; min-height:220px; }
  .validation-shell { grid-template-columns:240px minmax(380px,1fr); }
  .validation-fields { grid-column:1 / -1; max-height:none; grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:relative; height:auto; min-height:0; }
  .brand-box { display:none; }
  .business-picker { max-width:360px; }
  .nav-list { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .nav-link { justify-content:center; text-align:center; }
  .sidebar-spacer, .copyright { display:none; }
  .user-panel { grid-template-columns:1fr auto auto; align-items:center; }
  .main { padding:18px; }
  .dashboard-layout, .workspace-split, .admin-layout, .collection-layout { grid-template-columns:1fr; }
  .directory-card { min-height:520px; }
  .validation-shell { grid-template-columns:1fr; }
  .validation-side { position:static; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .document-frame { height:650px; }
}
@media (max-width: 700px) {
  .login-page { grid-template-columns:1fr; }
  .login-brand { display:none; }
  .login-form-wrap { padding:22px; }
  .main { padding:14px; }
  .page-header { flex-direction:column; }
  .header-actions { width:100%; justify-content:flex-start; }
  .kpi-grid { grid-template-columns:1fr 1fr; }
  .capture-grid { grid-template-columns:1fr; }
  .capture-card.email { grid-column:auto; }
  .lifecycle { grid-template-columns:1fr; }
  .nav-list { grid-template-columns:1fr 1fr; }
  .nav-link { justify-content:flex-start; }
  .user-panel { grid-template-columns:1fr; }
  .detail-grid, .form-grid { grid-template-columns:1fr; }
  .form-grid .span-2 { grid-column:auto; }
  .validation-side { grid-template-columns:1fr; }
  .validation-fields { grid-template-columns:1fr; }
  .document-frame { height:520px; }
  .kpi { min-height:105px; }
}


/* supplier-directory readability and validation preview */
.directory-copy { min-width:0; display:grid; gap:3px; }
.directory-copy strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; line-height:1.25; }
.directory-copy small { display:flex; flex-wrap:wrap; align-items:center; column-gap:5px; row-gap:1px; color:var(--muted); font-size:11px; line-height:1.4; }
.directory-copy .meta-separator { opacity:.72; }
.directory-status { display:flex; align-items:center; justify-content:flex-end; gap:7px; white-space:nowrap; }
.document-preview { position:relative; min-height:620px; overflow:hidden; border:1px solid var(--border); border-radius:10px; background:#eef2f6; }
.document-frame { display:block; width:100%; height:780px; border:0; background:white; border-radius:0; }
.document-image { display:block; width:100%; max-height:780px; object-fit:contain; background:white; }
.document-preview-fallback { display:none; padding:18px; color:var(--muted); text-align:center; }
.document-preview-fallback a { color:var(--primary); font-weight:750; }

/* v1.6.3 unified application pages — no standalone shells */
.operations-tabs,.intelligence-tabs{margin-bottom:14px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow)}
.operations-kpis{grid-template-columns:repeat(6,minmax(0,1fr))}
.operations-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(330px,.75fr);gap:14px;margin-bottom:14px}
.operations-lower{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.operations-services .table-wrap{padding:0 17px 17px}
.operations-incidents .activity-row{grid-template-columns:auto minmax(0,1fr) auto}
.operations-pipeline{display:grid;gap:13px}
.operations-pipeline>div{display:grid;grid-template-columns:minmax(90px,1fr) auto;gap:6px 12px;align-items:center}
.operations-pipeline .progress{grid-column:1/-1}
.health-summary-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;padding:0 17px 17px}
.health-total{padding:16px;border:1px solid var(--border);border-radius:11px;background:var(--surface-2);text-align:center}
.health-total strong{display:block;font-size:28px}.health-total span{display:block;margin-top:4px;color:var(--muted);text-transform:uppercase;font-size:10px;font-weight:800;letter-spacing:.08em}
.health-total.green strong{color:var(--success)}.health-total.amber strong{color:var(--warning)}.health-total.red strong{color:var(--danger)}
.intelligence-card{overflow:hidden}
.intelligence-hero{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:24px;border-bottom:1px solid var(--border);background:linear-gradient(135deg,var(--surface),var(--primary-soft))}
.intelligence-hero h2{margin:4px 0 7px;font-size:24px}.intelligence-hero p{margin:0;color:var(--muted);line-height:1.55;max-width:760px}
.intelligence-stats{display:flex;gap:10px}.intelligence-stats>div{min-width:92px;padding:12px 14px;border:1px solid var(--border);border-radius:12px;background:var(--surface)}
.intelligence-stats strong,.intelligence-stats span{display:block}.intelligence-stats strong{font-size:22px;color:var(--primary)}.intelligence-stats span{font-size:11px;color:var(--muted)}
.alias-toolbar{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:18px 18px 0}
.alias-table{min-width:920px}.alias-field strong{display:block}.alias-field small{display:block;margin-top:3px;color:var(--muted);font-family:ui-monospace,SFMono-Regular,Consolas,monospace}
.alias-chips{display:flex;flex-wrap:wrap;gap:6px}.alias-pill{display:inline-flex;align-items:center;gap:6px;padding:6px 9px;border:1px solid var(--border);border-radius:999px;background:var(--surface-2);color:var(--primary);font-size:11px}
.alias-pill button{border:0;background:transparent;color:var(--muted);cursor:pointer;padding:0}.alias-add{display:flex;gap:7px;min-width:280px}.alias-add .input{min-width:0}.alias-add .btn{flex:0 0 auto}
.flow-designer{display:grid;grid-template-columns:240px minmax(440px,1fr) 285px;gap:14px;height:calc(100vh - 150px);min-height:610px}
.flow-library,.flow-canvas-panel,.flow-properties{min-width:0;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.flow-library,.flow-properties{display:flex;flex-direction:column}.flow-panel-heading{padding:15px 16px;border-bottom:1px solid var(--border)}.flow-panel-heading h2{margin:0 0 3px;font-size:16px}.flow-panel-heading p{margin:0;color:var(--muted);font-size:12px}
.flow-module-list{padding:10px 12px 18px;overflow:auto}.flow-module-group h3{margin:14px 0 8px;font-size:10px;text-transform:uppercase;letter-spacing:.09em;color:var(--muted)}
.flow-module-item{display:flex;align-items:center;gap:9px;padding:10px;border:1px solid var(--border);border-radius:11px;margin-bottom:8px;cursor:grab;background:var(--surface)}.flow-module-item:hover{border-color:var(--primary);box-shadow:var(--shadow)}
.flow-module-icon{display:grid;place-items:center;width:32px;height:32px;flex:0 0 32px;border-radius:9px;background:var(--primary-soft);color:var(--primary);font-weight:850}.flow-module-item strong,.flow-module-item small{display:block}.flow-module-item strong{font-size:12px}.flow-module-item small{font-size:10px;color:var(--muted);margin-top:2px}
.flow-canvas-panel{display:grid;grid-template-rows:auto minmax(0,1fr)}.flow-canvas-toolbar{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:12px 14px;border-bottom:1px solid var(--border)}.flow-canvas-toolbar>div:first-child{display:grid;gap:3px;min-width:0}.flow-canvas-toolbar input{border:0;outline:0;background:transparent;color:var(--text);min-width:0}.flow-canvas-toolbar #flowName{font-weight:850;font-size:14px}.flow-canvas-toolbar #flowDescription{font-size:11px;color:var(--muted)}.flow-canvas-tools{display:flex;align-items:center;gap:6px;white-space:nowrap}.flow-canvas-tools span{width:48px;text-align:center;font-size:11px;color:var(--muted)}
#flowViewport{position:relative;min-width:0;min-height:0;overflow:hidden;background-color:var(--surface-2);background-image:radial-gradient(color-mix(in srgb,var(--primary) 35%,transparent) 1px,transparent 1px);background-size:20px 20px;touch-action:none;cursor:grab}#flowViewport.is-panning{cursor:grabbing}
#flowCanvas{position:absolute;left:0;top:0;width:2200px;height:1600px;transform-origin:0 0;will-change:transform}#flowConnections{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.flow-connection{fill:none;stroke:var(--primary);stroke-width:2}.flow-connection-arrow{fill:var(--primary)}
.flow-node{position:absolute;width:220px;min-height:80px;border:1px solid var(--border-strong);border-radius:12px;background:var(--surface);box-shadow:var(--shadow);cursor:move;user-select:none}.flow-node.selected{border-color:var(--primary);box-shadow:var(--focus),var(--shadow)}.flow-node-head{display:flex;align-items:center;gap:9px;padding:10px 12px;border-bottom:1px solid var(--border)}.flow-node-head .flow-module-icon{width:28px;height:28px;flex-basis:28px}.flow-node-body{padding:10px 12px;color:var(--muted);font-size:11px;line-height:1.4}.flow-node-outcome{margin-top:7px;color:var(--primary);font-weight:750}.flow-port{position:absolute;width:11px;height:11px;border:2px solid var(--surface);border-radius:50%;background:var(--primary);top:35px}.flow-port.in{left:-6px}.flow-port.out{right:-6px}
#flowEmptyCanvas{position:absolute;inset:0;display:grid;place-content:center;text-align:center;color:var(--muted);pointer-events:none;gap:4px}#flowEmptyCanvas strong{color:var(--text)}
.flow-empty-properties{padding:20px 16px;color:var(--muted);font-size:12px}.flow-properties form{display:grid;gap:12px;padding:15px;overflow:auto}.flow-properties label{display:grid;gap:5px;font-size:11px;font-weight:750}.flow-run-panel{margin:0 15px;padding-top:15px;border-top:1px solid var(--border)}.flow-run-panel h3{font-size:13px}.flow-test-row{display:flex;justify-content:space-between;gap:8px;font-size:10px;padding:7px 0}.flow-test-row strong{color:var(--success)}
@media(max-width:1250px){.operations-kpis{grid-template-columns:repeat(3,minmax(0,1fr))}.operations-lower{grid-template-columns:1fr 1fr}.flow-designer{grid-template-columns:210px minmax(400px,1fr)}.flow-properties{position:fixed;right:16px;top:90px;bottom:16px;width:300px;z-index:30}.flow-properties:has(#flowPropertiesForm[hidden]){display:none}}
@media(max-width:980px){.operations-grid,.operations-lower{grid-template-columns:1fr}.flow-designer{height:auto;grid-template-columns:1fr}.flow-library{max-height:320px}.flow-canvas-panel{height:68vh;min-height:520px}.flow-properties{left:12px;right:12px;top:auto;bottom:12px;width:auto;max-height:70vh}.intelligence-hero{align-items:flex-start;flex-direction:column}}
@media(max-width:700px){.operations-kpis{grid-template-columns:1fr 1fr}.health-summary-row{grid-template-columns:1fr}.alias-toolbar{align-items:stretch;flex-direction:column}.flow-canvas-toolbar{align-items:flex-start;flex-direction:column}.flow-canvas-tools{width:100%;overflow:auto}}


/* v1.6.4 validation evidence workspace */
.validation-source-card{min-width:0}
.validation-source-head{align-items:center;flex-wrap:wrap}
.validation-source-actions{display:flex;align-items:center;justify-content:flex-end;gap:7px;flex-wrap:wrap}
.validation-source-actions .chip{padding:6px 9px}
.document-toolbar{display:grid;grid-template-columns:auto minmax(220px,1fr) auto;align-items:center;gap:12px;margin-bottom:10px;padding:8px 10px;border:1px solid var(--border);border-radius:9px;background:var(--surface-2)}
.document-page-controls,.document-zoom-controls{display:flex;align-items:center;gap:7px;white-space:nowrap}
.document-selection-hint{color:var(--muted);font-size:11px;text-align:center;line-height:1.35}
.document-selection-hint strong{color:var(--primary)}
.document-preview{position:relative;min-height:620px;max-height:780px;overflow:auto;border:1px solid var(--border);border-radius:10px;background:#cfd8e2;padding:12px}
.document-page-stage{position:relative;width:100%;min-width:100%;margin:0 auto;background:#fff;box-shadow:0 8px 30px rgba(0,20,40,.22);transform-origin:top left}
.document-page-image{display:block;width:100%;height:auto;background:#fff;user-select:none;-webkit-user-drag:none}
.document-overlay{position:absolute;inset:0;pointer-events:none}
.document-region{position:absolute;display:block;min-width:4px;min-height:4px;border-radius:3px;cursor:pointer;pointer-events:auto;padding:0;background:rgba(28,151,232,.13);border:2px solid #1c97e8;box-shadow:0 0 0 1px rgba(255,255,255,.55) inset}
.document-region span{position:absolute;left:-2px;top:-20px;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:2px 5px;border-radius:4px;background:#0869a7;color:#fff;font-size:9px;font-weight:850;letter-spacing:.02em;box-shadow:0 2px 6px rgba(0,0,0,.22)}
.document-region.green{border-color:#08a466;background:rgba(8,164,102,.12)}
.document-region.green span{background:#08794e}
.document-region.amber{border-color:#d89212;background:rgba(216,146,18,.15)}
.document-region.amber span{background:#9f6705}
.document-region.red{border-color:#db4054;background:rgba(219,64,84,.14)}
.document-region.red span{background:#a82639}
.document-region.selected{border-width:3px;border-color:#ffca28;background:rgba(255,202,40,.22);z-index:6}
.document-region.selected span{background:#8b6500}
.ocr-region{border:1px dashed rgba(0,119,198,.85);background:rgba(0,155,255,.06);z-index:8}
.ocr-region:hover{background:rgba(0,155,255,.22);border-style:solid}
.raw-text-panel{margin-top:12px;border:1px solid var(--border);border-radius:10px;background:var(--surface-2);overflow:hidden}
.raw-text-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 12px;border-bottom:1px solid var(--border)}
.raw-text-head>div:last-child{display:flex;gap:7px}
.raw-text-panel pre{margin:0;max-height:320px;overflow:auto;padding:14px;white-space:pre-wrap;word-break:break-word;color:var(--text);font:12px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;user-select:text}
.field-card{display:block;cursor:pointer;transition:border-color .15s,box-shadow .15s,background .15s}
.field-card:hover{border-color:color-mix(in srgb,var(--primary) 50%,var(--border))}
.field-card.selected{border-color:var(--primary);background:var(--primary-soft);box-shadow:0 0 0 2px color-mix(in srgb,var(--primary) 22%,transparent)}
.field-card-bottom{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:7px}
.field-pick{border:0;background:transparent;color:var(--primary);font-size:10px;font-weight:850;cursor:pointer;padding:3px 0;white-space:nowrap}
.field-pick:disabled{opacity:.45;cursor:not-allowed}
.supplier-master-note{display:block;margin-top:7px;padding:6px 8px;border-radius:7px;font-size:10px;font-weight:800}
.supplier-master-note.matched{background:var(--success-soft);color:var(--success)}
.supplier-master-note.unmatched{background:var(--warning-soft);color:var(--warning)}
.check-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
.check-actions .btn{background:var(--surface)}
@media(max-width:1400px){.document-toolbar{grid-template-columns:1fr 1fr}.document-selection-hint{grid-column:1/-1;grid-row:2}.document-zoom-controls{justify-content:flex-end}}
@media(max-width:700px){.document-toolbar{grid-template-columns:1fr}.document-selection-hint{grid-column:auto;grid-row:auto;text-align:left}.document-zoom-controls{justify-content:flex-start}.raw-text-head{align-items:flex-start;flex-direction:column}.validation-source-actions{justify-content:flex-start}}

/* v1.6.5 document picking */
.field-pick.active{color:#fff;background:var(--primary);border-radius:6px;padding:5px 8px}
.document-overlay.pick-mode{cursor:crosshair}
.document-overlay.pick-mode .ocr-region{border-width:2px;background:rgba(0,155,255,.12)}
.document-overlay.pick-mode .ocr-region:hover{background:rgba(0,155,255,.3);box-shadow:0 0 0 2px rgba(255,255,255,.8)}
