:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #111827;
  --muted: #64748b;
  --subtle: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --success: #047857;
  --success-soft: #ecfdf5;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --danger: #b42318;
  --danger-soft: #fff1f2;
  --violet: #6d28d9;
  --violet-soft: #f5f3ff;
  --radius: 12px;
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .16);
  --sidebar-width: 246px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #111722;
  --surface-2: #151c28;
  --surface-3: #1b2432;
  --text: #edf2f7;
  --muted: #9aa8bb;
  --subtle: #6f7d91;
  --border: #263244;
  --border-strong: #38465a;
  --primary: #60a5fa;
  --primary-soft: rgba(37, 99, 235, .13);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, .12);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, .12);
  --danger: #fb7185;
  --danger-soft: rgba(244, 63, 94, .12);
  --violet: #a78bfa;
  --violet-soft: rgba(139, 92, 246, .12);
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.app-shell { min-height: 100vh; }

/* La distribución estática no expone funciones que requieren el harness local. */
.nav-item[data-view="chat"], #aiFloatTrigger, #aiFloatPanel, .ai-alert-button { display: none !important; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand-block { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--text); color: var(--surface);
  font-weight: 750; letter-spacing: -.03em;
}
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-size: .92rem; letter-spacing: -.01em; }
.brand-block span { margin-top: 2px; color: var(--muted); font-size: .75rem; }
.side-nav { display: grid; gap: 4px; }
.nav-item {
  width: 100%; min-height: 42px; padding: 0 10px;
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 9px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); text-align: left; font-size: .875rem; font-weight: 560;
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.is-active { color: var(--text); background: var(--surface-3); }
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; }
.nav-icon svg, [data-icon] svg { width: 18px; height: 18px; display: block; }
.nav-count { min-width: 24px; padding: 2px 6px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-size: .7rem; text-align: center; }
.nav-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--danger); }
.nav-ai { padding: 2px 6px; border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border)); border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-size: .57rem; font-weight: 760; letter-spacing: .04em; }
.sidebar-foot { margin-top: auto; padding: 12px 6px 0; }
.scope-card { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.scope-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.scope-card strong, .scope-card span { display: block; }
.scope-card strong { font-size: .8rem; }
.scope-card span, .sidebar-foot p { color: var(--muted); font-size: .72rem; }
.scope-card span { margin-top: 2px; }
.sidebar-foot p { margin: 10px 2px 0; line-height: 1.45; }

.main-area { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 64px; padding: 0 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-actions, .breadcrumb, .month-picker { display: flex; align-items: center; }
.topbar-left, .topbar-actions { gap: 10px; }
.breadcrumb { gap: 8px; font-size: .82rem; }
.breadcrumb span, .breadcrumb b { color: var(--subtle); font-weight: 500; }
.breadcrumb strong { font-weight: 620; }
.month-picker { height: 38px; gap: 8px; padding: 0 8px 0 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.month-picker span { color: var(--muted); font-size: .75rem; }
.month-picker select { border: 0; outline: 0; background: transparent; color: var(--text); font-size: .82rem; font-weight: 650; cursor: pointer; }
.icon-button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.icon-button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.icon-button > svg, .icon-button > [data-icon] > svg { width: 18px; height: 18px; flex: none; }
#themeButton { min-width: 38px; max-width: 38px; min-height: 38px; max-height: 38px; flex: 0 0 38px; overflow: hidden; }
#themeButton .theme-toggle-icon { width: 18px; height: 18px; display: grid; place-items: center; overflow: hidden; }
#themeButton .theme-toggle-icon > svg { width: 18px !important; height: 18px !important; max-width: 18px; max-height: 18px; display: block; }
.mobile-only { display: none; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: 28px 30px 60px; outline: none; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: clamp(1.55rem, 2.5vw, 2rem); letter-spacing: -.035em; line-height: 1.15; }
.page-heading p { max-width: 760px; margin: 7px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.button { min-height: 38px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); text-decoration: none; font-size: .8rem; font-weight: 620; cursor: pointer; }
.button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.button.primary { background: var(--text); border-color: var(--text); color: var(--surface); }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button svg { width: 16px; height: 16px; }

.audit-brief {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface);
}
.brief-copy { padding: 22px 24px; border-right: 1px solid var(--border); }
.brief-copy h2 { margin: 0; font-size: 1rem; letter-spacing: -.01em; }
.brief-copy p { max-width: 820px; margin: 9px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.65; }
.brief-points { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; }
.brief-point { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 600; }
.brief-point i { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); }
.brief-point.good i { background: var(--success); }
.brief-point.warn i { background: var(--warning); }
.brief-point.bad i { background: var(--danger); }
.source-box { padding: 20px 22px; background: var(--surface-2); }
.source-box h3 { margin: 0 0 12px; font-size: .78rem; }
.source-line { display: grid; grid-template-columns: 80px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: .75rem; }
.source-line span { color: var(--muted); }
.source-line strong { text-align: right; overflow-wrap: anywhere; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.kpi { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--border); }
.kpi:last-child { border-right: 0; }
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .72rem; font-weight: 620; }
.kpi-value { margin-top: 8px; font-size: clamp(1.25rem, 2.2vw, 1.65rem); font-weight: 690; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.kpi-note { margin-top: 5px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.delta { font-size: .69rem; font-weight: 700; }
.delta.up { color: var(--danger); }
.delta.down { color: var(--success); }
.delta.flat { color: var(--muted); }

.reconcile { margin-top: 16px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.reconcile-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.reconcile-head h2, .section-head h2 { margin: 0; font-size: .95rem; letter-spacing: -.015em; }
.reconcile-head p, .section-head p { margin: 4px 0 0; color: var(--muted); font-size: .76rem; }
.coverage-value { font-size: .8rem; font-weight: 700; }
.coverage-rail { height: 12px; margin-top: 16px; display: flex; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.coverage-rail span { min-width: 0; transition: width .35s ease; }
.coverage-verified { background: var(--success); }
.coverage-review { background: var(--warning); }
.coverage-missing { background: var(--danger); }
.coverage-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; color: var(--muted); font-size: .72rem; }
.coverage-legend span { display: inline-flex; align-items: center; gap: 6px; }
.coverage-legend i { width: 7px; height: 7px; border-radius: 50%; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 16px; margin-top: 16px; }
.panel { min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.panel.flush { padding: 0; overflow: hidden; }
.chart-wrap { min-height: 250px; margin-top: 18px; }
.line-chart { width: 100%; height: 250px; overflow: visible; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: var(--primary-soft); }
.chart-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.chart-text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-value { fill: var(--text); font-size: 11px; font-weight: 700; font-family: inherit; }
.donut-layout { display: grid; grid-template-columns: 156px 1fr; align-items: center; gap: 24px; margin-top: 20px; }
.donut { position: relative; width: 148px; aspect-ratio: 1; border-radius: 50%; }
.donut::after { content: ""; position: absolute; inset: 19px; border-radius: 50%; background: var(--surface); }
.donut-center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-size: 1.35rem; letter-spacing: -.04em; }
.donut-center span { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.legend-list { display: grid; gap: 11px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; font-size: .76rem; }
.legend-row i { width: 8px; height: 8px; border-radius: 3px; }
.legend-row span { color: var(--muted); }
.legend-row strong { font-variant-numeric: tabular-nums; }
.rank-list { display: grid; gap: 14px; margin-top: 18px; }
.rank-row { display: grid; grid-template-columns: minmax(110px, 150px) 1fr auto; align-items: center; gap: 10px; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .75rem; }
.rank-track { height: 7px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.rank-fill { height: 100%; border-radius: inherit; background: var(--primary); }
.rank-value { min-width: 72px; text-align: right; font-size: .72rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.timeline { position: relative; display: grid; gap: 0; margin-top: 16px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 9px; bottom: 10px; width: 1px; background: var(--border); }
.timeline-item { position: relative; display: grid; grid-template-columns: 78px 1fr auto; gap: 12px; padding: 0 0 17px 22px; }
.timeline-item::before { content: ""; position: absolute; left: 2px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline-date { color: var(--muted); font-size: .72rem; font-weight: 650; }
.timeline-copy strong { display: block; font-size: .78rem; }
.timeline-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: .71rem; }
.timeline-amount { font-size: .74rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.section-block { margin-top: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.search-field { position: relative; flex: 1 1 220px; min-width: 180px; }
.search-field svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search-field input, .filter-select { height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .76rem; outline: 0; }
.search-field input { width: 100%; padding: 0 12px 0 34px; }
.search-field input:focus, .filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filter-select { max-width: 180px; padding: 0 30px 0 10px; }
.problem-toggle { height: 36px; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .75rem; cursor: pointer; }
.problem-toggle input { accent-color: var(--primary); }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 11px 12px; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--border); text-align: left; font-size: .68rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { cursor: pointer; transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.money { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.concept-cell { min-width: 220px; }
.concept-cell strong, .concept-cell span { display: block; }
.concept-cell strong { font-size: .78rem; }
.concept-cell span { margin-top: 3px; color: var(--muted); font-size: .69rem; }
.muted-cell { color: var(--muted); white-space: nowrap; }
.difference-negative, .difference-positive { font-weight: 700; }
.difference-negative { color: var(--danger); }
.difference-positive { color: var(--warning); }
.file-count { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.file-count svg { width: 14px; height: 14px; }
.status-stack { display: grid; justify-items: start; gap: 5px; }
.empty-table { padding: 50px 20px !important; text-align: center; color: var(--muted); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: .71rem; }
.bank-table { min-width: 1420px; }
.bank-movement { min-width: 250px; }
.bank-movement strong, .bank-movement span { display: block; }
.bank-movement strong { font-size: .72rem; }
.bank-movement span { max-width: 310px; margin-top: 4px; color: var(--muted); font-size: .69rem; line-height: 1.4; }
.bank-note { min-width: 280px; max-width: 360px; color: var(--muted); font-size: .71rem; line-height: 1.45; }
.unassigned-panel { margin-top: 16px; border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.unassigned-movement { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.unassigned-movement > div { display: grid; grid-template-columns: max-content 1fr; align-items: center; gap: 7px 10px; }
.unassigned-movement strong { font-size: .78rem; }
.unassigned-movement span { grid-column: 2; color: var(--muted); font-size: .71rem; line-height: 1.45; }
.unassigned-movement b { white-space: nowrap; color: var(--danger); font-size: .86rem; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; font-size: .68rem; font-weight: 690; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge.verified { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 18%, transparent); }
.badge.difference, .badge.missing { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 18%, transparent); }
.badge.partial, .badge.review { color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 18%, transparent); }
.badge.incomplete { color: var(--violet); background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 18%, transparent); }
.badge.duplicate { color: var(--primary); background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.badge.neutral { color: var(--muted); background: var(--surface-3); border-color: var(--border); }

.insight-list { display: grid; gap: 9px; margin-top: 16px; }
.insight { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.insight-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.insight-icon svg { width: 15px; height: 15px; }
.insight strong { display: block; font-size: .76rem; }
.insight p { margin: 3px 0 0; color: var(--muted); font-size: .71rem; line-height: 1.5; }

.compare-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .75fr); gap: 16px; }
.compare-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .76rem; }
.compare-table th, .compare-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: right; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; }
.compare-table th { color: var(--muted); font-size: .68rem; }
.compare-bars { display: grid; gap: 13px; margin-top: 18px; }
.compare-bar-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: .73rem; }
.compare-bar-label span { color: var(--muted); }
.compare-bar-track { height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.compare-bar-fill { height: 100%; background: var(--primary); border-radius: inherit; }

.provider-grid, .document-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.provider-card, .document-card { padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.provider-card { cursor: pointer; transition: border-color .15s, transform .15s; }
.provider-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.provider-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.provider-avatar { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--muted); font-size: .77rem; font-weight: 750; }
.provider-card h3, .document-card h3 { margin: 0; font-size: .82rem; }
.provider-card .category, .document-card p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.provider-total { margin-top: 17px; font-size: 1.25rem; font-weight: 700; letter-spacing: -.035em; }
.provider-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.provider-meta span { display: block; color: var(--muted); font-size: .65rem; }
.provider-meta strong { display: block; margin-top: 3px; font-size: .73rem; }
.document-card { display: flex; flex-direction: column; min-height: 170px; }
.document-icon { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--danger); }
.document-icon svg { width: 17px; height: 17px; }
.document-card h3 { margin-top: 12px; overflow-wrap: anywhere; }
.document-card .button { margin-top: auto; align-self: flex-start; }
.document-month { margin-top: 16px; }
.document-section + .document-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.document-section > h3 { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.document-section > h3 span { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); font-size: .68rem; letter-spacing: 0; }

.alert-list { display: grid; gap: 10px; margin-top: 16px; }
.alert-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.alert-symbol { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; }
.alert-symbol svg { width: 18px; height: 18px; }
.alert-row.important .alert-symbol { color: var(--danger); background: var(--danger-soft); }
.alert-row.attention .alert-symbol { color: var(--warning); background: var(--warning-soft); }
.alert-row.info .alert-symbol { color: var(--primary); background: var(--primary-soft); }
.alert-copy strong { display: block; font-size: .8rem; }
.alert-copy p { margin: 4px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.5; }
.alert-source { margin-top: 8px; color: var(--subtle); font-size: .67rem; }
.alert-actions { display: grid; justify-items: end; gap: 8px; }
.ai-alert-button { min-height: 30px; padding: 0 9px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border)); border-radius: 8px; background: var(--surface); color: var(--primary); font-size: .65rem; font-weight: 680; white-space: nowrap; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.ai-alert-button:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.ai-alert-button:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }
.ai-alert-button svg { width: 13px; height: 13px; }

.chat-layout { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 16px; min-height: calc(100vh - 188px); }
.chat-context { align-self: start; padding: 17px; }
.chat-context-head { display: flex; align-items: center; gap: 10px; padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.chat-context-head h2, .chat-title h2 { margin: 0; font-size: .82rem; }
.chat-context-head p, .chat-title p { margin: 3px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.4; }
.tool-mark, .assistant-mark { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); }
.tool-mark svg, .assistant-mark svg { width: 17px; height: 17px; }
.tool-list { display: grid; gap: 0; margin-top: 7px; }
.tool-list > div { padding: 11px 3px; border-bottom: 1px solid var(--border); }
.tool-list > div:last-child { border-bottom: 0; }
.tool-list strong, .tool-list span { display: block; }
.tool-list strong { font: 650 .68rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.tool-list span { margin-top: 4px; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.harness-safety { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; margin-top: 13px; padding: 11px; border-radius: 9px; color: var(--success); background: var(--success-soft); }
.harness-safety svg { width: 16px; height: 16px; margin-top: 1px; }
.harness-safety p { margin: 0; color: var(--muted); font-size: .67rem; line-height: 1.45; }
.harness-safety strong { color: var(--success); }
.chat-panel { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { min-height: 66px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--border); }
.chat-title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.harness-status { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); font-size: .64rem; font-weight: 650; }
.harness-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--subtle); }
.harness-status.online { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 20%, var(--border)); }
.harness-status.online i { background: var(--success); }
.harness-status.offline { color: var(--danger); background: var(--danger-soft); }
.harness-status.offline i { background: var(--danger); }
.harness-status.checking i { animation: status-pulse 1s infinite alternate; }
.chat-document-row { display: grid; grid-template-columns: auto minmax(160px, 1fr) auto; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.chat-document-row label { color: var(--muted); font-size: .68rem; font-weight: 650; }
.chat-document-row select { min-width: 0; height: 34px; padding: 0 30px 0 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .7rem; outline: 0; }
.chat-document-row select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chat-document-row .button { min-height: 34px; padding: 0 10px; }
.chat-auto-search { display: grid; grid-template-columns: 22px 1fr; gap: 9px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--primary); background: var(--primary-soft); }
.chat-auto-search svg { width: 16px; height: 16px; }
.chat-auto-search strong, .chat-auto-search span { display: block; }
.chat-auto-search strong { font-size: .7rem; }
.chat-auto-search span { margin-top: 2px; color: var(--muted); font-size: .64rem; }
.chat-transcript { min-height: 340px; flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 17px; padding: 22px 20px; }
.chat-message { display: grid; grid-template-columns: 31px minmax(0, 1fr); gap: 9px; max-width: 88%; }
.chat-message.user { grid-template-columns: minmax(0, 1fr) 31px; justify-self: end; }
.chat-message.user .chat-avatar { grid-column: 2; grid-row: 1; background: var(--text); color: var(--surface); font-size: .55rem; font-weight: 700; }
.chat-message.user .chat-bubble { grid-column: 1; grid-row: 1; background: var(--primary); color: white; border-color: var(--primary); border-radius: 12px 4px 12px 12px; }
.chat-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); }
.chat-avatar svg { width: 15px; height: 15px; }
.chat-bubble { min-width: 0; padding: 11px 13px; border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; background: var(--surface-2); color: var(--text); }
.chat-message.error .chat-bubble { border-color: color-mix(in srgb, var(--danger) 28%, var(--border)); background: var(--danger-soft); }
.chat-copy { font-size: .75rem; line-height: 1.65; overflow-wrap: anywhere; }
.chat-copy h3 { margin: 12px 0 4px; font-size: .75rem; }
.chat-copy h3:first-child { margin-top: 0; }
.chat-copy code { padding: 1px 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); font: .68rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.chat-list-item { display: grid; grid-template-columns: 12px 1fr; gap: 4px; }
.chat-spacer { height: 7px; }
.chat-meta { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--subtle); font-size: .62rem; }
.ai-comparisons { display: grid; gap: 7px; margin-top: 11px; }
.ai-comparisons section { padding: 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ai-comparisons section > strong { display: block; margin-bottom: 6px; font-size: .7rem; }
.ai-comparisons section > div { display: grid; grid-template-columns: 88px 1fr; gap: 7px; padding: 3px 0; font-size: .63rem; }
.ai-comparisons section span { color: var(--muted); }
.ai-comparisons section b { font-weight: 650; overflow-wrap: anywhere; }
.ai-comparisons section em { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--warning); font-size: .62rem; font-style: normal; }
.ai-captures { display: grid; gap: 9px; margin-top: 11px; }
.ai-captures figure { margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ai-captures a { display: block; background: #e5e7eb; }
.ai-captures img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.ai-captures figcaption { display: block; padding: 8px 9px; }
.ai-captures figcaption strong, .ai-captures figcaption span { display: block; }
.ai-captures figcaption strong { font-size: .66rem; }
.ai-captures figcaption span { margin-top: 2px; color: var(--muted); font-size: .59rem; }
.chat-tool-pills { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 9px; }
.chat-tool-pills span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-size: .6rem; font-weight: 650; }
.chat-tool-pills svg { width: 11px; height: 11px; }
.chat-bubble.thinking { display: flex; align-items: center; gap: 5px; min-height: 46px; }
.chat-bubble.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: thinking-dot .9s ease-in-out infinite alternate; }
.chat-bubble.thinking span:nth-child(2) { animation-delay: .15s; }
.chat-bubble.thinking span:nth-child(3) { animation-delay: .3s; }
.chat-bubble.thinking em { margin-left: 4px; color: var(--muted); font-size: .68rem; font-style: normal; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 20px 12px 60px; }
.chat-suggestions button { padding: 7px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .65rem; cursor: pointer; }
.chat-suggestions button:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.chat-composer { margin: 0 16px 8px; padding: 8px; display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 8px; align-items: end; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 22px rgba(15, 23, 42, .05); }
.chat-composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chat-composer textarea { width: 100%; max-height: 130px; resize: vertical; padding: 6px 7px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .74rem; line-height: 1.5; }
.chat-send { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px; background: var(--primary); color: white; cursor: pointer; }
.chat-send:disabled { opacity: .5; cursor: wait; }
.chat-send svg { width: 17px; height: 17px; }
.chat-footer { padding: 0 16px 11px; color: var(--subtle); text-align: center; font-size: .6rem; }
@keyframes thinking-dot { to { opacity: .28; transform: translateY(-2px); } }
@keyframes status-pulse { to { opacity: .25; } }

.ai-float-trigger { position: fixed; right: 22px; bottom: 22px; z-index: 70; min-height: 46px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; background: var(--primary); color: white; box-shadow: 0 14px 36px rgba(37, 99, 235, .3); font-size: .74rem; font-weight: 700; cursor: pointer; transition: transform .15s, opacity .15s; }
.ai-float-trigger:hover { transform: translateY(-2px); }
.ai-float-trigger.is-hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
.ai-float-trigger svg { width: 17px; height: 17px; }
.ai-float-panel { position: fixed; right: 18px; bottom: 18px; z-index: 75; width: min(460px, calc(100vw - 36px)); height: min(720px, calc(100vh - 36px)); display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transform: translateY(18px) scale(.98); transform-origin: bottom right; transition: opacity .18s, transform .18s; overflow: hidden; }
.ai-float-panel.is-open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.ai-float-header { min-height: 64px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.ai-float-header .assistant-mark { width: 32px; height: 32px; }
.ai-float-status { min-height: 30px; padding: 0 14px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); color: var(--muted); background: var(--surface-2); font-size: .61rem; }
.ai-float-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--subtle); }
.ai-float-status.online { color: var(--success); }
.ai-float-status.online i { background: var(--success); }
.ai-float-status.offline { color: var(--danger); }
.ai-float-status.offline i { background: var(--danger); }
.ai-float-transcript { min-height: 0; flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 14px; padding: 16px 14px; }
.ai-float-transcript .chat-message { max-width: 96%; }
.ai-float-composer { flex: none; margin-top: 8px; }

.drawer-scrim { position: fixed; inset: 0; z-index: 79; background: rgba(2, 6, 23, .46); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.detail-drawer { position: fixed; inset: 12px 12px 12px auto; z-index: 80; width: min(1080px, calc(100vw - 24px)); display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(calc(100% + 30px)); transition: transform .22s ease; overflow: hidden; }
.detail-drawer.is-open { transform: translateX(0); }
.drawer-scrim.is-open { opacity: 1; pointer-events: auto; }
.drawer-header { min-width: 0; min-height: 72px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.drawer-header > div { min-width: 0; }
.drawer-header h2 { margin: 0; overflow-wrap: anywhere; font-size: 1.05rem; letter-spacing: -.02em; }
.drawer-body { min-width: 0; min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 390px) minmax(0, 1fr); overflow: hidden; }
.expense-detail { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 18px; border-right: 1px solid var(--border); }
.detail-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.confidence { color: var(--muted); font-size: .69rem; }
.detail-section { min-width: 0; margin-top: 20px; }
.detail-section h3 { margin: 0 0 10px; color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.detail-field { padding: 11px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-field:nth-child(2n) { border-right: 0; }
.detail-field:nth-last-child(-n+2) { border-bottom: 0; }
.detail-field span, .comparison-row span { display: block; color: var(--muted); font-size: .66rem; }
.detail-field strong { display: block; margin-top: 4px; font-size: .76rem; }
.comparison-box { padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.comparison-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.comparison-row:last-child { border-bottom: 0; }
.comparison-row strong { font-size: .8rem; font-variant-numeric: tabular-nums; }
.reason-box { padding: 12px 13px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 9px 9px 0; color: var(--muted); font-size: .74rem; line-height: 1.55; }
.liqu-note-card { padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.liqu-note-card p { margin: 10px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.55; }
.liqu-note-card > strong { display: block; margin-top: 13px; font-size: .7rem; }
.liqu-note-card.conflict { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-soft); }
.liqu-note-card.unverified { border-color: color-mix(in srgb, var(--violet) 30%, var(--border)); }
.liqu-note-card.partial { border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.liqu-note-card.supported { border-color: color-mix(in srgb, var(--success) 28%, var(--border)); }
.confidence-list { display: grid; gap: 6px; }
.confidence-item { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .71rem; }
.confidence-item i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.evidence-list { min-width: 0; display: grid; gap: 7px; }
.evidence-button { min-width: 0; max-width: 100%; width: 100%; padding: 10px; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); text-align: left; cursor: pointer; }
.evidence-button > div { min-width: 0; overflow: hidden; }
.evidence-button:hover, .evidence-button.is-active { border-color: var(--primary); background: var(--primary-soft); }
.evidence-button svg { width: 15px; height: 15px; color: var(--danger); }
.evidence-button strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .69rem; }
.evidence-button span { display: block; margin-top: 2px; color: var(--muted); font-size: .63rem; }
.document-preview { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #2f3540; }
.preview-toolbar { min-width: 0; min-height: 48px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.preview-toolbar strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.preview-toolbar a { color: var(--primary); font-size: .7rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.document-preview iframe { flex: 1; width: 100%; min-height: 480px; border: 0; background: #fff; }
.preview-empty { flex: 1; display: grid; place-items: center; padding: 30px; color: #cbd5e1; text-align: center; }
.preview-empty svg { width: 34px; height: 34px; margin: 0 auto 10px; }
.preview-empty p { max-width: 280px; margin: 0; font-size: .76rem; line-height: 1.5; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); padding: 10px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: .75rem; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.mobile-scrim { display: none; }

@media (max-width: 1120px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .dashboard-grid, .compare-layout { grid-template-columns: 1fr; }
  .provider-grid, .document-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-scrim { position: fixed; inset: 0; z-index: 39; display: block; background: rgba(2, 6, 23, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .mobile-scrim.is-open { opacity: 1; pointer-events: auto; }
  .main-area { margin-left: 0; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 14px; }
  .content { padding: 22px 16px 50px; }
  .audit-brief { grid-template-columns: 1fr; }
  .brief-copy { border-right: 0; border-bottom: 1px solid var(--border); }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .drawer-body { display: block; overflow-x: hidden; overflow-y: auto; }
  .expense-detail { min-height: auto; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--border); }
  .document-preview { height: 70vh; min-height: 560px; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-context { display: none; }
  .chat-panel { min-height: calc(100vh - 180px); }
}

@media (max-width: 600px) {
  .breadcrumb span, .breadcrumb b, .month-picker span { display: none; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi, .kpi:nth-child(2) { border-right: 0; border-bottom: 1px solid var(--border); }
  .kpi:last-child { border-bottom: 0; }
  .donut-layout { grid-template-columns: 1fr; justify-items: center; }
  .legend-list { width: 100%; }
  .provider-grid, .document-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 64px 1fr; }
  .timeline-amount { grid-column: 2; }
  .alert-row { grid-template-columns: 34px 1fr; }
  .alert-actions { grid-column: 2; justify-items: start; grid-auto-flow: column; align-items: center; }
  .detail-drawer { inset: 0; width: 100vw; border-radius: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-field, .detail-field:nth-child(2n) { border-right: 0; border-bottom: 1px solid var(--border); }
  .detail-field:last-child { border-bottom: 0; }
  .chat-header { align-items: flex-start; }
  .harness-status { max-width: 140px; white-space: normal; }
  .chat-document-row { grid-template-columns: 1fr auto; }
  .chat-document-row label { grid-column: 1 / -1; }
  .chat-message { max-width: 96%; }
  .chat-suggestions { padding-left: 20px; }
  .ai-float-trigger { right: 14px; bottom: 14px; }
  .ai-float-panel { inset: 0; width: 100vw; height: 100vh; max-height: none; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
