body { margin: 0; color: var(--color-text); background: var(--color-canvas); font: 14px/1.5 system-ui, sans-serif; }
main { max-width: 900px; margin: 2rem auto; padding: 1.5rem; background: var(--color-surface); border-radius: 12px; }
header { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.language { white-space: nowrap; }
label { display: block; margin: 1rem 0; }
input, select, button { font: inherit; padding: .5rem; }
button, a { cursor: pointer; }
button { margin: .2rem; }
li { padding: .5rem 0; border-bottom: 1px solid var(--color-border); overflow-wrap: anywhere; }
dialog { max-width: 32rem; border: 1px solid var(--color-border-strong); border-radius: 8px; }
#login-required::backdrop { background: var(--color-overlay); }
.login-required-actions { display: flex; align-items: center; gap: .75rem; }
.login-required-actions a { display: inline-block; padding: .5rem .7rem; border: 1px solid var(--color-text-muted); border-radius: 4px; }

.review-dialog {width: 94vw; max-width: 1500px; max-height: 90vh; overflow: auto;}
.review-layout {display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem;}
.review-page {display: block; width: 100%; height: auto; border: 1px solid var(--color-border-strong); margin: 1rem 0; touch-action: none;}
.review-dialog textarea {display: block; width: 95%;}
.review-dialog dl {display: grid; grid-template-columns: 1fr 1fr; font-size: .85rem;}
.review-dialog dd {margin: 0; overflow-wrap: anywhere;}
.review-dialog pre {white-space: pre-wrap; overflow-wrap: anywhere;}
@media (max-width: 700px) {.review-layout {grid-template-columns: 1fr;}}

.document-item { padding: .5rem 0; }
.document-name { font-weight: 600; }
.document-heading { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.document-heading .document-name { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.document-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; margin: 0; }
.document-actions button { font-size: .8rem; line-height: 1.2; padding: .15rem .35rem; margin: 0; min-height: 24px; }
.document-actions button:disabled { cursor: default; }
.document-steps { font-size: .85rem; line-height: 1.5; color: var(--color-text-muted); }
.document-completed { font-weight: 500; }

.review-line-error { color: var(--color-danger); border-color: var(--color-danger-border); }
.review-processing-warning { padding: 1rem; border: 1px solid var(--color-danger-border); border-radius: .5rem; background: var(--color-danger-surface); color: var(--color-danger); font-weight: 600; }

.document-phase, .document-status { font-weight: 500; }
.status-running { color: var(--color-danger); }
.status-waiting { color: var(--color-info); }
.status-succeeded { color: var(--color-success); }
.status-failed { color: var(--color-danger); }
.status-unknown { color: var(--color-text-muted); }

.review-layout > div { min-width: 0; }
.review-table-scroll { overflow: auto; max-height: 65vh; border: 1px solid var(--color-border-strong); }
.review-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .7rem; line-height: 1.35; }
.review-table caption { text-align: left; font-weight: 600; padding: .5rem; }
.review-table th, .review-table td { border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); padding: .2rem .22rem; vertical-align: top; }
.review-table thead th { position: sticky; top: 0; background: var(--color-surface-inset); z-index: 1; text-align: left; }
.review-table tbody tr:nth-child(even) { background: var(--color-surface-inset); }
.review-table .cell-number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.review-table .cell-description { min-width: 7rem; overflow-wrap: anywhere; }
.review-table .cell-supplier_article_code { min-width: 4rem; overflow-wrap: anywhere; }
.review-table button { font-size: inherit; margin: 0; padding: .15rem .35rem; }
.review-table th span { display: block; font-size: .7rem; }
.review-table tbody tr.review-row-selected { background: var(--color-source-surface); outline: 2px solid var(--color-source); outline-offset: -2px; }
.review-table tbody tr.review-line-error { background: var(--color-danger-surface); }
.review-table tfoot { background: var(--color-surface-inset); font-weight: 600; }
.review-table tfoot td, .review-table tfoot th { border-top: 1px solid var(--color-success-border); }
.review-table tfoot tr:not(:first-child) td { font-weight: 400; white-space: normal; }
.review-table tfoot .review-extracted-totals { background: var(--color-surface-inset); }
.review-table tfoot .review-calculated-totals { background: var(--color-surface-inset); }
.review-item-checks > summary { cursor: pointer; font-weight: 600; }
.review-checks { margin: .6rem 0; }
.review-checks h3 { font-size: .9rem; margin: .4rem 0; }
.review-checks p { font-size: .78rem; margin: .2rem 0 .35rem; }
.review-checks .review-check-legend { margin: .65rem 0 0; text-align: end; color: var(--color-text-subtle); }
.review-checks ul { list-style: none; padding: 0; margin: 0; }
.review-checks li { display: flex; gap: .4rem; padding: .1rem 0; border: 0; font-size: .83rem; }
.review-check-symbol { flex: 0 0 1rem; font-weight: 700; }
.review-check-passed .review-check-symbol { color: var(--color-success); }
.review-check-failed .review-check-symbol { color: var(--color-danger); }
.review-check-not_checked .review-check-symbol,
.review-check-needs_review .review-check-symbol,
.review-check-warning .review-check-symbol { color: var(--color-warning); }

/* Keep the existing palette; organize commands and saved documents. */
header {display:block;border-bottom:1px solid var(--color-border-strong);padding-bottom:.65rem;}
header h1 {margin:0;}
.language {display:flex;gap:.4rem;padding:.7rem 0;}
.language button[aria-pressed="true"] {background:var(--color-surface-inset);border:2px solid var(--color-text-muted);font-weight:600;}
.icon-command {display:inline-flex;align-items:center;justify-content:center;min-width:0;min-height:0;padding:.15rem .25rem;}
.icon-command svg {width:18px;height:18px;}
.account-actions {display:flex;align-items:center;justify-content:space-between;gap:1rem;margin:.75rem 0;}
.account-actions label {display:flex;align-items:center;gap:.5rem;margin:0;}
.review-titlebar {display:flex;align-items:center;justify-content:space-between;gap:1rem;}
.review-titlebar h2 {margin:.25rem 0;}
.review-close {flex:0 0 auto;}
button:focus-visible, summary:focus-visible {outline:3px solid var(--color-info);outline-offset:2px;}
.issuer-group {border:1px solid var(--color-border-strong);border-radius:8px;margin:.65rem 0;overflow:hidden;}
.issuer-group > summary {cursor:pointer;font-weight:600;background:var(--color-canvas);padding:.65rem;overflow-wrap:anywhere;}
.issuer-group ul {list-style:none;margin:0;padding:0 1rem;}
.issuer-group li:last-child {border-bottom:0;}
#documents {padding-left:1.3rem;}
@media (max-width:600px) {main {margin:.5rem;padding:.75rem;} .language {flex-wrap:wrap;} .account-actions {align-items:flex-start;} .account-actions label {align-items:flex-start;flex-direction:column;} }

.document-filters {display:flex;flex-wrap:wrap;align-items:end;gap:.65rem;margin:1rem 0;}
.document-filters label {margin:0;min-width:0;}
.document-filters label span {display:block;font-size:.85rem;}
.document-filters input {width:100%;box-sizing:border-box;}
.document-filters button {margin:0;}

.catalog-document-heading { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.catalog-document-heading .document-name { flex: 1; min-width: 12rem; overflow-wrap: anywhere; }
.catalog-document-heading .document-actions { margin: 0; display: flex; gap: .4rem; }
.saved-notification { max-width: 34rem; border: 1px solid var(--color-success); padding: .75rem; background: var(--color-success-surface); margin-block: 1rem; }
.saved-notification::backdrop { background: var(--color-overlay); }
.saved-notification button { margin-left: .75rem; }
.review-data { overflow-wrap: anywhere; }
.review-data dt { font-weight: 600; margin-top: .35rem; }
.review-data dd { margin-left: .8rem; }
.review-total { font-weight: 700; border-top: 1px solid var(--color-border-strong); padding-top: .6rem; }
.review-confirmation { border: 1px solid var(--color-border-strong); border-radius: 6px; margin-block: .75rem; padding: .65rem; }
.review-confirmation-status { font-weight: 600; margin: 0 0 .5rem; }
.review-confirmation label { display: block; margin-block: .5rem; }
.review-dialog .review-data { display: block; }

.review-results { font-size: .875rem; }
.review-results dl { font-size: .8rem; }
.review-details-panel { border-top: 1px solid var(--color-border-strong); margin-top: .75rem; padding-top: .5rem; }
.review-details-panel > summary { cursor: pointer; font-weight: 600; }
.review-details-panel > details { margin-top: .5rem; }

.confirmation-dialog { max-width: min(34rem, calc(100vw - 4rem)); }
.confirmation-dialog h2 { margin-top: 0; font-size: 1.15rem; }
.confirmation-dialog p { white-space: pre-wrap; overflow-wrap: anywhere; }
.confirmation-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
/* Preview is plain text: document contents never become HTML. */
.exclusion-preview { max-width: 48rem; max-height: 85vh; overflow: auto; }
.exclusion-preview p { white-space: pre-wrap; overflow-wrap: anywhere; }


/* Visual identity adapted from Invoices-site; functional selectors stay stable. */
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { color:var(--color-text); background:var(--color-surface-muted); font-family:Arial, sans-serif; }
main { max-width:1160px; margin:0 auto; padding:0 32px 64px; background:transparent; border-radius:0; }
.app-header { display:flex; align-items:center; justify-content:space-between; min-height:84px; border-bottom:1px solid var(--color-border); padding:0; }
.brand { display:inline-flex; align-items:center; gap:10px; color:var(--color-text); font-size:21px; font-weight:700; text-decoration:none; }
.brand-mark { display:grid; grid-template-columns:repeat(2,6px); gap:3px; width:25px; height:25px; padding:5px; background:var(--color-accent); }
.brand-mark span { background:var(--color-surface-muted); }
.header-note,.muted,.pilot-note { color:var(--color-text-muted); }
.header-note { font-size:14px; }
h1,h2,h3 { line-height:1.15; }
h1 { margin:0 0 12px; font-size:clamp(30px,4vw,44px); font-weight:600; }
h2 { font-size:23px; font-weight:600; }
.eyebrow { margin:0 0 16px; color:var(--color-primary); font-size:11px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; }
button,input,select,textarea { border:1px solid var(--color-border); border-radius:5px; background:var(--color-surface); color:var(--color-text); }
button { padding:8px 13px; min-height:36px; }
button:hover:not(:disabled) { background:var(--color-primary-soft); border-color:var(--color-primary); }
button:disabled { opacity:.55; cursor:default; }
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible { outline:3px solid var(--color-primary); outline-offset:3px; }
.language { justify-content:flex-end; padding:12px 0; }
.language button { border:0; background:transparent; padding:4px 9px; font-size:12px; }
.language button[aria-pressed="true"] { border:0; background:var(--color-primary-soft); color:var(--color-primary); }
.account-actions { padding:16px 0; margin:0 0 28px; border-bottom:1px solid var(--color-border); }
.account-actions label { color:var(--color-text-muted); font-size:13px; }
.account-actions select { max-width:100%; }
.workspace-heading { margin:24px 0; }
.workspace-heading .muted { margin:0; }
.document-filters { padding:24px 0; gap:16px; border-bottom:1px solid var(--color-border); }
.document-filters label span { color:var(--color-text-muted); margin-bottom:6px; }
.document-filters input,.document-filters select { min-height:40px; }
.section-title { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:30px; }
.section-title h2 { margin:0; }
#documents { list-style:none; padding:0; }
#documents > li { background:var(--color-surface); padding:18px; border:1px solid var(--color-border); border-radius:8px; margin:12px 0; }
.document-actions { gap:6px; }
.document-actions button { min-height:32px; padding:5px 8px; }
.document-steps { margin-top:8px; color:var(--color-text-muted); }
.catalog-title { border-top:1px solid var(--color-border); padding-top:30px; }
.issuer-group { border-color:var(--color-border); }
.issuer-group > summary { background:var(--color-primary-soft); padding:16px; }
.issuer-group ul { background:var(--color-surface); }
dialog { padding:28px; border:1px solid var(--color-border); box-shadow:0 24px 80px var(--color-shadow-dialog); color:var(--color-text); }
dialog::backdrop { background:var(--color-overlay); }
.login-required-actions { flex-wrap:wrap; margin-top:24px; }
.login-required-actions a,.primary-link { display:inline-flex; align-items:center; justify-content:center; min-height:46px; padding:0 20px; background:var(--color-text); color:var(--color-surface); font-weight:600; text-decoration:none; border:0; border-radius:4px; }
.login-required-actions a:hover,.primary-link:hover { background:var(--color-primary); }
.welcome { display:grid; grid-template-columns:1.2fr 1fr; gap:48px; align-items:center; min-height:560px; }
.welcome h1 { font-size:clamp(38px,5.5vw,68px); max-width:620px; line-height:1.04; }
.welcome-summary { color:var(--color-text-muted); max-width:450px; font-size:18px; line-height:1.6; margin:24px 0; }
.pilot-note { font-size:12px; max-width:400px; margin-top:20px; }
.welcome-art { background:var(--color-primary-soft); border-radius:50% 50% 8px 8px; padding:58px 38px; }
.paper-preview { position:relative; background:var(--color-surface); padding:32px; min-height:300px; box-shadow:0 18px 30px var(--color-shadow-paper); transform:rotate(-5deg); }
.paper-brand { display:block; color:var(--color-primary); font-size:19px; font-weight:700; margin-bottom:30px; }
.paper-line { display:block; height:7px; background:var(--color-border); width:60%; margin:12px 0; }
.paper-line.wide { width:85%; }.paper-line.short { width:35%; margin-left:auto; }
.paper-table { margin:30px 0; }.paper-table span { display:block; height:20px; border-bottom:1px solid var(--color-border); }
.paper-seal { position:absolute; right:-16px; bottom:25px; display:grid; place-items:center; width:58px; height:58px; border-radius:50%; background:var(--color-accent); color:var(--color-text); font-size:26px; }
@media(max-width:700px) {
 main { margin:0; padding:0 18px 40px; }
 .app-header { min-height:72px; }.header-note { display:none; }
 .welcome { grid-template-columns:1fr; gap:24px; min-height:0; padding:36px 0; }.welcome-art { display:none; }
 .account-actions { gap:12px; }.account-actions label { min-width:0; flex:1; }
 .document-filters { gap:12px; }
 .document-filters label { flex:1 1 180px; }.document-filters select { width:100%; }
 dialog { max-width:calc(100vw - 28px); padding:20px; }.review-dialog { width:calc(100vw - 20px); }
 .section-title h2 { font-size:20px; }
}

#email-auth-form { margin-top:20px; border-block:1px solid var(--color-border); padding:18px 0; }
#email-auth-form label { margin:12px 0 5px; }
#email-auth-email,#email-auth-password,#email-auth-repeat { width:100%; min-height:42px; }
#email-auth-submit { background:var(--color-primary); color:var(--color-on-primary); width:100%; margin:12px 0; }
.email-auth-tabs,.email-auth-links { display:flex; flex-wrap:wrap; gap:8px; }
.email-auth-tabs button[aria-pressed="true"] { background:var(--color-primary-soft); border-color:var(--color-primary); }
.email-auth-links button { background:transparent; border:0; padding:4px 0; font-size:12px; color:var(--color-primary); }
#email-auth-form .show-password { display:flex; align-items:center; gap:8px; font-size:13px; }
#email-auth-form .muted,#email-auth-message { font-size:13px; }
#login-required { max-height:calc(100svh - 32px); overflow:auto; }

#login-required h2 { margin-top:0; }
#email-auth-form { padding:12px 0; margin-top:12px; }
#email-auth-form .pilot-note { margin:12px 0 0; }
#email-auth-message:empty { display:none; }
#login-required .login-required-actions { margin-top:16px; }
#login-required { width:min(32rem, calc(100vw - 28px)); }

#account-linking { max-width: 34rem; width: calc(100% - 3rem); }
#account-linking label { display: block; margin-top: 1rem; }
#account-linking input { box-sizing: border-box; width: 100%; }
#account-linking p { line-height: 1.5; }
#link-form button[type="submit"] { margin-top: 1rem; }
#link-review { font-weight: 600; overflow-wrap: anywhere; }
#link-message { white-space: pre-wrap; }

@font-face { font-family:"Google Sans"; font-style:normal; font-weight:500; font-display:swap; src:url("/static/brand/google-sans.ttf") format("truetype"); }
a.google-sign-in { box-sizing:border-box; display:inline-flex; align-items:center; justify-content:center; gap:10px; min-height:40px; padding:9px 12px; border:1px solid var(--color-provider-border); border-radius:4px; background:var(--color-provider-surface); color:var(--color-provider-text); font-family:"Google Sans",Arial,sans-serif; font-size:14px; font-weight:500; line-height:20px; text-decoration:none; }
a.google-sign-in:hover { background:var(--color-provider-hover); }
a.google-sign-in img { flex:none; width:20px; height:20px; object-fit:contain; background:var(--color-provider-surface); }

/* Conversion workspace: first GUI milestone. */
body { background:var(--color-canvas); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
main { max-width:1600px; padding:0 32px 36px; }
.app-header { min-height:76px; border-bottom:0; }
.brand-mark { border-radius:6px; }
.header-note { font-size:12px; letter-spacing:.02em; }
.language { position:absolute; top:20px; right:34px; padding:0; }
.app-header .header-note { margin-right:110px; }
.app-shell { display:grid; grid-template-columns:210px minmax(0,1fr); min-height:calc(100vh - 112px); border:1px solid var(--color-border); border-radius:16px; overflow:hidden; background:var(--color-surface); box-shadow:0 8px 30px var(--color-shadow-subtle); }
.sidebar { display:flex; flex-direction:column; padding:28px 14px 22px; background:var(--color-surface-muted); border-right:1px solid var(--color-border-soft); }
.sidebar-label { margin:0 14px 18px; font-size:11px; font-weight:650; letter-spacing:.12em; color:var(--color-text-faint); }
.main-nav { display:flex; flex-direction:column; gap:5px; }
.main-nav button, .sidebar #logout { display:flex; align-items:center; gap:11px; padding:11px 13px; margin:0; text-align:left; font-size:13px; font-weight:500; border:1px solid transparent; background:transparent; border-radius:7px; }
.sidebar #logout { margin-top:12px; }
.main-nav button[aria-current="page"] { background:var(--color-primary-soft); color:var(--color-primary-ink); font-weight:650; }
.nav-icon { width:19px; height:20px; display:grid; place-items:center; font-size:19px; color:var(--color-text-subtle); }
.main-nav button[aria-current="page"] .nav-icon { color:var(--color-primary-ink); }
.nav-divider { height:1px; background:var(--color-border-soft); margin:18px 12px; }
.sidebar-bottom { margin-top:auto; padding:42px 14px 0; color:var(--color-text-faint); font-size:11px; }
.sidebar-bottom p { line-height:1.6; margin:7px 0 18px; }
@media (max-width:760px) {
 .sidebar #logout { align-self:flex-end; margin-top:6px; padding:9px; min-height:36px; }
}
.small-brand { color:var(--color-text-muted); font-size:15px; font-weight:650; }
.dev-badge { display:inline-block; border:1px solid var(--color-border-soft); border-radius:4px; padding:3px 7px; font-size:11px; }
.app-content { padding:0 34px 28px; min-width:0; }
.account-actions { min-height:76px; margin:0; padding:12px 0; gap:16px; }
.account-actions label { min-width:0; flex:1; font-size:11px; }
.account-actions label > span { display:none; }
.account-actions select { border:0; padding-left:0; background:transparent; font-size:12px; max-width:300px; text-overflow:ellipsis; }
.account-tools { display:flex; align-items:center; gap:8px; margin-inline-start:auto; }
.account-tools button { margin:0; font-size:11px; min-height:32px; }
.credit-pill { display:flex; align-items:center; gap:7px; border:0; background:var(--color-surface-inset); }
.credit-dot { width:6px; height:6px; border-radius:50%; background:var(--color-neutral); }
.notification-button { display:grid; place-items:center; border:0; }
.user-button { border-color:var(--color-border); }
.workspace-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin:18px 0 20px; }
.workspace-heading h1,.secondary-view h1 { font-size:30px; line-height:1.2; font-weight:650; letter-spacing:-.035em; margin-bottom:9px; }
.workspace-heading .eyebrow,.secondary-view .eyebrow { font-size:10px; letter-spacing:.14em; margin-bottom:10px; }
.workspace-heading .muted,.secondary-view > .muted { font-size:12px; line-height:1.7; }
button.button-primary { background:var(--color-primary); border-color:var(--color-primary); color:var(--color-on-primary); font-weight:550; }
button.button-primary:hover:not(:disabled) { background:var(--color-primary-hover); color:var(--color-on-primary); }
#upload-shortcut { flex:none; margin:0; white-space:nowrap; font-size:12px; padding:10px 14px; }
.upload-queue { margin-bottom:12px; padding:10px 12px; border:1px solid var(--color-border); border-radius:8px; background:var(--color-surface-muted); }
#progress:empty { display:none; }
#progress { color:var(--color-primary); font-size:12px; margin:0 0 6px; }
.documents-panel { border:1px solid var(--color-border); border-radius:9px; }
.stage-filters { display:flex; overflow-x:auto; gap:18px; padding:0 20px; border-bottom:1px solid var(--color-border-soft); }
.stage-filters button { display:flex; align-items:center; gap:6px; flex:none; margin:0; min-height:48px; padding:10px 0; border:0; border-bottom:2px solid transparent; border-radius:0; color:var(--color-text-subtle); font-size:12px; background:transparent; }
.stage-filters button[aria-pressed="true"] { color:var(--color-primary); border-bottom-color:var(--color-primary); font-weight:650; }
.stage-filters [data-stage-count] { background:var(--color-neutral-surface); color:var(--color-text-subtle); border-radius:4px; min-width:18px; padding:1px 4px; text-align:center; font-size:10px; }
.stage-filters button[aria-pressed="true"] [data-stage-count] { background:var(--color-primary-soft); color:var(--color-primary); }
.document-filters { padding:10px 20px 12px; margin:0; gap:10px; background:var(--color-surface-muted); }
.document-filters label { flex:0 1 160px; }
.document-filters label:first-child { flex:0 1 320px; }
.document-filters label span { font-size:11px; margin-bottom:5px; }
.document-filters input,.document-filters select { min-height:34px; font-size:11px; border-color:var(--color-border); width:100%; }
.document-filters button { font-size:11px; min-height:34px; padding:6px 9px; }
.active-document-filters { flex:1 0 100%; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:6px 10px; border:1px solid var(--color-primary-border); border-radius:6px; background:var(--color-primary-soft); color:var(--color-primary-ink); }
#document-filter-status { min-width:0; overflow-wrap:anywhere; font-size:12px; font-weight:650; }
.active-document-filters button { flex:none; }
.list-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; border-top:1px solid var(--color-border-soft); padding:12px 20px; }
.list-heading h2 { margin:0; font-size:13px; font-weight:650; }
.list-heading .muted { font-size:11px; text-align:right; }
#documents { margin:0; }
#documents > li { border:0; border-bottom:1px solid var(--color-border-soft); border-radius:0; padding:18px 20px; margin:0; background:transparent; }
#documents > li:last-child { border-bottom:0; }
.document-heading { flex-wrap:nowrap; gap:12px; }
.document-identity { display:flex; align-items:center; gap:12px; flex:1; min-width:0; }
.document-identity > div { min-width:0; }
.document-name { font-size:12px; font-weight:550; overflow-wrap:anywhere; }
.document-type { color:var(--color-text-faint); font-size:11px; font-weight:400; }
.document-supplier { display:block; font-size:11px; color:var(--color-text-subtle); margin-top:3px; }
.file-icon { flex:none; width:32px; height:38px; display:grid; place-items:center; border:1px solid var(--color-border); border-radius:5px; background:var(--color-surface-muted); color:var(--color-text-subtle); font-size:8px; font-weight:650; letter-spacing:.04em; }
.stage-badge { display:inline-flex; white-space:nowrap; align-items:center; gap:5px; background:var(--color-neutral-surface); color:var(--color-neutral); padding:4px 8px; border-radius:5px; font-size:10px; }
.stage-badge::before { content:""; width:4px; height:4px; background:currentColor; border-radius:50%; }
.stage-processing { background:var(--color-info-surface); color:var(--color-info); }
.stage-review { background:var(--color-warning-surface); color:var(--color-warning); }
.stage-ready { background:var(--color-success-surface); color:var(--color-success); }
.document-actions { flex-wrap:nowrap; gap:8px; }
.document-actions button { font-size:11px; min-height:30px; border-radius:5px; padding:5px 10px; }
.document-more { position:relative; }
.document-more > summary { list-style:none; cursor:pointer; font-size:0; border:1px solid transparent; border-radius:4px; padding:4px 7px; }
.document-more > summary::-webkit-details-marker { display:none; }
.document-more > summary::after { content:"⋯"; font-size:20px; line-height:20px; color:var(--color-text-subtle); }
.document-more-menu { position:absolute; right:0; top:34px; z-index:3; display:flex; flex-direction:column; align-items:stretch; min-width:160px; padding:8px; gap:6px; background:var(--color-surface); border:1px solid var(--color-border); border-radius:7px; box-shadow:0 8px 22px var(--color-shadow-menu); }
.document-more-menu button { text-align:left; }
.document-technical { margin:10px 0 0 44px; }
.document-technical > summary { color:var(--color-text-subtle); cursor:pointer; font-size:11px; }
.document-steps { font-size:11px; line-height:1.7; padding:8px 0; }
.document-attention { margin:8px 0 0 44px; color:var(--color-warning); font-size:11px; }
.workspace-empty { text-align:center; padding:24px 16px; border-top:1px solid var(--color-border-soft); color:var(--color-text-subtle); }
.workspace-empty strong { color:var(--color-text-muted); font-size:13px; }
.workspace-empty p { max-width:390px; margin:8px auto; font-size:11px; line-height:1.7; }
.workspace-footer { color:var(--color-text-subtle); font-size:11px; text-align:center; margin-top:24px; }
.phase-help { padding:10px 20px; background:var(--color-warning-surface); color:var(--color-warning); margin:12px 0 0; font-size:11px; }
#load-more { margin:12px 20px 18px; font-size:11px; }
.secondary-view { padding:34px 0; outline:none; }
.feature-card { background:var(--color-surface); border:1px solid var(--color-border); border-radius:10px; padding:24px; margin-top:24px; }
.feature-card h2 { font-size:17px; letter-spacing:-.02em; }
.feature-card p { color:var(--color-text-subtle); font-size:13px; line-height:1.8; max-width:650px; }
.feature-value { font-size:36px !important; margin:10px 0; }
.feature-icon { color:var(--color-primary); font-size:24px; }
.feature-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.help-steps { list-style:none; counter-reset:help; padding:0; }
.help-steps li { counter-increment:help; border:0; padding:18px 0 18px 50px; position:relative; }
.help-steps li::before { content:counter(help); position:absolute; left:0; top:18px; display:grid; place-items:center; width:30px; height:30px; border-radius:8px; background:var(--color-primary-soft); color:var(--color-primary-ink); font-size:12px; }
.help-steps strong { font-size:13px; }
.help-steps p { color:var(--color-text-subtle); font-size:12px; line-height:1.8; max-width:650px; }
.review-dialog { width:calc(100vw - 40px); max-width:1600px; max-height:94vh; border-radius:14px; padding:24px; background:var(--color-surface-muted); }
.review-titlebar { padding-bottom:16px; border-bottom:1px solid var(--color-border); margin-bottom:20px; }
.review-titlebar h2 { font-size:20px; letter-spacing:-.025em; }
.review-layout { gap:24px; grid-template-columns:minmax(0,1fr) minmax(0,1.15fr); }
.review-layout > div { background:var(--color-surface); border:1px solid var(--color-border); border-radius:9px; padding:16px; }
.review-confirmation { background:var(--color-success-surface); border-color:var(--color-success-border); padding:18px; border-radius:8px; }
.review-table { font-size:11px; }
.review-table th,.review-table td { padding:7px 6px; }
.review-table thead th { background:var(--color-primary-soft); }
@media(min-width:1600px) { .language { right:calc((100vw - 1600px)/2 + 34px); } }
@media(max-width:1100px) { main { padding:0 18px 24px; }.app-shell { grid-template-columns:180px minmax(0,1fr); }.app-content { padding:0 22px 24px; }.main-nav button { font-size:11px; gap:8px; padding:10px; }.stage-filters { gap:14px; }.document-heading { flex-wrap:wrap; }.document-identity { flex-basis:60%; }.document-actions { margin-left:44px; } }
@media(max-width:760px) { main { padding:0 12px 20px; }.app-header { min-height:65px; }.language { top:17px; right:16px; }.app-shell { display:block; border-radius:10px; }.sidebar { padding:8px; border-right:0; border-bottom:1px solid var(--color-border-soft); }.sidebar-label,.sidebar-bottom,.nav-divider { display:none; }.main-nav { flex-direction:row; overflow-x:auto; gap:4px; }.main-nav button { flex:none; padding:9px; min-height:36px; }.nav-icon { display:none; }.app-content { padding:0 16px 20px; }.account-actions { min-height:60px; margin:0; gap:8px; flex-wrap:wrap; }.account-actions label { flex:1; }.account-actions select { max-width:180px; }.credit-pill { display:none !important; }.workspace-heading { margin-top:24px; gap:10px; }.workspace-heading h1,.secondary-view h1 { font-size:26px; }.workspace-heading .muted { max-width:300px; }.stage-filters { padding:0 14px; gap:16px; }.document-filters { padding:14px; }.document-filters label:first-child { flex-basis:100%; }.document-filters label { flex:1; }.list-heading { padding:12px 14px; }#documents > li { padding:16px 14px; }.document-identity { flex-basis:100%; }.stage-badge { margin-left:44px; }.document-actions { margin-left:auto; flex-wrap:wrap; }.feature-grid { grid-template-columns:1fr; gap:0; }.review-layout { grid-template-columns:1fr; }.review-dialog { width:calc(100vw - 16px); padding:14px; }.review-layout > div { padding:10px; } }
@media(prefers-reduced-motion:no-preference) { button { transition:background-color .15s,border-color .15s; } }

.app-header { padding-right:190px; }
.app-header .header-note { margin-right:0; text-align:right; }
.app-version { color:var(--color-text-muted); font-size:11px; white-space:nowrap; }
@media(max-width:520px) {
  .app-header { flex-direction:column; align-items:flex-start; justify-content:center; gap:4px; }
}
.document-technical summary:focus-visible,.document-more summary:focus-visible { outline:3px solid var(--color-primary); outline-offset:3px; }
.document-actions > span { max-width:140px; font-size:11px; color:var(--color-text-subtle); }
@media(max-width:760px) { .app-header { padding-right:130px; } }

@media(max-width:760px) { .workspace-heading { flex-direction:column; align-items:flex-start; }.workspace-heading .muted { max-width:none; }#upload-shortcut { margin:0; } }

.welcome-sign-in { display:flex; flex-wrap:wrap; align-items:center; gap:12px; }
.welcome-sign-in > a,.welcome-sign-in > button { display:inline-flex; align-items:center; justify-content:center; gap:10px; width:210px; height:44px; min-height:44px; margin:0; padding:9px 12px; border:1px solid var(--color-provider-border); border-radius:4px; background:var(--color-provider-surface); color:var(--color-provider-text); font:500 14px/20px "Google Sans",Arial,sans-serif; text-decoration:none; }
.welcome-sign-in > a:hover,.welcome-sign-in > button:hover { background:var(--color-provider-hover); border-color:var(--color-provider-border); }
.welcome-sign-in svg { flex:none; width:20px; height:20px; }
@media(max-width:520px) { .welcome-sign-in { flex-direction:column; align-items:stretch; max-width:320px; }.welcome-sign-in > a,.welcome-sign-in > button { width:100%; } }

.document-dates { display:flex; flex-wrap:wrap; gap:3px 14px; margin-top:5px; font-size:11px; color:var(--color-text-muted); line-height:1.6; }
.document-dates time { white-space:nowrap; font-variant-numeric:tabular-nums; }
.document-date-details { display:grid; grid-template-columns:max-content 1fr; gap:3px 14px; margin:12px 0 0; font-size:11px; }
.document-date-details dt,.document-date-details dd { margin:0; }
.document-date-details time { font-variant-numeric:tabular-nums; }
@media(max-width:520px) { .document-date-details { grid-template-columns:1fr; gap:2px; }.document-date-details dd { margin-bottom:5px; } }

/* Stable workflow columns keep commands aligned across document stages. */
.documents-table-scroll { overflow-x:auto; padding-bottom:8px; }
.documents-table-scroll:focus-visible { outline:2px solid var(--color-primary); outline-offset:-2px; }
.documents-table { width:100%; min-width:780px; table-layout:fixed; border-collapse:collapse; margin:12px 0 0; }
.documents-table th { background:var(--color-surface-muted); color:var(--color-text-subtle); font-size:10px; font-weight:550; text-align:left; padding:10px 8px; border-bottom:1px solid var(--color-border); }
.documents-table th:first-child { width:auto; padding-left:20px; }
.documents-table th:nth-child(2) { width:100px; }
.documents-table th:nth-child(3) { width:90px; }
.documents-table th:nth-child(4) { width:80px; }
.documents-table th:nth-child(5) { width:90px; }
.documents-table th:last-child { width:40px; padding-right:16px; }
.documents-table td { vertical-align:top; padding:18px 8px; border-bottom:1px solid var(--color-border-soft); }
.documents-table tbody tr:last-child td { border-bottom:0; }
.documents-table .document-content-cell { padding-left:20px; }
.documents-table .document-command-cell,.documents-table .document-state-cell { padding-top:20px; }
.document-command-cell button,
.trash-table td:last-child > button,
.session-table td:last-child > button,
.api-key-table td:last-child > button { display:inline-flex; align-items:center; justify-content:center; margin:0; min-height:30px; padding:5px 10px; font-size:11px; border-radius:5px; white-space:nowrap; }
.document-command-cell > button { width:100%; }
.document-command-cell:last-child { padding-right:16px; }
.document-command-cell .document-more > summary { text-align:center; padding:4px 0; }
.document-no-command { display:block; line-height:30px; color:var(--color-text-faint); font-size:11px; }
.document-lock { display:block; font-size:10px; color:var(--color-text-subtle); line-height:1.5; padding-top:6px; }
.documents-table .stage-badge { margin-left:0; margin-top:3px; }
.documents-table .document-identity { align-items:flex-start; }
.documents-table .document-more-menu { top:28px; }
@media(max-width:760px) { .documents-table { min-width:760px; }.documents-table th:first-child,.documents-table .document-content-cell { padding-left:14px; }.documents-table .document-identity { gap:8px; }.documents-table .document-technical,.documents-table .document-attention { margin-left:40px; } }
.visually-hidden { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.documents-table-scroll:has(.document-more[open]) { padding-bottom:140px; }
.document-command-note { display:block; font-size:9px; color:var(--color-text-subtle); margin-top:4px; text-align:center; }

/* Current work stays reachable while browsing other stages or account views. */
.activity-panel { position:fixed; right:24px; bottom:20px; width:430px; max-width:calc(100vw - 32px); z-index:8; background:var(--color-surface); border:1px solid var(--color-primary-border); border-radius:12px; box-shadow:0 8px 30px var(--color-shadow-menu); overflow:hidden; }
.activity-toggle { display:flex; align-items:center; gap:10px; width:100%; margin:0; padding:14px 16px; border:0; border-radius:0; background:var(--color-primary); color:var(--color-on-primary); text-align:left; }
.activity-toggle > span:first-child { font-size:12px; font-weight:650; }
#activity-counts { flex:1; font-size:10px; }
.activity-toggle[aria-expanded="false"] > span:last-child { transform:rotate(180deg); }
.activity-intro { display:flex; align-items:flex-start; gap:12px; padding:12px 16px 8px; }
.activity-intro p { margin:0; color:var(--color-text-subtle); font-size:10px; flex:1; }
.activity-intro button { margin:0; padding:2px 4px; min-height:24px; font-size:10px; }
.activity-message,.activity-stale { margin:0 16px 8px; padding:8px; border-radius:5px; font-size:10px; overflow-wrap:anywhere; }
.activity-message { background:var(--color-primary-soft); color:var(--color-primary-ink); }
.activity-stale { background:var(--color-warning-surface); color:var(--color-warning); }
#activity-list { list-style:none; margin:0; padding:0; max-height:min(360px,45vh); overflow:auto; overscroll-behavior:contain; }
#activity-list > li { padding:12px 16px; border-top:1px solid var(--color-border-soft); border-bottom:0; }
.activity-info { display:flex; flex-direction:column; gap:4px; }
.activity-info strong { font-size:12px; font-weight:550; overflow-wrap:anywhere; }
.activity-state { font-size:11px; color:var(--color-primary-ink); }
.activity-info small { font-size:10px; color:var(--color-text-subtle); }
.activity-running::before { content:""; display:inline-block; width:9px; height:9px; margin-right:6px; border:2px solid var(--color-primary-border); border-top-color:var(--color-primary); border-radius:50%; animation:activity-spin 1s linear infinite; vertical-align:-2px; }
.activity-actions { display:flex; align-items:center; gap:6px; margin-top:9px; }
.activity-actions button { margin:0; padding:5px 9px; min-height:30px; font-size:10px; }
.activity-actions .activity-dismiss { margin-left:auto; padding:2px 8px; font-size:18px; color:var(--color-text-subtle); background:transparent; border:0; }
.stage-arrival { animation:stage-arrival 1.6s ease-out; }
.document-arrival { animation:stage-arrival 2s ease-out; }
.review-next { margin-left:auto; font-size:11px; }
@keyframes activity-spin { to { transform:rotate(360deg); } }
@keyframes stage-arrival { 0%,35% { background:var(--color-primary-soft-hover); box-shadow:inset 0 0 0 2px var(--color-primary-border); } 100% { box-shadow:inset 0 0 0 0 transparent; } }
@media(max-width:760px) { .activity-panel { right:12px; bottom:12px; max-width:calc(100vw - 24px); }.activity-toggle { padding:12px; flex-wrap:wrap; gap:6px; }.activity-toggle > span:first-child { font-size:11px; }#activity-counts { font-size:9px; }.review-titlebar { flex-wrap:wrap; }.review-next { order:3; flex-basis:100%; margin:0; }.review-titlebar h2 { flex:1; } }
@media(prefers-reduced-motion:reduce) { .activity-running::before,.stage-arrival,.document-arrival { animation:none; } }
#signed-in { padding-bottom:64px; }
.session-startup { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:12px; min-height:120px; padding:20px; background:var(--color-surface); border:1px solid var(--color-border); border-radius:12px; }
.session-startup p,.session-startup button { margin:0; }
.session-spinner { width:16px; height:16px; border:2px solid var(--color-primary-border); border-top-color:var(--color-primary); border-radius:50%; animation:activity-spin 1s linear infinite; }
@media(prefers-reduced-motion:reduce) { .session-spinner { animation:none; } }

.manual-editor { width: min(960px, 94vw); max-height: 90vh; overflow: auto; }
.manual-editor-titlebar { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; }
.manual-editor-titlebar h2 { margin:0; }
.manual-editor button { min-height:36px; padding:5px 10px; }
.manual-editor .manual-editor-close { flex:none; width:36px; margin:0; padding:0; font-size:1.25rem; line-height:1; }
.manual-editor fieldset { margin: 1.2rem 0; padding: 1rem; border: 1px solid var(--color-border); border-radius: .6rem; }
.manual-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px,100%), 1fr)); gap: 1rem; }
.manual-fields label { display:flex; flex-direction:column; gap:.65rem; margin:0; }
.manual-vat-fields { grid-template-columns:1fr; }
.manual-fields input { width: 100%; box-sizing: border-box; }
.manual-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:.6rem; margin-top:1.5rem; }
.manual-editor .manual-actions button { margin:0; }
.manual-editor .confirmation-actions button { min-width:0; }
.manual-banner { padding: 1rem; border: 1px solid var(--color-border); border-radius: .6rem; }
.manual-value { text-decoration: underline dotted; text-underline-offset: .3em; }
/* The review table is the correction surface; numeric order stays unchanged. */
.review-table caption button { margin-left:1rem; font-size:.85em; }
.inline-correction-tools { display:flex; align-items:center; flex-wrap:wrap; gap:.6rem; margin:1rem 0 .5rem; }
.review-dialog .review-table caption button, .review-dialog .inline-correction-tools button { min-height:32px; padding:4px 8px; }
.inline-correction-tools > span:first-child { flex:1 1 240px; }
.review-table .inline-result-value { box-sizing:border-box; width:100%; min-width:6rem; margin:0; padding:.35rem; border:1px solid transparent; border-radius:4px; background:transparent; color:inherit; font:inherit; }
.review-table textarea.inline-result-value { min-width:13rem; resize:vertical; }
.review-table .cell-number .inline-result-value { text-align:right; }
.review-table .inline-result-value:hover,.review-table .inline-result-value:focus { border-color:var(--color-border); background:var(--color-surface); }
.manual-draft-cell { box-shadow:inset 0 -2px var(--color-primary); }
.manual-removed td:not(:last-child) { opacity:.45; text-decoration:line-through; }
.documents-table .document-command-cell button { white-space:normal; }
.documents-table th:nth-child(6) { width:110px; }
.documents-table th:last-child { width:75px; }
.documents-table { min-width:920px; }
.review-table.inline-editable thead th:last-child,.review-table.inline-editable tbody td:last-child { position:sticky; right:0; background:var(--color-surface); border-left:1px solid var(--color-border); z-index:1; }
.review-table.inline-editable thead th:last-child { z-index:3; }
.review-dialog .review-table tbody th[scope="row"],
.review-dialog .review-table.inline-editable tbody td:last-child { vertical-align:middle; }
.review-dialog .review-table tbody th[scope="row"] > button,
.review-dialog .review-table.inline-editable tbody td:last-child > button,
.review-dialog .review-zoom button { margin:0; min-height:30px; min-width:30px; padding:4px 8px; font-size:11px; border-radius:5px; white-space:nowrap; }
/* Document and current result lead the review; explanations follow them. */
.review-layout { align-items:start; }
.review-pages { max-height:60vh; overflow:auto; }
.review-pages .review-page:first-child { margin-top:0; }
.review-document-column > p { font-size:.85rem; margin:.7rem 0; }
.review-direct-actions { display:flex; gap:.5rem; flex-wrap:wrap; margin:1rem 0; }
.review-ai-form { border-top:1px solid var(--color-border); padding-top:.8rem; margin-top:1rem; }
.review-ai-form h3 { margin:.25rem 0 .7rem; font-size:1rem; }
.review-ai-form textarea { box-sizing:border-box; width:100%; margin:.5rem 0; }
.review-ai-inspector { margin-top:1rem; padding:1rem; border:1px solid var(--color-primary); border-radius:8px; background:var(--color-surface-muted); }
.review-results > .review-table-scroll { max-height:60vh; margin-top:0; }
.review-result-state { font-size:.85rem; font-weight:600; }
.review-finding-summary { font-size:.85rem; color:var(--color-text-subtle); }
.review-notes { border-top:1px solid var(--color-border); margin-top:1rem; padding-top:1rem; }
.review-notes > summary { cursor:pointer; font-weight:600; }
.review-notes > *:not(summary) { margin-top:1rem; }
#upload-status { list-style:none; padding:0; margin:0; max-height:160px; overflow:auto; font-size:12px; }
#upload-status li { padding:.3rem 0; overflow-wrap:anywhere; }
#upload-status .upload-state-failed { color:var(--color-warning); }
.review-zoom { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.review-zoom output { min-width:38px; text-align:center; font-size:11px; font-variant-numeric:tabular-nums; }
.review-pages .review-page { max-width:none; flex:none; }
.review-prepared-instructions, .review-own-instructions {
  padding:12px;
  border:1px solid var(--color-border);
  border-radius:8px;
  margin:0 0 10px;
}
.review-prepared-instructions { background:var(--color-primary-subtle); }
.review-prepared-instructions h4, .review-own-instructions h4 { margin:0 0 .4rem; font-size:.9rem; }
.review-prepared-instructions p, .review-own-instructions label { font-size:.8rem; color:var(--color-text-subtle); }
.review-instruction-extra { margin:0 0 10px; font-size:.8rem; }
.review-instruction-extra summary { cursor:pointer; color:var(--color-primary-ink); }
.review-prepared-actions { display:flex; flex-wrap:wrap; gap:6px; }
.review-prepared-actions button { font-size:12px; margin:0; }
.review-priority-totals { border:1px solid var(--color-primary-border); border-radius:8px; padding:14px; margin:14px 0; background:var(--color-surface-muted); }
.review-priority-totals h3 { font-size:15px; margin:0 0 12px; }
.review-totals-comparison { width:100%; border-collapse:collapse; font-size:13px; }
.review-totals-comparison th,.review-totals-comparison td { padding:10px 6px; text-align:right; vertical-align:top; border-bottom:1px solid var(--color-border); }
.review-totals-comparison th:first-child { text-align:left; }
.review-totals-comparison td { font-weight:650; font-variant-numeric:tabular-nums; }
.review-totals-comparison small { display:block; font-weight:400; font-size:10px; margin-top:5px; }
.review-priority-totals > p { font-size:11px; color:var(--color-text-subtle); margin-bottom:0; }
.review-priority-checklist { margin:14px 0; }
.review-priority-checklist > summary { font-weight:600; cursor:pointer; }
.review-check-group { list-style:none; font-weight:650; padding:12px 0 4px; }
.review-totals-comparison td { font-size:16px; }
/* Leave room for the totals comparison even when the invoice has many items. */
.review-results > .review-table-scroll { max-height:40vh; }

.credits-history{overflow-x:auto}.credits-ledger{width:100%;border-collapse:collapse;text-align:left;font-size:.9rem}.credits-ledger th,.credits-ledger td{padding:.75rem;border-bottom:1px solid var(--color-border);vertical-align:top}.credits-ledger th{white-space:nowrap}
.credit-sections{display:grid;gap:1.5rem}
.production-purchase-option{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem;padding:.5rem 0;border-bottom:1px solid var(--color-border-soft)}
.production-purchase-option strong{min-width:10rem}
.sepa-pending-list{list-style:none;margin:0;padding:0}
.sepa-payment-details{display:flex;align-items:center;flex-wrap:wrap;gap:1rem;margin-block:1rem}
.sepa-payment-details[hidden]{display:none}
.sepa-payment-details img{max-width:100%;height:auto;border:1px solid var(--color-border);border-radius:.5rem}
.sepa-payment-details dl{margin:0}
.sepa-payment-details dt{font-weight:600}
.sepa-payment-details dd{margin:0 0 .45rem;overflow-wrap:anywhere}

/* Shared modal foundation: all hues come from palette.css, including focus/backdrop. */
dialog{font:inherit;line-height:1.55;background:var(--color-surface);color:var(--color-text);border:1px solid var(--color-border);border-radius:16px;padding:24px;max-height:calc(100dvh - 32px);box-shadow:0 24px 80px var(--color-shadow-dialog);overflow:auto}
dialog::backdrop{background:var(--color-overlay)}
dialog h2{margin:0 0 16px;font-size:20px;font-weight:650;line-height:1.3}
dialog p{overflow-wrap:anywhere}
dialog button{font:inherit;font-size:13px;min-height:40px;padding:9px 16px;border-radius:8px}
dialog input,dialog select,dialog textarea{font:inherit}
dialog .button-primary{background:var(--color-primary);border-color:var(--color-primary);color:var(--color-on-primary)}
dialog .button-primary:hover:not(:disabled){background:var(--color-primary-hover);border-color:var(--color-primary-hover);color:var(--color-on-primary)}
.message-dialog{width:28rem;max-width:calc(100vw - 32px);margin:auto;padding:24px;background:var(--color-surface);border:1px solid var(--color-border)}
.dialog-heading{display:flex;align-items:center;gap:12px;margin-bottom:18px}
.dialog-heading h2{margin:0;font-size:18px}
.dialog-mark{flex:none;padding:7px;border-radius:10px;background:var(--color-primary-soft);color:var(--color-primary)}
.message-dialog > p{margin:0;white-space:pre-wrap}
.dialog-actions,.confirmation-actions{display:flex;justify-content:flex-end;align-items:center;gap:10px;flex-wrap:wrap;margin:24px 0 0;padding-top:18px;border-top:1px solid var(--color-border-soft)}
.dialog-actions button,.confirmation-actions button{margin:0;min-width:88px}
.confirmation-dialog{width:32rem;max-width:calc(100vw - 32px)}
.exclusion-preview{width:48rem}
@media(max-width:520px){dialog{padding:20px;border-radius:12px}.message-dialog,.confirmation-dialog{max-width:calc(100vw - 24px)}.dialog-actions,.confirmation-actions{gap:8px;margin-top:20px;padding-top:16px}.dialog-actions button,.confirmation-actions button{min-height:44px}}

/* Batch controls share the semantic palette and keep selection scope visible. */
.batch-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:14px 20px;border-bottom:1px solid var(--color-border-soft)}
.batch-toolbar > span{flex:1 1 220px;font-size:12px;color:var(--color-text-muted)}
.batch-select-heading{display:flex;align-items:center;gap:10px;margin:0}
.document-selection{flex:none;margin:10px 0 0;accent-color:var(--color-primary)}
.batch-select-heading input{accent-color:var(--color-primary)}
.batch-dialog{width:42rem;max-width:calc(100vw - 24px)}
.batch-dialog select,.export-dialog select{display:block;max-width:100%;width:100%;margin-top:6px}
.batch-outcomes{list-style:none;padding:0;margin:18px 0;max-height:40vh;overflow:auto}
.batch-outcomes li{display:flex;flex-direction:column;gap:4px;padding:10px 0;border-bottom:1px solid var(--color-border-soft);overflow-wrap:anywhere}
.batch-outcomes span{font-size:12px;color:var(--color-text-muted)}
.batch-outcomes [data-state="failed"] span{color:var(--color-warning)}
.batch-outcomes [data-state="succeeded"] span{color:var(--color-success)}
@media(max-width:520px){.batch-toolbar{padding:12px}.batch-toolbar > span{flex-basis:100%}}

.manual-new-row{background:var(--color-primary-soft)}
.review-table caption button{margin-left:8px;margin-top:6px}

/* Keep the format label above the native select, including its focus outline. */
.export-dialog{width:32rem;max-width:calc(100vw - 32px)}
.export-format-field{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;min-width:0;margin:18px 0}
.export-format-field > label{display:block;margin:0;overflow-wrap:anywhere}
.export-format-field > select{display:block;width:100%;min-width:0;max-width:100%;margin:0}

/* User history uses the same semantic palette as the workspace. */
.history-filters{display:flex;align-items:end;flex-wrap:wrap;gap:14px;margin:24px 0}
.history-filters>div{flex:1 1 160px;min-width:0}
.history-filters label{display:block;margin-bottom:8px}
.history-filters input,.history-filters select{width:100%;min-width:0}
.history-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:20px 0}
.history-stat{padding:16px;border:1px solid var(--color-border);border-radius:12px;background:var(--color-surface)}
.history-stat span{display:block;color:var(--color-text-muted);font-size:13px}
.history-stat strong{display:block;margin-top:8px;font-size:26px;color:var(--color-text)}
.history-wallet{margin-bottom:24px}
.history-warning{color:var(--color-warning)}
.history-table-scroll{overflow:auto;border:1px solid var(--color-border);border-radius:12px;background:var(--color-surface)}
.history-events{border:1px solid var(--color-border);border-radius:12px;background:var(--color-surface)}
.history-events>summary{cursor:pointer;padding:10px 12px;font-weight:600}
.history-events>.history-table-scroll{border:0;border-top:1px solid var(--color-border);border-radius:0}
.history-table{width:100%;min-width:620px;margin:0}
.history-table th,.history-table td{padding:6px 10px;line-height:1.35}
.history-table td small{display:block;margin-top:2px;color:var(--color-text-muted)}
.history-document{border:0;margin:0;padding:0;min-height:24px;text-align:left;color:var(--color-primary);background:transparent;white-space:normal;overflow-wrap:anywhere}
.history-pagination{display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:8px;margin:8px 10px}
.history-pagination button{min-height:32px;margin:0;padding:4px 8px}
@media(max-width:520px){.history-filters>div{flex-basis:100%}.history-summary{grid-template-columns:repeat(2,minmax(0,1fr))}}

@media(max-width:900px){.history-summary{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Support and messages share the semantic palette and the existing modal rhythm. */
.notification-count{display:inline-block;min-width:20px;padding:2px 6px;border-radius:12px;background:var(--color-primary);color:var(--color-on-primary);font-size:11px;text-align:center}
.message-banner{padding:18px 22px;border:1px solid var(--color-border);border-left:4px solid var(--color-primary);border-radius:12px;background:var(--color-primary-soft);margin:20px 0}
.message-banner p{margin:8px 0;white-space:pre-wrap;overflow-wrap:anywhere}
.message-preferences,.help-actions{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin:20px 0}
.message-preferences label{display:flex;gap:10px;align-items:center;flex:1}
.support-card{padding:22px;border:1px solid var(--color-border);border-radius:12px;background:var(--color-surface);margin:18px 0}
.support-card>span{font-size:12px;color:var(--color-primary);font-weight:600}
.support-card p{white-space:pre-wrap;overflow-wrap:anywhere}
.support-card small{display:block;color:var(--color-text-muted);margin:10px 0}
.support-reply{margin:16px 0;padding:12px 16px;border-left:3px solid var(--color-primary);background:var(--color-primary-soft);border-radius:6px}
.support-reply h4,.support-reply p{margin:0}
.support-reply div + div{margin-top:10px}
.support-reply [tabindex]:focus{outline:2px solid var(--color-primary);outline-offset:3px;border-radius:3px}
.support-reply time,.support-timeline time{display:block;color:var(--color-text-muted);font-size:.875em}
.support-timeline{list-style:none;margin:8px 0 0;padding:0}
.support-timeline li{padding:8px 0;border-color:var(--color-border-soft)}
.support-timeline li:last-child{border-bottom:0}
.support-timeline details{margin-top:4px;color:var(--color-text-muted)}
.support-timeline details p{margin:4px 0}
#messages-list { display: grid; gap: .35rem; }
.message-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title action" "meta action"; gap: .15rem .8rem;
  padding: .5rem .75rem; border: 1px solid var(--color-border); border-radius: .5rem;
  background: var(--color-surface); overflow-wrap: anywhere;
}
.message-card h2 { grid-area: title; font-size: 1rem; line-height: 1.3; margin: 0; }
.message-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: .1rem .75rem; color: var(--color-text-muted); font-size: .8rem; }
.message-meta span:first-child { color: var(--color-primary-ink); }
.message-actions { grid-area: action; align-self: center; }
.message-actions button { min-height: 32px; padding: .25rem .65rem; margin: 0; }
@media (max-width: 32rem) {
  .message-card { grid-template-areas: "title title" "meta action"; }
}
.message-card[data-kind="service"]{border-left:4px solid var(--color-primary)}
.support-dialog{width:38rem;max-width:calc(100vw - 24px)}
.support-dialog form>label:not(.support-consent){display:block;margin:18px 0 8px}
.support-dialog textarea,.support-dialog select{display:block;width:100%;min-width:0}
.support-dialog textarea{font:inherit;padding:12px;border:1px solid var(--color-border);border-radius:8px;color:var(--color-text);background:var(--color-surface);resize:vertical}
.support-dialog details{margin:20px 0}
.support-dialog pre{max-width:100%;white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}
.support-consent{display:flex;align-items:flex-start;gap:12px;margin:20px 0}
.support-consent input{flex:none;margin-top:5px;accent-color:var(--color-primary)}
.demo-dialog{width:62rem;max-width:calc(100vw - 24px)}
.demo-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.2fr);gap:24px}
.demo-invoice{padding:26px;border:1px solid var(--color-border);background:var(--color-surface);box-shadow:0 4px 18px var(--color-border-soft)}
.demo-invoice>span{color:var(--color-primary);font-weight:600;font-size:12px}
.demo-invoice>strong{display:block;border-top:1px solid var(--color-border);padding-top:16px}
.demo-layout .credits-ledger{width:100%;margin:0}
@media(max-width:700px){.demo-layout{grid-template-columns:1fr}.review-titlebar{flex-wrap:wrap}.support-dialog .confirmation-actions{flex-wrap:wrap}}

.notification-button{position:relative}
.notification-button .notification-count{position:absolute;top:0;right:0;transform:translate(25%,-25%)}

.trash-table{width:100%;min-width:620px}
.credits-ledger.trash-table th,.credits-ledger.trash-table td{padding:8px 10px;vertical-align:middle}
.trash-table th[scope="row"]{font-weight:600;max-width:30rem;overflow-wrap:anywhere}
.trash-table td:last-child{min-width:90px}
#view-trash>button{margin:12px 0}
#view-trash .history-table-scroll{border:1px solid var(--color-border);border-radius:12px;background:var(--color-surface)}

.session-card{margin-top:24px}
.session-heading,.session-tools{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap}
.session-heading>div:first-child{flex:1;min-width:220px}
.session-heading p{max-width:48rem}
.session-tools{justify-content:flex-end}
.session-table{width:100%;min-width:680px;margin:0}
.session-table th[scope="row"]{font-weight:600;max-width:20rem;overflow-wrap:anywhere}
.session-table td{vertical-align:top}
.session-table small{display:block;margin-top:6px;color:var(--color-text-muted)}
.session-current{display:block;width:fit-content;margin-top:8px;padding:3px 8px;border-radius:6px;color:var(--color-primary-ink);background:var(--color-primary-soft);font-size:12px}
#sessions-more{margin-top:16px}
.api-key-table { min-width:550px; }
.api-key-table td, .api-key-table th[scope="row"] { vertical-align:middle; }
#api-keys-refresh { margin:10px 0 0; }
#api-key-form fieldset { min-width:0; margin:0 0 12px; border:1px solid var(--color-border); border-radius:8px; }
.api-key-form-title { font-size:1.125rem; font-weight:700; }
.api-key-fields, .api-key-scopes { display:flex; flex-wrap:wrap; gap:10px 16px; }
.api-key-fields { margin-bottom:12px; }
.api-key-fields label { flex:1 1 160px; min-width:0; }
.api-key-fields input { display:block; width:100%; margin-top:6px; }
.api-key-secret-field { display:flex; align-items:stretch; gap:14px; margin-top:6px; }
#api-key-secret { flex:1; min-width:0; }
.api-key-secret-field button { flex:none; display:grid; place-items:center; min-width:40px; padding:0; margin:0; }
#api-key-copy-status { margin:0; }
#api-key-copy-status:not(:empty) { margin-top:6px; }
.api-key-scopes label { display:flex; align-items:center; gap:6px; }

/* Account closure preview uses the shared semantic palette. */
.closure-dialog{width:40rem;max-width:calc(100vw - 24px)}
.closure-organization{padding:16px 0;border-block:1px solid var(--color-border-soft);margin:16px 0}
.closure-organization h3{overflow-wrap:anywhere}
.closure-counts{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 20px}
.closure-counts dt{color:var(--color-text-muted)}
.closure-counts dd{margin:0;font-variant-numeric:tabular-nums;text-align:right}

.credit-package{display:flex;flex-wrap:wrap;gap:8px 20px;padding:14px 0;border-bottom:1px solid var(--color-border-soft)}
.credit-package strong{flex:1 1 180px}.credit-package small{flex-basis:100%;color:var(--color-text-muted)}

.request-pending { cursor: progress; }
button.request-pending::after {
  content: ''; display: inline-block; vertical-align: middle; margin-inline-start: .4em;
  width: .75em; height: .75em; border: 2px solid currentColor; border-inline-end-color: transparent;
  border-radius: 50%; animation: request-spin .8s linear infinite;
}
.request-status:not(:empty) {
  position: fixed; inset-inline-start: 50%; bottom: 1rem; transform: translateX(-50%);
  z-index: 100; width: max-content; max-width: 90vw; padding: .5rem .85rem;
  color: var(--color-text); background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: .5rem; pointer-events: none;
}
@keyframes request-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { button.request-pending::after { animation: none; } }
