/* DOCflow processing desk. Presentation only; workflow and access remain in JS. */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.desk-shortcuts { display:block; margin-top:7px; font-size:10px; }
.summary-currency { display:inline-flex; align-items:baseline; gap:7px; }
.summary-currency small { color:var(--muted); font-size:10px; }
.due-note.soon { color:var(--amber); }
:root {
  --desk-surface: color-mix(in srgb, var(--bg) 48%, var(--paper));
  --desk-hover: color-mix(in srgb, var(--soft) 24%, var(--paper));
  --desk-border: color-mix(in srgb, var(--line) 80%, var(--paper));
  --desk-shadow: 0 1px 2px #261b1603, 0 12px 32px #261b1604;
}
[data-theme="dark"] {
  --desk-surface: color-mix(in srgb, var(--bg) 42%, var(--paper));
  --desk-hover: color-mix(in srgb, var(--soft) 38%, var(--paper));
  --desk-border: var(--line);
  --desk-shadow: 0 1px 2px #0000000a, 0 12px 32px #00000010;
}

/* A quieter frame leaves the invoice list as the primary working surface. */
#listing .title-row { align-items: center; gap: 20px; margin-bottom: 24px; }
#listing .title-row h1 { font-weight: 660; letter-spacing: -.045em; }
#deskIntro { max-width: 650px; margin: 0; line-height: 1.7; }
#listUpdated { display: block; min-height: 18px; margin-top: 8px; font-size: 10px; line-height: 1.6; color: var(--muted); font-variant-numeric: tabular-nums; }
#refresh { min-width: 44px; min-height: 44px; flex-shrink: 0; }
#refresh:hover:not(:disabled) .df-icon { transform: rotate(30deg); }
#refresh .df-icon { transition: transform .25s ease; }
.stats { gap: 12px; margin-bottom: 22px; }
.stat { border-color: var(--desk-border); box-shadow: var(--desk-shadow); padding: 18px 20px; }
.stat .stat-arrow { transition: transform .2s ease, opacity .2s ease; }
.stat:hover .stat-arrow { transform: translateX(3px); opacity: .85; }
.stat:focus-visible { outline-offset: 4px; }
.stat strong { margin-top: 14px; }
.list-card { position: relative; border-color: var(--desk-border); box-shadow: var(--desk-shadow); border-radius: 20px; isolation: isolate; }

/* Quick lenses are separate from the detailed search and accounting filters. */
.desk-focus { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 15px 20px; border-bottom: 1px solid var(--line); background: var(--desk-surface); }
.desk-focus button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 14px; border-color: transparent; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 500; line-height: 1.45; }
.desk-focus button:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.desk-focus button[aria-pressed="true"] { background: var(--paper); border-color: var(--desk-border); color: var(--accent); box-shadow: 0 2px 4px #241a1805; font-weight: 650; }
.desk-focus button .df-icon { width: 16px; height: 16px; }
.desk-focus button small, .desk-focus button .focus-count { padding: 1px 6px; border-radius: 5px; color: inherit; background: var(--bg); font-size: 10px; font-variant-numeric: tabular-nums; }
.desk-focus button[aria-pressed="true"] :is(small, .focus-count) { background: var(--soft); }
.list-card .toolbar { padding: 18px 20px 12px; gap: 12px; }
.list-card .search { border: 1px solid var(--desk-border); background: var(--desk-surface); min-height: 46px; }
.list-card .search:focus-within { background: var(--paper); outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 1px; }
.list-card .search input { min-height: 44px; font-size: 13px; }
.list-card #accounting { background-color: var(--paper); font-size: 12px; }
.list-card .toolbar .overdue { font-size: 11px; }
#export { min-height: 44px; background: var(--paper); }

.desk-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 20px 15px; }
.desk-tools > * { min-width: 0; }
.desk-sort { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.desk-sort > span { flex-shrink: 0; }
.desk-sort select { min-height: 44px; width: auto; max-width: 100%; border-color: transparent; background-color: transparent; font-size: 12px; padding-left: 8px; padding-right: 34px; background-position: right 9px center; color: var(--ink); }
.desk-sort select:hover { background-color: var(--desk-surface); border-color: var(--line); }
#toggleFilters { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 8px 12px; border-color: transparent; color: var(--muted); background: transparent; font-size: 11px; }
#toggleFilters .df-icon { width: 16px; height: 16px; }
#toggleFilters:hover, #toggleFilters[aria-expanded="true"] { color: var(--accent); background: var(--soft); }

.desk-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 14px; padding: 17px 20px 20px; border-top: 1px solid var(--line); background: var(--desk-surface); animation: desk-reveal .18s ease-out; }
.desk-filters > label { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.desk-filters input, .desk-filters select { width: 100%; max-width: 100%; min-width: 0; min-height: 44px; background-color: var(--paper); font-size: 13px; color: var(--ink); }
.desk-filters input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
.desk-filters input::-webkit-date-and-time-value { text-align: left; min-height: 1.45em; }
#resetFilters { min-height: 44px; font-size: 11px; white-space: normal; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 15px; }
.filter-chips:empty { display: none; }
.filter-chips button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 8px 11px; border-radius: 9px; border-color: color-mix(in srgb, var(--accent) 18%, var(--line)); background: color-mix(in srgb, var(--soft) 55%, var(--paper)); color: var(--accent); font-size: 11px; text-align: left; overflow-wrap: anywhere; }
.filter-chips button:hover { background: var(--soft); border-color: var(--accent); }
.filter-chips button .df-icon { width: 13px; height: 13px; }

.list-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px 18px; padding: 13px 20px; background: var(--desk-surface); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; }
.list-summary:empty { display: none; }
.list-summary > :is(div, span) { min-width: 0; overflow-wrap: anywhere; }
.list-summary strong { color: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.list-summary .currency-totals { display: flex; flex-wrap: wrap; gap: 8px 15px; }
.list-summary .currency-totals > span { white-space: nowrap; }
.list-progress { display: flex; align-items: center; gap: 9px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--desk-surface); color: var(--muted); font-size: 11px; line-height: 1.6; }
.list-progress:before { content: ''; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: desk-pulse 1.3s ease-in-out infinite; }
.list-progress:empty { display: none; }
#results { transition: opacity .18s ease; }
#results[aria-busy="true"] { opacity: .66; transition-delay: .18s; }

/* Keep native table semantics on wide layouts, with generous document targets. */
.list-card th { padding: 0 16px; height: 47px; font-size: 10px; font-weight: 550; background: var(--desk-surface); }
.list-card th button[data-sort] { display: inline-flex; align-items: center; justify-content: flex-start; gap: 7px; width: 100%; min-width: 0; min-height: 44px; padding: 8px 0; border: 0; border-radius: 0; background: transparent; font-size: 10px; font-weight: 550; color: var(--muted); text-align: left; white-space: normal; }
.list-card th button[data-sort]:hover { background: transparent; color: var(--ink); }
.list-card th button[data-sort]:focus-visible { outline-offset: -2px; border-radius: 6px; }
.list-card th[aria-sort="ascending"] button, .list-card th[aria-sort="descending"] button { color: var(--accent); font-weight: 650; }
.list-card th button[data-sort] .df-icon { width: 13px; height: 13px; }
.list-card th.amount button { justify-content: flex-end; text-align: right; }
.list-card tbody tr { animation: desk-row-in .2s ease-out both; transition: background .16s ease; }
.list-card tbody tr:nth-child(2) { animation-delay: 12ms; }
.list-card tbody tr:nth-child(3) { animation-delay: 24ms; }
.list-card tbody tr:nth-child(4) { animation-delay: 36ms; }
.list-card tbody tr:nth-child(5) { animation-delay: 48ms; }
.list-card tbody tr:nth-child(6) { animation-delay: 60ms; }
.list-card tbody tr:hover, .list-card tbody tr:focus-within { background: var(--desk-hover); }
.list-card td { padding: 19px 16px; }
.list-card .doc-open { min-height: 48px; gap: 11px; }
.list-card .doc-open:focus-visible { outline-offset: 5px; border-radius: 4px; }
.list-card .doc-icon { border: 1px solid color-mix(in srgb, var(--accent) 8%, var(--line)); background: color-mix(in srgb, var(--soft) 45%, var(--paper)); transition: border-color .18s, background .18s; }
.list-card .doc-open:hover .doc-icon { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--soft); }
.list-card .row-title { font-size: 12px; line-height: 1.5; font-weight: 600; }
.row-secondary { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.row-secondary .pill { margin: 2px 4px 2px 0; font-size: 9px; }
.due-note { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.late .due-note, .due-note.late { color: var(--accent); }
.list-card td.amount { font-size: 12px; font-weight: 550; }
.list-card td.amount small { font-weight: 400; }
.list-card .pagination { border-top: 1px solid var(--line); padding: 16px 20px; }
.pagination button { border-radius: 10px; }
.empty-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 9px; margin-top: 20px; }
.empty .empty-actions button { margin: 0; min-height: 44px; font-size: 12px; }

/* Document navigation stays outside the scrolling data and preview areas. */
#detail .detail-head { gap: 16px; }
.detail-controls { display: flex; align-items: center; gap: 13px; flex-shrink: 0; }
.doc-navigation { display: flex; align-items: center; gap: 5px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--desk-surface); }
.doc-navigation button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 17px; }
.doc-navigation button .df-icon { width: 17px; height: 17px; }
.doc-navigation button:hover:not(:disabled) { color: var(--accent); background: var(--paper); }
.doc-navigation button:disabled { opacity: .3; }
#documentPosition { min-width: 47px; padding: 0 4px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
#closeDetail { border-color: var(--line); background: var(--paper); }
#closeDetail:hover { background: var(--desk-surface); border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.detail-summary { display: grid; grid-template-columns: 1.2fr repeat(2, minmax(0, 1fr)); gap: 14px; margin: 2px 0 19px; padding: 15px; border: 1px solid var(--desk-border); border-radius: 14px; background: var(--desk-surface); }
.detail-summary:empty { display: none; }
.detail-summary:has(> :nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-summary > * { display: flex; flex-direction: column; min-width: 0; gap: 5px; margin: 0; }
.detail-summary :is(span, dt) { font-size: 10px; line-height: 1.5; color: var(--muted); }
.detail-summary :is(strong, dd) { margin: 0; font-size: 12px; line-height: 1.55; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.detail-summary > :first-child strong { font-size: 17px; line-height: 1.35; letter-spacing: -.025em; }
.detail-summary .late, .detail-summary .late strong { color: var(--accent); }
.detail-jump { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 5px; padding-bottom: 13px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-jump button { min-height: 44px; padding: 8px 12px; border-color: transparent; background: transparent; color: var(--muted); font-size: 11px; font-weight: 500; }
.detail-jump button:hover, .detail-jump button[aria-current="true"], .detail-jump button[aria-pressed="true"] { color: var(--accent); background: var(--soft); }
#detail .data-pane { scroll-padding-top: 18px; }
#detail :is(.field, .history, #fields h3) { scroll-margin-top: 18px; }
#docState .pill { font-size: 10px; padding: 5px 9px; }
#editForm > .save-row { gap: 12px; box-shadow: 0 -10px 15px -15px #0000003b; }
#dirty { color: var(--amber); font-size: 11px; line-height: 1.6; }
#detail .extraction-actions button { min-height: 44px; font-size: 11px; }
#detail.is-working .detail-controls button:disabled { opacity: .45; }

@container (max-width: 1050px) {
  .list-card .toolbar { grid-template-columns: minmax(0, 1fr) auto auto; }
  .list-card .toolbar .search { grid-column: 1 / -1; }
}
@container (max-width: 760px) {
  .desk-focus { gap: 6px; padding: 13px 15px; }
  .desk-focus button { flex: 1 1 calc(50% - 6px); padding-inline: 9px; font-size: 11px; }
  .list-card .toolbar { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 15px 15px 9px; }
  .list-card .toolbar .search, .list-card .toolbar #accounting { grid-column: 1 / -1; }
  .desk-tools { padding: 0 15px 12px; gap: 5px; }
  .desk-sort { gap: 4px; flex: 1 1 170px; }
  .desk-sort select { width: 100%; max-width: 230px; }
  #toggleFilters { padding-inline: 8px; }
  .desk-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px 15px 16px; }
  .desk-filters #resetFilters { grid-column: 1 / -1; justify-self: start; }
  .filter-chips { padding: 0 15px 14px; }
  .list-summary, .list-progress { padding-inline: 15px; }
  .list-card .table-wrap { overflow: visible; }
  .list-card table, .list-card tbody, .list-card tr, .list-card td { display: block; min-width: 0; }
  .list-card thead { display: none; }
  .list-card tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; padding: 18px 16px; border-top: 1px solid var(--line); }
  .list-card td { min-width: 0; border: 0; padding: 0; }
  .list-card td:first-child, .list-card td:nth-child(2) { grid-column: 1 / -1; }
  .list-card td:nth-child(2) { display: block; color: var(--muted); font-size: 11px; }
  .list-card td:nth-child(3) { align-self: center; font-size: 11px; }
  .list-card td:nth-child(2) small { display: block; margin-top: 4px; }
  .list-card td.amount { text-align: right; }
  .list-card .doc-open { max-width: 100%; min-height: 48px; }
  .list-card .row-title, .list-card .doc-open small { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .list-card .doc-open small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .list-card .row-secondary { font-size: 10px; line-height: 1.6; }
  .list-card .pagination { padding: 14px 15px; }
}
@container (max-width: 390px) {
  .desk-filters { grid-template-columns: minmax(0, 1fr); }
  .desk-sort { flex-basis: 100%; }
  .desk-sort select { max-width: none; }
  #toggleFilters { width: 100%; justify-content: flex-start; }
  .list-summary { align-items: flex-start; }
  .list-summary .currency-totals { flex-basis: 100%; }
}
@container (max-width: 440px) {
  .detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; padding: 13px; }
  .detail-summary > :first-child { grid-column: 1 / -1; }
  .detail-summary:has(> :nth-child(4)) > :first-child { grid-column: auto; }
}
@media (max-width: 1000px) {
  #detail .detail-head { padding: 12px 18px; }
  .detail-controls { gap: 9px; }
  .detail-head h2 { font-size: 16px; }
  .detail-summary { margin-bottom: 16px; }
}
@media (max-width: 760px) {
  #listing .title-row { align-items: flex-start; gap: 12px; margin-bottom: 21px; }
  #listing .title-row h1 { font-size: 27px; line-height: 1.2; margin-block: 10px 9px; }
  #deskIntro { font-size: 12px; max-width: none; }
  #listUpdated { font-size: 10px; margin-top: 7px; }
  #refresh { margin-top: 16px; }
  .stats { gap: 10px; margin-bottom: 18px; }
  .stat { padding: 16px; }
  .stat strong { font-size: 28px; }
  .list-card { border-radius: 17px; }
  .list-card .search input, .list-card #accounting, .desk-sort select, .desk-filters input, .desk-filters select { font-size: 16px; }
  .desk-sort select { padding-left: 6px; }
  .desk-sort > span { font-size: 10px; }
  .empty { padding: 38px 20px; }
  .empty-actions { align-items: stretch; }
  .empty-actions button { flex: 1 1 150px; }
  #detail .detail-head { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; gap: 10px; }
  .doc-navigation { gap: 0; padding: 2px; }
  .detail-controls { gap: 8px; }
  #documentPosition { min-width: 40px; font-size: 10px; }
  .detail-jump { gap: 4px; padding-bottom: 11px; }
  .detail-jump button { flex: 1 1 auto; padding-inline: 9px; }
}
@media (max-width: 600px) {
  #detail .detail-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding-bottom: 10px; }
  #detail .detail-identity { min-width: 0; }
  #detail .detail-identity h2 { -webkit-line-clamp: 1; line-height: 1.5; }
  #detail .detail-identity > .brand-mark { width: 19px; height: 24px; }
  #detail .detail-controls { justify-content: space-between; width: 100%; }
  #detail .doc-navigation { background: transparent; border-color: transparent; padding: 0; gap: 3px; }
  #detail .doc-navigation button { background: var(--desk-surface); border: 1px solid var(--line); }
  #detail #documentPosition { min-width: 51px; }
  .detail-summary > :first-child strong { font-size: 18px; }
}
@media (max-height: 650px) {
  #detail .detail-head { display: flex; flex-wrap: nowrap; padding-block: 8px; gap: 10px; }
  #detail .detail-controls { width: auto; gap: 7px; }
  #detail .detail-identity > .brand-mark { display: none; }
  #detail .detail-head h2 { font-size: 13px; -webkit-line-clamp: 1; }
  #detail .detail-head .eyebrow { font-size: 8px; }
  #detail .doc-navigation { border: 0; background: transparent; padding: 0; gap: 0; }
  #detail #documentPosition { min-width: 35px; font-size: 9px; }
  #detail .detail-summary { padding: 11px; gap: 10px; }
}
@keyframes desk-reveal { from { opacity: .55; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes desk-row-in { from { opacity: .65; } to { opacity: 1; } }
@keyframes desk-pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .desk-focus button[aria-pressed="true"], #toggleFilters[aria-expanded="true"], .detail-jump button[aria-current="true"] { outline: 2px solid Highlight; }
  .list-progress:before { background: CanvasText; }
  .desk-sort select { -webkit-appearance: auto; appearance: auto; background-image: none; padding-right: 10px; }
}

.desk-filters > p { grid-column:1 / -1; margin:0; font-size:10px; }
