:root {
  --ink: #19211d;
  --muted: #6d7771;
  --line: #dfe4df;
  --paper: #f7f6f1;
  --panel: #ffffff;
  --forest: #173f34;
  --forest-2: #245b4a;
  --sage: #dfece5;
  --amber: #b86d24;
  --red: #a8463b;
  --shadow: 0 18px 48px rgba(34, 45, 39, 0.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--forest); color: white; font-family: Georgia, serif; font-size: 24px;
  box-shadow: 0 6px 18px rgba(23,63,52,.22);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; letter-spacing: -.02em; }
h2 { font-size: 17px; letter-spacing: -.015em; }
h3 { font-size: 15px; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.milestone { display: flex; align-items: center; gap: 9px; color: var(--forest); background: var(--sage); border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 650; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #39916f; box-shadow: 0 0 0 4px rgba(57,145,111,.14); }
.brand-link { color: inherit; text-decoration: none; }
.topbar-action { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid var(--forest); border-radius: 9px; color: white; background: var(--forest); box-shadow: 0 6px 16px rgba(23,63,52,.16); font-size: 11px; font-weight: 750; text-decoration: none; transition: .16s ease; }
.topbar-action:hover { background: var(--forest-2); transform: translateY(-1px); }
.topbar-action.secondary { border-color: var(--line); color: var(--forest); background: white; box-shadow: none; }
.topbar-action.secondary:hover { border-color: #a7b8af; background: #f7f9f7; }
.sync-button-icon { font-size: 16px; line-height: 1; }
.topbar-actions-auth { display: flex; align-items: center; gap: 9px; }
.signed-in-user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.signed-in-user strong { max-width: 190px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.signed-in-user small { margin-top: 3px; color: var(--muted); font-size: 8px; text-transform: capitalize; }

.login-page-body { min-height: 100%; background: radial-gradient(circle at 25% 10%, #edf4ef 0, transparent 38%), var(--paper); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.97); box-shadow: var(--shadow); }
.login-brand { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.login-copy { padding: 28px 0 22px; }
.login-copy h2 { margin-top: 6px; font-size: 26px; }
.login-copy > p:last-child { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.microsoft-sign-in { width: 100%; display: flex; align-items: center; justify-content: center; gap: 11px; padding: 12px 16px; border: 1px solid #b7beb9; border-radius: 9px; color: var(--ink); background: white; font-size: 12px; font-weight: 700; text-decoration: none; transition: .16s ease; }
.microsoft-sign-in:hover { border-color: var(--forest); background: #f8faf8; transform: translateY(-1px); }
.microsoft-mark { width: 17px; height: 17px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.microsoft-mark i:nth-child(1) { background: #f25022; }.microsoft-mark i:nth-child(2) { background: #7fba00; }
.microsoft-mark i:nth-child(3) { background: #00a4ef; }.microsoft-mark i:nth-child(4) { background: #ffb900; }
.login-help { margin-top: 15px; color: var(--muted); font-size: 9px; text-align: center; }
.login-error { margin-bottom: 14px; padding: 10px 12px; border: 1px solid #edc5c0; border-radius: 8px; color: var(--red); background: #fff4f2; font-size: 10px; line-height: 1.45; }

.access-page { max-width: 1120px; }
.access-table-wrap { overflow-x: auto; }
.access-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.access-table th { padding: 9px 12px; color: var(--muted); font-size: 8px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
.access-table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.access-table td:first-child strong, .access-table td:first-child small { display: block; }
.access-table td:first-child small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.access-table td:last-child { width: 1%; text-align: right; white-space: nowrap; }
.access-status { display: inline-flex; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 750; }
.access-status.active { color: var(--forest); background: var(--sage); }
.access-status.inactive { color: var(--red); background: #f8e4e1; }
.access-modal { width: min(460px, calc(100% - 32px)); }
.access-field { display: grid; gap: 5px; margin: 14px 0; }
.access-field span { color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.access-field input, .access-field select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; font: inherit; }
.access-field input:read-only { color: var(--muted); background: #f3f5f2; }
.access-check { display: flex; align-items: center; gap: 8px; margin: 15px 0; font-size: 11px; }
.audit-list { display: grid; }
.audit-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 2px; border-top: 1px solid var(--line); }
.audit-row:first-child { border-top: 0; }
.audit-row strong { font-size: 10px; }.audit-row p, .audit-row time { margin-top: 3px; color: var(--muted); font-size: 9px; }

.sync-page-body { min-height: 100%; height: auto; background: #f3f5f2; }
.sync-page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 56px; }
.sync-page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.sync-page-heading h2 { margin-top: 5px; font-size: 27px; letter-spacing: -.025em; }
.sync-page-heading > div > p:last-child { margin-top: 7px; color: var(--muted); font-size: 12px; }
.sync-safety-badge { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid #cddbd3; border-radius: 999px; color: var(--forest); background: var(--sage); font-size: 10px; font-weight: 750; white-space: nowrap; }
.sync-safety-dot { width: 7px; height: 7px; border-radius: 50%; background: #39916f; box-shadow: 0 0 0 3px rgba(57,145,111,.12); }
.sync-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; border: 1px solid var(--line); border-radius: 13px; background: white; overflow: hidden; box-shadow: 0 10px 30px rgba(34,45,39,.045); }
.sync-summary article { min-width: 0; padding: 15px 17px; }
.sync-summary article + article { border-left: 1px solid var(--line); }
.sync-summary span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.sync-summary strong { font-size: 18px; }
.sync-section { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 10px 30px rgba(34,45,39,.045); }
.sync-section-title { margin-bottom: 13px; }
.sync-section-title p { margin-top: 4px; color: var(--muted); font-size: 10px; }
.sync-connection-list { display: grid; gap: 12px; }
.sync-connection-card { border: 1px solid var(--line); border-radius: 12px; background: #fafbf9; overflow: hidden; }
.sync-connection-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px; border-bottom: 1px solid var(--line); background: white; }
.sync-company-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sync-company-mark { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--forest); font-family: Georgia, serif; font-size: 18px; }
.sync-company-title-row { display: flex; align-items: center; gap: 9px; }
.sync-company-identity p { margin-top: 3px; color: var(--muted); font-size: 10px; }
.sync-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 750; }
.sync-status > span { width: 6px; height: 6px; border-radius: 50%; }
.sync-status.unconfigured { color: #7d561f; background: #fbefdc; }
.sync-status.unconfigured > span { background: var(--amber); }
.sync-card-actions { display: flex; align-items: center; gap: 8px; }
.sync-card-actions button:disabled { cursor: not-allowed; opacity: .48; transform: none; box-shadow: none; }
.sync-connection-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.sync-detail { min-width: 0; padding: 13px 15px; background: #fafbf9; }
.sync-detail.wide { grid-column: 1 / -1; }
.sync-detail span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.sync-detail strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sync-detail strong.empty-value { color: var(--muted); font-weight: 600; }
.sync-setup-note { display: flex; align-items: center; gap: 8px; padding: 10px 15px; color: var(--muted); background: #f5f7f4; font-size: 10px; }
.sync-setup-note > span { flex: 0 0 auto; width: 17px; height: 17px; display: grid; place-items: center; border: 1px solid #aebeb5; border-radius: 50%; color: var(--forest); font-size: 9px; font-weight: 800; }
.sync-empty-activity { min-height: 155px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; border: 1px dashed #ccd5cf; border-radius: 11px; color: var(--muted); text-align: center; background: #fafbf9; }
.sync-empty-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--forest); background: var(--sage); font-size: 18px; }
.sync-empty-activity p { max-width: 420px; font-size: 10px; line-height: 1.5; }
.sync-service-banner { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; padding: 12px 14px; border: 1px solid #d6dfda; border-radius: 11px; background: #f8faf8; }
.sync-service-icon { flex: 0 0 auto; width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid #9fb3a8; border-radius: 50%; color: var(--forest); font-size: 11px; font-weight: 800; }
.sync-service-banner strong { display: block; font-size: 11px; }
.sync-service-banner p { margin-top: 2px; color: var(--muted); font-size: 10px; }
.sync-endpoint-status { margin-left: auto; padding: 5px 8px; border-radius: 999px; color: #8a5a18; background: #fff1dd; font-size: 9px; font-weight: 750; white-space: nowrap; }
.sync-endpoint-status.ready { color: #315b48; background: #e5f1e9; }
.sync-status.ready { color: #315b48; background: #e7f2eb; }
.sync-status.ready > span { background: #39916f; }
.sync-status.verified { color: white; background: var(--forest); }
.sync-status.verified > span { background: #85d3ac; }
.sync-status.error { color: var(--red); background: #f9e7e5; }
.sync-status.error > span { background: var(--red); }
.sync-setup-note.ready { color: #315b48; background: #edf5f0; }
.sync-error-value { color: var(--red); }
.sync-activity-list { display: grid; }
.sync-activity-row { display: grid; grid-template-columns: 9px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px 6px; border-top: 1px solid var(--line); }
.sync-activity-row:first-child { border-top: 0; }
.sync-activity-marker { width: 7px; height: 7px; border-radius: 50%; background: #8ba197; }
.sync-activity-row.success .sync-activity-marker { background: #39916f; }
.sync-activity-row.error .sync-activity-marker { background: var(--red); }
.sync-activity-row strong { font-size: 10px; }
.sync-activity-row p { margin-top: 2px; color: var(--muted); font-size: 10px; }
.sync-activity-row time { color: var(--muted); font-size: 9px; white-space: nowrap; }

@media (max-width: 760px) {
  .sync-page { width: min(100% - 24px, 1180px); padding-top: 22px; }
  .sync-page-heading, .sync-connection-header { align-items: stretch; flex-direction: column; }
  .sync-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-summary article:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .sync-summary article:nth-child(4) { border-top: 1px solid var(--line); }
  .sync-connection-details { grid-template-columns: 1fr; }
  .sync-detail.wide { grid-column: auto; }
  .sync-card-actions { justify-content: flex-end; }
}

.workspace {
  --rail-width: 238px;
  --document-width: minmax(380px, 1fr);
  position: relative;
  height: calc(100vh - 76px);
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-width) 7px var(--document-width) 7px minmax(360px, 1fr);
  background: var(--line);
}
.workspace.invoice-hidden { grid-template-columns: var(--rail-width) 7px 38px 0 minmax(410px, 1fr); }
.workspace.selection-hidden { grid-template-columns: 38px 0 var(--document-width) 7px minmax(360px, 1fr); }
.workspace.selection-hidden.invoice-hidden { grid-template-columns: 38px 0 38px 0 minmax(410px, 1fr); }
.workspace.vendor-page-mode { grid-template-columns: var(--rail-width) 7px 0 0 minmax(360px, 1fr); }
.workspace.vendor-page-mode.selection-hidden { grid-template-columns: 38px 0 0 0 minmax(360px, 1fr); }
.workspace.vendor-page-mode .document-panel,
.workspace.vendor-page-mode .panel-resizer { display: none; }
.workspace.vendor-page-mode .extraction-toolbar { display: none; }
.invoice-rail, .document-panel, .extraction-panel { min-width: 0; background: var(--panel); }
.invoice-rail { grid-column: 1; }
.rail-resizer { grid-column: 2; }
.document-panel { grid-column: 3; }
.panel-resizer { grid-column: 4; }
.extraction-panel { grid-column: 5; }
.invoice-rail { min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 14px; border-right: 1px solid var(--line); }
.selector-tab-bar { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 4px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.selector-tab { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 750; }
.selector-tab:hover { background: #f3f5f2; }
.selector-tab.active { color: var(--forest); background: var(--sage); }
.selector-tab .count-badge { min-width: 22px; padding: 3px 5px; font-size: 9px; }
.selector-panel { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.rail-heading, .panel-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.rail-heading { padding: 0 8px 16px; }
.rail-actions { display: flex; align-items: center; gap: 6px; }
.rail-toggle { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 8px; color: var(--forest); background: white; cursor: pointer; font-size: 20px; line-height: 1; }
.rail-toggle:hover { background: #f3f5f2; border-color: #a7b8af; }
.count-badge { min-width: 30px; padding: 5px 8px; border-radius: 999px; background: #eef1ee; color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.search-box { display: flex; align-items: center; gap: 7px; margin: 0 2px 14px; padding: 9px 11px; border: 1px solid var(--line); background: #fafbf9; border-radius: 10px; color: var(--muted); }
.search-box:focus-within { border-color: #8aa99a; box-shadow: 0 0 0 3px rgba(36,91,74,.1); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.invoice-list { min-height: 0; flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 5px; padding: 1px 6px 18px 2px; scrollbar-gutter: stable; }
.vendor-row-chevron { color: var(--forest); transition: transform .16s ease; }
.vendors-list { min-height: 0; flex: 1; overflow-y: auto; padding: 1px 2px 12px; }
.saved-company-group { border-bottom: 1px solid #e5eae6; }
.vendor-group, .destination-group { min-width: 0; }
.vendor-row { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) 28px; align-items: center; }
.vendor-row:has(.vendor-heading:only-child) { grid-template-columns: minmax(0,1fr); }
.vendor-page-button { width: 24px; height: 28px; display: grid; place-items: center; margin-right: 3px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 18px; font-weight: 800; line-height: 1; }
.vendor-page-button:hover { color: var(--forest); background: var(--sage); }
.hierarchy-heading { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 7px; border: 0; color: var(--ink); background: transparent; cursor: pointer; text-align: left; }
.hierarchy-heading span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hierarchy-heading:hover { background: #f3f5f2; }
.hierarchy-heading[aria-expanded="true"] .vendor-row-chevron { transform: rotate(90deg); }
.company-heading { padding: 10px 7px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.vendor-heading { padding: 9px 4px 9px 17px; font-size: 11px; font-weight: 700; }
.destination-heading { padding: 8px 7px 8px 27px; color: var(--muted); font-size: 10px; font-weight: 700; }
.saved-invoice-list { min-width: 0; display: grid; gap: 3px; padding: 0 4px 7px 30px; }
.saved-invoice-button { width: 100%; min-width: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 9px; border: 0; border-radius: 8px; color: var(--ink); background: transparent; cursor: pointer; text-align: left; }
.saved-invoice-button:hover { background: #f3f5f2; }
.saved-invoice-button.active { color: white; background: var(--forest); }
.saved-preview-number { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; }
.saved-preview-total { white-space: nowrap; color: var(--muted); font-size: 10px; font-weight: 700; }
.saved-invoice-button.active .saved-preview-total { color: #bed2c8; }
.readonly-line-table tbody tr { cursor: default; }
.vendor-page { display: grid; gap: 16px; }
.vendor-page-heading { padding: 5px 2px 2px; }
.vendor-page-heading h2 { margin-top: 4px; font-size: 22px; }
.vendor-page-heading > p:last-child { margin-top: 5px; color: var(--muted); font-size: 11px; }
.vendor-page-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.vendor-page-invoices { display: grid; gap: 5px; }
.vendor-page-invoice { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 11px 12px; border: 1px solid transparent; border-radius: 9px; color: var(--ink); background: #f7f9f7; cursor: pointer; text-align: left; }
.vendor-page-invoice:hover { border-color: #9fb4a9; background: var(--sage); }
.vendor-page-invoice strong, .vendor-page-invoice small { display: block; }
.vendor-page-invoice strong { font-size: 12px; }
.vendor-invoice-heading { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.vendor-invoice-heading strong { flex: 0 0 auto; }
.vendor-invoice-heading em { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.vendor-page-invoice small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.vendor-page-invoice > span:last-child { font-size: 12px; font-weight: 750; }
.vendor-configuration { background: #fafbf9; }
.vendor-configuration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.vendor-configuration-field { min-width: 0; }
.vendor-configuration-field.wide { grid-column: 1 / -1; }
.vendor-configuration-field > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.vendor-configuration-value { min-height: 34px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; font-size: 11px; line-height: 1.45; white-space: normal; }
.vendor-configuration-value.empty { color: transparent; }
.vendor-configuration-input { width: 100%; min-height: 34px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--ink); background: white; font: inherit; font-size: 11px; line-height: 1.4; }
.vendor-configuration-input:focus { border-color: #7f9f8f; box-shadow: 0 0 0 3px rgba(36,91,74,.1); }
.vendor-company-toggle { width: 100%; min-height: 34px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--forest); background: white; cursor: pointer; font: inherit; font-size: 11px; font-weight: 750; text-align: left; }
.vendor-company-toggle:hover, .vendor-company-toggle:focus-visible { border-color: #7f9f8f; background: var(--sage); outline: 0; box-shadow: 0 0 0 3px rgba(36,91,74,.1); }
textarea.vendor-configuration-input { min-height: 68px; resize: vertical; }
.default-item-editor { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; }
.default-item-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.default-item-chip { max-width: 100%; display: inline-flex; align-items: center; gap: 7px; padding: 6px 7px 6px 9px; border: 1px solid #cfd9d3; border-radius: 999px; color: var(--ink); background: white; font-size: 10px; }
.default-item-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.default-item-chip button { flex: 0 0 auto; width: 18px; height: 18px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: #edf1ee; cursor: pointer; font-size: 14px; line-height: 1; }
.default-item-chip button:hover { color: white; background: var(--red); }
.vendor-configuration-choice { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid #e7d2b9; border-radius: 9px; color: var(--ink); background: #fff9f0; font-size: 11px; font-weight: 650; }
.vendor-configuration-choice input { width: 16px; height: 16px; accent-color: var(--forest); }
.invoice-button { width: 100%; border: 0; border-radius: 11px; padding: 11px 12px; text-align: left; background: transparent; color: var(--ink); cursor: pointer; transition: .16s ease; }
.invoice-button:hover { background: #f3f5f2; }
.invoice-button.active { background: var(--forest); color: white; box-shadow: 0 8px 20px rgba(23,63,52,.18); }
.invoice-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
.invoice-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.invoice-button.active .invoice-meta { color: #bed2c8; }
.inbox-invoice-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 9px; align-items: baseline; }
.inbox-vendor, .inbox-amount { font-size: 11px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-amount { text-align: right; }
.inbox-multiple { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--amber); font-size: 9px; font-weight: 800; text-align: right; white-space: nowrap; }
.inbox-filename, .inbox-due-date { min-width: 0; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-due-date { text-align: right; }
.invoice-button.active .inbox-filename, .invoice-button.active .inbox-due-date { color: #bed2c8; }
.rail-message { padding: 24px 10px; color: var(--muted); font-size: 12px; text-align: center; }

.document-panel, .extraction-panel { display: flex; flex-direction: column; min-height: 0; }
.extraction-panel { overflow: hidden; }
.workspace.invoice-hidden .document-panel { display: flex; }
.workspace.invoice-hidden .document-panel > :not(.invoice-tab), .workspace.invoice-hidden .panel-resizer { display: none; }
.workspace.vendor-page-mode .document-panel,
.workspace.vendor-page-mode .invoice-tab,
.workspace.vendor-page-mode .panel-resizer { display: none; }
.workspace.selection-hidden .invoice-rail { display: flex; padding: 0; }
.workspace.selection-hidden .invoice-rail > :not(.collapsed-selector-stack) { display: none; }
.workspace.selection-hidden .rail-resizer { display: none; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.rail-resizer, .panel-resizer { position: relative; z-index: 2; cursor: col-resize; background: var(--line); touch-action: none; }
.rail-resizer::after, .panel-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 3px; background: transparent; transition: background .15s ease; }
.rail-resizer:hover::after, .rail-resizer.dragging::after, .rail-resizer:focus-visible::after,
.panel-resizer:hover::after, .panel-resizer.dragging::after, .panel-resizer:focus-visible::after { background: #7da08f; }
.rail-resizer:focus-visible, .panel-resizer:focus-visible { outline: 2px solid var(--forest-2); outline-offset: -2px; }
.collapsed-panel-tab { width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 13px 0; border: 0; border-right: 1px solid var(--line); color: var(--forest); background: #f8faf8; cursor: pointer; }
.collapsed-selector-stack { width: 100%; height: 100%; min-height: 0; display: grid; grid-template-rows: 1fr 1fr; }
.collapsed-selector-stack .collapsed-panel-tab + .collapsed-panel-tab { border-top: 1px solid var(--line); }
.collapsed-panel-tab:hover { background: var(--sage); }
.collapsed-tab-arrow { font-size: 20px; line-height: 1; }
.collapsed-tab-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 750; letter-spacing: .04em; }
.invoice-tab { border-left: 1px solid var(--line); background: white; }
body.resizing-panels { cursor: col-resize; user-select: none; }
body.resizing-panels iframe { pointer-events: none; }
.panel-toolbar { min-height: 74px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.extraction-toolbar { position: relative; z-index: 40; flex: 0 0 auto; background: white; }
.extraction-toolbar > div { min-width: 0; }
.panel-toolbar h2 { margin-top: 3px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-stage { min-height: 0; flex: 1; padding: 14px; background: #eceeea; }
#pdf-frame { width: 100%; height: 100%; border: 0; border-radius: 10px; background: white; box-shadow: var(--shadow); }
.empty-state { height: 100%; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--muted); padding: 28px; }
.empty-state p { max-width: 330px; font-size: 12px; line-height: 1.55; }
.paper-icon { width: 66px; height: 78px; display: grid; place-items: center; background: white; border: 1px solid #d8ddd8; border-radius: 8px 8px 15px 8px; color: var(--forest); font-size: 11px; font-weight: 800; box-shadow: var(--shadow); }
.spark-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--sage); color: var(--forest); font-size: 20px; }

.ghost-button, .primary-button { border-radius: 9px; padding: 9px 12px; font-size: 11px; font-weight: 750; text-decoration: none; transition: .16s ease; }
.ghost-button { border: 1px solid var(--line); color: var(--forest); background: white; }
.ghost-button:hover { border-color: #a7b8af; background: #f7f9f7; }
.ghost-button.disabled { opacity: .42; pointer-events: none; }
.primary-button { flex: 0 0 auto; white-space: nowrap; border: 0; color: white; background: var(--forest); cursor: pointer; box-shadow: 0 6px 16px rgba(23,63,52,.18); }
.primary-button:hover:not(:disabled) { background: var(--forest-2); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .42; box-shadow: none; }

.extraction-content { overflow: auto; padding: 16px 18px 30px; }
.empty-state.compact { min-height: 440px; }
.loading-card { border: 1px solid var(--line); border-radius: 14px; padding: 22px; background: #fafbf9; text-align: center; }
.spinner { width: 26px; height: 26px; margin: 0 auto 12px; border: 3px solid #dbe5df; border-top-color: var(--forest); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card h3 { margin-bottom: 6px; }
.loading-card p, .error-card p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.error-card { padding: 16px; border: 1px solid #e8c7c3; border-radius: 12px; background: #fff7f6; color: var(--red); }

.section { margin-bottom: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.section-title h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.details-button { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; color: var(--forest); background: white; cursor: pointer; font-size: 10px; font-weight: 750; }
.details-button:hover, .details-button[aria-expanded="true"] { border-color: #9fb4a9; background: var(--sage); }
.line-section-actions { display: flex; align-items: center; gap: 7px; }
.line-items-title { justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.line-title-group { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.line-balance { color: var(--muted); font-size: 10px; font-weight: 650; }
.line-balance-number.remaining { color: var(--ink); }
.line-balance-number.excess { color: var(--red); }
.delete-lines-button { border: 1px solid #d8aaa5; border-radius: 8px; padding: 6px 9px; color: var(--red); background: #fff7f6; cursor: pointer; font-size: 10px; font-weight: 750; }
.delete-lines-button:hover { border-color: var(--red); background: #f9e7e5; }
.cache-note { font-size: 10px; color: var(--muted); }
.recognition-note { margin-top: 9px; padding: 9px 11px; border-radius: 9px; background: #f4f6f4; color: var(--muted); font-size: 11px; line-height: 1.45; }
.recognition-note.matched { background: #edf5f0; color: #315b48; }
.recognition-note.ambiguous { background: #fff5e8; color: #8a5a18; }
.recognition-guidance { color: var(--muted); font-size: 12px; line-height: 1.55; }
.field-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: visible; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.field { min-width: 0; padding: 10px 11px; background: white; }
.field.wide { grid-column: 1 / -1; }
.field-label { display: block; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.field-value { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 12px; font-weight: 650; line-height: 1.35; white-space: pre-line; }
.editable-field { position: relative; z-index: 1; display: block; }
.editable-field:focus-within { z-index: 100; }
.field-input { width: 100%; margin-top: 3px; padding: 5px 6px; border: 1px solid transparent; border-radius: 6px; outline: 0; color: var(--ink); background: #f7f9f7; font-size: 12px; font-weight: 650; line-height: 1.35; }
.field-input:hover:not([readonly]) { border-color: #cbd5cf; }
.field-input:focus:not([readonly]) { border-color: #7f9f8f; background: white; box-shadow: 0 0 0 3px rgba(36,91,74,.1); }
.field-input[readonly] { color: var(--muted); cursor: default; }
.address-input { min-height: 62px; resize: vertical; font-family: inherit; }
.vendor-options { position: absolute; z-index: 1000; top: calc(100% - 5px); left: 8px; right: 8px; max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: 0 18px 48px rgba(20,35,27,.22); }
.vendor-option { display: block; width: 100%; min-height: 34px; padding: 8px 10px; border: 0; border-bottom: 1px solid #eef1ee; color: var(--ink); background: white; cursor: pointer; text-align: left; font-size: 11px; }
.vendor-option:last-child { border-bottom: 0; }
.vendor-option:hover { color: white; background: var(--forest); }
.routing-warning { margin-top: 8px; padding: 9px 10px; border-radius: 9px; background: #fff7ea; color: #8d581d; font-size: 10px; line-height: 1.45; }
.summary-row { display: flex; flex-wrap: wrap; gap: 7px; }
.status-pill { border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 750; }
.status-pill.neutral { background: #eef1ee; color: var(--muted); }
.status-pill.matched { background: #e4f1ea; color: #256149; }
.status-pill.ambiguous { background: #fff0dc; color: #975b19; }
.status-pill.unmatched { background: #f9e7e5; color: #983f36; }
.line-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.line-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.line-table th { position: sticky; top: 0; padding: 8px; color: var(--muted); background: #f4f6f3; font-size: 8px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.line-table td { padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; line-height: 1.35; }
.line-table tbody tr { cursor: pointer; transition: background .14s ease, box-shadow .14s ease; }
.line-table tbody tr.selected-line { background: #e4f1ea; box-shadow: inset 3px 0 0 var(--forest-2); }
.line-table tbody tr.selected-line .line-input { background: rgba(255,255,255,.76); }
.line-details-section .detail-column { display: none; }
.line-details-section.details-visible .detail-column { display: table-cell; }
.line-table .num { text-align: right; white-space: nowrap; }
.line-input { width: 100%; min-width: 74px; padding: 5px 6px; border: 1px solid transparent; border-radius: 6px; outline: 0; color: var(--ink); background: #f7f9f7; font-size: 10px; }
.line-input:hover { border-color: #cbd5cf; }
.line-input:focus { border-color: #7f9f8f; background: white; box-shadow: 0 0 0 3px rgba(36,91,74,.1); }
.line-input.number-input { min-width: 82px; text-align: right; }
.line-input.item-input { min-width: 180px; font-weight: 700; }
.item-input-wrapper { position: relative; min-width: 180px; display: flex; align-items: center; }
.item-input-wrapper .item-input { padding-right: 27px; }
.item-menu-toggle { position: absolute; top: 50%; right: 3px; width: 23px; height: 23px; display: flex; align-items: center; justify-content: center; padding: 0; transform: translateY(-50%); border: 0; border-radius: 5px; color: var(--forest); background: transparent; cursor: pointer; }
.item-menu-toggle > span { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; }
.item-menu-toggle:hover { background: var(--sage); }
.line-input.description-input { display: block; min-width: 210px; min-height: 27px; overflow-y: hidden; resize: none; box-sizing: border-box; font-family: inherit; line-height: 1.35; }
.line-input.short-input { min-width: 62px; }
.floating-options { position: fixed; z-index: 10000; max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: 0 18px 48px rgba(20,35,27,.28); }
.floating-options .vendor-option.keyboard-active { color: var(--forest); background: var(--sage); outline: none; }
.checkbox-cell { text-align: center; }
.switch { position: relative; display: inline-block; width: 30px; height: 17px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: #cdd4d0; transition: .16s ease; }
.switch-track::after { content: ""; position: absolute; width: 13px; height: 13px; top: 2px; left: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.22); transition: .16s ease; }
.switch input:checked + .switch-track { background: var(--forest-2); }
.switch input:checked + .switch-track::after { transform: translateX(13px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #7f9f8f; outline-offset: 2px; }
.item-cell { min-width: 115px; }
.desc-cell { min-width: 170px; }
.match-label { display: inline-block; margin-bottom: 3px; font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.match-label.matched { color: #267153; }
.match-label.ambiguous { color: var(--amber); }
.match-label.unmatched { color: var(--red); }
.qbd-item { display: block; color: var(--ink); font-weight: 650; }
.candidates { margin: 3px 0 0; padding-left: 13px; color: var(--muted); }
.line-submit-row { display: flex; justify-content: flex-end; margin-top: 14px; }
.submit-invoice-button { border: 0; border-radius: 9px; padding: 10px 18px; color: #fff; background: #d8751f; box-shadow: 0 6px 16px rgba(166,83,13,.2); cursor: pointer; font-size: 11px; font-weight: 800; }
.submit-invoice-button:hover:not(:disabled) { background: #bc5f11; transform: translateY(-1px); }
.submit-invoice-button:disabled { opacity: .55; cursor: wait; }
.modal-backdrop { position: fixed; z-index: 20000; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(20,32,26,.48); }
.modal-backdrop[hidden] { display: none; }
.validation-modal { width: min(440px, 100%); padding: 24px; border-radius: 16px; background: #fff; box-shadow: 0 24px 70px rgba(10,25,17,.3); }
.validation-heading { display: flex; align-items: center; gap: 12px; }
.validation-icon { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #9b581b; background: #fff0dc; font-size: 20px; font-weight: 850; }
.validation-messages { display: grid; gap: 8px; margin-top: 12px; color: var(--ink); font-size: 12px; line-height: 1.5; }
.validation-messages p { padding: 9px 10px; border-radius: 8px; background: #f5f7f4; }
.validation-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 210px minmax(360px, 1fr); }
  .workspace.selection-hidden { grid-template-columns: 38px minmax(360px, 1fr); }
  .workspace.invoice-hidden { grid-template-columns: 210px 38px; }
  .workspace.selection-hidden.invoice-hidden { grid-template-columns: 38px 38px; }
  .document-panel { grid-column: 2; }
  .rail-resizer, .panel-resizer { display: none; }
  .extraction-panel { position: fixed; z-index: 5; right: 0; top: 76px; width: min(480px, 52vw); height: calc(100vh - 76px); box-shadow: -18px 0 45px rgba(27,40,33,.12); }
  .workspace.invoice-hidden .extraction-panel { left: 248px; right: 0; width: auto; box-shadow: none; }
  .workspace.invoice-hidden.selection-hidden .extraction-panel { left: 76px; }
}
@media (max-width: 760px) {
  .milestone { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 76px); grid-template-columns: 1fr; }
  .invoice-rail, .document-panel, .extraction-panel { grid-column: 1; }
  .invoice-rail { max-height: 250px; }
  .document-panel { height: 70vh; }
  .extraction-panel { position: static; width: auto; height: auto; box-shadow: none; }
  .empty-state.compact { min-height: 280px; }
}
