:root {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  color: oklch(0.25 0.01 130);
  background: oklch(0.965 0.012 85);
  --background: oklch(0.965 0.012 85);
  --sidebar: oklch(0.97 0.012 85);
  --primary: oklch(0.58 0.05 145);
  --primary-soft: oklch(0.94 0.018 145);
  --muted: oklch(0.5 0.012 130);
  --line: oklch(0.9 0.015 120);
  --danger: #a64235;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px;
  color: inherit; background: white; cursor: pointer; font-size: 12px; font-weight: 500;
}
button:hover { background: var(--primary-soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
button svg, .brand svg, .search svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary { background: var(--primary); border-color: var(--primary); color: white; }
.primary:hover { background: oklch(0.52 0.05 145); }
.small { font-size: 11px; padding: 6px 9px; }
.ghost { border-color: transparent; background: transparent; }
.danger { color: var(--danger); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: 224px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--sidebar); z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 8px; min-height: 77px; padding: 20px;
  border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; font-size: 23px; font-weight: 650; letter-spacing: -.7px; line-height: 1.2;
}
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: 0; }
.brand-icon { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--primary); color: white; font-size: 23px; font-weight: 600; letter-spacing: -.6px; }
#tabs { flex: 1; padding: 16px 12px; }
#tabs button { width: 100%; justify-content: flex-start; gap: 12px; margin-bottom: 4px; padding: 10px 12px; border: 0; background: transparent; color: var(--muted); font-size: 14px; text-align: left; white-space: nowrap; }
#tabs button:hover { background: var(--primary-soft); }
#tabs button.active { background: color-mix(in oklab, var(--primary) 10%, transparent); color: var(--primary); }
.sidebar-footer { display: flex; gap: 10px; align-items: center; padding: 16px; border-top: 1px solid var(--line); font-size: 12px; flex-wrap: wrap; }
.sidebar-footer strong { font-weight: 500; }
.sidebar-footer small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.workspace-avatar { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; color: var(--primary); background: white; font-weight: 600; }
main { margin-left: 224px; min-width: 0; }
/* Staging only (see client.ts): a banner above every page and an amber sidebar edge. */
.staging-banner {
  position: sticky; top: 0; z-index: 9; padding: 8px 24px;
  background: oklch(0.9 0.09 85); color: oklch(0.32 0.06 70); font-size: 13px; font-weight: 500;
  border-bottom: 1px solid oklch(0.8 0.1 80);
}
body.staging .app-sidebar { border-right: 4px solid oklch(0.8 0.12 80); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; min-height: 77px; border-bottom: 1px solid var(--line); }
h1 { font-size: 18px; font-weight: 600; line-height: 1.4; margin: 0; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
h3 { font-size: 13px; font-weight: 600; }
p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 12px; }
.page-header p { font-size: 12px; margin: 4px 0 0; }
.workspace-body { padding: 18px 24px; }
.toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); }
.toolbar select { min-width: 130px; }
.toolbar .field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); }
.month-picker { position: relative; display: flex; color: oklch(0.25 0.01 130); }
.month-picker > button { border-radius: 0; padding: 8px 9px; min-height: 34px; }
.month-picker > button + button { margin-left: -1px; }
.month-picker > button:first-child { border-radius: 6px 0 0 6px; }
.month-picker > #month-next { border-radius: 0 6px 6px 0; }
.month-picker > button svg { width: 14px; height: 14px; }
.month-button { min-width: 122px; justify-content: flex-start; gap: 8px; font-weight: 500; }
.month-button svg { color: var(--muted); }
.month-button[aria-expanded="true"] { background: var(--primary-soft); }
.month-popover { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 272px; padding: 12px; background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 36px oklch(0.3 0.02 130 / .16); font-size: 12px; }
.month-popover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-popover-head strong { font-size: 13px; font-weight: 600; }
.month-popover-head button { padding: 6px; border-color: transparent; }
.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.month-cell { position: relative; padding: 9px 0 12px; border-color: transparent; font-weight: 500; }
.month-cell.has-invoices::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--primary); }
.month-cell.selected, .month-cell.selected:hover { background: var(--primary); border-color: var(--primary); color: white; }
.month-cell.selected::after { background: white; }
.month-cell.today:not(.selected) { border-color: var(--line); }
.month-cell:disabled { opacity: .3; background: transparent; }
.month-popover-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.month-legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.month-legend::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.month-popover-foot button { padding: 5px 9px; font-size: 11px; }
input, select, textarea { color: inherit; background: white; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; max-width: 100%; min-width: 0; font-size: 12px; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { accent-color: var(--primary); }
.panel { min-width: 0; background: white; border: 1px solid var(--line); border-radius: 9px; padding: 20px; margin-bottom: 16px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head p { font-size: 12px; margin-bottom: 0; max-width: 860px; }
.section-head > div { min-width: 0; }
.section-head > button { flex-shrink: 0; }
.recurring-summary { border-left: 3px solid var(--primary); padding: 16px 20px; }
#recurring-scope { font-size: 11px; margin-bottom: 0; }
.recurring-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 12px 0; }
.recurring-metrics span { color: var(--muted); font-size: 11px; }
.recurring-metrics strong { display: block; margin-top: 3px; font-size: clamp(24px, 2.2vw, 30px); font-weight: 600; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.recurring-summary p:last-child { margin-bottom: 0; }
.reporting-basis { margin-top: 12px; }
.reporting-basis summary { font-size: 11px; }
.reporting-basis p { margin: 8px 0 0; font-size: 12px; }
.settings-panel > summary { font-size: 14px; font-weight: 600; }
.settings-panel:not([open]) > summary { margin-bottom: 0; }
.settings-panel[open] > summary { margin-bottom: 12px; }
.explanation { font-size: 11px; max-width: 1100px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.summary-card { min-width: 0; justify-content: space-between; gap: 12px; text-align: left; padding: 12px; font-weight: 400; border-radius: 7px; }
.summary-card > span:first-child { min-width: 0; }
.summary-card span span { display: block; color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin: 3px 0; font-size: 21px; font-weight: 600; color: var(--primary); }
.summary-card small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.summary-card.selected { background: color-mix(in oklab, var(--primary) 5%, white); border-color: var(--primary); box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary) 20%, transparent); }
.summary-card[data-attention=overdue] strong { color: var(--danger); }
.register-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; background: white; color: var(--muted); }
.search input { border: 0; background: transparent; width: 215px; padding-left: 0; }
#row-count { margin-left: auto; font-size: 11px; color: var(--muted); }
.category-filter { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; background: white; max-height: 65vh; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; min-width: 85px; }
th { position: sticky; top: 0; z-index: 1; background: #fcfcf9; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
td { max-width: 350px; line-height: 1.5; }
td strong { font-weight: 500; }
.sourced-value small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in oklab, var(--primary) 3%, white); }
#billing-table th, #billing-table td { padding: 9px 10px; }
#billing-table th:nth-child(2) { min-width: 172px; }
#billing-table th:nth-child(5) { min-width: 235px; }
#billing-table td:nth-child(3), #billing-table td:nth-child(4), #billing-table td:nth-child(8) { white-space: nowrap; }
#billing-table td:nth-child(11), #billing-table td:nth-child(12), #billing-table th:nth-child(11), #billing-table th:nth-child(12) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#billing-table td:last-child { min-width: 185px; }
#billing-table th:last-child, #billing-table td:last-child { position: sticky; right: 0; background: white; box-shadow: -1px 0 var(--line); }
#billing-table th:last-child { z-index: 2; background: #fcfcf9; }
.cell-description { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; line-height: 1.5; margin: 0; min-width: 215px; max-width: 245px; }
.module-pills { display: flex; gap: 4px; flex-wrap: wrap; min-width: 100px; max-width: 160px; }
.badge { display: inline-block; border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; font-size: 10px; font-weight: 500; line-height: 1.4; white-space: nowrap; }
.badge.sage { background: var(--primary-soft); color: oklch(0.4 0.04 145); border-color: transparent; }
.badge.warning-badge { background: #faf1df; color: #876425; border-color: #e9d8b5; }
.sort-button { border: 0; background: transparent; padding: 0; font-size: 11px; font-weight: 500; color: var(--muted); }
.sort-button::after { content: ""; border-left: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 4px solid currentColor; margin-left: 4px; opacity: 0; }
.sort-button:hover::after, .sort-button:focus-visible::after { opacity: .4; }
.sort-button.sorted { color: oklch(0.3 0.01 130); }
.sort-button.sorted::after { opacity: 1; }
th[aria-sort=descending] .sort-button::after { transform: rotate(180deg); }
.column-head { display: inline-flex; align-items: center; gap: 3px; min-height: 20px; }
.filter-button { padding: 3px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); }
.filter-button svg { width: 12px; height: 12px; }
.filter-button:hover { border-color: var(--line); background: white; }
.filter-button.active { background: var(--primary); border-color: var(--primary); color: white; }
.filter-button.active svg { fill: currentColor; }
.column-filter { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(290px, calc(100vw - 16px)); overflow: auto; padding: 12px; background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 36px oklch(0.3 0.02 130 / .16); font-size: 12px; }
.column-filter strong { font-size: 13px; font-weight: 600; }
.column-filter-sort { display: flex; gap: 6px; }
.column-filter-sort button { flex: 1; padding: 5px 8px; font-size: 11px; }
.column-filter-list { min-height: 60px; max-height: 240px; overflow: auto; padding: 4px 0; border: 1px solid var(--line); border-radius: 6px; }
.column-filter-list label { display: flex; align-items: center; gap: 8px; padding: 4px 10px; cursor: pointer; }
.column-filter-list label:hover { background: var(--primary-soft); }
.column-filter-list input { flex-shrink: 0; width: auto; margin: 0; padding: 0; }
.column-filter-list .select-all { border-bottom: 1px solid var(--line); margin-bottom: 2px; font-weight: 500; }
.column-filter-list .blank { color: var(--muted); font-style: italic; }
.column-filter-list .count { margin-left: auto; color: var(--muted); font-size: 11px; }
.column-filter-list p { margin: 8px 10px; color: var(--muted); }
.column-filter .note { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.column-filter .error { margin: 0; color: var(--danger); font-size: 11px; }
.column-filter-actions { display: flex; justify-content: flex-end; gap: 6px; }
.register-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -2px 0 10px; color: var(--muted); font-size: 11px; }
.filter-chip { padding: 4px 8px; border-color: transparent; border-radius: 999px; background: var(--primary-soft); color: oklch(0.35 0.04 145); font-size: 11px; }
.filter-chip::after { content: "×"; margin-left: 2px; font-size: 13px; line-height: 1; }
.table-note { font-size: 10px; margin: 8px 0 14px; }
.table-help { margin: 14px 0; color: var(--muted); font-size: 12px; }
.tab-count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 600; text-align: center; }
button.link { padding: 0; border: 0; background: none; color: var(--primary); font-size: 11px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
button.link:hover { background: none; color: oklch(0.35 0.06 145); }
button.link.danger { color: var(--danger); }
#drafts-table .draft-actions { gap: 8px; flex-wrap: nowrap; }
#drafts-table td:nth-child(3), #drafts-table td:nth-child(4), #drafts-table .actions button { white-space: nowrap; }
.dialog-actions #save, .dialog-actions #raise-draft { order: 3; }
/* A subscription line still missing its rate or tier in a draft. */
.component label.missing input { border-color: #e9d8b5; background: #fffaf0; }
.empty { padding: 30px 16px; text-align: center; background: white; border: 1px dashed var(--line); border-radius: 7px; color: var(--muted); font-size: 12px; }
.view-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.view-tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 16px; color: var(--muted); }
.view-tabs button.active { border-bottom-color: var(--primary); color: var(--primary); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart { width: 100%; height: auto; min-height: 170px; max-height: 280px; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart text.value { fill: oklch(0.35 0.03 145); font-size: 10px; }
.chart rect.bar { fill: var(--primary); }
.chart rect.bar.negative { fill: oklch(0.7 0.11 55); }
.fy-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px 18px; background: white; border: 1px solid var(--line); border-radius: 9px; }
.fy-bar h2 { margin: 0 0 4px; }
.fy-bar p { margin: 0; font-size: 12px; color: var(--muted); }
.fy-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.fy-controls label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: var(--background); }
.segmented button { border: 0; background: transparent; padding: 7px 12px; border-radius: 5px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: white; color: oklch(0.25 0.01 130); box-shadow: 0 1px 2px oklch(0.3 0.02 130 / .12); }
.chart-note { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.chart rect.missing { fill: var(--primary-soft); stroke: var(--line); stroke-dasharray: 3 3; }
.chart line { stroke: var(--line); }
.panel > .table-wrap, .panel > div > .table-wrap { margin-top: 12px; }
details { border-top: 1px solid var(--line); padding: 14px 0 4px; margin-top: 14px; }
summary { cursor: pointer; font-size: 12px; font-weight: 500; margin-bottom: 10px; }
.coverage p { font-size: 11px; }
.coverage label { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; font-size: 12px; }
.warning { background: #fcf5e7; color: #876425; padding: 10px 12px; border: 1px solid #eee1c7; border-radius: 6px; font-size: 11px; }
.error { background: #fcf0eb; color: var(--danger); padding: 12px; border-radius: 6px; font-size: 12px; }
#notice { background: var(--primary-soft); color: oklch(0.35 0.04 145); border: 1px solid var(--line); padding: 12px 16px; border-radius: 7px; margin-bottom: 16px; font-size: 12px; }
#notice.error { background: #fcf0eb; color: var(--danger); }
footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 12px; font-size: 10px; color: var(--muted); }
.chat { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; max-width: 1240px; margin: 0 auto; }
.chat-main { min-width: 0; display: flex; flex-direction: column; min-height: calc(100dvh - 150px); }
.chat-sidebar { position: sticky; top: 18px; display: flex; flex-direction: column; max-height: calc(100dvh - 130px); background: white; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.chat-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 10px 14px; border-bottom: 1px solid var(--line); }
.chat-sidebar-head h2 { margin: 0; font-size: 13px; }
#chat-threads { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
#chat-threads li { position: relative; display: flex; align-items: stretch; border-radius: 7px; }
#chat-threads li:hover, #chat-threads li.active { background: var(--primary-soft); }
#chat-threads li.active .chat-thread span { color: var(--primary); font-weight: 600; }
.chat-thread { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 30px 8px 10px; border: 0; background: transparent; text-align: left; font-weight: 400; }
.chat-thread:hover { background: transparent; }
.chat-thread span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.chat-thread small { color: var(--muted); font-size: 10px; }
.chat-thread-delete { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; opacity: 0; }
#chat-threads li:hover .chat-thread-delete, #chat-threads li.active .chat-thread-delete, .chat-thread-delete:focus-visible { opacity: 1; }
.chat-thread-delete:hover { color: var(--danger); background: white; }
.chat-threads-empty { padding: 12px 8px; color: var(--muted); font-size: 12px; }
.chat-welcome { text-align: center; padding: 56px 12px 36px; }
.chat-mark { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 12px; color: white; background: var(--primary); font-size: 24px; }
.chat-welcome h2 { font-size: 23px; font-weight: 500; }
.chat-prompts { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
#chat-messages { flex: 1; }
.chat-message { margin: 14px 0; padding: 16px 18px; background: white; border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.chat-message > strong { display: block; margin-bottom: 8px; font-size: 11px; color: var(--primary); }
.chat-message > div { white-space: pre-wrap; font-size: 13px; line-height: 1.7; }
.chat-message > div.markdown { white-space: normal; line-height: 1.6; }
.chat-answer.markdown p { margin: 0 0 10px; }
.chat-answer.markdown h4 { margin: 18px 0 8px; font-size: 13px; color: oklch(0.3 0.01 130); }
.chat-answer.markdown ul, .chat-answer.markdown ol { margin: 0 0 12px; padding-left: 20px; }
.chat-answer.markdown li { margin: 3px 0; }
.chat-answer.markdown > :last-child { margin-bottom: 0; }
.chat-clarification { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.chat-clarification-custom { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chat-clarification-custom label { display: grid; gap: 6px; flex: 1; min-width: 160px; font-size: 12px; }
.chat-clarification-custom input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.chat-assumptions { margin-top: 12px; padding: 8px 12px; border-left: 3px solid var(--line); background: #fcfcf9; border-radius: 0 6px 6px 0; }
.chat-assumptions h5 { margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.chat-assumptions ul { margin: 0; padding-left: 16px; font-size: 12px; line-height: 1.5; color: oklch(0.38 0.01 130); }
.chat-suggestions { margin-top: 12px; }
.chat-suggestions button { font-weight: 400; text-align: left; }
.chat-table { overflow-x: auto; margin: 6px 0 14px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.chat-table table { font-size: 12px; line-height: 1.4; }
.chat-table th, .chat-table td { min-width: 0; padding: 7px 10px; }
.chat-table th { position: static; background: #fcfcf9; white-space: normal; }
.chat-table tbody tr:nth-child(even) td { background: #fcfcf9; }
.chat-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chat-table tbody tr.total td { font-weight: 650; background: var(--primary-soft); border-top: 1px solid var(--line); }
.chat-table tr:last-child td { border-bottom: 0; }
.chat-user { width: fit-content; max-width: 80%; margin-left: auto; padding: 10px 14px; background: var(--primary-soft); border-color: transparent; }
.chat-message > small { display: block; color: var(--muted); font-size: 10px; margin-top: 14px; }
.change-review { margin: 14px 0 4px; padding: 14px 16px; border: 1px solid var(--primary); border-radius: 8px; background: #fcfcf9; white-space: normal; }
.change-review[data-status=applied] { border-color: var(--line); }
.change-review:not([data-status=pending]):not([data-status=applied]) { border-color: #e9d8b5; }
.change-review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.change-review h3 { margin: 0; font-size: 14px; }
.change-operation { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.change-operation h4 { margin: 0; font-size: 13px; }
.change-operation h5 { margin: 14px 0 6px; color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.change-subtitle { margin: 2px 0 8px; color: var(--muted); font-size: 12px; }
.change-review .table-wrap { margin-top: 6px; max-height: none; }
.change-review th[scope=row] { position: static; width: 32%; color: inherit; background: transparent; font-size: 12px; white-space: normal; }
.change-review td { white-space: pre-wrap; }
.change-review td:last-child { color: var(--muted); font-size: 11px; }
.change-lines td { white-space: nowrap; overflow-wrap: normal; font-variant-numeric: tabular-nums; }
.change-lines td:last-child { white-space: normal; min-width: 190px; }
.change-review .change-lines th[scope=row] { width: auto; min-width: 170px; }
.change-notes { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.change-review-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.change-review-actions small { flex: 1; min-width: 200px; color: var(--muted); font-size: 11px; }
.change-review-actions p { margin: 0; font-size: 12px; }
.change-review-actions a { color: var(--primary); font-size: 12px; }
.chat-working { padding: 8px 0; color: var(--primary); }
.chat-composer { position: sticky; bottom: 12px; padding: 10px 12px; margin-top: 12px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 24px #26332714; }
.chat-composer textarea { display: block; width: 100%; border: 0; padding: 6px 2px; min-height: 52px; max-height: 200px; resize: none; }
.chat-composer textarea:focus-visible { outline: none; }
.chat-composer:focus-within { border-color: var(--primary); }
.chat-composer-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.chat-hint { flex: 1; min-width: 0; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-effort { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.chat-effort select { padding: 5px 8px; font-size: 11px; }
.chat-privacy { font-size: 10px; line-height: 1.6; margin: 8px 2px 0; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 1000px) {
  .chat { grid-template-columns: 1fr; }
  .chat-sidebar { position: static; order: -1; max-height: 210px; }
  .chat-main { min-height: 0; }
}
#chat-error { padding: 12px; background: #fcf0eb; border-radius: 6px; }
.report-filter { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; color: oklch(0.35 0.04 145); background: var(--primary-soft); border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 24px; width: min(850px, 94vw); max-height: 92dvh; color: inherit; background: white; box-shadow: 0 16px 70px #26332726; }
dialog::backdrop { background: #20271f50; }
dialog label { display: flex; flex-direction: column; gap: 6px; margin: 9px 0; font-size: 11px; color: var(--muted); }
dialog input, dialog select, dialog textarea { width: 100%; }
dialog p { font-size: 12px; }
dialog ul { font-size: 12px; line-height: 1.7; max-height: 240px; overflow: auto; }
dialog .check { flex-direction: row; align-items: flex-start; line-height: 1.5; }
dialog .check input { width: auto; flex-shrink: 0; }
.dialog-heading { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.dialog-heading h2 { font-size: 18px; }
.form-section-title { margin: 20px 0 6px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -24px; background: white; border-top: 1px solid var(--line); margin-top: 20px; padding: 16px 0 0; }
.component { border: 1px solid var(--line); border-radius: 7px; padding: 12px; margin: 12px 0; background: #fcfcf9; }
.component .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#zoho-draft-status .zoho-delete-draft { color: var(--danger); padding: 2px 4px; font-weight: 400; }
#zoho-review-dialog { width: min(920px, 94vw); }
#zoho-review-dialog fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
#zoho-review-destination, #zoho-review-status { overflow-wrap: anywhere; }
#zoho-review-source summary { cursor: pointer; font-size: 12px; }
#zoho-review-source-description { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.zoho-review-line { display: grid; grid-template-columns: minmax(125px, 1fr) minmax(160px, 1.5fr) 70px 115px 100px auto; align-items: end; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.zoho-review-line label { margin: 0; min-width: 0; }
.zoho-review-line textarea { min-height: 38px; resize: vertical; }
.zoho-review-line input, .zoho-review-line select, .zoho-review-line textarea { padding: 8px; }
.zoho-review-line button { margin-bottom: 2px; }
#zoho-review-add { margin-top: 10px; }
.zoho-review-discount { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 12px; }
#zoho-review-totals-section h3 { font-size: 12px; margin: 12px 0 8px; }
#zoho-review-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
#zoho-review-totals dt { color: var(--muted); font-size: 11px; }
#zoho-review-totals dd { margin: 4px 0 0; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#zoho-review-warnings { padding: 10px 12px 10px 28px; border: 1px solid #e9d8b5; border-radius: 6px; background: #faf1df; max-height: none; }
.zoho-review-footer { position: sticky; bottom: -24px; padding: 12px 0 0; background: white; }
.zoho-review-footer .dialog-actions { justify-content: flex-end; position: static; margin-top: 10px; padding: 10px 0 0; }
#zoho-review-error p { margin: 6px 0; }
#zoho-review-error:focus { outline: 2px solid var(--danger); outline-offset: 2px; }
#zoho-review-error summary { cursor: pointer; }
#zoho-review-error pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 100px; overflow: auto; font-size: 11px; }
#quickbooks-draft-status .quickbooks-delete { color: var(--danger); padding: 2px 4px; font-weight: 400; }
#quickbooks-dialog { width: min(760px, 94vw); }
#quickbooks-destination, #quickbooks-status, #quickbooks-customer { overflow-wrap: anywhere; }
#quickbooks-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
#quickbooks-lines th, #quickbooks-lines td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
#quickbooks-lines th:nth-child(n+2), #quickbooks-lines td:nth-child(n+2) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#quickbooks-lines td:first-child { white-space: pre-wrap; overflow-wrap: anywhere; }
#quickbooks-totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
#quickbooks-totals dt { color: var(--muted); }
#quickbooks-totals dd { margin: 0; text-align: right; }
#quickbooks-totals .total { font-weight: 600; color: inherit; }
#quickbooks-warnings { padding: 10px 12px 10px 28px; border: 1px solid #e9d8b5; border-radius: 6px; background: #faf1df; max-height: none; }
#quickbooks-error p { margin: 6px 0; }
#quickbooks-error:focus { outline: 2px solid var(--danger); outline-offset: 2px; }
#quickbooks-error summary { cursor: pointer; }
#quickbooks-error pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 100px; overflow: auto; font-size: 11px; }
@media (max-width: 720px) {
  .zoho-review-line { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .zoho-review-line button { justify-self: end; align-self: end; }
  #zoho-review-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .zoho-review-discount { grid-template-columns: 1fr; gap: 0; }
}
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(580px, 100vw); height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; border-left: 1px solid var(--line); padding: 24px; }
dialog.drawer .section-head { align-items: flex-start; }
.payment-status { margin: 14px 0 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--primary-soft); color: inherit; font-size: 12px; }
.invoice-documents { margin: 12px 0 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--primary-soft); }
.invoice-documents h3 { margin: 0 0 4px; font-size: 12px; }
.invoice-documents ul { margin: 0; padding-left: 18px; max-height: none; }
.invoice-documents a, .draft-document { color: var(--primary); }
.invoice-documents small { color: var(--muted); font-size: 11px; }
.invoice-documents .change-review { margin-top: 10px; }
.invoice-documents summary { cursor: pointer; font-size: 12px; font-weight: 500; }
.field-hint { color: var(--muted); font-size: 10px; line-height: 1.4; }
.draft-document { font-size: 11px; align-self: center; }
.payment-status.overdue { background: #faf1df; border-color: #e9d8b5; color: #876425; }
/* Sign-in is a full page: it covers the app until the session is known, and keeps open forms underneath. */
body.checking-session > .app-sidebar, body.checking-session > main { visibility: hidden; }
#login-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 24px; border: 0; border-radius: 0; box-shadow: none; background: var(--background); }
#login-dialog[open] { display: grid; place-items: center; }
#login-dialog::backdrop { background: var(--background); }
.login-card { width: min(380px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 16px 50px #2633271a; }
#login-dialog .login-brand { min-height: 0; padding: 0 0 22px; margin-bottom: 22px; border: 0; border-bottom: 1px solid var(--line); }
#login-form h1 { margin-bottom: 4px; }
#login-form label { font-size: 12px; margin: 14px 0; }
#login-form input { padding: 10px 12px; font-size: 14px; }
#login-form .primary { width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 13px; }
#login-error { margin: 12px 0 0; }
.login-note { margin: 18px 0 0; font-size: 12px; text-align: center; }
@media (max-width: 1100px) {
  .page-header { align-items: flex-start; flex-wrap: wrap; }
  .section-head { flex-wrap: wrap; }
  .stats { gap: 8px; }
  .summary-card { gap: 8px; padding: 10px; }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-sidebar { position: static; width: 100%; }
  .brand { border-bottom: 0; min-height: auto; padding: 14px 16px; }
  .sidebar-footer { position: absolute; right: 12px; top: 13px; padding: 0; border: 0; background: var(--sidebar); }
  .sidebar-footer > .workspace-avatar, .sidebar-footer > div { display: none; }
  #tabs { display: flex; gap: 4px; padding: 0 10px 10px; overflow-x: auto; flex: none; }
  #tabs button { width: auto; flex-shrink: 0; padding: 9px 10px; font-size: 12px; margin: 0; gap: 6px; }
  main { margin-left: 0; }
  .page-header { padding: 16px; }
  .workspace-body { padding: 16px; }
  .recurring-summary { padding: 16px; }
  .toolbar { gap: 10px; }
  .toolbar select { min-width: 95px; }
  .toolbar label, .toolbar .field { flex: 1; }
  .month-button { flex: 1; }
  .stats { grid-template-columns: 1fr; }
  .summary-card { padding: 10px 12px; }
  .summary-card > span:first-child { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; width: 100%; }
  .summary-card span span { align-self: center; }
  .summary-card strong { margin: 0; grid-row: 1 / 3; grid-column: 2; align-self: center; }
  .summary-card small { grid-row: 2; }
  .recurring-metrics { gap: 12px; }
  .recurring-metrics strong { font-size: 22px; }
  .search { flex: 1; min-width: 180px; }
  .search input { width: 100%; }
  #row-count { margin-left: 0; }
  .panel { padding: 16px; }
  .chart { min-width: 480px; }
  div:has(> .chart) { overflow-x: auto; }
  .form-grid, .component .form-grid { grid-template-columns: 1fr; }
  dialog, dialog.drawer { padding: 18px; }
  .dialog-actions { bottom: -18px; }
}
@media (max-width: 430px) {
  .recurring-metrics { grid-template-columns: 1fr; gap: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 120ms, border-color 120ms; }
}

/* Purposeful loading states. */
.download-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 8px; flex-shrink: 0; }
.download-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
#analytics, #reports, #billing, #accounts { position: relative; min-height: 300px; }
.page-skeleton { position: absolute; inset: 0; z-index: 3; background: #fafbf7; padding: 18px; min-height: 360px; }
.skeleton-cards { display: flex; gap: 16px; margin-bottom: 24px; }
.skeleton-cards span { height: 70px; flex: 1; border-radius: 8px; }
.skeleton-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.skeleton-plot { display: flex; gap: 12px; align-items: flex-end; height: 200px; padding: 30px 16px 0; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.skeleton-plot span { flex: 1; border-radius: 4px 4px 0 0; }
.skeleton-row { height: 32px; margin: 14px 0; border-radius: 5px; }
.skeleton-cards span, .skeleton-row, .skeleton-plot span { background: linear-gradient(100deg,#e7ece3 25%,#f4f6f0 50%,#e7ece3 75%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) {
  .page-enter { animation: page-enter 240ms ease-out; }
  .page-enter .panel { animation: page-enter 300ms ease-out; }
  .skeleton-cards span, .skeleton-row, .skeleton-plot span { animation: shimmer 1.3s linear infinite; }
  .chart .bar { transform-box: fill-box; transform-origin: center bottom; animation: bar-grow 350ms ease-out; }
}
@keyframes page-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes bar-grow { from { transform: scaleY(.05); } to { transform: scaleY(1); } }
@media (max-width: 760px) { .skeleton-charts { grid-template-columns: 1fr; } }

.license-bar-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(70px, 1fr) 140px; align-items: center; gap: 12px; margin: 14px 0; font-size: 12px; }
.license-label { overflow-wrap: anywhere; }
.license-track { height: 14px; border-radius: 4px; background: #eef1e9; overflow: hidden; }
.license-fill { height: 100%; background: #71876d; border-radius: 4px; }
.license-bar-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.license-bar-row strong small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
/* Overview: three sections, each saying which period its charts cover. */
.overview-section { margin-bottom: 28px; }
.overview-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; padding: 14px 18px; background: white; border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 9px; }
.overview-section-head h2 { margin: 0 0 4px; font-size: 16px; }
.overview-section-head p { margin: 0; font-size: 12px; color: var(--muted); }
.section-note { margin: 0 0 12px; font-size: 11px; color: var(--muted); }
.panel .section-head h3 { margin: 0 6px 0 0; display: inline; font-size: 14px; }
.period-chip { display: inline-block; vertical-align: 1px; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: oklch(0.38 0.04 145); font-size: 10px; font-weight: 500; white-space: nowrap; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.net { height: 3px; background: oklch(0.3 0.02 130); }
.chart line.net-mark { stroke: oklch(0.3 0.02 130); stroke-width: 3; }
.chart line.connector { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart rect.bar.total { fill: oklch(0.5 0.05 145); }
.chart rect.bar.gain { fill: oklch(0.68 0.09 145); }
.chart rect.bar.loss { fill: oklch(0.7 0.11 55); }
.chart rect.s-arr, .swatch.s-arr, .chart rect.s-licences, .swatch.s-licences { fill: var(--primary); background: var(--primary); }
.chart rect.s-new, .swatch.s-new { fill: oklch(0.5 0.08 150); background: oklch(0.5 0.08 150); }
.chart rect.s-existing, .swatch.s-existing { fill: oklch(0.78 0.05 150); background: oklch(0.78 0.05 150); }
.chart rect.s-expansion, .swatch.s-expansion { fill: oklch(0.65 0.1 145); background: oklch(0.65 0.1 145); }
.chart rect.s-recovered, .swatch.s-recovered { fill: oklch(0.65 0.07 200); background: oklch(0.65 0.07 200); }
.chart rect.s-reduction, .swatch.s-reduction { fill: oklch(0.78 0.1 70); background: oklch(0.78 0.1 70); }
.chart rect.s-churn, .swatch.s-churn { fill: oklch(0.62 0.14 40); background: oklch(0.62 0.14 40); }
.chart rect.s-invoiced, .swatch.s-invoiced, .chart rect.s-nrr, .swatch.s-nrr, .chart rect.s-won, .swatch.s-won { fill: var(--primary); background: var(--primary); }
.chart rect.s-collected, .swatch.s-collected, .chart rect.s-grr, .swatch.s-grr { fill: oklch(0.7 0.07 220); background: oklch(0.7 0.07 220); }
.chart rect.s-lost, .swatch.s-lost { fill: oklch(0.7 0.11 55); background: oklch(0.7 0.11 55); }
.chart rect.s-inr, .swatch.s-inr { fill: var(--primary); background: var(--primary); }
.chart rect.s-usd, .swatch.s-usd { fill: oklch(0.7 0.07 220); background: oklch(0.7 0.07 220); }
.chart rect.s-php, .swatch.s-php { fill: oklch(0.78 0.1 80); background: oklch(0.78 0.1 80); }
.chart rect.s-aud, .swatch.s-aud { fill: oklch(0.65 0.08 300); background: oklch(0.65 0.08 300); }
@media (prefers-reduced-motion: no-preference) { .license-fill { animation: bar-grow-x 350ms ease-out; transform-origin: left; } }
@keyframes bar-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.report-disclosure > summary { font-size: 15px; font-weight: 600; cursor: pointer; }
.report-disclosure .section-head { margin-top: 16px; }

/* Detailed reports use light disclosure rows instead of individual cards. */
#reports > details.panel { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; padding: 14px 0; margin: 0; }
#reports > details.panel > summary { font-size: 14px; font-weight: 500; }
#reports > details.panel[open] { padding-bottom: 20px; }
/* Invoice Summary: paged long registers */
.table-more { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; font-size: 11px; color: var(--muted); }
/* Commissions */
.commission-toolbar { margin: 0 0 4px; }
.commission-toolbar input { width: 150px; }
.commission-toolbar .actions { display: flex; gap: 6px; flex-wrap: wrap; }
#commission-summary td:first-child, #incentive-table td:first-child { white-space: nowrap; font-weight: 500; }
#commission-summary td:not(:first-child), #commission-summary th:not(:first-child),
#incentive-table td:not(:first-child), #incentive-table th:not(:first-child) { text-align: right; white-space: nowrap; }
#commission-summary tr.commission-native td { color: var(--muted); }
#commission-summary tr.commission-rate td { color: var(--muted); font-size: 11px; }
#commission-summary tr.commission-total td { font-weight: 650; background: var(--primary-soft); }
#commission-rules { margin: 8px 0 0; padding-left: 18px; font-size: 12px; }
#commission-rules li { margin-bottom: 4px; }
#incentive-entities { margin-bottom: 8px; }
/* Settings: exchange rates */
.rates-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.rates-grid h3, .rate-form h3 { margin: 0 0 8px; font-size: 13px; }
.rate-form { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.rate-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 12px; }
.rate-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); }
.rate-fields .wide { grid-column: 1 / -1; }
.rate-form .actions { display: flex; gap: 8px; }
@media (max-width: 900px) { .rates-grid { grid-template-columns: 1fr; } .rate-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rates-grid th, .rates-grid td { min-width: 0; }

/* Upload documents: choose files, watch each being read, then a summary of the new drafts. */
dialog.upload-dialog { width: min(560px, 94vw); }
.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; border: 1.5px dashed var(--line); border-radius: 10px; background: #fafbf7; text-align: center; cursor: pointer; }
.drop-zone strong { font-size: 14px; }
.drop-zone span, .drop-zone small { color: var(--muted); font-size: 11px; }
.drop-zone.dragging, .drop-zone:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-facts { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.7; max-height: none; }
.upload-file { margin: 0 0 12px; font-weight: 500; overflow-wrap: anywhere; }
.upload-file small { color: var(--muted); font-weight: 400; }
.upload-steps { list-style: none; margin: 0; padding: 0; max-height: none; }
.upload-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.upload-steps li:first-child { border-top: 0; }
.upload-steps li > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.upload-steps strong { font-size: 13px; }
.upload-steps small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.upload-steps li[data-state=pending] { color: var(--muted); }
.upload-steps li[data-state=pending] small { display: none; }
.upload-steps progress { width: 100%; height: 6px; accent-color: var(--primary); }
.upload-steps li:not([data-state=active]) progress { display: none; }
.step-icon { flex-shrink: 0; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--line); font-size: 11px; font-weight: 700; color: white; }
li[data-state=active] .step-icon { border-color: var(--primary-soft); border-top-color: var(--primary); }
li[data-state=done] .step-icon { border-color: var(--primary); background: var(--primary); }
li[data-state=done] .step-icon::after { content: "✓"; }
li[data-state=failed] .step-icon { border-color: oklch(0.62 0.14 40); background: oklch(0.62 0.14 40); }
li[data-state=failed] .step-icon::after { content: "!"; }
.upload-wait { margin: 12px 0 0; color: var(--muted); font-size: 11px; }
.upload-result-title { margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.upload-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf7; }
.upload-summary dt { color: var(--muted); font-size: 11px; }
.upload-summary dd { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.upload-match { margin: 0 0 8px; color: var(--muted); font-size: 11px; }
.upload-document { margin: 0 0 12px; font-size: 12px; line-height: 1.5; }
.upload-document small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.upload-results { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.upload-results li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.upload-results li:first-child { border-top: 0; }
.upload-results li > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.upload-results strong { font-size: 13px; overflow-wrap: anywhere; }
.upload-results small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.upload-results li[data-state=failed] small { color: oklch(0.45 0.12 40); }
.upload-changes, .upload-missing { margin: 0 0 12px; font-size: 12px; }
.upload-changes p, .upload-missing p { margin: 0 0 4px; font-weight: 500; }
.upload-changes ul, .upload-missing ul { margin: 0; padding: 8px 12px 8px 28px; border-radius: 8px; max-height: 160px; overflow-y: auto; }
.upload-changes ul { background: var(--primary-soft); }
.upload-missing ul { background: #fbf3e6; color: oklch(0.42 0.08 60); }
.upload-changes > p:last-child:not(:first-child) { margin-top: 6px; font-weight: 400; color: var(--muted); }
/* Raise invoice: the invoice number, what is missing, and what was flagged when the documents were read. */
dialog.raise-dialog { width: min(520px, 94vw); }
.raise-number { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 14px; font-weight: 500; font-size: 12px; }
.raise-number input { font-size: 14px; }
.raise-number small { color: var(--muted); font-weight: 400; font-size: 11px; }
.raise-checks { margin: 0 0 12px; font-size: 12px; }
.raise-checks p { margin: 0 0 4px; }
.raise-confirm { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.upload-check-list { margin: 0; padding: 10px 14px 10px 30px; border-radius: 8px; background: #fbf3e6; color: oklch(0.42 0.08 60); max-height: 180px; }
#drafts-table tbody tr.row-new { background: var(--primary-soft); }
@media (prefers-reduced-motion: no-preference) {
  li[data-state=active] .step-icon { animation: spin 1.8s linear infinite; }
  #drafts-table tbody tr.row-new { transition: background-color 1.5s ease-out; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Ask Plumo: the steps of an answer, live while it is prepared and folded above it afterwards. */
.chat-live { margin-top: 6px; }
.chat-live-head { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--primary); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chat-live-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-live-time { flex-shrink: 0; color: var(--muted); font-weight: 400; }
.chat-live-dots { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; height: 16px; }
.chat-live-dots span { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
@keyframes chat-dot-pulse {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-3px); opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .chat-live-dots span { animation: chat-dot-pulse 1.2s ease-in-out infinite; }
  .chat-live-dots span:nth-child(2) { animation-delay: .15s; }
  .chat-live-dots span:nth-child(3) { animation-delay: .3s; }
}
.chat-step-list { list-style: none; margin: 0; padding: 0; }
.chat-step-list li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 12px; }
.chat-step-list li > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chat-step-list li > div > span { overflow-wrap: anywhere; }
.chat-step-list small { color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-step-list li[data-state=active] > div > span:first-child { color: oklch(0.3 0.02 130); font-weight: 500; }
.chat-step-list .step-icon { width: 16px; height: 16px; font-size: 9px; }
li[data-state=retry] .step-icon { border-color: oklch(0.78 0.1 70); background: oklch(0.78 0.1 70); }
li[data-state=retry] .step-icon::after { content: "↻"; }
.chat-steps { margin: 4px 0 8px; }
.chat-steps summary { cursor: pointer; color: var(--muted); font-size: 11px; list-style-position: inside; }
.chat-steps[open] summary { margin-bottom: 4px; }
.chat-steps .chat-step-list { padding-left: 2px; border-left: 2px solid var(--line); margin-left: 4px; padding-left: 10px; }

/* Ask Plumo: "Show as chart" under answer tables. */
.chat-chart-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 4px; color: var(--primary); }
.chat-chart-toggle[aria-expanded=true] { background: var(--primary-soft); border-color: var(--primary); }
.chat-chart { margin: 4px 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.chat-chart h5 { margin: 6px 0 2px; color: var(--muted); font-size: 11px; font-weight: 500; }
.chart rect.s-1, .swatch.s-1 { fill: var(--primary); background: var(--primary); }
.chart rect.s-2, .swatch.s-2 { fill: oklch(0.7 0.07 220); background: oklch(0.7 0.07 220); }
.chart rect.s-3, .swatch.s-3 { fill: oklch(0.78 0.1 80); background: oklch(0.78 0.1 80); }
.chart rect.s-4, .swatch.s-4 { fill: oklch(0.65 0.08 300); background: oklch(0.65 0.08 300); }
.chart rect.s-5, .swatch.s-5 { fill: oklch(0.7 0.11 40); background: oklch(0.7 0.11 40); }
.chart rect.s-6, .swatch.s-6 { fill: oklch(0.6 0.05 180); background: oklch(0.6 0.05 180); }
/* Draft table and filter language; scoped to the Drafts page. */
:is(#drafts, #billing) { --draft-muted: oklch(0.93 0.012 100); --draft-band: color-mix(in oklch, var(--background) 65%, var(--draft-muted)); --draft-surface: color-mix(in oklch, var(--background) 65%, white); background: var(--draft-surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: none; padding: 0; overflow: hidden; font-size: 14px; }
:is(#drafts, #billing) .draft-register-head { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-start; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.draft-selects { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.draft-selects label { margin: 0; }
:is(#drafts, #billing) .draft-selects input, :is(#drafts, #billing) .draft-selects select { height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--background); font-size: 14px; outline: none; margin: 0; color: inherit; }
:is(#drafts, #billing) .draft-selects select { width: auto; max-width: 200px; padding: 0 28px 0 8px; font-weight: 500; }
.draft-search { position: relative; }
:is(#drafts, #billing) .draft-search input { width: 256px; max-width: 100%; padding: 0 12px 0 32px; }
.draft-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.8; pointer-events: none; }
:is(#drafts, #billing) :is(input,select,button):focus-visible { outline: 2px solid color-mix(in oklch,var(--primary) 30%,transparent); outline-offset: 2px; }
#upload-documents { margin-left: auto; flex-shrink: 0; height: 32px; border-radius: 8px; padding: 0 12px; font-size: 14px; }
.draft-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#draft-filters:not([hidden]) { padding: 10px 20px; border-bottom: 1px solid var(--line); }
:is(#drafts, #billing) .filter-chip { border-radius: 999px; font-size: 12px; }
:is(#drafts, #billing) .table-wrap { border: 0; border-radius: 0; background: transparent; margin: 0; overflow-x: auto; }
:is(#drafts, #billing) table { width: 100%; min-width: 1020px; font-size: 14px; border-collapse: collapse; }
:is(#drafts, #billing) thead th { background: var(--draft-band); color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
:is(#drafts, #billing) td { background: transparent; padding: 14px 12px; border-bottom: 1px solid color-mix(in oklch,var(--line) 60%,transparent); color: inherit; }
:is(#drafts, #billing) th:first-child, :is(#drafts, #billing) td:first-child { padding-left: 20px; }
:is(#drafts, #billing) td:first-child { min-width: 220px; font-weight: 500; }
:is(#drafts, #billing) th:last-child, :is(#drafts, #billing) td:last-child { padding-right: 20px; text-align: right; white-space: nowrap; }
:is(#drafts, #billing) th:nth-child(4), :is(#drafts, #billing) td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; }
:is(#drafts, #billing) td:nth-child(4) { font-weight: 500; white-space: nowrap; }
:is(#drafts, #billing) .sourced-value small { font-size: 12px; font-weight: 400; }
.draft-row { cursor: pointer; transition: background-color 150ms ease; }
:is(#drafts, #billing) .draft-row:hover { background: color-mix(in oklch,var(--primary-soft) 65%,var(--draft-surface)); }
:is(#drafts, #billing) .draft-row:focus-visible { outline: 2px solid color-mix(in oklch,var(--primary) 30%,transparent); outline-offset: -2px; }
:is(#drafts, #billing) .badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; letter-spacing: -.1px; white-space: nowrap; }
.draft-description { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; min-width: 0; max-width: 100%; line-height: 1.5; color: var(--muted); }
.draft-actions { justify-content: flex-end; }
:is(#drafts, #billing) .draft-actions button { display: inline-flex; gap: 4px; color: var(--primary); font-size: 14px; font-weight: 500; text-decoration: none; opacity: .7; border: 0; background: transparent; padding: 0; }
:is(#drafts, #billing) .draft-actions button::after { content: '›'; font-size: 16px; }
:is(#drafts, #billing) .draft-actions button:hover { opacity: 1; }
:is(#drafts, #billing) td.draft-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
/* Drawer shell, tabs and full-distance entrance. */
.invoice-drawer-header { position: relative; }
.drawer-close { position: absolute; right: 0; top: 0; width: 32px; height: 32px; padding: 0; border: 0; background: transparent; font-size: 24px; color: var(--muted); }
.invoice-header-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
#invoice-dialog.drawer { font-size: 14px; }
#invoice-dialog.drawer :is(label,p,input,select,textarea,button) { font-size: 14px; }
#invoice-dialog.drawer .form-section-title, #invoice-dialog.drawer small { font-size: 12px; }
#invoice-dialog.draft-layout { width: min(640px,100vw); background: var(--background); padding: 0; }
#invoice-dialog.draft-layout #invoice-form { min-height: 100%; }
.draft-layout .invoice-drawer-header { background: white; border-bottom: 1px solid var(--line); padding: 24px; }
.draft-layout .drawer-close { right: 16px; top: 16px; }
#invoice-dialog.draft-layout .drawer-close { font-size: 24px; }
.invoice-draft-status { position: absolute; right: 64px; top: 24px; padding: 6px 14px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); border: 1px solid color-mix(in oklch,var(--primary) 25%,transparent); font-size: 14px; font-weight: 500; }
.draft-layout .invoice-eyebrow { max-width: calc(100% - 132px); margin: 0 36px 8px 0; line-height: 1.5; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.draft-layout .dialog-heading { border: 0; margin: 0; padding: 0 36px 0 0; }
#invoice-dialog.draft-layout #invoice-title { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.draft-layout #invoice-subtitle { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; margin: 22px 0 0; font-variant-numeric: tabular-nums; }
.draft-layout #invoice-subtitle strong { font-size: 32px; line-height: 1.2; font-weight: 600; letter-spacing: -.5px; }
.draft-layout #invoice-subtitle span { color: var(--muted); font-size: 14px; }
.draft-layout .invoice-header-actions { margin: 16px 0 0; }
.draft-layout .invoice-header-actions button { border-radius: 8px; padding: 7px 12px; font-weight: 500; }
.draft-layout #invoice-documents { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0; margin: 16px 0 0; border: 0; border-radius: 0; background: transparent; }
.draft-layout #invoice-documents > .section-head { order: 1; margin: 0; padding: 0; flex-shrink: 0; }
.draft-layout #invoice-documents > ul { display: flex; flex: 1 1 240px; flex-wrap: wrap; gap: 8px 16px; list-style: none; padding: 0; margin: 0; max-height: none; }
.draft-layout #invoice-documents li { margin: 0; font-size: 14px; min-width: 0; }
.draft-layout #invoice-documents a { color: var(--primary); text-decoration: none; overflow-wrap: anywhere; }
.draft-layout #invoice-documents a:hover { text-decoration: underline; }
#invoice-dialog.draft-layout #attach-document { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: 22px; font-weight: 400; }
.draft-layout #invoice-documents > .change-review { order: 2; flex-basis: 100%; }
.invoice-detail-tabs { display: flex; gap: 4px; overflow-x: auto; position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); padding: 0 24px; background: color-mix(in oklch,var(--background) 95%,transparent); backdrop-filter: blur(8px); }
#invoice-dialog .invoice-detail-tabs button { padding: 12px 10px; background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
#invoice-dialog .invoice-detail-tabs button[aria-selected=true] { border-bottom-color: var(--primary); color: var(--primary); }
.draft-layout .invoice-pane-content { padding: 20px 24px; }
.draft-layout .invoice-pane { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.draft-layout .invoice-pane > .form-section-title { margin: 0 0 14px; }
.draft-layout .invoice-pane > details { border: 0; margin: 0; padding: 0; }
.draft-layout .invoice-pane > details > summary { display: none; }
.draft-layout .invoice-pane > details > p { margin-top: 0; color: var(--muted); line-height: 1.6; }
.draft-layout .invoice-pane > details#source-details { margin-top: 16px; }
.draft-layout .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.draft-layout #form-error { margin: 0 24px 20px; }
#invoice-dialog.draft-layout :is(input,select,textarea,button):focus-visible { outline: 2px solid color-mix(in oklch,var(--primary) 30%,transparent); outline-offset: 2px; }
#invoice-dialog:not(.draft-layout) .drawer-section-label { display: none; }
@keyframes draft-drawer-enter { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes draft-backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
 #invoice-dialog.drawer[open] { animation: draft-drawer-enter 420ms cubic-bezier(.22,.68,0,1) both; }
 #invoice-dialog.drawer[open]::backdrop { animation: draft-backdrop-enter 300ms ease-out both; }
}
@media (max-width:640px) {
 .draft-selects { width: 100%; }
 .draft-selects label { flex: 1 1 120px; }
 .draft-selects .draft-search { flex-basis: 100%; }
 #drafts .draft-search input, #drafts .draft-selects select { width: 100%; max-width: none; }
}
@media (max-width:480px) {
 .draft-layout .invoice-drawer-header { padding: 20px 16px; }
 .invoice-draft-status { top: 20px; right: 52px; }
 .draft-layout #invoice-subtitle strong { font-size: 28px; }
 .invoice-detail-tabs { padding: 0 16px; }
 .draft-layout .invoice-pane-content { padding: 16px; }
 .draft-layout .form-grid { grid-template-columns: 1fr; }
}

/* Compact invoice identity with actions on the same top row. */
.draft-layout .invoice-drawer-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; }
.draft-layout .invoice-eyebrow { grid-column: 1; max-width: none; margin: 0 0 6px; padding-right: 0; }
.draft-layout .dialog-heading { grid-column: 1; min-width: 0; padding: 0; }
#invoice-dialog.draft-layout #invoice-title { font-size: 18px; line-height: 1.4; letter-spacing: -.2px; overflow-wrap: anywhere; padding-right: 0; }
.draft-layout .invoice-header-actions { grid-column: 2; grid-row: 1 / span 2; align-self: start; margin: 0; padding-right: 30px; flex-wrap: wrap; min-width: 0; max-width: 100%; justify-content: flex-end; }
.draft-layout .invoice-header-actions button { max-width: 100%; white-space: normal; }
.draft-layout .invoice-header-actions #draft-more { width: 36px; padding: 7px 0; }
#draft-more svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
#draft-more-menu { position: absolute; right: 34px; top: calc(100% + 4px); z-index: 20; min-width: 200px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: 0 8px 24px color-mix(in oklch, black 14%, transparent); }
.draft-layout .invoice-header-actions #draft-more-menu button { display: flex; width: 100%; justify-content: flex-start; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; white-space: nowrap; }
.draft-layout .invoice-header-actions #draft-more-menu button:is(:hover, :focus-visible) { background: var(--primary-soft); }
.draft-layout .invoice-header-actions #draft-more-menu #raise-draft:not([hidden]) + #delete-draft { margin-top: 4px; padding-top: 9px; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; }
@media (pointer: coarse) {
  .draft-layout .invoice-header-actions #draft-more { min-width: 44px; min-height: 44px; }
  .draft-layout .invoice-header-actions #draft-more-menu button { min-height: 44px; }
}
.draft-layout #invoice-subtitle { margin-top: 20px; }
.draft-layout #invoice-documents, .draft-layout #draft-missing, .draft-layout #zoho-draft-status, .draft-layout #quickbooks-draft-status { grid-column: 1 / -1; }
.invoice-duplicate-note { grid-column: 1 / -1; margin: 8px 0 0; color: var(--warn); font-size: 12px; line-height: 1.4; }
#invoice-siblings { color: var(--muted); }
#invoice-siblings button.link { font-size: 12px; }
.accounting-customer { display: grid; gap: 4px; margin: 0 0 12px; font-size: 12px; font-weight: 600; }
.accounting-customer input { font-weight: 400; }
.draft-layout #invoice-documents { margin-top: 14px; }
#invoice-dialog.draft-layout #attach-document { width: auto; height: auto; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 12px; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width:480px) {
 .draft-layout .invoice-drawer-header { grid-template-columns: minmax(0, 1fr); }
 .draft-layout .invoice-header-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; padding-right: 0; margin-top: 12px; }
 .draft-layout .dialog-heading, .draft-layout .invoice-eyebrow { padding-right: 30px; }
}

/* Align header utilities and keep related attachment actions together. */
.draft-layout .drawer-close { top: 8px; right: 12px; }
.draft-layout .invoice-header-actions { padding-right: 34px; }
.draft-layout #invoice-documents { justify-content: flex-start; gap: 12px; }
.draft-layout #invoice-documents > ul { flex: 0 1 auto; max-width: 100%; }
.invoice-ready-banner { display: flex; gap: 10px; align-items: flex-start; margin: 16px 24px 0; padding: 12px 14px; border: 1px solid color-mix(in oklch, var(--primary) 25%, transparent); border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.invoice-ready-banner > span { font-size: 18px; line-height: 1.4; }
#invoice-dialog .invoice-ready-banner p { margin: 0; font-size: 13px; line-height: 1.5; }
.invoice-ready-banner strong { font-weight: 600; }
@media (max-width:480px) { .invoice-ready-banner { margin: 12px 16px 0; } }

.draft-layout .invoice-drawer-header > .invoice-ready-banner { grid-column: 1 / -1; margin: 16px 0 0; }

/* Shared document status banners: automation and fixable missing details. */
:root { --warn-soft: oklch(0.95 0.05 85); --warn: oklch(0.43 0.09 70); }
.invoice-ready-banner { padding: 12px 16px; gap: 12px; border: 0; border-radius: 8px; background: var(--primary-soft); }
.invoice-ready-banner > svg { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.invoice-ready-banner:not(.invoice-input-banner) > svg { width: 20px; height: 20px; }
#invoice-dialog .invoice-ready-banner p { font-size: 14px; line-height: 1.5; }
.invoice-input-banner { background: var(--warn-soft); color: var(--warn); }

.draft-layout #draft-missing ul { background: transparent; color: var(--muted-foreground, #68665f); border: 0; padding-top: 4px; padding-bottom: 0; }

.invoice-detail-tabs .invoice-tab-complete { color: var(--primary); font-weight: 600; }
.invoice-detail-tabs .invoice-tab-input { color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 1px 4px; font-weight: 600; }

#invoice-dialog .invoice-detail-tabs button.needs-input { color: var(--warn); }
#invoice-dialog .invoice-detail-tabs button.needs-input[aria-selected="true"] { border-bottom-color: var(--warn); }

/* Captured fields: aligned reading mode and compact missing-value tags. */
.draft-layout .form-grid { display: block; }
.draft-layout .captured-field { display: flex; gap: 16px; margin: 0; padding: 12px 0; border-top: 1px solid var(--line); }
.draft-layout .captured-field dt { width: 112px; flex-shrink: 0; color: var(--muted); font-size: 14px; font-weight: 400; }
.draft-layout .captured-field dd { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; flex: 1; min-width: 0; margin: 0; font-weight: 500; }
.captured-value { flex: 0 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.captured-empty { color: var(--muted); font-weight: 400; }
#invoice-dialog .captured-edit { padding: 0; width: 24px; height: 24px; background: transparent; border: 0; color: var(--muted); opacity: 0; flex-shrink: 0; }
.captured-field:hover .captured-edit, .captured-field:focus-within .captured-edit { opacity: 1 !important; }
.draft-layout .captured-field :is(input,select,textarea) { flex: 1; min-width: 100px; margin: 0; }
.draft-layout .captured-pending .captured-value { flex: 0 0 auto; color: var(--warn); font-weight: 500; background: var(--warn-soft); border: 1px solid color-mix(in oklch,var(--warn) 18%,transparent); border-radius: 999px; padding: 2px 9px; font-size: 12px; line-height: 20px; }
@media (hover:none) { #invoice-dialog .captured-edit { opacity: 1; } }

/* Value boxes open a single explicit Save/Cancel editor. */
#invoice-dialog .captured-target { display: flex; justify-content: flex-start; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; max-width: 100%; padding: 2px 6px; margin: -2px -6px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; font-size: 14px; font-weight: 500; }
#invoice-dialog .captured-target:hover, #invoice-dialog .captured-target:focus-visible { background: var(--background); }
.captured-pencil { color: var(--muted); opacity: 0; flex-shrink: 0; }
.captured-target:hover .captured-pencil, .captured-target:focus-visible .captured-pencil { opacity: 1; }
.captured-missing { display: none; }
#invoice-dialog .captured-field .captured-editor { flex: 1; width: 192px; min-width: 100px; max-width: 100%; margin: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--background); font-size: 14px; }
#invoice-dialog .captured-editor:focus { outline: none; border-color: var(--primary); }
#invoice-dialog [data-draft-calculated] .captured-target:disabled { opacity: 1; cursor: default; }
#invoice-dialog #draft-revenue-usd { padding: 2px 5px; font-size: 11px; }
#draft-gst-row select { min-width: 0; max-width: 100%; }
@media (pointer: coarse) { #draft-gst, #draft-revenue-usd { min-height: 44px; } }
#invoice-dialog #raise-next-invoice { flex: 0 0 auto; padding: 4px 5px; font-size: 11px; white-space: nowrap; }
#invoice-dialog .captured-field:has(#raise-next-invoice:not([hidden])) dd { flex-wrap: nowrap; align-items: center; }
@media (max-width: 480px) {
  #invoice-dialog .captured-field:has(#raise-next-invoice:not([hidden])) { gap: 4px; }
  #invoice-dialog .captured-field:has(#raise-next-invoice:not([hidden])) dt { width: 80px; font-size: 12px; }
  #invoice-dialog .captured-field:has(#raise-next-invoice:not([hidden])) dd { gap: 4px; }
  #invoice-dialog .captured-field:has(#raise-next-invoice:not([hidden])) .captured-target { gap: 4px; padding: 2px; }
  #invoice-dialog #raise-next-invoice { padding: 4px 3px; }
}
@media (pointer: coarse) { #raise-next-invoice { min-height: 44px; } }
#invoice-dialog .captured-save, #invoice-dialog .captured-cancel { padding: 4px 8px; border-radius: 8px; font-size: 14px; }
#invoice-dialog .captured-save { background: var(--primary); color: white; border-color: var(--primary); }
@media (hover:none) { .captured-pencil { opacity: 1; } }
/* Subscription lines in drafts: Users, Rate and Period; the other fields are behind More. */
.lines-compact:not(.lines-more) .line-extra { display: none; }
.lines-compact .component { margin: 10px 0; padding: 4px 12px 8px; }
.lines-compact .component .captured-field { padding: 9px 0; border-top: 0; }
.lines-compact .component .captured-field + .captured-field { border-top: 1px solid var(--line); }
.lines-compact .component > button { margin-top: 4px; }
#invoice-dialog .line-period .captured-editor { flex: 0 1 148px; min-width: 132px; }
.line-period.captured-editing .field-source-tag { display: none; }
.captured-dash { align-self: center; color: var(--muted); }
@media (max-width: 480px) {
  #invoice-dialog .line-period .captured-editor { flex: 1 1 100%; }
  .line-period .captured-dash { display: none; }
  .lines-compact .component .captured-field { flex-wrap: wrap; row-gap: 2px; }
  .lines-compact .component .captured-field .field-source-tag { margin-left: 128px; }
}
#lines-more { display: flex; margin-top: 12px; }
.lines-empty { margin: 0; color: var(--muted); }
.line-kind { display: inline-block; margin: 0 0 4px; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 500; }

#billing .register-toolbar { margin: 0; padding: 14px 20px; border-bottom: 1px solid var(--line); gap: 8px; }
#billing .register-toolbar :is(input,select,button) { height: 32px; border-radius: 8px; font-size: 14px; background: var(--background); }
#billing .register-toolbar .search { margin-left: 4px; }
#billing #row-count { display: none; }
#billing [data-export="invoices"] { margin-left: auto; }
#billing #register-filters:not([hidden]) { padding: 10px 20px; margin: 0; border-bottom: 1px solid var(--line); }
#billing :is(.table-help,.coverage,.table-more) { margin: 12px 20px; }
#billing .actions { justify-content: flex-end; }
#billing-table :is(th,td):last-child { padding-left: 0; padding-right: 12px; }
#billing .actions .row-open { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; padding: 0; color: var(--muted); }
#billing tr:is(:hover, :focus-visible) .row-open, #billing .row-open:focus-visible { color: var(--primary); }
@media (pointer: coarse) { #billing .actions .row-open { min-width: 44px; min-height: 44px; } }
#invoice-dialog.draft-layout #cancel-invoice { margin-top: 16px; }

#billing th:nth-child(4), #billing td:nth-child(4) { text-align: left; font-weight: 400; }
#billing :is(th,td):nth-child(n+12):nth-child(-n+15) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#billing .cell-description { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-width: 220px; max-width: 320px; white-space: normal; line-height: 1.5; color: var(--muted); }
body:has(#billing:not([hidden])) #refresh { display: none; }

body:has(#billing:not([hidden])) footer { display: none; }
body:has(#billing:not([hidden])) #workspace-toolbar :is(select,button) { min-height: 32px; border-radius: 8px; background-color: var(--background); font-size: 14px; }
#billing .table-help { display: none; }

#billing tbody td:last-child { background: inherit; }
#billing thead th:last-child { background: var(--draft-band); }
#billing thead button { text-transform: uppercase; letter-spacing: .6px; font-size: 12px; font-weight: 500; }

/* Shared register sizing: controls wrap, while column content stays inside its cell. */
:is(#drafts,#billing) { min-width: 0; max-width: 100%; }
:is(#drafts,#billing) .table-wrap { width: 100%; max-width: 100%; scrollbar-gutter: stable; }
#billing table { table-layout: fixed; min-width: 0; }
#billing-table :is(th,td) { min-width: 0; max-width: none; padding: 14px 12px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
#billing-table :is(th,td):first-child { padding-left: 20px; }
#billing-table :is(th,td):last-child { min-width: 0; position: static; box-shadow: none; }
#billing-table td:nth-child(2) strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
#billing .cell-description { min-width: 0; max-width: 100%; font-size: 14px; margin: 0; }
#billing .sourced-value { overflow: hidden; }
#billing .sourced-value small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#billing .column-head { display: flex; justify-content: space-between; max-width: 100%; gap: 6px; }
#billing .sort-button { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#billing .register-toolbar { align-items: center; gap: 12px; }
#billing .category-filter { margin: 0; gap: 8px; font-size: 12px; flex: 0 1 auto; min-width: 0; }
#billing .category-filter select { width: auto; max-width: 240px; min-width: 150px; margin: 0; padding: 0 28px 0 10px; }
#billing .register-toolbar .search { position: relative; padding: 0; border-radius: 8px; height: 32px; flex: 1 1 230px; max-width: 300px; margin: 0; background: var(--background); }
#billing .search svg { position: absolute; width: 14px; height: 14px; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
#billing .register-toolbar .search input { width: 100%; min-width: 0; height: 30px; padding: 0 12px 0 32px; font-size: 14px; background: transparent; }
#billing [data-export="invoices"] { flex-shrink: 0; }
#drafts table { table-layout: fixed; width: 100%; min-width: 1020px; font-size: 13px; }
#drafts th:nth-child(1) { width: 18%; } #drafts th:nth-child(2) { width: 7%; } #drafts th:nth-child(3) { width: 10%; } #drafts th:nth-child(4) { width: 12%; } #drafts th:nth-child(5) { width: 29%; } #drafts th:nth-child(6) { width: 14%; } #drafts th:nth-child(7) { width: 10%; }
#drafts td:first-child { min-width: 0; }
#drafts .draft-actions button, #drafts .draft-selects :is(input,select), #drafts #upload-documents { font-size: 13px; }
#drafts thead th, #drafts .badge { font-size: 11px; }
#drafts td { overflow: hidden; overflow-wrap: anywhere; vertical-align: middle; }
#drafts .draft-description { min-width: 0; max-width: 100%; }
.draft-layout .invoice-drawer-header > #invoice-paid-banner { grid-column: 1 / -1; margin: 16px 0 0; }
@media (max-width:650px) { #billing .category-filter { flex: 1 1 200px; } #billing .category-filter select { flex: 1; max-width: none; min-width: 0; } #billing .register-toolbar .search { max-width: none; } }

#billing .category-filter select { max-width: none; width: 220px; }
#billing #period { width: 300px; }
#billing .register-toolbar .search { flex: 0 1 256px; }
#billing .sort-button { flex: 0 1 auto; text-align: left; }
#billing .column-head { justify-content: flex-start; }
#billing .column-filter { flex-shrink: 0; }
#drafts .draft-selects select { max-width: none; min-width: 150px; }
#drafts .draft-search input { width: 256px; }

#drafts table { width: 100%; min-width: 1000px; }
#drafts th:nth-child(1) { width: 18%; } #drafts th:nth-child(2) { width: 7%; } #drafts th:nth-child(3) { width: 10%; } #drafts th:nth-child(4) { width: 12%; } #drafts th:nth-child(5) { width: 29%; } #drafts th:nth-child(6) { width: 14%; } #drafts th:nth-child(7) { width: 10%; }

/* Quiet KPI row: page-colour fill, one fact per card. */
body:has(#billing:not([hidden])) #stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 0 0 24px; }
#stats .summary-card { background: var(--background); border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-height: 82px; text-align: left; box-shadow: none; }
#stats .summary-card > span { display: block; min-width: 0; }
#stats .summary-card > span > span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
#stats .summary-card strong { display: block; font-size: 20px; font-weight: 600; letter-spacing: -.3px; font-variant-numeric: tabular-nums; color: inherit; margin-top: 4px; }
#stats .summary-card strong.kpi-positive { color: var(--primary); }
#stats .summary-card strong.kpi-attention { color: var(--warn); }
#stats .summary-card.selected { background: var(--background); border-color: var(--line); box-shadow: none; }
#stats .summary-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Alignment follows column meaning rather than its former position. */
#billing-table :is(th,td):nth-child(n) { text-align: left; }
#billing-table :is(th,td).num { text-align: right; font-variant-numeric: tabular-nums; }
#billing-table :is(th,td):last-child { text-align: right; }
@media (max-width:640px) { body:has(#billing:not([hidden])) #stats { grid-template-columns: repeat(2,minmax(0,1fr)); } }

#billing #invoice-coverage { display: none; }
#billing table { min-width: 1000px; }
#billing-table td:nth-child(5), #billing-table td:nth-child(6) { white-space: normal; }

#tabs { overflow-y: auto; }
.nav-section + .nav-section { margin-top: 20px; }
#tabs .nav-section-label { margin: 0 12px 8px; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .5px; text-transform: uppercase; }
@media (max-width:900px) { #tabs .nav-section { display: inline-flex; align-items: center; gap: 4px; margin: 0 12px 0 0; } #tabs .nav-section-label { margin: 0 4px; white-space: nowrap; } }

/* Same compact filter controls as Draft invoices. */
#billing .register-toolbar { padding: 14px 20px; gap: 8px; }
#billing .category-filter { font-size: 0; gap: 0; flex: 0 0 auto; }
#billing .category-filter select, #billing #period { width: 180px; min-width: 0; max-width: 100%; height: 32px; padding: 0 28px 0 8px; font-size: 14px; font-weight: 500; }
#billing #invoice-status-filter { width: 150px; }
#billing .register-toolbar .search { flex: 0 1 256px; max-width: 256px; }
#billing .column-filter-button { display: none; }
@media(max-width:600px) { #billing .register-toolbar .search { flex: 1 1 100%; max-width: none; } }

#billing .filter-button { display: none; }

/* Shared workspace design language: quiet surfaces, compact controls, readable data. */
:root { --surface-soft: color-mix(in oklch,var(--background) 65%,white); --header-soft: color-mix(in oklch,var(--background) 65%,oklch(0.93 0.012 100)); }
:is(#analytics,#reports,#commissions,#accounts,#settings,#ask) { min-width: 0; font-size: 14px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) .panel,
:is(#accounts,#settings).panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); box-shadow: none; padding: 20px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) .section-head { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
:is(#analytics,#reports,#commissions,#accounts,#settings) :is(h2,h3) { font-size: 14px; font-weight: 600; letter-spacing: -.2px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) .section-head p { font-size: 12px; line-height: 1.6; color: var(--muted); max-width: 70ch; }
:is(#analytics,#reports,#commissions,#accounts,#settings) .table-wrap { border-radius: 12px; background: var(--surface-soft); border-color: var(--line); max-width: 100%; }
:is(#analytics,#reports,#commissions,#accounts,#settings) table { font-size: 14px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) th { background: var(--header-soft); font-size: 12px; font-weight: 500; letter-spacing: .5px; text-transform: uppercase; padding: 10px 12px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) td { padding: 14px 12px; border-bottom-color: color-mix(in oklch,var(--line) 60%,transparent); line-height: 1.5; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
:is(#analytics,#reports,#commissions,#accounts,#settings) :is(th,td):first-child { padding-left: 20px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) :is(th,td):last-child { padding-right: 20px; }
:is(#analytics,#reports,#commissions,#accounts,#settings) tbody tr:hover { background: color-mix(in oklch,var(--primary-soft) 65%,var(--surface-soft)); }
:is(#analytics,#reports,#commissions,#accounts,#settings) .toolbar,
:is(#analytics,#reports,#commissions,#accounts,#settings) .register-toolbar { gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 0; margin: 0 0 12px; border-bottom: 1px solid var(--line); background: transparent; }
:is(#analytics,#reports,#commissions,#accounts,#settings) :is(.toolbar,.register-toolbar,.fy-controls) :is(input,select,button),
#workspace-toolbar :is(input,select,button) { min-height: 32px; border-radius: 8px; font-size: 14px; box-shadow: none; }
:is(#analytics,#reports,#commissions,#accounts,#settings) :is(input,select) { background: var(--background); }
:is(#analytics,#reports,#commissions,#accounts,#settings) .search { position: relative; height: 32px; width: 256px; max-width: 100%; padding: 0; border-radius: 8px; background: var(--background); }
:is(#analytics,#reports,#commissions,#accounts,#settings) .search svg { position: absolute; width: 14px; height: 14px; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
:is(#analytics,#reports,#commissions,#accounts,#settings) .search input { min-width: 0; width: 100%; height: 30px; padding: 0 12px 0 32px; margin: 0; }
:is(#analytics,#reports,#commissions,#accounts,#settings) .badge { border-radius: 999px; font-size: 12px; padding: 2px 10px; }
#analytics .overview-section-head { padding: 0 0 12px; margin-bottom: 16px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
#analytics .overview-section-head h2 { font-size: 16px; }
#analytics .chart-grid { gap: 16px; }
#analytics .chart-grid > .panel { background: white; }
#analytics .chart text { font-size: 12px; }
#analytics .chart text.value { font-size: 11px; }
#analytics .chart-note, #analytics .section-note { font-size: 12px; line-height: 1.6; }
#analytics .segmented { border-radius: 8px; background: var(--background); }
#analytics .segmented button { border-radius: 6px; font-size: 12px; }
#analytics .segmented button[aria-pressed=true] { box-shadow: none; background: var(--primary-soft); color: var(--primary); }
#recurring-summary { padding: 16px 20px; border-radius: 16px; background: var(--background); box-shadow: none; }
#recurring-summary h2 { font-size: 14px; }
.recurring-metrics { gap: 12px; }
.recurring-metrics > div { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--background); }
.recurring-metrics span { font-size: 12px; color: var(--muted); }
.recurring-metrics strong { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
#reports .report-disclosure { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 0; }
#reports .report-disclosure > summary { font-size: 14px; }
#settings .rate-form { background: transparent; border-radius: 12px; padding: 16px 0; }
#settings .rate-fields { gap: 12px; }
#settings .rate-fields label { font-size: 12px; color: var(--muted); }
#settings .rate-fields :is(input,select) { border-radius: 8px; min-width: 0; font-size: 14px; }
#ask { gap: 24px; }
#ask .chat-main { min-width: 0; }
#ask .chat-sidebar { border-radius: 16px; background: var(--surface-soft); box-shadow: none; }
#ask .chat-sidebar-head { padding: 16px; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
#ask .chat-sidebar-head h2 { font-size: 14px; font-weight: 600; }
#ask .chat-thread { border-radius: 8px; }
#ask .chat-thread span { font-size: 14px; }
#ask .chat-thread small { font-size: 12px; }
#ask .chat-welcome { padding: 40px 12px 24px; }
#ask .chat-welcome h2 { font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
#ask .chat-welcome p { font-size: 14px; color: var(--muted); }
#ask .chat-prompts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; max-width: 640px; margin: 24px auto 0; }
#ask .chat-prompts button { min-width: 0; padding: 14px 16px; border-radius: 12px; border-color: var(--line); background: var(--surface-soft); font-size: 14px; text-align: left; justify-content: flex-start; line-height: 1.5; }
#ask .chat-prompts button:hover { background: var(--primary-soft); }
#ask .chat-message { border-radius: 16px; padding: 16px 20px; font-size: 14px; line-height: 1.7; background: var(--surface-soft); box-shadow: none; }
#ask .chat-message > strong { font-size: 12px; }
#ask .chat-composer { border-radius: 16px; border: 1px solid var(--line); background: var(--surface-soft); box-shadow: none; padding: 12px 16px; }
#ask .chat-composer textarea { font-size: 14px; line-height: 1.6; background: transparent; }
#ask .chat-composer-bar { gap: 8px; flex-wrap: wrap; }
#ask .chat-composer :is(button,select) { min-height: 32px; border-radius: 8px; }
#ask :is(.chat-privacy,.chat-hint) { font-size: 12px; line-height: 1.6; }
body:has(:is(#analytics,#reports,#commissions,#accounts,#settings):not([hidden])) footer { display: none; }
@media(max-width:700px) { #ask .chat-prompts { grid-template-columns: 1fr; } :is(#analytics,#reports,#commissions,#accounts,#settings) .panel { padding: 16px; } }
/* Preserve readable columns instead of wrapping names or action labels mid-word. */
:is(#analytics,#reports,#commissions,#accounts,#settings) button { white-space: nowrap; }
#accounts table { min-width: 1800px; }
#accounts :is(th,td) { min-width: 160px; overflow-wrap: normal; }
#accounts :is(th,td):first-child { min-width: 120px; }
#accounts :is(th,td):nth-child(2) { min-width: 240px; }
#accounts :is(th,td):nth-child(3) { min-width: 200px; }
#accounts .sourced-value small { font-size: 12px; line-height: 1.5; }
#commissions :is(th,td) { min-width: 120px; overflow-wrap: normal; }
#commissions :is(th,td):first-child { min-width: 220px; }
#settings table { min-width: 1000px; }
#settings :is(th,td) { overflow-wrap: normal; }
#settings :is(th,td):last-child { min-width: 100px; }
#settings .actions { flex-wrap: wrap; gap: 8px; }
#recurring-summary { border: 0; border-left: 0; padding: 0; background: transparent; }
#workspace-toolbar :is(select,button) { background-color: var(--background); }
#ask .chat-prompts button { font-weight: 500; }

/* Focused chat composer with two lightweight suggestions. */
#ask #chat-setup { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in oklch,var(--warn) 16%,transparent); border-radius: 8px; padding: 12px 16px; font-size: 14px; line-height: 1.5; }
#ask .chat-main { width: 100%; max-width: 800px; margin: 0 auto; }
#ask .chat-main:has(#chat-welcome:not([hidden])) #chat-messages { flex: 0; }
#ask .chat-welcome { padding: 64px 12px 24px; }
#ask .chat-composer { position: static; margin-top: 12px; border-radius: 20px; padding: 16px; background: var(--surface-soft); }
#ask .chat-composer textarea { min-height: 68px; }
#ask .chat-prompts { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; max-width: 100%; margin: 12px 0 0; }
#ask .chat-prompts button { padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 400; background: transparent; line-height: 1.5; }
#ask #chat-new { background: transparent; color: var(--muted); border-color: var(--line); font-size: 12px; }
#ask .chat-hint { display: none; }
#ask .chat-effort { margin-left: auto; }
#ask .chat-privacy { text-align: center; max-width: 70ch; margin: 16px auto; font-size: 11px; }
@media(max-width:700px) { #ask .chat-welcome { padding-top: 32px; } }

#ask .chat-prompts button { background: var(--primary-soft); border-color: color-mix(in oklch,var(--primary) 25%,var(--line)); color: oklch(0.36 0.035 145); }
#ask .chat-prompts button:hover { background: color-mix(in oklch,var(--primary-soft) 80%,var(--primary)); }
#ask #chat-send { margin-left: auto; }

/* Successful draft upload choreography, scaled to the actual seven-column register. */
@keyframes upload-row-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes upload-agent-message { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes upload-field-roll { from { opacity: 0; transform: translateY(55%); filter: blur(2px); } to { opacity: 1; transform: translateY(0); filter: blur(0); } }
@keyframes upload-row-complete { from { background: color-mix(in oklch,var(--primary) 9%,transparent); } to { background: transparent; } }
@keyframes upload-agent-spin { to { transform: rotate(360deg); } }
#drafts .upload-working-row { animation: upload-row-enter 420ms ease-out both; background: color-mix(in oklch,var(--primary) 5%,transparent); pointer-events: none; }
.upload-agent-message { display: flex; align-items: center; gap: 8px; color: var(--primary); font-size: 12px; font-weight: 500; animation: upload-agent-message 480ms ease-out both; }
.upload-agent-spinner { width: 14px; height: 14px; flex-shrink: 0; border: 2px solid color-mix(in oklch,var(--primary) 25%,transparent); border-top-color: var(--primary); border-radius: 50%; animation: upload-agent-spin 800ms linear infinite; }
.upload-field-ghost { display: block; width: 75%; height: 10px; border-radius: 999px; background: color-mix(in oklch,var(--primary) 16%,transparent); }
.upload-field-roll { animation: upload-field-roll 520ms cubic-bezier(0.16,1,0.3,1) both; }
#drafts .upload-complete-row { animation: upload-row-complete 900ms ease-out both; }
@media(prefers-reduced-motion:reduce) { .upload-working-row,.upload-agent-message,.upload-agent-spinner,.upload-field-roll,.upload-complete-row { animation: none !important; } }

.draft-layout #invoice-top-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 20px; margin-top: 16px; }
.draft-layout #invoice-top-fields .captured-field { gap: 8px; padding: 8px 0; }
.draft-layout #invoice-top-fields .captured-field dt { width: 104px; font-size: 12px; }
#invoice-dialog #invoice-top-fields .captured-target { font-size: 12px; }
.draft-layout .invoice-detail-tabs { flex-wrap: wrap; padding-top: 4px; }
#invoice-dialog .invoice-detail-tabs button { padding: 10px 8px; font-size: 12px; }
@media(max-width:480px) { .draft-layout #invoice-top-fields { grid-template-columns: 1fr; } }

.draft-layout .invoice-detail-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
#invoice-dialog .invoice-detail-tabs button { flex-shrink: 0; }

#billing #summary-month { width: 130px; }
#billing #summary-year { width: 90px; }
#billing #period { width: 155px; }
#billing .register-toolbar .search { flex: 1 1 220px; max-width: 256px; }
#invoice-dialog.draft-layout .invoice-header-actions #cancel-invoice { margin: 0; color: var(--danger); border-color: color-mix(in oklch,var(--danger) 30%,var(--line)); background: transparent; }
/* Save invoice sits at the bottom of every tab and is shown only once the invoice has been edited. */
.invoice-footer { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; padding: 12px 24px; background: var(--background); border-top: 1px solid var(--line); }
@media (max-width: 480px) { .invoice-footer { padding: 12px 16px; } }
/* A saved invoice's documents use the draft's strip at the top; each file has a small remove button */
.invoice-documents li { display: inline-flex; align-items: center; gap: 2px; }
.document-remove { border: 0; background: transparent; color: var(--muted); padding: 0 5px; font-size: 16px; line-height: 1; cursor: pointer; }
.document-remove:hover, .document-remove:focus-visible { color: var(--danger); }
#invoice-documents-status { grid-column: 1 / -1; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
#invoice-documents-status.error { color: var(--danger); background: #fcf0eb; padding: 10px 12px; border-radius: 6px; }

/* Invoice identity strip: tag, amount and compact billing text rather than a field table. */
.draft-layout #invoice-top-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.draft-layout #invoice-top-fields .captured-field { display: flex; padding: 0; margin: 0; border: 0; gap: 0; }
.draft-layout #invoice-top-fields .captured-field dt { display: none; }
.draft-layout #invoice-top-fields .captured-field dd { align-items: center; }
#invoice-dialog #invoice-top-fields .captured-target { font-size: 14px; margin: 0; padding: 2px 0; }
#invoice-top-fields [data-header-field="status"] { order: 0; }
#invoice-top-fields [data-header-field="instalment_amount"] { order: 1; flex-basis: calc(100% - 110px); }
#invoice-dialog #invoice-top-fields [data-header-field="instalment_amount"] .captured-target { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
#invoice-top-fields [data-header-field="invoice_type"] { order: 2; }
#invoice-top-fields [data-header-field="payment_type"] { order: 3; }
#invoice-top-fields [data-header-field="payment_type"]::before { content: '|'; color: var(--muted); margin-right: 12px; }
#invoice-dialog #invoice-top-fields .invoice-status-tag { display: inline-flex; align-items: center; padding: 2px 10px; border: 1px solid var(--line); background: var(--primary-soft); color: var(--primary); border-radius: 999px; font-size: 12px; font-weight: 500; }
#invoice-top-fields [data-header-field="instalment_amount"] { align-items: baseline; gap: 8px; }
.draft-layout #invoice-top-fields [data-header-field="instalment_amount"] dt { display: block; width: auto; color: var(--muted); font-size: 12px; }

/* One headline amount, then status and the invoice type/payment sequence. */
.draft-layout #invoice-subtitle { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; }
.draft-layout #invoice-subtitle .captured-field { border: 0; padding: 0; margin: 0; }
.draft-layout #invoice-subtitle .captured-field dt { display: none; }
#invoice-dialog #invoice-subtitle .captured-target { padding: 0; margin: 0; background: transparent; font-size: 32px; font-weight: 600; line-height: 1.2; }
#invoice-subtitle .captured-pencil { font-size: 14px; }
.draft-layout #invoice-top-fields { margin-top: 12px; gap: 8px; }
#invoice-top-fields [data-header-field="status"] { flex-basis: 100%; }
#invoice-top-fields [data-header-field="invoice_type"] { order: 1; }
#invoice-top-fields [data-header-field="payment_type"] { order: 2; }
.draft-layout #invoice-documents { margin-top: 16px; }
#invoice-dialog.draft-layout #invoice-subtitle .captured-value { font-size: 32px; font-weight: 600; line-height: 1.2; }
#invoice-dialog.draft-layout #invoice-subtitle .invoice-hero-meta { font-size: 14px; font-weight: 400; }

/* Currency → amount → status, with a single evenly spaced billing line. */
#invoice-dialog.draft-layout #invoice-subtitle { align-items: center; gap: 10px; }
#invoice-dialog.draft-layout #invoice-subtitle .invoice-hero-meta { order: 0; }
#invoice-subtitle [data-header-field="instalment_amount"] { order: 1; flex: 0 1 auto; }
#invoice-subtitle [data-header-field="status"] { order: 2; margin-left: 6px; }
#invoice-dialog #invoice-subtitle .invoice-status-tag { display: inline-flex; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 500; line-height: 18px; }
#invoice-dialog.draft-layout #invoice-subtitle [data-header-field="status"] .captured-value { font-size: 12px; font-weight: 500; line-height: 18px; }
.draft-layout #invoice-top-fields { gap: 8px; align-items: center; margin-top: 12px; }
.invoice-billing-label { order: 0; color: var(--muted); font-size: 14px; margin-right: 2px; }
#invoice-top-fields [data-header-field="payment_type"]::before { margin: 0 8px 0 0; }
#invoice-top-fields [data-header-field="payment_type"] { align-items: center; }
#invoice-dialog.draft-layout .drawer-close { top: 24px; right: 12px; width: 24px; height: 32px; font-size: 18px; line-height: 1; }
@media(max-width:480px) { #invoice-dialog.draft-layout .drawer-close { top: 20px; } }
#invoice-dialog :is(#invoice-subtitle,#invoice-top-fields) .captured-target { position: relative; }
#invoice-dialog :is(#invoice-subtitle,#invoice-top-fields) .captured-pencil { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 4px; font-size: 12px; }
#invoice-top-fields [data-header-field="payment_type"]::before { margin-right: 8px; }

.draft-layout #invoice-review-status { grid-column: 1; justify-self: start; display: inline-flex; margin-top: 8px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; line-height: 18px; font-weight: 500; }
.draft-save-status { margin-left: 8px; font-size: 12px; line-height: 18px; color: var(--muted); }
.draft-save-status.failed { color: var(--danger); }
.draft-layout #invoice-review-status.pending { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in oklch,var(--warn) 20%,var(--line)); }
.draft-layout #invoice-subtitle { margin-top: 16px; }

.draft-upload-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
#drafts .draft-upload-actions button { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 14px; }
#drafts .draft-upload-actions #upload-documents { margin-left: 0; }

#invoice-dialog #invoice-hero-total { font-size: 32px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.draft-layout #received-fields .instalment-total-field { margin-bottom: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
#invoice-dialog .instalment-total-field .captured-target:disabled { opacity: 1; cursor: default; }

.draft-layout .invoice-drawer-header > #invoice-payment-pending-banner { grid-column: 1 / -1; margin: 16px 0 0; }

#invoice-dialog .invoice-header-actions { position: relative; }
#raise-missing-hint { position: absolute; right: 34px; top: calc(100% + 6px); width: max-content; max-width: 200px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--background); color: var(--muted); font-size: 11px; line-height: 1.4; font-weight: 400; z-index: 2; }

#billing #summary-entity { width: 145px; }

#billing #summary-month { width: 170px; }
.invoice-validation-notes { margin: 12px 0; padding: 8px 12px 8px 28px; color: var(--warn); background: var(--warn-soft); border-radius: 6px; font-size: 12px; line-height: 1.5; }

#drafts .draft-description-more { padding: 0; margin-top: 3px; font-size: 12px; line-height: 1.4; color: var(--primary); text-decoration: underline; }

/* Provenance belongs beside the value and remains a single quiet line. */
.field-source-tag { flex: 0 0 auto; align-self: center; white-space: nowrap; font-size: 11px; line-height: 1.4; padding: 3px 7px; border-radius: 5px; color: var(--muted); background: color-mix(in srgb, currentColor 7%, transparent); }
.field-source-tag.source-pending { color: var(--warn, #865b20); background: var(--warn-soft, #f5ecd9); }
.captured-with-source.captured-pending .captured-value { background: transparent; border: 0; padding: 0; color: var(--muted); }
.captured-with-source > dd { min-width: 0; }

.field-source-tag.source-automatic { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

.field-source-tag.source-manual { color: #426d95; background: #edf4fb; }

.field-source-tag.source-optional { color: #79638f; background: #f3eef8; }
