/* Reset and base */
*, *::before, *::after { box-sizing: border-box; }

:root {
  /* Sized to the longest nav label ("Document Management" needs ~208px:
     padding + icon + gap + text) plus a little slack, so the sidebar takes
     only what it needs and leaves more room for content. */
  --sidebar-width: 220px;

  /* Cross-organization security signal. Deliberately stronger than
     --warning (#9a6700): this is a boundary warning, not a field-level one.
     Dark ink on this fill measures 5.62:1, clearing WCAG AA for small text. */
  --elevated-signal: #bf8700;

  /* Height the elevated-context banner adds above the app shell. Zero unless
     body.elevated-context overrides it, so every consumer can subtract it
     unconditionally instead of hardcoding a magic number. */
  --elevated-chrome: 0px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-canvas);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex: 1;
  min-height: 0; /* Allow flex children to shrink below content size */
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  transition: width 0.2s ease, transform 0.2s ease;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 6px rgba(28, 24, 19, 0.05), 1px 0 2px rgba(28, 24, 19, 0.04);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding-bottom: 28px; /* Reserve exactly the fixed footer's height (see .app-footer) so the sidebar-user block's own 12px padding reads symmetric top/bottom */
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
}
.logo {
  display: flex;
  align-items: center;
  padding: 0 18px;
  min-height: 51px;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  transition: padding 0.2s ease;
  overflow: hidden;
}
.logo img {
  /* Sized by .logo-full / .logo-icon rules */
}
.nav-items {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
}
.nav-items li a,
.nav-items li > span {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  color: var(--fg);
  text-decoration: none;
  transition: background 0.15s, padding 0.2s ease, gap 0.2s ease;
}
.nav-items li a iconify-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  font-size: 20px;
}
.nav-items li a:hover {
  background: var(--brand-tint-hover);
  text-decoration: none;
}
.nav-items li.active a {
  background: var(--brand-tint);
  border-left: 2px solid var(--brand);
  padding-left: 16px;
  color: var(--brand-pressed);
}
.nav-items li.active a iconify-icon {
  color: var(--brand-pressed);
}
.nav-items li.disabled span {
  color: var(--fg-subtle);
  cursor: not-allowed;
}
.nav-items li.disabled span::after {
  content: 'Coming soon';
  font-size: 10px;
  background: var(--border);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  margin-left: auto;
}

/* Keyboard shortcut hints — revealed while Command (or Control) is held, see
   js/sidebar-shortcuts.js.

   The digit is a pseudo-element inside the icon's OWN box and the glyph
   underneath only fades, so revealing it adds nothing to the flex row. That's
   what lets one rule serve the 300px expanded sidebar, the 60px icon rail and
   the detail-page rail alike — none of them shift by a pixel when the numbers
   appear. `color: inherit` carries the active row's brand tint onto its
   number for free. */
.nav-items li a iconify-icon[data-nav-key] { position: relative; }
.nav-items li a iconify-icon[data-nav-key]::after {
  content: attr(data-nav-key);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 13px/1 var(--font-mono);
  color: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.nav-items li a iconify-icon[data-nav-key] svg { transition: opacity 0.12s ease; }

/* Appearing is instant. The numbers answer a key that is already down, so any
   ramp on the way in reads as the sidebar lagging behind the keyboard; the
   transitions above are left to run only on the way back to icons. */
body.nav-shortcut-hints .nav-items li a iconify-icon[data-nav-key]::after,
body.nav-shortcut-hints .nav-items li a iconify-icon[data-nav-key] svg { transition: none; }
body.nav-shortcut-hints .nav-items li a iconify-icon[data-nav-key] svg { opacity: 0; }
body.nav-shortcut-hints .nav-items li a iconify-icon[data-nav-key]::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .nav-items li a iconify-icon[data-nav-key]::after,
  .nav-items li a iconify-icon[data-nav-key] svg { transition: none; }
}

/* Sidebar user section */
.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  transition: padding 0.2s ease;
}
.user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--r-lg);
  transition: background 0.15s, padding 0.2s ease;
}
.user-trigger:hover {
  background: var(--bg-muted);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.user-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}
.user-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-size: 14px;
}
.user-chevron {
  color: var(--fg-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.sidebar-user.expanded .user-chevron {
  transform: rotate(180deg);
}
.user-menu {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.15s ease-out, opacity 0.15s ease-out, padding 0.15s ease-out;
  padding-top: 0;
}
.sidebar-user.expanded .user-menu {
  max-height: 200px;
  opacity: 1;
  padding-top: 8px;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  border-radius: var(--r-lg);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  transition: background 0.15s;
}
.user-menu-item:hover {
  background: var(--bg-muted);
}

/* Tenant switcher (super admin) */
.tenant-switcher {
  padding: 0 0 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.tenant-switcher form { margin: 0; }
.tenant-select {
  width: 100%;
  height: 32px;
  padding: 0 32px 0 10px;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font: var(--text-sm);
  text-overflow: ellipsis;
  cursor: pointer;
}
.tenant-select:hover {
  border-color: var(--brand);
}
.tenant-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 109, 189, 0.15);
}

/* Super admin warning banner */
/* Cross-organization elevated context.
   The banner is a sibling of .app-container, not a child of main.content, so an
   HTMX swap of the content region cannot leave it and the border disagreeing. */
body.elevated-context {
  --elevated-chrome: 44px;
  padding-top: var(--elevated-chrome);
}

.elevated-context-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--elevated-chrome);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: rgba(191, 135, 0, 0.15);
  border-bottom: 1px solid rgba(191, 135, 0, 0.4);
  color: var(--warning);
  font-size: 14px;
  /* Must outrank the fixed .sidebar (200) and .app-footer (201). */
  z-index: 300;
}
.elevated-context-banner iconify-icon {
  font-size: 18px;
}
.elevated-context-banner strong {
  color: var(--warning);
}
body.elevated-context .sidebar {
  top: var(--elevated-chrome);
  height: calc(100vh - var(--elevated-chrome));
  border-left: 6px solid var(--elevated-signal);
  border-top: 6px solid var(--elevated-signal);
}
body.elevated-context .content {
  border-top: 6px solid var(--elevated-signal);
  border-right: 6px solid var(--elevated-signal);
}
body.elevated-context .app-footer {
  border-top: 6px solid var(--elevated-signal);
  background: var(--elevated-signal);
}
body.elevated-context .app-footer .footer-link {
  color: var(--fg);
  font-size: 11px;
  font-weight: 600;
}

/* Logo header (unauthenticated pages) */
.logo-header {
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-container:has(.logo-header) {
  flex-direction: column;
}
.app-container:has(.logo-header) .content,
.app-container:not(:has(.sidebar)) .content {
  margin-left: 0; /* No sidebar on unauthenticated pages */
}

/* Main content */
.content {
  flex: 1;
  background: var(--bg-canvas);
  padding: 24px;
  padding-bottom: 26px; /* Space for fixed footer */
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: auto;
  scrollbar-color: var(--fg-faint) var(--bg-muted);
}
.content::-webkit-scrollbar {
  width: 12px;
}
.content::-webkit-scrollbar-track {
  background: var(--bg-muted);
  border-radius: var(--r-lg);
}
.content::-webkit-scrollbar-thumb {
  background: var(--fg-faint);
  border-radius: var(--r-lg);
  border: 2px solid var(--bg-muted);
}
.content::-webkit-scrollbar-thumb:hover {
  background: var(--fg-subtle);
}
/* Logo variants — crossfade via opacity, no display toggling */
.logo {
  position: relative;
}
.logo-icon {
  /* Collapsed sidebars crop the wordmark down to its circle (below) rather than
     swapping to this standalone icon, so the circle keeps its exact size and
     position across expanded/collapsed states. */
  display: none;
}
.logo-full {
  width: 104px;
  height: auto;
  opacity: 1;
  flex-shrink: 0;   /* never squish inside the narrow collapsed rail — it is cropped, not scaled */
  /* Expanded shows the whole wordmark; collapsed rails clip everything right of
     the circle (the wordmark is `[circle][gap][Orcha]`; circle ends ~28px, text
     starts ~32px of the 104px render), so the circle keeps its exact size and
     position and only the "Orcha" text slides away. */
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.2s ease;
}

/* Nav item labels and user info — hide via width, not display */
.nav-items li a span,
.user-name,
.user-chevron {
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.2s ease, opacity 0.2s ease;
}

/* Responsive sidebar — compact */
@media (max-width: 1366px) {
  :root {
    --sidebar-width: 220px;
  }
}

/* Responsive sidebar — icon rail */
@media (max-width: 1023px) {
  :root {
    --sidebar-width: 60px;
  }

  .sidebar {
    width: 60px;
    overflow: visible;
  }

  /* Logo: crop the wordmark to its circle (text scrolls out of the narrow rail);
     left padding matches the expanded logo so the circle never shifts. */
  .logo {
    justify-content: flex-start;
    /* Centre the circle in the 60px rail so it lines up with the nav icons below:
       circle centre sits ~16.7px into the 104px wordmark, so 30 − 16.7 ≈ 13.3px. */
    padding: 0 0 0 13.3px;
  }
  .logo-full { clip-path: inset(0 74px 0 0); }   /* show only the circle (left ~30px) */

  /* Active-tenant selector: centred building icon replaces the cramped
     dropdown; the dropdown returns on hover-expand.
     Vertical padding (8px) matches the hover-expand value exactly (see
     .sidebar:hover .active-tenant-selector below) and the icon takes the
     dropdown trigger's 32px height, so this element's own height never
     changes between collapsed and hover-expanded — see the activity-row
     comment below for why that matters. */
  .active-tenant-selector { padding: 8px 0; display: flex; justify-content: center; }
  .active-tenant-selector form { display: none; }
  .active-tenant-selector .tenant-select-icon { display: inline-flex; align-items: center; height: 32px; font-size: 20px; color: var(--fg-muted); }

  /* The collapsed rail shows only the History clock, as a plain rail icon;
     Recent activity returns with the pill + clock row on hover-expand, with
     the clock first so it stays under the pointer that expanded the rail.
     Recent activity is hidden visually but stays focusable, and takes the
     clock's spot while it has keyboard focus; the upload popover lives in its
     wrapper and must still open over a collapsed rail.

     The clock's 36px row and 12px margins are exactly as tall as the
     expanded row (12px + 38px + 10px), so .nav-items starts at the same
     y-coordinate in both states and hovering only ever grows the sidebar's
     WIDTH — no nav icon jumps up or down the instant :hover starts/stops
     matching. */
  .sidebar:not(:hover) .sidebar-activity-row {
    position: relative;
    flex-direction: column;
    gap: 0;
    margin: 12px 4px;
    width: 52px;
  }
  .sidebar:not(:hover) .sidebar-activity-row > .pipeline-indicator { position: static; }
  .sidebar:not(:hover) .pipeline-indicator-btn:not(:focus-visible) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .sidebar:not(:hover) .pipeline-indicator-btn:focus-visible {
    position: absolute;
    inset: 0;
    z-index: 1;
    justify-content: center;
    width: auto;
    padding: 0;
    gap: 0;
    border: none;
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: none;
  }
  .sidebar:not(:hover) .pipeline-indicator-btn:focus-visible .pipeline-indicator-label { display: none; }
  .sidebar:hover .recent-pages__trigger { order: -1; }
  .sidebar:not(:hover) .recent-pages__trigger {
    flex: none;
    width: 100%;
    height: 36px;
    aspect-ratio: auto;
    padding: 0;
    border: none;
    border-radius: var(--r-md);
    background: transparent;
    box-shadow: none;
    color: var(--fg);
    font-size: 20px;
  }
  .sidebar:not(:hover) .recent-pages__trigger[aria-expanded="true"] { background: var(--bg-muted); }

  /* Nav items: hide labels, center icons.
     Vertical padding (9px) matches the hover-expand value exactly — same
     reasoning as the activity row above, applied per-row instead of once
     above the list: each row's own height must stay identical between
     collapsed and hover-expanded so ITS icon doesn't shift either. */
  .sidebar .nav-items li a {
    justify-content: center;
    padding: 9px 0;
    gap: 0;
  }
  .sidebar .nav-items li a span { width: 0; opacity: 0; }
  .sidebar .nav-items li a iconify-icon { font-size: 20px; }
  .sidebar .nav-items li.active a {
    padding-left: 0;
    border-left: 2px solid var(--brand);
  }

  /* User section: avatar only.
     Vertical padding (12px) matches the hover-expand value exactly — same
     reasoning as the activity row above; .sidebar-user sits at the
     bottom via margin-top:auto, so a height change here shifts the avatar
     icon's own position rather than anything below it, but it's the same
     class of jump. */
  .sidebar-user { padding: 12px 0; }
  .user-trigger {
    justify-content: center;
    gap: 0;   /* avoid the 10px flex gap offsetting the centred avatar */
    padding: 8px;
  }
  .user-name { flex: 0; width: 0; opacity: 0; }
  .user-chevron { width: 0; opacity: 0; }
  .user-menu { max-height: 0; overflow: hidden; opacity: 0; }

  /* Hover-expand collapsed sidebar */
  .sidebar:hover {
    width: 300px;
    overflow-y: auto;
  }
  .sidebar:hover .logo {
    justify-content: flex-start;
    padding: 0 18px;
  }
  .sidebar:hover .logo-full { clip-path: inset(0 0 0 0); }   /* reveal full wordmark on hover-expand */
  .sidebar:hover .active-tenant-selector { padding: 8px 12px; display: block; }
  .sidebar:hover .active-tenant-selector form { display: block; }
  .sidebar:hover .active-tenant-selector .tenant-select-icon { display: none; }
  .sidebar:hover .nav-items li a {
    justify-content: flex-start;
    /* Vertical padding (9px) must match the collapsed value above exactly —
       same reasoning as the activity row's comment above. */
    padding: 9px 18px;
    gap: 11px;
  }
  .sidebar:hover .nav-items li a span { width: auto; opacity: 1; }
  .sidebar:hover .nav-items li.active a {
    padding-left: 16px;
  }
  .sidebar:hover .sidebar-user { padding: 12px; }
  .sidebar:hover .user-trigger {
    justify-content: flex-start;
    gap: 10px;
  }
  .sidebar:hover .user-name { flex: 1; width: auto; opacity: 1; }
  .sidebar:hover .user-chevron { width: auto; opacity: 1; }

  /* Content adjusts */
  .content {
    margin-left: 60px;
  }
}

/* Compact sidebar mode — forced icon rail on the document detail view.
   Triggered via :has(.detail-container) so it works regardless of whether
   the user landed on the page via HTMX body swap or a direct navigation.
   No hover-expand; users click an icon to navigate away. Mirrors the
   @media (max-width: 1023px) collapse rules above. The .sidebar width
   and .content margin-left already have transitions, so the shrink
   animates smoothly when :has() starts/stops matching. */
body:has(.detail-container) {
  --sidebar-width: 60px;
}
body:has(.detail-container) .sidebar {
  width: 60px;
  overflow-x: hidden;
  overflow-y: auto;
}
body:has(.detail-container) .logo {
  justify-content: flex-start;
  /* Centre the circle in the 60px rail so it lines up with the nav icons below. */
  padding: 0 0 0 13.3px;
}
body:has(.detail-container) .logo-full { clip-path: inset(0 74px 0 0); }   /* show only the circle */
body:has(.detail-container) .active-tenant-selector { padding: 8px 0; display: flex; justify-content: center; }
body:has(.detail-container) .active-tenant-selector form { display: none; }
body:has(.detail-container) .active-tenant-selector .tenant-select-icon { display: inline-flex; align-items: center; height: 32px; font-size: 20px; color: var(--fg-muted); }
body:has(.detail-container) .sidebar:not(:hover) .sidebar-activity-row {
  position: relative;
  flex-direction: column;
  gap: 0;
  margin: 12px 4px;
  width: 52px;
}
body:has(.detail-container) .sidebar:not(:hover) .sidebar-activity-row > .pipeline-indicator { position: static; }
body:has(.detail-container) .sidebar:not(:hover) .pipeline-indicator-btn:not(:focus-visible) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body:has(.detail-container) .sidebar:not(:hover) .pipeline-indicator-btn:focus-visible {
  position: absolute;
  inset: 0;
  z-index: 1;
  justify-content: center;
  width: auto;
  padding: 0;
  gap: 0;
  border: none;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: none;
}
body:has(.detail-container) .sidebar:not(:hover) .pipeline-indicator-btn:focus-visible .pipeline-indicator-label { display: none; }
body:has(.detail-container) .sidebar:hover .recent-pages__trigger { order: -1; }
body:has(.detail-container) .sidebar:not(:hover) .recent-pages__trigger {
  flex: none;
  width: 100%;
  height: 36px;
  aspect-ratio: auto;
  padding: 0;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  box-shadow: none;
  color: var(--fg);
  font-size: 20px;
}
body:has(.detail-container) .sidebar:not(:hover) .recent-pages__trigger[aria-expanded="true"] { background: var(--bg-muted); }
body:has(.detail-container) .sidebar .nav-items li a {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
}
body:has(.detail-container) .sidebar .nav-items li a span { width: 0; opacity: 0; }
body:has(.detail-container) .sidebar .nav-items li a iconify-icon { font-size: 20px; }
body:has(.detail-container) .sidebar .nav-items li.active a {
  padding-left: 0;
  border-left: 2px solid var(--brand);
}
body:has(.detail-container) .sidebar-user { padding: 12px 0; }
body:has(.detail-container) .user-trigger {
  justify-content: center;
  gap: 0;   /* avoid the 10px flex gap offsetting the centred avatar */
  padding: 8px;
}
body:has(.detail-container) .user-name { flex: 0; width: 0; opacity: 0; }
body:has(.detail-container) .user-chevron { width: 0; opacity: 0; }
body:has(.detail-container) .user-menu { max-height: 0; overflow: hidden; opacity: 0; }
body:has(.detail-container) .content {
  margin-left: 60px;
}

/* Hover-expand collapsed sidebar (detail view) */
body:has(.detail-container) .sidebar:hover {
  width: 300px;
  overflow-y: auto;
}
body:has(.detail-container) .sidebar:hover .logo {
  justify-content: flex-start;
  padding: 0 18px;
}
body:has(.detail-container) .sidebar:hover .logo-full { clip-path: inset(0 0 0 0); }
body:has(.detail-container) .sidebar:hover .active-tenant-selector { padding: 8px 12px; display: block; }
body:has(.detail-container) .sidebar:hover .active-tenant-selector form { display: block; }
body:has(.detail-container) .sidebar:hover .active-tenant-selector .tenant-select-icon { display: none; }
body:has(.detail-container) .sidebar:hover .nav-items li a {
  justify-content: flex-start;
  /* Vertical padding (9px) must match the collapsed value above exactly —
     same reasoning as the @media (max-width: 1023px) mirror of this rule above. */
  padding: 9px 18px;
  gap: 11px;
}
body:has(.detail-container) .sidebar:hover .nav-items li a span { width: auto; opacity: 1; }
body:has(.detail-container) .sidebar:hover .nav-items li.active a {
  padding-left: 16px;
}
body:has(.detail-container) .sidebar:hover .sidebar-user { padding: 12px; }
body:has(.detail-container) .sidebar:hover .user-trigger {
  justify-content: flex-start;
  gap: 10px;
}
body:has(.detail-container) .sidebar:hover .user-name { flex: 1; width: auto; opacity: 1; }
body:has(.detail-container) .sidebar:hover .user-chevron { width: auto; opacity: 1; }

/* Icon rail on the bank transaction page below 1440px. Its workbench pairs
   each side's evidence with its document side by side, which is cramped next
   to the expanded sidebar at laptop widths. Scoped to the page's allocation
   card so an embedded workbench (the accounting clearing dialog) never
   collapses the sidebar. Mirrors the detail-view rail above, hover-expand
   included; above 1440px the sidebar stays expanded. */
@media (max-width: 1439px) {
  body:has(.banking-detail-card [data-bank-invoice-workbench]) {
    --sidebar-width: 60px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar {
    width: 60px;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .logo {
    justify-content: flex-start;
    padding: 0 0 0 13.3px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .logo-full { clip-path: inset(0 74px 0 0); }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .active-tenant-selector { padding: 8px 0; display: flex; justify-content: center; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .active-tenant-selector form { display: none; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .active-tenant-selector .tenant-select-icon { display: inline-flex; align-items: center; height: 32px; font-size: 20px; color: var(--fg-muted); }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .sidebar-activity-row {
    position: relative;
    flex-direction: column;
    gap: 0;
    margin: 12px 4px;
    width: 52px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .sidebar-activity-row > .pipeline-indicator { position: static; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .pipeline-indicator-btn:not(:focus-visible) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .pipeline-indicator-btn:focus-visible {
    position: absolute;
    inset: 0;
    z-index: 1;
    justify-content: center;
    width: auto;
    padding: 0;
    gap: 0;
    border: none;
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: none;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .pipeline-indicator-btn:focus-visible .pipeline-indicator-label { display: none; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .recent-pages__trigger { order: -1; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .recent-pages__trigger {
    flex: none;
    width: 100%;
    height: 36px;
    aspect-ratio: auto;
    padding: 0;
    border: none;
    border-radius: var(--r-md);
    background: transparent;
    box-shadow: none;
    color: var(--fg);
    font-size: 20px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:not(:hover) .recent-pages__trigger[aria-expanded="true"] { background: var(--bg-muted); }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items li a {
    justify-content: center;
    padding: 9px 0;
    gap: 0;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items li a span { width: 0; opacity: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items li a iconify-icon { font-size: 20px; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items li.active a {
    padding-left: 0;
    border-left: 2px solid var(--brand);
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar-user { padding: 12px 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .user-trigger {
    justify-content: center;
    gap: 0;
    padding: 8px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .user-name { flex: 0; width: 0; opacity: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .user-chevron { width: 0; opacity: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .user-menu { max-height: 0; overflow: hidden; opacity: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .content {
    margin-left: 60px;
  }

  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover {
    width: 300px;
    overflow-y: auto;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .logo {
    justify-content: flex-start;
    padding: 0 18px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .logo-full { clip-path: inset(0 0 0 0); }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .active-tenant-selector { padding: 8px 12px; display: block; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .active-tenant-selector form { display: block; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .active-tenant-selector .tenant-select-icon { display: none; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items li a {
    justify-content: flex-start;
    padding: 9px 18px;
    gap: 11px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items li a span { width: auto; opacity: 1; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items li.active a {
    padding-left: 16px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .sidebar-user { padding: 12px; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .user-trigger {
    justify-content: flex-start;
    gap: 10px;
  }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .user-name { flex: 1; width: auto; opacity: 1; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .user-chevron { width: auto; opacity: 1; }
}

/* Sidebar groups (li.nav-group): a toggle row with the group's icon and a
   chevron, then indented subpages on a guide line. In every icon rail the
   subpages fold away behind the group icon until the rail hover-expands; the
   rail selectors below mirror the plain-row rules above for each rail. */
.nav-items .nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 18px;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, padding 0.2s ease, gap 0.2s ease;
}
.nav-items .nav-group-toggle:hover { background: var(--brand-tint-hover); }
.nav-items .nav-group-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.nav-items .nav-group-toggle iconify-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  font-size: 20px;
}
.nav-items .nav-group-toggle span {
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.2s ease, opacity 0.2s ease;
}
.nav-items .nav-group-toggle .nav-group-chevron {
  margin-left: auto;
  font-size: 16px;
  color: var(--fg-subtle);
  transition: transform 0.15s ease;
}
.nav-group.open > .nav-group-toggle .nav-group-chevron { transform: rotate(180deg); }
.nav-group.has-active > .nav-group-toggle,
.nav-group.has-active > .nav-group-toggle iconify-icon:first-child { color: var(--brand-pressed); }
.nav-sub {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
}
.nav-group:not(.open) > .nav-sub { display: none; }
.nav-sub::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 0;
  bottom: 8px;
  border-left: 1px solid var(--border-strong);
}
.nav-items .nav-sub li a {
  padding: 7px 18px 7px 44px;
  gap: 9px;
  color: var(--fg-muted);
}
.nav-items .nav-sub li a iconify-icon { font-size: 16px; }
.nav-items .nav-sub li.active a {
  padding-left: 42px;
  color: var(--brand-pressed);
}
@media (prefers-reduced-motion: reduce) {
  .nav-items .nav-group-toggle,
  .nav-items .nav-group-toggle span,
  .nav-items .nav-group-toggle .nav-group-chevron { transition: none; }
}

/* Group in the 60px icon rails. An open group keeps its subpages in the rail
   as icon-only rows with the same vertical metrics as when the rail
   hover-expands, so expanding never moves the rows below (the rail rule
   above) and the subpages stay reachable by keyboard. A closed group shows
   only its icon, tinted when it holds the current page. */
@media (max-width: 1023px) {
  .sidebar .nav-items .nav-group-toggle { justify-content: center; padding: 9px 0; gap: 0; }
  .sidebar .nav-items .nav-group-toggle span { width: 0; opacity: 0; }
  .sidebar .nav-items .nav-group-toggle .nav-group-chevron { display: none; }
  .sidebar .nav-items .nav-group.has-active:not(.open) > .nav-group-toggle { background: var(--brand-tint); border-left: 2px solid var(--brand); }
  .sidebar .nav-items .nav-sub::before { display: none; }
  .sidebar .nav-items .nav-sub li a { justify-content: center; padding: 7px 0; gap: 0; }
  .sidebar .nav-items .nav-sub li a iconify-icon { font-size: 16px; }
  .sidebar .nav-items .nav-sub li.active a { padding-left: 0; }
  .sidebar:hover .nav-items .nav-group-toggle { justify-content: flex-start; padding: 9px 18px; gap: 11px; }
  .sidebar:hover .nav-items .nav-group-toggle span { width: auto; opacity: 1; }
  .sidebar:hover .nav-items .nav-group-toggle .nav-group-chevron { display: flex; }
  .sidebar:hover .nav-items .nav-group.has-active > .nav-group-toggle { background: none; border-left: 0; }
  .sidebar:hover .nav-items .nav-sub::before { display: block; }
  .sidebar:hover .nav-items .nav-sub li a { justify-content: flex-start; padding: 7px 18px 7px 44px; gap: 9px; }
  .sidebar:hover .nav-items .nav-sub li.active a { padding-left: 42px; }
}
body:has(.detail-container) .sidebar .nav-items .nav-group-toggle { justify-content: center; padding: 9px 0; gap: 0; }
body:has(.detail-container) .sidebar .nav-items .nav-group-toggle span { width: 0; opacity: 0; }
body:has(.detail-container) .sidebar .nav-items .nav-group-toggle .nav-group-chevron { display: none; }
body:has(.detail-container) .sidebar .nav-items .nav-group.has-active:not(.open) > .nav-group-toggle { background: var(--brand-tint); border-left: 2px solid var(--brand); }
body:has(.detail-container) .sidebar .nav-items .nav-sub::before { display: none; }
body:has(.detail-container) .sidebar .nav-items .nav-sub li a { justify-content: center; padding: 7px 0; gap: 0; }
body:has(.detail-container) .sidebar .nav-items .nav-sub li a iconify-icon { font-size: 16px; }
body:has(.detail-container) .sidebar .nav-items .nav-sub li.active a { padding-left: 0; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-group-toggle { justify-content: flex-start; padding: 9px 18px; gap: 11px; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-group-toggle span { width: auto; opacity: 1; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-group-toggle .nav-group-chevron { display: flex; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-group.has-active > .nav-group-toggle { background: none; border-left: 0; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-sub::before { display: block; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-sub li a { justify-content: flex-start; padding: 7px 18px 7px 44px; gap: 9px; }
body:has(.detail-container) .sidebar:hover .nav-items .nav-sub li.active a { padding-left: 42px; }
@media (max-width: 1439px) {
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-group-toggle { justify-content: center; padding: 9px 0; gap: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-group-toggle span { width: 0; opacity: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-group-toggle .nav-group-chevron { display: none; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-group.has-active:not(.open) > .nav-group-toggle { background: var(--brand-tint); border-left: 2px solid var(--brand); }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-sub::before { display: none; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-sub li a { justify-content: center; padding: 7px 0; gap: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-sub li a iconify-icon { font-size: 16px; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar .nav-items .nav-sub li.active a { padding-left: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-group-toggle { justify-content: flex-start; padding: 9px 18px; gap: 11px; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-group-toggle span { width: auto; opacity: 1; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-group-toggle .nav-group-chevron { display: flex; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-group.has-active > .nav-group-toggle { background: none; border-left: 0; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-sub::before { display: block; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-sub li a { justify-content: flex-start; padding: 7px 18px 7px 44px; gap: 9px; }
  body:has(.banking-detail-card [data-bank-invoice-workbench]) .sidebar:hover .nav-items .nav-sub li.active a { padding-left: 42px; }
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.global-command-header {
  min-height: 51px;
  margin: -24px -24px 24px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* Page-owned command headers share the shell header's position above notices. */
.content > .global-command-header {
  order: -1;
  flex-shrink: 0;
}

#processing-pause-banner {
  flex-shrink: 0;
}

button:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
.btn[aria-disabled="true"],
[data-pause-disabled][aria-disabled="true"],
[data-pause-disabled]:hover,
[data-pause-disabled]:active {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
  box-shadow: none;
  transform: none;
}
/* A busy button shows its own spinner and keeps its colour. */
button[aria-busy="true"]:disabled,
.ap-batch-commit.htmx-request:disabled,
.ap-batch-run-checks.htmx-request:disabled,
.workflow-check-button.htmx-request:disabled,
.workflow-export-button.htmx-request:disabled {
  opacity: 1;
  filter: none;
  cursor: progress;
}

/* Document type filter tabs */
.document-type-filter {
  display: flex;
  gap: 2px;
  margin-right: 12px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}
.filter-tab {
  padding: 7px 14px;
  color: var(--fg-muted);
  text-decoration: none;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.filter-tab:hover {
  color: var(--fg);
  background: var(--bg-muted);
  text-decoration: none;
}
.filter-tab.active {
  color: var(--brand-pressed);
  background: var(--brand-tint);
  border-color: transparent;
}

/* Review Queue tab toggle — Re-routing / Financial Notices / Other */
.view-toggle {
  display: inline-flex;
  background: var(--bg-muted);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 0;
  margin-right: 8px;
  flex-shrink: 0;
}
.view-toggle .seg {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: calc(var(--r-md) - 2px);
  text-decoration: none;
  color: var(--fg-muted);
  white-space: nowrap;
  line-height: 1.4;
  display: inline-block;
}
.view-toggle .seg.active {
  background: var(--surface);
  color: var(--brand-pressed);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.view-toggle a.seg:hover {
  color: var(--fg);
  text-decoration: none;
}
.view-toggle .seg .n {
  margin-left: 4px;
  font-weight: 700;
  opacity: 0.7;
}

/* AP workflow overflow: the third position becomes More once four workflows
   are enabled. `details` keeps the menu keyboard-accessible without a page
   specific script or a hard-coded list of optional workflows. */
.view-toggle-more {
  position: relative;
  flex-shrink: 0;
}
.view-toggle-more > .more-summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  list-style: none;
}
.view-toggle-more > .more-summary::-webkit-details-marker {
  display: none;
}
.view-toggle-more > .more-summary iconify-icon {
  font-size: 13px;
  transition: transform 120ms ease;
}
.view-toggle-more[open] > .more-summary iconify-icon {
  transform: rotate(180deg);
}
.workflow-more-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 20;
  min-width: 190px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.workflow-more-title {
  margin: 4px 9px 7px;
  color: var(--fg-subtle);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.workflow-more-item {
  display: block;
  padding: 8px 9px;
  border-radius: var(--r-sm);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.workflow-more-item:hover,
.workflow-more-item[aria-current="page"] {
  color: var(--brand-pressed);
  background: var(--brand-tint);
  text-decoration: none;
}

/* Coming soon placeholder */
.coming-soon-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  text-align: center;
  color: var(--fg-subtle);
}
.coming-soon-placeholder p {
  margin: 0;
  font-size: 16px;
}

/* Pagination controls */
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-indicator {
  color: var(--fg-muted);
  font-size: 14px;
  min-width: 60px;
  text-align: center;
}
.pagination-page-picker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--fg-muted);
  font-size: 14px;
  white-space: nowrap;
}
.pagination-page-picker select {
  min-width: 42px;
  padding: 4px 16px 4px 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}
.pagination-page-picker select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Search input */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input {
  width: 240px;
  height: 32px;
  box-sizing: border-box;
  padding: 0 12px 0 34px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder {
  color: var(--fg-faint);
}
.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7681' stroke-width='2'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E") center/contain no-repeat;
  cursor: pointer;
}
.search-icon {
  position: absolute;
  left: 11px;
  color: var(--fg-subtle);
  font-size: 16px;
  pointer-events: none;
}

/* While the modifier is held the magnifier becomes the K that focuses this
   box — the same swap the sidebar icons do, on the same class the chord
   itself keys off, so the hint can't appear on a box ⌘K won't reach. */
.command-bar .search-icon::after {
  content: "K";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 12px/1 var(--font-mono);
  color: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.command-bar .search-icon svg { transition: opacity 0.12s ease; }
body.nav-shortcut-hints .command-bar .search-icon::after,
body.nav-shortcut-hints .command-bar .search-icon svg { transition: none; }
body.nav-shortcut-hints .command-bar .search-icon svg { opacity: 0; }
body.nav-shortcut-hints .command-bar .search-icon::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .command-bar .search-icon::after,
  .command-bar .search-icon svg { transition: none; }
}

.search-toolbar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.search-toolbar > .command-bar { flex: 1 1 auto; min-width: 0; }
.recent-pages__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 clamp(24px, calc(100% - 120px), 38px);
  width: 38px;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
  color: var(--fg);
  font-size: 16px;
  cursor: pointer;
}
.recent-pages__trigger:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.recent-pages__trigger[aria-expanded="true"] { background: var(--bg-muted); }
.recent-pages__trigger:focus-visible,
.recent-pages__close:focus-visible,
.recent-pages__link:focus-visible,
.recent-pages__more:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.recent-pages__panel {
  position: fixed;
  z-index: 400;
  width: min(420px, calc(100vw - 20px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: popover-enter 0.15s ease-out;
  color: var(--fg);
}
.recent-pages__panel::before { content: ""; position: absolute; top: -6px; left: var(--caret-left, 30px); width: 12px; height: 12px; background: var(--bg-subtle); border-top: 1px solid var(--border); border-left: 1px solid var(--border); transform: rotate(45deg); }
.recent-pages__panel[hidden] { display: none; }
.recent-pages__header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); border-radius: 7px 7px 0 0; background: var(--bg-subtle); }
.recent-pages__heading { margin: 0; font-size: 13px; font-weight: 600; }
.recent-pages__count { color: var(--fg-subtle); font-size: 12px; }
.recent-pages__close { margin-left: auto; flex: none; width: 24px; height: 24px; border: 0; border-radius: 4px; background: transparent; color: var(--fg-muted); font-size: 16px; line-height: 1; cursor: pointer; }
.recent-pages__close:hover { color: var(--fg); background: var(--bg-muted); }
.recent-pages__scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; border-radius: 0 0 7px 7px; }
.recent-pages__list { list-style: none; padding: 0; margin: 0; }
.recent-pages__item { margin: 0; padding: 0; }
.recent-pages__link { display: block; padding: 10px 16px; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--bg-muted); }
.recent-pages__link:hover { background: var(--bg-subtle); }
.recent-pages__label { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-pages__meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 3px; color: var(--fg-subtle); font-size: 11px; }
.recent-pages__time { flex: none; white-space: nowrap; }
.recent-pages__empty { margin: 0; padding: 24px 16px; font-size: 13px; color: var(--fg-subtle); }
.recent-pages__more { display: block; margin: 10px 16px 14px; width: calc(100% - 32px); padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--fg); font: inherit; font-size: 12px; cursor: pointer; }
.recent-pages__more:hover { background: var(--bg-hover); }
.recent-pages__more[hidden] { display: none; }
/* Detailed search is opened independently from the overview filter. */
.command-bar { gap: 6px; }
.command-bar .search-input {
  padding-right: 32px;
}
.list-search-status {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 2;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-subtle);
  font-size: 12px;
  white-space: nowrap;
}
.list-search-status:not(:empty) { padding: 2px 5px; }
[data-search-state="error"] .list-search-status { color: var(--danger); }
.list-search-spinner {
  display: none;
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  pointer-events: none;
  animation: list-search-spin 0.8s linear infinite;
}
[data-search-state="searching"] > .search-icon { visibility: hidden; }
[data-search-state="searching"] > .list-search-spinner { display: block; }
@keyframes list-search-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .list-search-spinner { animation: none; }
}
.command-bar__detailed {
  position: absolute;
  top: 1px;
  right: 1px;
  display: flex;
  width: 32px;
  height: 30px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-subtle);
  font-size: 16px;
  cursor: pointer;
}
.command-bar__detailed:hover,
.command-bar__detailed[aria-expanded="true"] { background: var(--bg-hover); }
.command-bar__detailed:focus-visible,
.command-bar__result:focus-visible,
.command-bar__result-button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (max-width: 600px) {
  .search-toolbar { width: 100%; }
  .command-bar { width: 100%; min-width: 0; }
  .command-bar .search-input { width: 100%; min-width: 0; }
  .command-bar .command-bar__panel-anchor { right: 0; }
  .command-bar .command-bar__panel { width: 100%; }
}
.command-bar__panel-anchor { position: absolute; top: 100%; left: 0; z-index: 110; }
.command-bar__panel {
  width: min(680px, calc(100vw - var(--sidebar-width) - 48px));
  max-height: min(70vh, 640px);
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: auto;
}
.command-bar__empty { padding: 16px 12px; color: var(--fg-subtle); }
.command-bar__group-count { margin-left: 8px; font-weight: 400; text-transform: none; }
.command-bar__group-label {
  padding: 7px 12px 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
/* Shown in place of Documents/Partners while a query is too short for their
   trigram-indexed search — see `elsewhere/min-query-length`. Scoped to the
   actual command palette so page-local search bars do not inherit this hint. */
.command-bar .command-bar__hint {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

/* A result is either an <a> (a destination) or a <form> wrapping a submit
   button (an action that posts). The form carries no padding of its own — its
   button is the full-bleed row — so both shapes present one identical
   rectangle and the highlight lands in the same place either way. */
.command-bar__result { display: block; }
a.command-bar__result,
.command-bar__result > .command-bar__result-button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
a.command-bar__result:hover,
a.command-bar__result.is-active,
.command-bar__result:hover > .command-bar__result-button,
.command-bar__result.is-active > .command-bar__result-button {
  background: var(--brand-tint);
  text-decoration: none;
}
/* Document rows carry a category badge and an amount/date trailing column —
   several rows can share a title (the same counterparty across many
   transactions), and the badge/amount/date are what actually tell them
   apart. Pages/Partners/Actions rows have neither and fall back to plain
   title + meta, unchanged. */
.command-bar__result-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.command-bar__result-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.command-bar__result-meta { flex: none; font-size: 11px; color: var(--fg-subtle); white-space: nowrap; }
.command-bar__result-badge {
  flex: none;
  padding: 1px 5px;
  border-radius: var(--r-sm);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.5;
}
.command-bar__result-badge--ap,
.command-bar__result-badge--ar {
  background: var(--doctype-invoice-tint);
  color: var(--doctype-invoice-fg);
}
.command-bar__result-badge--contracts {
  background: var(--doctype-contract-tint);
  color: var(--doctype-contract-fg);
}
.command-bar__result-badge--document-management {
  background: var(--doctype-purchase-tint);
  color: var(--doctype-purchase-fg);
}
.command-bar__result-badge--banking {
  background: var(--doctype-banking-tint);
  color: var(--doctype-banking-fg);
}
.command-bar__result-badge--accounting {
  background: var(--doctype-accounting-tint);
  color: var(--doctype-accounting-fg);
}
.command-bar__result-trailing {
  display: flex;
  flex: none;
  align-items: baseline;
  gap: 8px;
  margin-left: 8px;
}
.command-bar__result-amount {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.command-bar__result-date {
  color: var(--fg-faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 720px) {
  a.command-bar__result,
  .command-bar__result > .command-bar__result-button {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .command-bar__result-main { flex-wrap: wrap; gap: 4px 8px; }
  .command-bar__result-title { min-width: 0; }
  .command-bar__result-meta {
    flex-basis: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .command-bar__result-trailing { margin-left: 0; justify-content: space-between; }
}

/* Cross-page search results. The stable anchor is positioned against its
   .search-container parent, so the wider result panel overlays the content
   below without changing the toolbar's layout. */
.elsewhere-search {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 110;
  width: 420px;
  padding-top: 8px;
}
.elsewhere-search:empty {
  display: none;
}
.elsewhere-search__chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 4px 10px;
  padding: 7px 12px;
  background: var(--brand-tint);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}
.elsewhere-search__disclosure {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.elsewhere-search__disclosure:focus-visible {
  outline: none;
  border-radius: var(--r-sm);
  box-shadow: var(--focus-ring);
}
.elsewhere-search.is-open .elsewhere-search__chip {
  border-radius: var(--r-md) var(--r-md) 0 0;
  box-shadow: none;
}
.elsewhere-search__chip-label {
  font-size: 12.5px;
  font-weight: 600;
}
.elsewhere-search__chip-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-left: auto;
}
.elsewhere-search__count {
  padding: 3px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}
.elsewhere-search__count:hover {
  border-color: var(--brand-border);
  color: var(--brand);
}
.elsewhere-search__count.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--fg-on-brand);
}
.elsewhere-search__toggle {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.elsewhere-search__toggle::before {
  content: "+";
}
.elsewhere-search.is-open .elsewhere-search__toggle::before {
  content: "\2212";
}
.elsewhere-search__panel {
  max-height: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: 0;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-popover);
  transition: max-height 0.22s var(--ease), opacity 0.18s var(--ease),
              visibility 0s linear 0.22s;
}
.elsewhere-search.is-open .elsewhere-search__panel {
  max-height: 300px;
  overflow-y: auto;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}
.elsewhere-search__group.is-hidden {
  display: none;
}
.elsewhere-search__group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.elsewhere-search__badge {
  padding: 3px 6px;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.elsewhere-search__badge--ap,
.elsewhere-search__badge--ar {
  background: var(--doctype-invoice-tint);
  color: var(--doctype-invoice-fg);
}
.elsewhere-search__badge--contracts {
  background: var(--doctype-contract-tint);
  color: var(--doctype-contract-fg);
}
.elsewhere-search__badge--document-management {
  background: var(--doctype-purchase-tint);
  color: var(--doctype-purchase-fg);
}
.elsewhere-search__group-title {
  color: var(--fg);
  font-size: 12px;
  font-weight: 600;
}
.elsewhere-search__group-count {
  color: var(--fg-subtle);
  font-size: 11.5px;
}
.elsewhere-search__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
}
.elsewhere-search__row:hover {
  background: var(--bg-hover);
  text-decoration: none;
}
.elsewhere-search__row-main {
  min-width: 0;
}
.elsewhere-search__row-title,
.elsewhere-search__row-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.elsewhere-search__row-title {
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 600;
}
.elsewhere-search__row-meta {
  margin-top: 1px;
  color: var(--fg-subtle);
  font-size: 11.5px;
}
.elsewhere-search__row-trailing {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.elsewhere-search__row-amount {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.elsewhere-search__row-date {
  color: var(--fg-faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Date range filter */
.european-date-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.european-date-picker {
  min-width: 30px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  cursor: pointer;
}
.european-date-picker:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.date-range-filter {
  display: flex;
  align-items: center;
  gap: 4px;
}
.date-range-filter input[type="date"],
.date-range-filter [data-european-date-display] {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  height: 32px;
  color-scheme: light;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.date-range-filter input[type="date"]:focus,
.date-range-filter [data-european-date-display]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.date-range-filter input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

/* Approval filter select — matches the toolbar date inputs / filter controls */
.ar-approval-filter select {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 13px;
  height: 32px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ar-approval-filter select:hover {
  border-color: var(--brand);
}
.ar-approval-filter select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* Filter dropdown */
.filter-dropdown {
  position: relative;
}
.filter-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-sizing: border-box;
  height: 32px;
  /* The row is a fixed 32px, so a label that breaks spills out of its own
     button. Filters keep their natural width and leave the row instead:
     `filter-overflow.js` moves whatever no longer fits into More filters. */
  white-space: nowrap;
  flex: none;
}
.filter-dropdown-trigger:hover {
  background: var(--bg-muted);
  color: var(--fg);
}
.filter-dropdown-trigger.has-selection {
  color: var(--brand-pressed);
  border-color: var(--brand-border);
  background: var(--brand-tint);
}
/* A batch action's "Show them in the list": a selected filter that names the
   invoice set and lifts it when clicked. */
.ap-only-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 12px;
  box-sizing: border-box;
  border: 1px solid var(--brand-border);
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--brand-pressed);
  font-size: 13px;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 64px;
  max-width: 220px;
  text-decoration: none;
}
.ap-only-filter span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-only-filter iconify-icon {
  flex: none;
}
.ap-only-filter:hover {
  text-decoration: none;
  background: var(--brand-tint-hover);
}
.ap-only-filter iconify-icon {
  font-size: 13px;
}
/* Status lists the process steps and the needs-attention facts together. */
#status-filter-dropdown .filter-dropdown-panel {
  max-height: min(560px, calc(100vh - 80px));
}
#status-filter-dropdown .filter-dropdown-options {
  max-height: min(480px, calc(100vh - 140px));
}
.filter-dropdown-trigger .filter-count {
  font-weight: 600;
}
/* A filter the page arrived with rather than one the reader chose — it names
   what narrowed the list, and removing it is the whole affordance. */
.filter-pill-removable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--brand-border);
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--brand-pressed);
  font-size: 13px;
  text-decoration: none;
}
.filter-pill-removable:hover {
  border-color: var(--brand);
}

/* Settlement is a correspondence like the document matches above it, so it
   reuses their row grammar; the tint marks it as the bank's own evidence. */
.match-group-transaction .match-group-icon {
  background: var(--brand-tint);
  color: var(--brand-pressed);
}
/* A transaction row can grow to several lines (one per matched transaction),
   so the row centers on the icon alone — align to the top instead, or it
   drifts toward the middle of a list it isn't part of. */
.match-group-transaction {
  align-items: flex-start;
}
.match-group-transaction .match-group-icon {
  margin-top: 2px;
}
/* The settlement badge sits beside the title it describes rather than
   pinned to the row's far edge, which stopped lining up with anything once
   the row grew past one matched transaction. */
.match-group-transaction .match-group-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
/* The way into Accounting's bank reconciliation keeps to the row's far edge,
   leaving the settlement badge beside its title. */
.match-group-transaction .match-group-action {
  margin-left: auto;
  flex-shrink: 0;
}
/* Unmatch beside Match or Reconcile: the pair keeps to the far edge together. */
.match-group-transaction .match-group-actions {
  display: inline-flex;
  flex-shrink: 0;
  gap: 6px;
  margin-left: auto;
}
.match-group-transaction .match-group-actions .match-group-action {
  margin-left: 0;
}
.match-group-transaction .match-group-note {
  margin: 4px 0 0;
  color: var(--fg-muted);
  font: var(--text-caption);
}
.match-transaction-rows {
  display: flex;
  flex-direction: column;
}
.match-transaction-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 3px 0;
}
.match-transaction-row .match-doc-link {
  flex: 0 0 auto;
  min-width: 108px;
}
.match-transaction-amount {
  flex: 1 1 auto;
}
.match-transaction-split strong {
  color: var(--fg);
  font-weight: 600;
}
.match-transaction-of {
  color: var(--fg-faint);
  font-weight: 400;
  margin: 0 4px;
}
.match-transaction-date {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

/* Occupies the slot the document rows give confidence, but says settlement —
   green closed, amber still owing. Never a percentage: an allocation either
   happened or did not. */
.settlement-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.settlement-badge-settled {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.settlement-badge-partial {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.settlement-badge-waiting {
  background: var(--info-tint);
  color: var(--azure-700);
  border: 1px solid var(--info-border);
}
.filter-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 280px;
  max-width: 300px;
  max-height: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  flex-direction: column;
}
.filter-dropdown.open .filter-dropdown-panel {
  display: flex;
}
/* The rule above matches by descent, so an open dropdown would also reveal the
   panels of any dropdown nested inside it. A nested one answers only to its
   own open state. */
.filter-dropdown .filter-dropdown:not(.open) > .filter-dropdown-panel {
  display: none;
}
.filter-dropdown-search {
  padding: 8px 12px;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.filter-dropdown-search::placeholder {
  color: var(--fg-faint);
}
.filter-dropdown-options {
  overflow-y: auto;
  max-height: 300px;
  padding: 4px 0;
}
.filter-dropdown-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  padding: 8px 12px 2px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.filter-dropdown-group-label:first-child {
  border-top: none;
  margin-top: 0;
}
.filter-dropdown-option.is-disabled {
  color: var(--fg-muted);
  opacity: 0.55;
  cursor: default;
}
.filter-dropdown-option.is-disabled:hover {
  background: transparent;
}
/* The approver picker lists more rows than the other filters; give it headroom
   so a small roster shows without scrolling. */
#ar-approval-filter-dropdown .filter-dropdown-options {
  max-height: 420px;
}
.filter-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.1s;
}
.filter-dropdown-option:hover {
  background: var(--brand-tint-hover);
}
button.filter-dropdown-option {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
}
.filter-dropdown-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1px solid var(--fg-faint);
  border-radius: var(--r-sm);
  background: var(--surface);
  margin: 0;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.filter-dropdown-option input[type="checkbox"]:hover {
  border-color: var(--brand);
}
.filter-dropdown-option input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.filter-dropdown-option input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.filter-dropdown-apply {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: var(--brand);
  border: none;
  border-top: 1px solid var(--border);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.filter-dropdown-apply:hover {
  background: var(--brand);
}
.filter-dropdown-option .option-number {
  font-weight: 500;
  min-width: 50px;
  color: var(--fg);
}
.filter-dropdown-option .option-name {
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-clear {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-muted);
  font-size: 13px;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--r-md);
  transition: color 0.15s, background 0.15s;
}
.filter-clear:hover {
  color: var(--fg);
  background: var(--bg-muted);
  text-decoration: none;
}

/* Single-select dropdown rows (status + date pills) */
a.filter-dropdown-option {
  text-decoration: none;
  color: var(--fg);
}
a.filter-dropdown-option:hover {
  text-decoration: none;
}

/* More Filters — category submenu (Supplier / Cost Centers / Accounts).
   The category-detail view adds a Back row on top of the usual search +
   options(300px) + Apply stack, so the shared 360px panel cap clips the
   Apply button once a category's options list is long enough to hit its
   own 300px max-height (Cost Centers, Accounts). Give this panel room for
   that extra row. */
#more-filters-dropdown .filter-dropdown-panel {
  left: auto;
  right: 0;
  max-width: min(300px, calc(100vw - 32px));
  max-height: 420px;
}
.filter-category-list {
  padding: 4px 0;
}
.filter-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.1s;
}
.filter-category-row:hover {
  background: var(--brand-tint-hover);
}
.filter-category-row .filter-count {
  font-weight: 600;
}
.filter-category-detail {
  display: none;
  flex-direction: column;
}
.filter-category-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.filter-category-back:hover {
  background: var(--bg-muted);
}

.filter-dropdown-option.is-active {
  color: var(--brand-pressed);
  font-weight: 600;
}
.filter-dropdown-option .option-check {
  min-width: 16px;
  font-size: 14px;
  color: var(--brand);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.card-body {
  padding: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.btn-primary {
  background: var(--brand);
  color: white;
  /* Matches .btn-secondary's 1px border with a transparent one so the two
     are the same height when they sit side by side in an action row. */
  border: 1px solid transparent;
}
.btn-primary:hover {
  background: var(--brand);
}
.btn-primary.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: default;
}
.btn-primary.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-muted);
  text-decoration: none;
}
/* A button that carries no chrome, for the secondary escape beside a real
   action — dismissing a selection, dropping one row of a form. Two callers were
   already asking for `.btn-link` and getting the default filled button, which
   gave a throwaway action the same weight as the decision next to it. */
.btn-link {
  padding-left: 0;
  padding-right: 0;
  background: transparent;
  border: 0;
  color: var(--fg-muted);
}
.btn-link:hover {
  background: transparent;
  color: var(--fg);
  text-decoration: underline;
}

.btn-danger {
  background: var(--danger-strong);
  color: white;
  border: 1px solid transparent;
}
.btn-danger:hover {
  background: var(--danger);
}
/* An action that undoes something, before its confirmation: red, but not the
   filled weight of the confirming button. */
.btn-danger-outline {
  background: var(--surface);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
}
.btn-danger-outline:hover {
  background: var(--danger-tint);
}

/* The workbench swaps its primary action for "Remove match…" with `hidden`,
   which `.btn`'s display would otherwise override. */
.bank-invoice-workbench__footer .btn[hidden] {
  display: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-sm {
  padding: 6px 13px;
  font-size: 13px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
}
.badge-in-progress {
  background: var(--warning);
  color: var(--fg-on-brand);
}
.badge-completed {
  background: var(--success);
  color: white;
}
.badge-failed {
  background: var(--danger-strong);
  color: white;
}
.badge-released {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
/* Invoice subtype (credit note / cancellation): a quiet marker beside the
   amount in the AP list and beside the "Invoice" title on the detail page. It
   sits next to figures, so it stays compact and never sets the row height. */
/* The viewer's own unsaved changes on an invoice, beside its number in the
   AP list. */
.badge-unsaved-changes {
  display: inline-flex;
  align-items: center;
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
  padding: 2px 4px;
  margin-left: 6px;
  font-size: 12px;
  line-height: 1;
  vertical-align: middle;
}
.badge-subtype {
  background: var(--info-tint);
  color: var(--azure-700);
  border: 1px solid var(--info-border);
  padding: 1px 6px;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}
/* An invoice booked to a consolidated accounting supplier (`via Amazon`), next
   to the seller's name in the AP list: neutral, so it reads as a note on the
   supplier rather than competing with the blue document-subtype badge. */
.badge-channel {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}
/* Document type (Deductions/Settlements lists + Settlement overview): unlike
   .badge-subtype (one quiet blue everywhere), each document family gets its
   own colour from the app's existing --doctype-* accents, so a reader
   scanning a column of mixed debit notes / rebate settlements / remittance
   advices can tell them apart at a glance rather than reading every label. */
.badge-doctype {
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}
.badge-doctype-invoice {
  background: var(--doctype-invoice-tint);
  color: var(--doctype-invoice-fg);
}
.badge-doctype-debit-note {
  background: var(--doctype-goods-tint);
  color: var(--doctype-goods-fg);
}
.badge-doctype-remittance {
  background: var(--doctype-banking-tint);
  color: var(--doctype-banking-fg);
}
.badge-doctype-statement {
  background: var(--doctype-accounting-tint);
  color: var(--doctype-accounting-fg);
}
.badge-doctype-rebate {
  background: var(--doctype-purchase-tint);
  color: var(--doctype-purchase-fg);
}
/* PROTOTYPE: Beta badge for prototype pages - can be removed when no longer needed */
.badge-beta {
  background: transparent;
  color: white;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px !important;
  margin-left: 8px;
  vertical-align: middle;
  border: 1px solid rgba(28, 24, 19, 0.18);
  border-radius: var(--r-sm);
  line-height: 1.2;
}
/* Status tints (DESIGN_DECISIONS.md §2): pale --*-tint fill + --*-border +
   --*-strong text token — was ad-hoc rgba. Matches `.pill-confidence`/badge
   treatment in the design (app.css:323, 218-219). */
.badge-validation-pass {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.badge-validation-warning {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.badge-validation-error {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
}
/* DATEV export status badges */
.badge-datev-pending {
  background: rgba(191, 135, 0, 0.15);
  color: var(--warning);
  border: 1px solid rgba(191, 135, 0, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-datev-success {
  background: rgba(26, 127, 55, 0.15);
  color: var(--success);
  border: 1px solid rgba(26, 127, 55, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-datev-failed {
  background: rgba(207, 34, 46, 0.15);
  color: var(--danger);
  border: 1px solid rgba(207, 34, 46, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.badge-datev-partial {
  background: rgba(191, 135, 0, 0.15);
  color: var(--warning);
  border: 1px solid rgba(191, 135, 0, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.badge-datev-partial:hover,
.badge-datev-failed:hover {
  filter: brightness(1.1);
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
iconify-icon {
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  height: 1em;
  justify-content: center;
  vertical-align: -0.125em;
  width: 1em;
}

iconify-icon > svg {
  display: block;
  height: 100%;
  width: 100%;
}

iconify-icon.spin {
  animation: spin 1s linear infinite;
}

/* Match count badges (list page Matches column) */
.matches-cell {
  vertical-align: middle;
}
/* Machine-value cells render in MONO (design rule: mono = data you compare/copy).
   Applies to received date, invoice number, total amount, due date. */
.cell-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.cell-amount {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
}
.cell-muted {
  color: var(--fg-muted);
}
/* AP overview list (#document-list) and Document Management list (#doc-mgmt-list):
   adopt the AR list's lighter typography (sans 14px instead of the mono
   machine-value rule above) so their Date Received / Renewal Date cells match the
   AR/AP list rhythm. Scoped to the list tables, so the mono cell treatment is
   unchanged elsewhere. */
#document-list .cell-mono,
#document-list .cell-amount,
#doc-mgmt-list .cell-mono,
#doc-mgmt-list .cell-amount,
#history-list .cell-mono,
#history-list .cell-amount,
.partner-approval-table .cell-mono,
.partner-approval-table .cell-amount {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
}
/* Overview list headers stay on one line, so a column is never narrower than
   its header. Auto-layout tables only: fixed-layout tables size their columns
   for wrapped headers. */
#document-list thead th:not(.ap-selection-cell),
#ar-invoice-list thead th,
#doc-mgmt-list thead th,
.payment-runs-table thead th {
  white-space: nowrap;
}
/* Exceptions page tables (#tenant-review-list Re-routing, #notices-list Financial
   Notices, #other-list Other tabs): same lighter sans treatment as above, so
   filenames, reference numbers, amounts, dates, and timestamps read as normal
   text like AP/Document Management's lists, not machine-value monospace. */
#tenant-review-list .cell-mono,
#tenant-review-list .cell-amount,
#notices-list .cell-mono,
#notices-list .cell-amount,
#other-list .cell-mono,
#other-list .cell-amount {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
}
/* Opaque sticky thead, matching AP/AR/Document Management (#document-list,
   #ar-invoice-list, #doc-mgmt-list): .documents-scroll-area already makes
   thead position:sticky, but with no background of its own -- these three
   tables' ids are on the <table> itself (not a wrapping div like AP's), so
   this is a direct id-scoped rule rather than AP's div-then-table pair. */
#tenant-review-list thead,
#notices-list thead,
#other-list thead {
  background: var(--surface);
}
#tenant-review-list thead th,
#notices-list thead th,
#other-list thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
/* Deduction clearing uses its own table rather than one of the document-list
   wrappers above. Keep its sticky header opaque while the rows scroll below it. */
.deduction-table thead,
.deduction-table thead th {
  background: var(--surface);
}
.deduction-table thead th {
  border-bottom: 1px solid var(--border);
}
/* Settlement Clearing uses a separate source table, so give its sticky header
   the same opaque surface as the deductions table and the AP lists. */
.settlement-source-table thead,
.settlement-source-table thead th {
  background: var(--surface);
}
.settlement-source-table thead th {
  border-bottom: 1px solid var(--border);
}
/* Re-routing only: .table forces width:100%, so on a wide viewport the
   browser hands ALL leftover space to whichever column has none of its
   own -- on this table's short filenames/reason phrases, that stranded
   Arrived via far from the rest with a large empty gap before it.
   Overriding back to width:auto lets the table shrink-to-fit its actual
   content instead, so all four columns sit together near the left; the
   .cell-truncate/truncate-inner wrapping (see queue-row) is the safety
   net for the rare unusually long filename/reason. */
/* Full-bleed width, matching AP/AR/Document Management's own tables --
   width:auto (an earlier attempt at this) shrank the table off the page's
   full width entirely, which read as broken/unstyled next to those tables.
   table-layout:fixed + the Hiccup's own <colgroup> is the actual fix for
   the original problem (Arrived via stranded far from Reason): in
   table-layout:auto, a column with no width of its own absorbs 100% of
   whatever's left over, however much that is; fixed layout bounds every
   column to its own share instead, so no single column can hog it all. */
#tenant-review-list {
  table-layout: fixed;
  min-width: 840px;
}
#notices-list {
  min-width: 1420px;
}
#other-list {
  min-width: 620px;
}
/* Completion toggle (Financial Notices list row + detail page) -- a click-to-
   toggle icon, not a checkbox: this app already uses square checkboxes for
   row *selection* elsewhere (documents/management, ar/batch); a click here
   IS the action, not a selection, so it deliberately uses a different shape. */
.toggle-complete {
  background: none; border: none; padding: 0; cursor: pointer;
  display: inline-flex; line-height: 0; font-size: 19px; color: var(--fg-subtle);
}
.toggle-complete:hover { color: var(--fg-muted); }
.toggle-complete.is-done { color: #2f8a4e; }
.toggle-complete.is-done:hover { color: #256f3e; }
.row-check-cell { width: 32px; text-align: center; }
/* Inbox bulk selection: ticking a row lays this bar over the column headers,
   as the AP list swaps its header row, without changing the columns' widths. */
.bulk-header-row { position: relative; }
.bulk-selection-bar {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--brand-tint);
  border-bottom: 1px solid var(--brand-border);
  color: var(--fg);
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
}
.bulk-selection-bar[hidden] { display: none; }
#notices-list .row-check-cell form,
#other-list .row-check-cell form {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}
.row-dismissed { opacity: 0.55; }
.row-dismissed:hover { opacity: 0.8; }
/* .row-dismissed is shared with inbox.clj's completed Financial Notice rows
   (#notices-list) -- scoped to #tenant-review-list so this Comment-column
   truncation only ever applies to the Re-routing Dismissed view's own rows,
   not Notices' Type column. */
#tenant-review-list .row-dismissed td:nth-child(3) {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The fixed layout and colgroup already bound each column, so the truncating
   Document and Reason cells only need the inner ellipsis, not the 360px cap. */
#tenant-review-list .row-dismissed td.cell-truncate {
  max-width: none;
}
.notified-yes { display: inline-flex; align-items: center; gap: 4px; color: var(--fg-muted); font-size: 13px; }
.notified-yes iconify-icon { color: var(--brand-pressed); font-size: 14px; }
.notified-no { color: var(--fg-subtle); font-size: 13px; }
#notices-list .cell-truncate.cell-notify-recipients {
  max-width: 220px;
  color: var(--fg-muted);
  font-size: 13px;
}
/* Notice detail page's own state bar -- same toggle mechanism as the list
   row's .toggle-complete icon, blown up into a full-width bar above Notice
   Details. */
.completed-toggle-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  margin-bottom: 16px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-muted); color: var(--fg);
  font-family: inherit;
  cursor: pointer; width: 100%; text-align: left;
}
.completed-toggle-bar.is-done { background: #eef4ec; color: #2f5c3a; border-color: #cfe3cc; }
.completed-toggle-bar .toggle-complete { font-size: 20px; }
.completed-toggle-bar .cta-label { flex: 1; }
.completed-toggle-bar .cta-sub { font-weight: 400; font-size: 12.5px; opacity: 0.75; }
/* Uniform width sized to the widest label ("Needs Review"), icon removed.
   Scoped off `.badge-subtype` — the Credit note / Cancellation pill sits in the
   amount cell, not the status column, and must shrink to its own label. */
#document-list .badge:not(.badge-subtype, .badge-compact, .badge-channel, .badge-unsaved-changes) {
  min-width: 96px;
  padding-top: 1px;
  padding-bottom: 1px;
}
/* Clip long free-text cells (client / supplier names, invoice numbers) with an
   ellipsis so a single long value can't widen the table into horizontal scroll.
   The inner element is the overflow container: a `<td>` in an auto-layout table
   ignores `max-width` against unbreakable `nowrap` text, but a block child whose
   overflow is hidden reports no min-content, so the cell honours the cap. */
.cell-truncate {
  max-width: 360px;
}
/* Descendant, not child: with trailing content the inner sits one level deeper
   inside `.truncate-row`, and it must keep truncating in both shapes. */
.cell-truncate .truncate-inner {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Text plus trailing content on one line (AP list: the Credit note badge beside
   the invoice number). The text absorbs the squeeze — `min-width: 0` is what lets
   a flex item shrink below its content and so actually ellipsis — while the
   trailing element holds its natural width. */
.cell-truncate > .truncate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cell-truncate > .truncate-row > .truncate-inner {
  min-width: 0;
}
.cell-truncate > .truncate-row > .badge-subtype,
.cell-truncate > .truncate-row > .badge-unsaved-changes {
  flex: 0 0 auto;
  margin-left: 0;
}
/* Invoice numbers are short; cap their column tighter than the 360px default so
   one very long number can't widen it (the full value stays on hover via title).
   The invoice cell is the only truncating mono cell in the AP list (Received/Due
   are mono but not truncating). */
#document-list .cell-truncate.cell-mono {
  max-width: 140px;
}
/* A trailing badge needs its own room, or it would spend the number's 140px. */
#document-list .cell-truncate.cell-mono.cell-truncate-has-trailing {
  max-width: 240px;
}

#ar-invoice-list .ar-invoice-number-cell {
  max-width: 140px;
}

/* Per-column caps for the other truncating tables. */
#notices-list .cell-truncate.notice-cell-document { max-width: 260px; }
#notices-list .cell-truncate.notice-cell-sender { max-width: 200px; }
#notices-list .cell-truncate.notice-cell-reference { max-width: 160px; }
#other-list .cell-truncate.other-cell-document { max-width: 300px; }
#doc-mgmt-list .cell-truncate.doc-mgmt-title { max-width: 300px; }
#doc-mgmt-list .cell-truncate.doc-mgmt-counterparty { max-width: 240px; }
.cell-truncate.inbox-history-confirmed-by { max-width: 200px; }
.cell-truncate.inbox-history-filed-under { max-width: 220px; }
.cell-truncate.export-history-created-by { max-width: 200px; }
#payable-review-list .cell-truncate { max-width: 280px; }

.match-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 60px;
  box-sizing: border-box;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
  margin-right: 4px;
}
.match-count-symbol { width: 1ch; text-align: center; }
/* At least one digit wide so single counts line up; a two-digit count widens
   the badge instead of spilling over its type label. */
.match-count-number { min-width: 1ch; text-align: center; }
/* min-width, not a fixed 3ch: "MATCH"/"MATCHES" need more than 3ch and were
   clipping against the badge's own background outside .deduction-table,
   which overrode this with the same min-width fix (now redundant, see
   below). */
.match-count-type   { width: auto; min-width: 3ch; text-align: left; }
.match-count-none .match-count-symbol { display: none; }
.match-count-none { background: var(--bg-muted); color: var(--fg-faint); border: 1px solid var(--border); }
/* Match badges coloured by reconciliation STATE (design: green=ok, amber=partial,
   red=mismatch, grey=none) rather than by document type. */
.match-count-ok       { background: var(--success-tint); color: var(--success-strong); border: 1px solid var(--success-border); }
.match-count-partial  { background: var(--warning-tint); color: var(--warning-strong); border: 1px solid var(--warning-border); }
/* Paid by a payment run, waiting for the bank statement: neither settled nor wrong. */
.match-count-sent     { background: var(--info-tint); color: var(--azure-700); border: 1px solid var(--info-border); }
.match-count-sent .match-count-symbol { display: inline-flex; width: auto; }
.match-count-sent iconify-icon { font-size: 10px; }
/* The TRA badge's [data-tip] sits near a table's right edge and names one
   payment per line, so it opens leftwards and keeps those lines. It takes no
   layout until shown, or the last row's hidden tooltip would lengthen the
   list's scroll, and opens above near the list's bottom
   (`match-badge-tips.js`). The badge is usually inside a link, which is what
   takes keyboard focus. */
.match-count-badge[data-tip]::after { display: none; right: 0; left: auto; white-space: pre-line; }
.match-count-badge[data-tip]:hover::after,
a:focus-visible > .match-count-badge[data-tip]::after { display: block; opacity: 1; }
.match-count-badge[data-tip][data-tip-placement="above"]::after { top: auto; bottom: calc(100% + var(--space-1)); }
.match-count-mismatch { background: var(--danger-strong); color: #fff; border: 1px solid var(--danger-strong); }
/* Present matches, but reconciliation hasn't resolved (null / rejected / unknown). */
.match-count-neutral  { background: var(--bg-muted); color: var(--fg-muted); border: 1px solid var(--border); }
.match-pending { color: var(--fg-muted); }

/* Deduction clearing presents one state-aware MATCH badge per row. The count,
   state icon, and colour stay together so the accountant reads one signal. */
.deduction-table .matches-cell {
  text-align: center;
  overflow: visible;
}
.deduction-table .matches-cell > * {
  display: block;
  margin: 0 auto;
}
.deduction-table .match-count-badge {
  margin-right: 0;
}
.deduction-table .match-count-type {
  text-align: center;
}
.settlement-source-table .settlement-deductions-cell {
  text-align: center;
}

/* Data check — whether a claim document's own numbers add up. Deliberately a
   square chip (not the Matches column's pill) with its own icon family, so
   it can never be mistaken for a match-review or reconciliation signal even
   at a glance. */
.data-check-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-md);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-subtle);
}
.data-check-badge iconify-icon { font-size: 12px; }
/* Financial Summary's own .detail-card-head icon rule (below, same
   specificity, later in the file) would otherwise win here and shift this
   badge's icon by its own +2px nudge, which this badge doesn't need --
   override back to unshifted regardless of which card head it sits in. */
.detail-card-head .data-check-badge iconify-icon { position: static; top: auto; }
.data-check-badge.is-ready iconify-icon { color: var(--success); }
.data-check-badge.is-amount-mismatch {
  background: var(--danger-tint); color: var(--danger-strong); border-color: var(--danger-border);
}
.data-check-badge.is-extraction-issue,
.data-check-badge.is-missing-supporting-document {
  background: var(--warning-tint); color: var(--warning-strong); border-color: var(--warning-border);
}

/* Reconciliation — does a confirmed match's own settlement amount agree with
   the claim. Pill-shaped like the Matches badge (it IS a match-quality
   signal), but intentionally smaller/simpler so it reads as a detail of the
   match rather than a duplicate of the Matches count itself. */
.reconciliation-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.reconciliation-chip iconify-icon { font-size: 11px; }
.reconciliation-chip.is-matched {
  background: var(--success-tint); color: var(--success-strong);
}
.reconciliation-chip.is-different {
  background: var(--danger-tint); color: var(--danger-strong);
}

/* Which team a deduction is routed to. Finance and Logistics get distinct
   accents so a column of them scans at a glance; an unconfirmed route stays
   quiet and dashed so it reads as "not decided yet", not as a third team. */
.function-route-badge {
  border: 1px solid transparent;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.function-route-badge.is-finance {
  background: var(--accent-violet-tint); color: var(--accent-violet);
}
.function-route-badge.is-supply-chain {
  background: var(--doctype-banking-tint); color: var(--doctype-banking-fg);
}
.function-route-badge.is-unassigned {
  background: transparent; color: var(--fg-muted); border: 1px dashed var(--border);
}
/* Where the team stands on a deduction or settlement: open stays quiet, in
   progress is amber, done is green. */
.work-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.work-status-badge iconify-icon { font-size: 11px; }
.work-status-badge.is-open {
  background: transparent; color: var(--fg-muted); border-color: var(--border);
}
.work-status-badge.is-in-progress {
  background: var(--warning-tint); color: var(--warning-strong);
}
.work-status-badge.is-done {
  background: var(--success-tint); color: var(--success-strong);
}
/* The Work section of a deduction or remittance: team, work status and what
   is open, then notes and changes. Choices are radio cards; the status colors
   follow the work-status badges, the team colors the team badges. */
.work-section { display: grid; gap: 14px; }
.deduction-clearing-detail-column .detail-section.work-section h2 { margin: 0; }
.work-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}
.work-last { color: var(--fg-subtle); font-size: 12px; }
.work-form { display: grid; gap: 16px; }
.work-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.work-label {
  padding: 0;
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.work-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-subtle);
  font: 500 10px/1 var(--font-mono);
}
@media (hover: none) { .work-key { display: none; } }

.work-team-choice,
.work-status-choice {
  display: grid;
  gap: 8px;
}
.work-team-choice { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.work-status-choice { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.work-team-option,
.work-status-option,
.work-reason-chip {
  position: relative;
  cursor: pointer;
}
.work-team-option input,
.work-status-option input,
.work-reason-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.work-team-card,
.work-status-card {
  display: flex;
  height: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s;
}
.work-team-option:hover .work-team-card,
.work-status-option:hover .work-status-card { border-color: var(--stone-400); }
.work-team-option input:focus-visible + .work-team-card,
.work-status-option input:focus-visible + .work-status-card,
.work-reason-chip input:focus-visible + span { box-shadow: var(--focus-ring); }

.work-team-card { align-items: center; gap: 10px; padding: 9px 12px; }
.work-team-icon {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: 16px;
}
.work-team-text { display: grid; min-width: 0; }
.work-team-text strong { font-size: 14px; }
.work-team-text small { color: var(--fg-subtle); font-size: 12px; line-height: 1.35; }
.work-team-option.is-finance input:checked + .work-team-card {
  border-color: var(--accent-violet);
  background: var(--accent-violet-tint);
  box-shadow: inset 0 0 0 1px var(--accent-violet);
}
.work-team-option.is-finance input:checked + .work-team-card .work-team-icon { background: var(--accent-violet); color: var(--fg-on-brand); }
.work-team-option.is-supply-chain input:checked + .work-team-card {
  border-color: var(--doctype-banking-fg);
  background: var(--doctype-banking-tint);
  box-shadow: inset 0 0 0 1px var(--doctype-banking-fg);
}
.work-team-option.is-supply-chain input:checked + .work-team-card .work-team-icon { background: var(--doctype-banking-fg); color: var(--fg-on-brand); }
.work-form:not(:has(input[name="team"]:checked)) .work-team-card { border-style: dashed; }

.work-reason {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}
.work-reason > iconify-icon { flex: none; margin-top: 2px; color: var(--brand); font-size: 14px; }
.work-reason-text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.work-reason-text p { margin: 0; }
.work-reason-title { color: var(--fg); font-weight: 500; }
.work-reason-title strong { font-weight: 700; }
.work-reason-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--r-sm);
}
.work-reason-details > summary::-webkit-details-marker { display: none; }
.work-reason-details > summary::after {
  content: "Why?";
  order: 2;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}
.work-reason-details[open] > summary::after { content: "Hide"; }
.work-reason-details > summary:hover::after { text-decoration: underline; }
.work-reason-details > summary:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.work-reason-chevron { order: 3; color: var(--brand); font-size: 13px; transition: transform .15s ease; }
.work-reason-details[open] .work-reason-chevron { transform: rotate(180deg); }
.work-reason-details .work-reason-evidence { margin-top: 4px; overflow-wrap: anywhere; }
.work-reason-text .work-reason-hint { font-size: 12px; }
.work-reason .btn { flex: none; align-self: center; margin: -4px -4px -4px 0; }
.work-reason.is-manual { background: var(--brand-tint); }
.work-reason.is-attention {
  border: 1px solid var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.work-reason.is-attention > iconify-icon { color: var(--warning); }
.work-reason.is-attention .work-reason-title { color: var(--warning-strong); }
.work-reason.is-attention .work-reason-details > summary::after,
.work-reason.is-attention .work-reason-chevron { color: var(--warning-strong); }
.work-form:has(input[name="team"]:checked) .work-reason.is-unassigned { display: none; }

.work-status-card { flex-direction: column; gap: 2px; padding: 8px 12px; }
.work-status-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
}
.work-status-card small { color: var(--fg-subtle); font-size: 12px; line-height: 1.35; }
.work-status-option.is-open input:checked + .work-status-card {
  border-color: var(--fg-muted);
  background: var(--bg-subtle);
  box-shadow: inset 0 0 0 1px var(--fg-muted);
}
.work-status-option.is-in-progress input:checked + .work-status-card {
  border-color: var(--amber-500);
  background: var(--warning-tint);
  box-shadow: inset 0 0 0 1px var(--amber-500);
}
.work-status-option.is-in-progress input:checked + .work-status-card .work-status-card-head { color: var(--warning-strong); }
.work-status-option.is-done input:checked + .work-status-card {
  border-color: var(--success);
  background: var(--success-tint);
  box-shadow: inset 0 0 0 1px var(--success);
}
.work-status-option.is-done input:checked + .work-status-card .work-status-card-head { color: var(--success-strong); }
.work-needs-team { display: none; }
.work-form:has(input[name="team"]):not(:has(input[name="team"]:checked)) .work-needs-team {
  display: block;
  color: var(--warning-strong);
  font-weight: 600;
}

.work-reasons {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}
.work-form:has(input[name="work-status"][value="in-progress"]:checked) .work-reasons { display: flex; }
.work-reasons legend {
  float: left;
  margin-right: 4px;
  padding: 0;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 600;
}
.work-reason-chip span {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
}
.work-reason-chip:hover span { border-color: var(--stone-400); }
.work-reason-chip input:checked + span {
  border-color: var(--warning-strong);
  background: var(--warning-strong);
  color: var(--fg-on-brand);
}

.work-done-check {
  display: none;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  background: var(--warning-tint);
}
.work-form:has(input[name="work-status"][value="done"]:checked) .work-done-check { display: grid; }
.work-done-check-title {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  color: var(--warning-strong);
  font-size: 13px;
  font-weight: 600;
}
.work-done-check-title iconify-icon { flex: none; margin-top: 2px; }
.work-done-check-title span { flex: 1 1 auto; }
.work-done-check-title .btn { flex: none; margin: -4px -4px -4px 0; white-space: nowrap; }
.work-done-check-list {
  max-height: 340px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.work-done-check-list li + li { border-top: 1px solid var(--border-subtle); }
.work-done-check-list label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.work-done-check-list label.is-disabled { cursor: not-allowed; opacity: 0.6; }
.work-done-check-list input { accent-color: var(--success); }
.work-done-check-main { display: grid; min-width: 0; }
.work-done-check-reference { font: 400 13px/1.4 var(--font-mono); }
.work-done-check-label {
  overflow: hidden;
  color: var(--fg-subtle);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.work-done-check-note { margin: 0; color: var(--warning-strong); font-size: 12px; }

.work-note {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
.work-note::placeholder { color: var(--fg-subtle); }
.work-note:focus-visible { border-color: var(--brand); outline: none; box-shadow: var(--focus-ring); }
.work-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 -14px -13px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface);
}
.work-actions-hint { flex: 1 1 auto; color: var(--fg-subtle); font-size: 12px; }

.work-conflict {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 13px;
}
.work-conflict > iconify-icon { flex: none; margin-top: 2px; font-size: 16px; }
.work-conflict p { margin: 0; }
.work-conflict ul { margin: 4px 0; padding-left: 18px; }

.work-timeline {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.work-timeline > li {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--border-subtle);
}
.work-avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-pill);
  background: var(--brand-tint);
  color: var(--brand-hover);
  font-size: 11px;
  font-weight: 700;
}
.work-timeline-body { display: grid; gap: 1px; min-width: 0; }
.work-timeline-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.work-timeline-meta time,
.work-timeline-change time { color: var(--fg-subtle); }
.work-timeline-change time { margin-left: 6px; }
.work-timeline-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.work-timeline-change { color: var(--fg-muted); font-size: 12px; }
.work-timeline-change strong { color: var(--fg); }
.work-timeline-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin: 5px 9px 0;
  border-radius: var(--r-pill);
  background: var(--border-strong);
}

.work-remittance-notes {
  margin-bottom: 8px;
  padding: 8px 12px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}
.work-remittance-notes-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
}
.work-remittance-notes-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.work-remittance-notes-empty { margin: 0 0 8px; color: var(--fg-subtle); font-size: 12px; }

.clearing-state { display: grid; }
.clearing-state small { color: var(--fg-subtle); font-size: 12px; }

.settlement-deduction-checks {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
@media (max-width: 760px) {
  .settlement-deduction-checks { justify-content: flex-start; }
}

/* Unified document status badges */
.badge-status-processing,
.badge-status-failed,
.badge-status-not-exported,
.badge-status-processed,
.badge-status-exported,
.badge-status-has-warnings,
.badge-status-notice,
.badge-status-supplier-contact,
.badge-status-rejected,
.badge-status-awaiting-approval,
.badge-status-approved {
  min-width: 112px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
}
.badge-status-processing {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.badge-status-failed {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
}
.badge-status-not-exported {
  background: var(--danger);
  color: #fff;
}
.badge-status-processed {
  background: var(--brand);
  color: #fff;
}
.badge-status-processed iconify-icon.spin {
  font-size: 12px;
}
.badge-status-exported {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.badge-status-exported .flag-check {
  font-size: 14px;
}
/* Approval decisions on the AP list pill (see `unified-status-badge`): a
   rejection reads as an error, an incomplete roster as pending, a full
   approval as done. */
.badge-status-rejected {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
}
.badge-status-awaiting-approval {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.badge-status-approved {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.badge-status-has-warnings {
  background: var(--info-tint);
  color: var(--azure-700);
  border: 1px solid var(--info-border);
}
.badge-status-has-warnings .flag-warning {
  font-size: 14px;
}
.badge-status-notice {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.badge-status-supplier-contact {
  background: var(--info-tint);
  color: var(--azure-700);
  border: 1px solid var(--info-border);
}

/* Table Status columns: one restrained, AP-derived visual contract. Layered on
   top of the legacy .badge-status-* rules above (same specificity, declared
   later, so it wins) rather than editing them, so callers that still key off
   the old class names keep working while every pill converges on one of five
   tint+border variants at a fixed width. */
.table-status-pill {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: var(--table-status-pill-width, 112px);
  min-width: 0;
  height: 22px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.table-status-pill-neutral {
  border: 1px solid var(--border-strong);
  background: var(--bg-muted);
  color: var(--fg-muted);
}

.table-status-pill-success {
  border: 1px solid var(--success-border);
  background: var(--success-tint);
  color: var(--success-strong);
}

.table-status-pill-warning {
  border: 1px solid var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.table-status-pill-danger {
  border: 1px solid var(--danger-border);
  background: var(--danger-tint);
  color: var(--danger-strong);
}

.table-status-pill-info {
  border: 1px solid var(--info-border);
  background: var(--info-tint);
  color: var(--azure-700);
}

#document-list { --table-status-pill-width: 160px; }
/* Narrower side padding fits the longest AP status labels into the column's
   fixed pill width without widening an already full table. */
#document-list .table-status-pill { padding-inline: 8px; }
/* The Matches chips are the widest cluster in the row; narrower chips keep the Status
   column inside the table instead of past its right edge. */
#document-list .match-count-badge { min-width: 52px; }
/* Nothing is reserved beside the amount unless a row of the list has a discount chip
   to put there. */
#document-list table:not(:has(.skonto-gutter:not(:empty))) .skonto-gutter {
  display: none !important;
}
/* A status longer than its pill is cut with an ellipsis; its full text is the pill's title. */
#document-list .table-status-pill {
  display: inline-block;
  overflow: hidden;
  line-height: 20px;
  text-align: center;
  text-overflow: ellipsis;
  vertical-align: middle;
}
/* Below the width where the full table fits its card, the columns tighten so that
   Status stays inside the table instead of past its right edge. */
@media (max-width: 1535px) {
  #document-list { --table-status-pill-width: 128px; }
  #document-list tbody td { padding-inline: 8px; }
  #document-list thead .column-filter-heading-controls { padding-inline: 6px; }
  #document-list .match-count-badge { min-width: 44px; }
  #document-list td.skonto-schedule-cell { min-width: 0 !important; }
  #document-list td.cell-truncate:not(.cell-mono) { max-width: 148px; }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.status-pill-success {
  border-color: var(--success-border);
  background: var(--success-tint);
  color: var(--success-strong);
}

/* Supplier communication — inline data-panel section (highlighted info/blue box,
   the same tint as the "Supplier contact" chip; everything lives here inline).
   Compound selector so it beats the later `.invoice-section` white background. */
.invoice-section.supplier-comms-section {
  background: var(--info-tint);
  border: 1px solid var(--info-border);
}
.supplier-comms-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.supplier-comms-head-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--azure-700);
}
.supplier-comms-head-title iconify-icon { font-size: 18px; color: var(--azure); }
.supplier-comms-status-tag {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--azure); color: #fff; white-space: nowrap;
}
.supplier-comms-reason { font-size: 13px; color: var(--fg); line-height: 1.45; margin-bottom: 12px; }
.supplier-comms-reason-hint { color: var(--fg-muted); }
.supplier-comms-fields { display: flex; flex-direction: column; gap: 12px; }
.supplier-comms-field-label-row { display: flex; align-items: center; justify-content: space-between; }
/* Small status dot + text, same visual language as .ar-save-status. The
   [hidden] override is load-bearing: an author `display` rule on the same
   class otherwise beats the UA stylesheet's `[hidden] { display: none }`,
   so the badge would show immediately instead of only once revealed. */
.supplier-comms-unsaved-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--fg-muted); white-space: nowrap;
}
.supplier-comms-unsaved-badge[hidden] { display: none; }
.supplier-comms-unsaved-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--warning); flex-shrink: 0;
}
.supplier-comms-recipient-warning {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 8px; padding: 10px 12px;
  border-radius: var(--r-lg); border: 1px solid var(--warning-border);
  background: var(--warning-tint);
  font-size: 13px; color: var(--fg); line-height: 1.45;
}
.supplier-comms-recipient-warning iconify-icon { color: var(--warning); font-size: 16px; flex: none; margin-top: 1px; }
.supplier-comms-recipient-input {
  width: 100%; max-width: 320px; font-size: 13px; padding: 6px 9px;
  border: 1px solid var(--info-border); border-radius: 6px;
  background: var(--surface); color: var(--fg);
}
.supplier-comms-subject-input {
  width: 100%; font-size: 13px; padding: 6px 9px;
  border: 1px solid var(--info-border); border-radius: 6px;
  background: var(--surface); color: var(--fg);
}
.supplier-comms-address-input {
  width: 100%; font-size: 13px; padding: 6px 9px;
  border: 1px solid var(--info-border); border-radius: 6px;
  background: var(--surface); color: var(--fg);
}
/* A locked (sent) field must not look editable — muted surface, muted text,
   not-allowed cursor, rather than rendering identically to a live field. */
.supplier-comms-recipient-input:disabled,
.supplier-comms-subject-input:disabled,
.supplier-comms-address-input:disabled,
.draft-body-textarea:disabled {
  background: var(--bg-muted); color: var(--fg-muted); cursor: not-allowed;
}
.supplier-comms-envelope {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px;
  margin: 8px 0 12px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-muted); font-size: 12px;
}
.supplier-comms-envelope-label { color: var(--fg-muted); }
.supplier-comms-envelope-value { min-width: 0; overflow-wrap: anywhere; }
.supplier-comms-form-error {
  margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--danger-border); border-radius: var(--r-lg);
  background: var(--danger-tint); color: var(--danger-strong); font-size: 13px;
}
.draft-body-textarea {
  width: 100%; resize: vertical; font-family: inherit; font-size: 13px;
  padding: 8px; border: 1px solid var(--border); border-radius: 4px;
  color: var(--fg); background: var(--bg);
  /* field-sizing grows the box to fit the drafted text (Chrome/Edge 123+);
     unsupported browsers just keep the taller `rows` fallback below. Either
     way, max-height caps it before falling back to scrolling. */
  field-sizing: content; max-height: 420px; overflow-y: auto;
}
.supplier-comms-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 14px;
}
.supplier-comms-blockers {
  margin-top: 13px;
  font-size: 13px;
  color: var(--danger-strong);
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.supplier-comms-blockers-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.supplier-comms-blockers-head iconify-icon { font-size: 16px; flex: none; }
.supplier-comms-blockers ul { margin: 7px 0 0; padding-left: 28px; list-style: disc; }
.supplier-comms-blockers li { margin-top: 2px; }
.supplier-comms-send-note {
  font-size: 13px;
  color: var(--fg-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.supplier-comms-ad {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--info-tint);
  border: 1px solid var(--info-border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 10px;
  margin-bottom: 10px;
}
/* Historically always the panel's first element, so this never needed its
   own top gap; now the approvers section can render ahead of it, so it
   needs the same :first-child reset every .invoice-section already gets. */
.supplier-comms-ad:first-child {
  margin-top: 0;
}
.supplier-comms-ad iconify-icon { font-size: 18px; color: var(--azure); flex: none; margin-top: 1px; }
.supplier-comms-ad-title { font-size: 13px; font-weight: 600; color: var(--azure-700); margin-bottom: 3px; }
.supplier-comms-ad-body { font-size: 13px; color: var(--fg); line-height: 1.45; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  vertical-align: middle;
}
.table tbody tr:hover {
  background: var(--bg-subtle);
}
.table tbody tr[hx-get],
.table tbody tr[data-row-href] {
  cursor: pointer;
}
.table tbody tr[role="link"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* Document line tables (PO, GRN) sit in a bordered box like the invoice's line
   items; a panel too narrow for every column scrolls the box, not the panel. */
.document-line-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.document-line-table-wrap > .document-line-table {
  margin: 0;
}
/* Long descriptions wrap and grow the row instead of pushing the other columns
   out of the box. */
.document-line-table th,
.document-line-table td {
  padding: 8px;
}
.document-line-table td {
  white-space: normal;
  vertical-align: top;
}
.document-line-table td.desc,
.document-line-table td.article {
  overflow-wrap: anywhere;
}
.document-line-table td.desc {
  min-width: 12rem;
}
.document-line-table td.article {
  min-width: 7rem;
}
.document-line-table th.numeric,
.document-line-table td.numeric {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.document-line-table td.nowrap {
  white-space: nowrap;
}
.document-line-table .line-reference {
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: 12px;
}

.banking-transactions thead th,
.banking-statements thead th,
.accounting-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.banking-transactions,
.banking-statements,
.accounting-table {
  table-layout: fixed;
}

.banking-transactions {
  min-width: 1150px;
  table-layout: auto;
  --banking-statement-max-width: 420px;
}

.banking-transactions th,
.banking-statements th,
.accounting-table th {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.banking-transactions th,
.banking-transactions td,
.banking-statements th,
.banking-statements td,
.accounting-table th,
.accounting-table td {
  padding-right: 8px;
  padding-left: 8px;
}

.accounting-open-items th,
.accounting-open-items td {
  padding-right: 4px;
  padding-left: 4px;
}

.accounting-table th > a {
  display: inline-flex;
  align-items: center;
}

.banking-transactions th:has(.glossary-term),
.banking-statements th:has(.glossary-term),
.accounting-table th {
  text-overflow: clip;
}

.banking-transactions th > a .glossary-term,
.banking-statements th > a .glossary-term,
.accounting-table th > a .glossary-term {
  flex: none;
  max-width: none;
}

.banking-transactions th:has(.glossary-term:hover),
.banking-transactions th:has(.glossary-term:focus-visible),
.banking-transactions th:has(.glossary-term:focus-within),
.banking-statements th:has(.glossary-term:hover),
.banking-statements th:has(.glossary-term:focus-visible),
.banking-statements th:has(.glossary-term:focus-within),
.accounting-table th:has(.glossary-term:hover),
.accounting-table th:has(.glossary-term:focus-visible),
.accounting-table th:has(.glossary-term:focus-within) {
  overflow: visible;
  z-index: 3;
}

.banking-transactions td,
.banking-statements td,
.accounting-table td {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banking-transactions td > *,
.banking-statements td > *,
.accounting-table td > * {
  max-width: 100%;
}

.banking-transactions .banking-column-date { width: 110px; }
.banking-transactions .banking-column-account { width: 180px; }
.banking-transactions .banking-column-counterparty { width: 220px; }
.banking-transactions .banking-column-remittance { width: 280px; }
.banking-transactions .banking-column-amount { width: 160px; }
.banking-transactions .banking-column-allocation { width: 180px; }
.banking-transactions .banking-column-direction { width: 100px; }
.banking-transactions .banking-column-reference { width: 160px; }
.banking-transactions .banking-column-remaining { width: 160px; }
.banking-transactions .banking-column-payment-type { width: 140px; }
.banking-transactions .banking-column-matched-to { width: 220px; }
.banking-transactions .banking-column-matched-by { width: 180px; }

.banking-transactions .cell-truncate.banking-cell-account { max-width: 164px; }
.banking-transactions .cell-truncate.banking-cell-counterparty { max-width: 204px; }
.banking-transactions .cell-truncate.banking-cell-remittance { max-width: 264px; }
.banking-transactions .cell-truncate.banking-cell-reference { max-width: 144px; }
.banking-transactions .cell-truncate.banking-cell-matched-to { max-width: 204px; }
.banking-transactions .cell-truncate.banking-cell-matched-by { max-width: 164px; }

.banking-statements .banking-statement-column-uploaded { width: 120px; }
.banking-statements .banking-statement-column-account { width: 200px; }
.banking-statements .banking-statement-column-period { width: 200px; }
.banking-statements .banking-statement-column-reference { width: 150px; }
.banking-statements .banking-statement-column-format { width: 80px; }
.banking-statements .banking-statement-column-status { width: 100px; }
.banking-statements .banking-statement-column-balance { width: 110px; }
.banking-statements .banking-statement-column-attention { width: 170px; }
.banking-statements .banking-statement-column-booked { width: 90px; }
.banking-statements .banking-statement-column-closing-balance { width: 160px; }

.banking-transactions .banking-column-source-statement { width: var(--banking-statement-max-width); }
.banking-statements .banking-statement-column-amount { width: 125px; }

.banking-transactions td[data-ap-column="source-statement"] {
  width: 1%;
}

.banking-transactions td[data-ap-column="source-statement"] > a {
  display: block;
  width: max-content;
  max-width: calc(var(--banking-statement-max-width) - 16px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.banking-statements .banking-upload-attempt-row[data-upload-status="failed"] {
  cursor: pointer;
}

.banking-statements .banking-upload-attempt-row[data-upload-status="failed"]:hover {
  background: var(--bg-subtle);
}

.banking-statements .banking-upload-attempt-row td {
  white-space: normal;
  vertical-align: middle;
}

.banking-statements .banking-upload-attempt-row td:first-child {
  white-space: nowrap;
}

.banking-upload-attempt-meta {
  display: block;
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  color: var(--fg-subtle);
  font-size: 12px;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.banking-upload-attempt-account,
.banking-upload-attempt-file-name,
.banking-upload-attempt-failure-summary {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banking-upload-attempt-file-name {
  color: var(--fg-subtle);
  font-size: 12px;
}

.banking-upload-attempt-status {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--danger-border);
  border-radius: var(--r-sm);
  background: var(--danger-tint);
  color: var(--danger-strong);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.banking-upload-attempt-status iconify-icon {
  font-size: 14px;
}

.banking-upload-attempt-status.is-checking {
  border-color: var(--info-border);
  background: var(--info-tint);
  color: var(--brand);
}

.banking-statements .banking-upload-attempt-row[data-upload-failure]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.banking-upload-failure-modal .modal-content {
  width: min(520px, calc(100vw - 32px));
}

.banking-upload-failure-modal .modal-body h4 {
  margin: 16px 0 6px;
}

.banking-upload-failure-modal .modal-body h4:first-of-type {
  margin-top: 0;
}

.banking-upload-failure-modal .modal-body p {
  margin-bottom: 0;
  color: var(--fg);
  line-height: 1.45;
}

.banking-upload-failure-modal .modal-body .banking-upload-failure-file {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--fg-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.banking-upload-failure-modal .modal-body .banking-upload-attempt-no-payments {
  margin-top: 16px;
  color: var(--fg-muted);
  font-size: 12px;
}

.banking-upload-failure-modal .modal-actions {
  flex-wrap: wrap;
}

.banking-upload-failure-modal .modal-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (min-width: 721px) and (max-width: 1399px) {
  #banking-page-body.banking-page-body {
    container-type: inline-size;
    overflow-x: auto;
  }

  #banking-page-body.banking-page-body > .banking-statements {
    width: 1440px;
    min-width: 1440px;
  }

  .banking-statements .banking-statement-column-uploaded { width: 150px; }
  .banking-statements .banking-statement-column-account { width: 175px; }
  .banking-statements .banking-statement-column-period { width: 180px; }
  .banking-statements .banking-statement-column-amount { width: 125px; }
  .banking-statements .banking-statement-column-reference { width: 135px; }
  .banking-statements .banking-statement-column-format { width: 70px; }
  .banking-statements .banking-statement-column-status { width: 125px; }
  .banking-statements .banking-statement-column-balance { width: 145px; }
  .banking-statements .banking-statement-column-attention { width: 240px; }
  .banking-statements .banking-statement-column-booked { width: 70px; }
  .banking-statements .banking-statement-column-closing-balance { width: 150px; }

  .banking-statements .banking-upload-attempt-file-name {
    overflow: hidden;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }
}

.accounting-table .accounting-column-action { width: 17%; }
.accounting-table .accounting-column-econ-date { width: 10%; }
.accounting-table .accounting-column-context { width: 32%; }
.accounting-table .accounting-column-amount { width: 13%; }
.accounting-table .accounting-column-detected { width: 15%; }
.accounting-table .accounting-column-origin { width: 13%; }

@media (min-width: 1400px) {
  .accounting-table .accounting-column-action { width: 12%; }
  .accounting-table .accounting-column-context { width: 37%; }
}

.accounting-table td:first-child .table-status-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accounting-exceptions td .table-status-pill {
  box-sizing: border-box;
  display: inline-block;
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 22px;
  padding: 3px 11px;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.accounting-open-items .accounting-open-item-column-account { width: 220px; }
.accounting-open-items .accounting-open-item-column-reference { width: 180px; }
.accounting-open-items .accounting-open-item-column-kind { width: 140px; }
.accounting-open-items .accounting-open-item-column-amount { width: 240px; }
.accounting-open-items th[data-column-filter="amount"] {
  min-width: 240px;
  white-space: nowrap;
  overflow-wrap: normal;
}
.accounting-open-items th[data-column-filter="amount"].column-filter-header .column-filter-heading-controls {
  display: inline-flex;
}
.accounting-open-items .accounting-open-item-column-doc { width: 100px; }
.accounting-open-items .accounting-open-item-column-booked { width: 110px; }
.accounting-open-items .accounting-open-item-column-due { width: 100px; }
.accounting-open-items .accounting-open-item-column-days-overdue { width: 100px; }
.accounting-open-items .accounting-open-item-column-candidates { width: 200px; }
.accounting-open-items .accounting-candidate-count-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Exceptions has no optional columns. */
.accounting-exceptions .accounting-column-action { width: 150px; }
.accounting-exceptions .accounting-column-econ-date { width: 120px; }
.accounting-exceptions .accounting-column-context { width: 360px; }
.accounting-exceptions .accounting-column-amount { width: 160px; }
.accounting-exceptions .accounting-column-detected { width: 140px; }
.accounting-exceptions .accounting-column-origin { width: 90px; }

.accounting-clearings {
  table-layout: auto;
  width: max-content;
}

/* Long values in other columns keep their existing truncation. */
.accounting-clearings th:not(.accounting-exported-on-cell):not(.accounting-export-file-cell),
.accounting-clearings td:not(.accounting-exported-on-cell):not(.accounting-export-file-cell) {
  max-width: 0;
}

.accounting-clearings .accounting-exported-on-text {
  display: inline-block;
  width: max-content;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.accounting-clearings .clearing-export-link {
  display: inline-flex;
  width: max-content;
  max-width: 440px;
}

.accounting-clearings .accounting-clearing-column-select { width: 40px; }
.accounting-clearings .accounting-clearing-column-created { width: 130px; }
.accounting-clearings .accounting-clearing-column-reference { width: 150px; }
.accounting-clearings .accounting-clearing-column-actor { width: 120px; }
.accounting-clearings .accounting-clearing-column-origin { width: 140px; }
.accounting-clearings .accounting-clearing-column-account { width: 220px; }
.accounting-clearings .accounting-clearing-column-amount { width: 130px; }
.accounting-clearings .accounting-clearing-column-difference { width: 130px; }
.accounting-clearings .accounting-clearing-column-state { width: 100px; }
/* Export content determines these widths, bounded by its wrappers. */
.accounting-clearings .accounting-clearing-column-export { width: 1px; }
.accounting-clearings .accounting-clearing-column-exported-on { width: 1px; }

/* Hidden optional columns reduce each table's minimum scroll width. These
   preference classes are already applied to #ap-column-preferences. */
#ap-column-preferences.ap-hide-item {
  --accounting-open-item-kind-hidden: 140px;
}
#ap-column-preferences.ap-hide-document-date {
  --accounting-open-item-doc-hidden: 100px;
}
#ap-column-preferences.ap-hide-booked {
  --accounting-open-item-booked-hidden: 110px;
}
#ap-column-preferences.ap-hide-days-overdue {
  --accounting-open-item-days-hidden: 100px;
}
#ap-column-preferences.ap-hide-candidates {
  --accounting-open-item-candidates-hidden: 200px;
}

#ap-column-preferences.ap-hide-actor {
  --accounting-clearing-actor-hidden: 120px;
}
#ap-column-preferences.ap-hide-origin {
  --accounting-clearing-origin-hidden: 140px;
}
#ap-column-preferences.ap-hide-exported-on {
  --accounting-clearing-exported-hidden: 180px;
}
#ap-column-preferences.ap-hide-export {
  --accounting-clearing-export-file-hidden: 140px;
}

#ap-column-preferences[data-preference-view="banking-transactions"].ap-hide-direction {
  --banking-direction-hidden: 100px;
}
#ap-column-preferences[data-preference-view="banking-transactions"].ap-hide-payment-type {
  --banking-payment-type-hidden: 140px;
}
#ap-column-preferences[data-preference-view="banking-transactions"].ap-hide-reference {
  --banking-reference-hidden: 160px;
}
#ap-column-preferences[data-preference-view="banking-transactions"].ap-hide-remaining {
  --banking-remaining-hidden: 160px;
}
#ap-column-preferences[data-preference-view="banking-transactions"].ap-hide-matched-to {
  --banking-matched-to-hidden: 220px;
}
#ap-column-preferences[data-preference-view="banking-transactions"].ap-hide-matched-by {
  --banking-matched-by-hidden: 180px;
}
.banking-transactions {
  min-width: calc(2090px
    - var(--banking-direction-hidden, 0px)
    - var(--banking-payment-type-hidden, 0px)
    - var(--banking-reference-hidden, 0px)
    - var(--banking-remaining-hidden, 0px)
    - var(--banking-matched-to-hidden, 0px)
    - var(--banking-matched-by-hidden, 0px));
}

#ap-column-preferences[data-preference-view="banking-statements"].ap-hide-uploaded {
  --banking-uploaded-hidden: 120px;
}
#ap-column-preferences[data-preference-view="banking-statements"].ap-hide-reference {
  --banking-statement-reference-hidden: 150px;
}
#ap-column-preferences[data-preference-view="banking-statements"].ap-hide-format {
  --banking-format-hidden: 80px;
}
#ap-column-preferences[data-preference-view="banking-statements"].ap-hide-balance-check {
  --banking-balance-hidden: 110px;
}
#ap-column-preferences[data-preference-view="banking-statements"].ap-hide-booked {
  --banking-booked-hidden: 90px;
}
.banking-statements {
  min-width: calc(1380px
    - var(--banking-uploaded-hidden, 0px)
    - var(--banking-statement-reference-hidden, 0px)
    - var(--banking-format-hidden, 0px)
    - var(--banking-balance-hidden, 0px)
    - var(--banking-booked-hidden, 0px));
}

.banking-amount-inflow,
.banking-amount-outflow {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.banking-amount-inflow {
  color: var(--success-strong);
}

.banking-amount-outflow {
  color: var(--danger-strong);
}

.table tbody tr.highlighted,
li.settlement-deduction:target {
  animation: highlight-fade 4s ease-out;
}
@keyframes highlight-fade {
  0%, 50% {
    background: rgba(10, 109, 189, 0.25);
  }
  100% {
    background: transparent;
  }
}

/* New row entrance animation */
@keyframes row-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.row-new { animation: row-slide-in 0.3s ease-out; }

/* Documents page: fixed header + scrollable table area */
.documents-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Needs Review pages use the shared light surface and flow vertically. */
.content-payable-review {
  background: var(--surface);
}

.payable-review-page {
  background: var(--surface);
  font-family: var(--font-sans);
  overflow-y: auto;
}

.payable-review-page > .page-header {
  flex: 0 0 auto;
}

.payable-review-page > .data-panel {
  display: block;
  flex: 0 0 auto;
  overflow: visible;
}

/* Needs Review lists use the same white, scrollable table surface as Accounts
   Payable. Row navigation follows AP, so there is no per-row review action. */
.payable-review-page > .documents-scroll-area {
  padding-right: 14px;
  padding-bottom: 14px;
}
.payable-review-table {
  min-width: 760px;
}
.payable-correction-work-table {
  table-layout: fixed;
  min-width: 900px;
}
.payable-correction-work-table th:first-child {
  width: 110px;
}
.payable-correction-work-table th:nth-child(2) {
  width: 220px;
}
.payable-correction-work-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}
.payable-correction-work-invoice {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.payable-correction-work-invoice + .payable-correction-work-invoice {
  margin-top: 6px;
}

@media (max-width: 720px) {
  .payable-correction-work-table {
    min-width: 0;
  }
}
.payable-conflict-dismiss-form {
  display: grid;
  gap: 8px;
}
.payable-conflict-dismiss-form .text-input {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.payable-conflict-dismiss-form .btn {
  justify-self: start;
}
.payable-conflict-supersession-form {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.payable-conflict-supersession-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}
.payable-conflict-supersession-form legend {
  margin-bottom: 6px;
  font-weight: 600;
}
.payable-conflict-supersession-form .payable-resolution-option:has(input:disabled) {
  cursor: default;
  opacity: 0.7;
}
.payable-conflict-supersession-form .text-input {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.payable-conflict-supersession-form textarea {
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.payable-conflict-supersession-blocked {
  margin: 0;
  color: var(--fg-muted);
  font-size: 13px;
}
.payable-conflict-supersession-form .btn {
  justify-self: start;
}
.payable-review-evidence-assessment {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--info-border);
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.4;
}
.payable-review-description {
  flex: 0 0 auto;
  margin: 0;
  padding: 16px 14px 2px;
  color: var(--fg-muted);
  background: var(--surface);
  font-size: 14px;
}
.payable-review-page .empty-state {
  min-height: 180px;
  box-sizing: border-box;
  background: var(--surface);
}
.payable-review-page .payable-correction-work-form,
.payable-review-page .payable-review-archive-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.payable-review-page .payable-correction-work-form input {
  flex: 1 1 180px;
  min-width: 0;
  max-width: none;
}
.payable-review-page .payable-correction-work-receipt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.payable-review-page .payable-correction-work-receipt .payable-correction-work-form {
  align-self: stretch;
}
.payable-review-page .payable-review-archive-form input {
  min-width: 180px;
  max-width: 260px;
}
.payable-review-page > .data-panel {
  margin: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.payable-review-page > .data-panel h2 {
  margin: 0 0 14px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}
.payable-review-members-scroll {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px;
}
.payable-review-members-table {
  min-width: 1120px;
}
.payable-review-evidence-line {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-top: 10px;
}
.payable-review-evidence-line .field-label {
  flex: 0 0 140px;
  margin: 0;
}
.payable-review-evidence-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.payable-review-detail-page .badge-warning {
  flex: 0 0 auto;
  white-space: nowrap;
}
.payable-review-evidence-header h2 {
  margin-bottom: 0;
}
.payable-review-evidence-intro {
  margin: 6px 0 0;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.4;
}
.payable-review-evidence-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.payable-review-evidence-group {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.payable-review-evidence-group.is-different {
  background: var(--surface);
}
.payable-review-evidence-group-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.payable-review-evidence-group-header iconify-icon {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--brand);
  font-size: 16px;
}
.payable-review-evidence-group.is-different .payable-review-evidence-group-header iconify-icon {
  color: var(--warning-strong);
}
.payable-review-evidence-group-header strong {
  display: block;
}
.payable-review-evidence-group-header strong {
  font-size: 13px;
  line-height: 1.35;
}
.payable-review-evidence-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.payable-review-evidence-group.is-empty .payable-review-evidence-chips {
  min-height: 24px;
}
.payable-review-evidence-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 11px;
  font-weight: 600;
}
.payable-review-evidence-group.is-different .payable-review-evidence-chip {
  border-color: var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.payable-review-page .status-strip {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.payable-review-page .status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

#payable-review-list thead,
#payable-correction-work-list thead,
#payable-review-members thead,
#payable-review-list thead th,
#payable-correction-work-list thead th,
#payable-review-members thead th {
  background: var(--surface);
}

#payable-review-list tbody tr:last-child td,
#payable-correction-work-list tbody tr:last-child td,
#payable-review-members tbody tr:last-child td {
  border-bottom: none;
}
.payable-review-page #payable-review-list td.cell-mono.cell-muted,
.payable-review-page #payable-correction-work-list td.cell-mono.cell-muted {
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
}
.payable-review-page .payable-resolution-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.payable-review-page:has(.payable-review-members) {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--space-4);
  row-gap: var(--space-4);
}

.payable-review-page:has(.payable-review-members) > .page-header,
.payable-review-page:has(.payable-review-members) > .payable-review-description,
.payable-review-page:has(.payable-review-members) > .payable-review-members {
  grid-column: 1 / -1;
}

.payable-review-page:has(.payable-review-members) > .page-header {
  margin-bottom: 0;
  justify-content: flex-start;
}

.payable-review-page:has(.payable-review-members) > .page-header .page-header-left {
  flex: 0 0 auto;
}

.payable-review-page:has(.payable-review-members) > .page-header .page-header-actions {
  margin-left: 0;
}

.payable-review-page:has(.payable-review-members) > .payable-review-description {
  margin: 0;
}

.payable-review-page:has(.payable-review-members) > .data-panel {
  margin: 0;
}

.payable-review-page:has(.payable-review-members) > .payable-review-evidence {
  grid-row: 3;
  grid-column: 1;
}

.payable-review-page:has(.payable-review-members) > .payable-review-resolution,
.payable-review-page:has(.payable-review-members) > .payable-review-dismiss {
  grid-column: 2;
}

.payable-review-page:has(.payable-review-members) > .payable-review-resolution {
  grid-row: 3;
}

.payable-review-page:has(.payable-review-members) > .payable-review-members {
  grid-row: 4;
}

.payable-review-page:has(.payable-review-members) > .payable-review-dismiss {
  grid-row: 5;
}

@media (max-width: 720px) {
  .payable-review-page > .page-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .payable-review-page:has(.payable-review-members) {
    display: flex;
  }
  .payable-review-evidence-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
  .payable-review-evidence-header {
    flex-direction: column;
  }
  .payable-review-evidence-summary {
    grid-template-columns: 1fr;
  }
  .payable-review-page > .data-panel {
    margin: 10px;
    padding: 12px;
  }
}

/* Needs Review detail follows the accounting workbench: context and
   resolution share the first row, while the documents occupy the full width
   below it. The page-level grid rules above predate this grouped markup. */
.payable-review-page:has(.payable-review-members) {
  display: block;
  overflow-y: auto;
}
.payable-review-page:has(.payable-review-members) > .page-header {
  margin: 0;
}
.payable-review-page:has(.payable-review-members) > .payable-review-description {
  margin: 0;
}
.payable-review-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 28px;
  margin: 14px;
}
.payable-review-top-row > .data-panel {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.payable-review-resolution-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.payable-review-resolution-panel > h2 {
  margin: 0;
}
.payable-review-resolution-panel .payable-resolution-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: none;
}
.payable-resolution-stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.payable-resolution-step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--fg-subtle);
  font-size: 12px;
  font-weight: 600;
}
.payable-resolution-step:not(:last-child)::after {
  content: "";
  height: 1px;
  flex: 1;
  margin: 0 10px;
  background: var(--border);
}
.payable-resolution-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg-muted);
  font-size: 11px;
}
.payable-resolution-step.is-active,
.payable-resolution-step.is-complete {
  color: var(--brand);
}
.payable-resolution-step.is-active .payable-resolution-step-number,
.payable-resolution-step.is-complete .payable-resolution-step-number {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--surface);
}
.payable-resolution-step-panel {
  display: grid;
  gap: 8px;
}
.payable-resolution-step-panel[hidden] {
  display: none;
}
.payable-resolution-step-heading {
  margin: 0;
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
}
.payable-resolution-step-copy {
  margin: 0 0 3px;
  color: var(--fg-muted);
  font-size: 12px;
}
.payable-resolution-step-panel .payable-resolution-options {
  gap: 7px;
}
.payable-resolution-step-panel .payable-resolution-option {
  padding: 10px;
}
.payable-resolution-step-panel .payable-resolution-option:has(input:disabled) {
  cursor: default;
}
.payable-resolution-summary {
  margin: 2px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--info-border);
  border-radius: var(--r-md);
  background: var(--info-tint);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.45;
}
.payable-resolution-notes {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-muted);
}
.payable-resolution-notes-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.payable-resolution-notes-header label {
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
}
.payable-resolution-notes-header span,
.payable-resolution-notes-copy {
  color: var(--fg-muted);
  font-size: 11px;
}
.payable-resolution-notes-copy {
  margin: 0;
}
.payable-resolution-notes textarea {
  width: 100%;
  min-height: 96px;
  box-sizing: border-box;
  padding: 10px 12px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.payable-resolution-notes textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.payable-resolution-notes textarea::placeholder {
  color: var(--fg-subtle);
}
.payable-resolution-step-controls [hidden] {
  display: none;
}
.payable-resolution-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--danger-border, #e7b8b8);
  border-radius: var(--r-md);
  background: var(--danger-bg, #fff4f4);
  color: var(--danger, #a33a3a);
  font-size: 12px;
}
.payable-resolution-step-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}
.payable-resolution-step-controls > span:last-child {
  display: flex;
  gap: 8px;
}
.payable-resolution-status {
  color: var(--fg-muted);
  font-size: 12px;
}
.payable-resolution-status strong {
  color: var(--fg);
  font-weight: 600;
}
.payable-review-dismiss {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.payable-review-dismiss summary {
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  list-style-position: inside;
}
.payable-review-dismiss[open] summary {
  margin-bottom: 10px;
  color: var(--fg);
}
.payable-review-dismiss-content {
  display: grid;
  gap: 8px;
}
.payable-review-dismiss-content p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
}
.payable-review-dismiss-content form {
  display: grid;
  gap: 8px;
}
.payable-review-dismiss-content .field-group {
  margin: 0;
}
.payable-review-dismiss-content input {
  width: 100%;
  box-sizing: border-box;
}
.payable-review-resolution-panel .field-group,
.payable-review-resolution-panel section {
  margin: 0;
}
/* The stepper already supplies the single divider before the active step.
   Do not add another one merely because the panels are adjacent sections. */
.payable-review-resolution-panel section + section {
  padding-top: 0;
  border-top: 0;
}
.payable-review-resolution-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(180px, .8fr);
  gap: 16px;
  align-items: start;
}
.payable-review-resolution-actions > section {
  min-width: 0;
  margin: 0;
}
.payable-review-resolution-actions > section + section {
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.payable-review-resolution-actions h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}
.payable-review-resolution-actions .payable-resolution-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 12px;
}
.payable-review-resolution-actions .payable-resolution-form > .field-group,
.payable-review-resolution-actions .payable-resolution-form > button {
  grid-column: 1 / -1;
}
.payable-review-resolution-actions .payable-resolution-form > .field-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.payable-review-resolution-actions .payable-resolution-form textarea {
  min-height: 34px;
  height: 34px;
  flex: 1;
  resize: vertical;
}
.payable-review-resolution-actions .payable-resolution-group {
  min-width: 0;
}
.payable-review-resolution-actions .payable-resolution-heading {
  margin-bottom: 6px;
  font-size: 12px;
}
.payable-review-resolution-actions .payable-resolution-options {
  gap: 5px;
}
.payable-review-resolution-actions .payable-resolution-option {
  padding: 7px 8px;
}
.payable-review-resolution-actions .payable-resolution-option small {
  line-height: 1.25;
}
.payable-review-resolution-actions form:not(.payable-resolution-form) .field-group {
  margin: 0 0 10px;
}
.payable-review-resolution-actions form:not(.payable-resolution-form) input {
  width: 100%;
  box-sizing: border-box;
}
.payable-review-members {
  margin: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.payable-review-members > h2 {
  margin: 0 0 14px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
}
.payable-review-document-grid {
  align-items: stretch;
}
.payable-review-document-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.payable-review-document-card > header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.payable-review-document-card > header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.payable-review-document-card > header p {
  margin: 4px 0 0;
  color: var(--fg-muted);
  font-size: 13px;
}
.payable-review-document-card .panel-company {
  color: var(--fg-muted);
  font-size: 13px;
}
.payable-review-document-card .pdf-panel {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: min(72vh, 820px);
  min-height: 520px;
  flex: 0 0 auto;
  border-right: 0;
  border-bottom: 1px solid var(--border);
  resize: none;
}
.payable-review-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.payable-review-document-card > .li-detail-grid,
.payable-review-document-card > .field-group,
.payable-review-document-card > .payable-review-archive-form {
  margin: 0;
  padding: 14px 16px;
}
.payable-review-document-card > .payable-review-archive-form {
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .payable-review-top-row {
    grid-template-columns: 1fr;
  }
  .payable-review-document-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .payable-review-page .payable-correction-work-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .payable-correction-work-table tbody,
  .payable-correction-work-table tr,
  .payable-correction-work-table td {
    display: block;
    width: auto;
  }
  .payable-correction-work-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .payable-correction-work-table td {
    padding: 6px 12px;
    border-bottom: 0;
  }
  .payable-review-top-row,
  .payable-review-members {
    margin: 10px;
  }
  .payable-review-document-card .pdf-panel {
    height: 600px;
    min-height: 360px;
  }
  .payable-resolution-stepper {
    grid-template-columns: 1fr;
    gap: 7px;
    border-bottom: 0;
    padding-bottom: 0;
  }
  .payable-resolution-step:not(:last-child)::after {
    display: none;
  }
  .payable-resolution-step-controls {
    align-items: flex-start;
    flex-direction: column;
  }
}

.documents-scroll-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  /* Full-bleed WHITE surface: the table area is white (design), not the sand
     canvas. The toolbar hairline lives on .page-header's border-bottom so it
     aligns with the sidebar logo row. */
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding-left: 14px;
  scrollbar-width: auto;
  scrollbar-color: var(--fg-faint) var(--bg-muted);
}

/* Full-bleed list pages: cancel the content gutter, restore padding on the
   toolbar only so filters don't touch the edges. The toolbar is white too,
   so the whole list surface reads white on the sand app canvas. */
.content:has(.documents-page) {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}
.documents-page > .page-header {
  /* Bottom hairline lives here (not on the scroll area below) so it lines up
     with the sidebar logo row's border-bottom. min-height matches the logo
     row's 51px exactly, regardless of which filters are present (AP vs AR),
     so the toolbar bottom border always aligns with the logo's. */
  min-height: 51px;
  padding: 6px 14px;
  margin-bottom: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.deduction-clearing-page > .page-header {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.deduction-clearing-page > .page-header .page-header-left {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}
.deduction-clearing-page > .page-header .page-header-actions {
  flex-wrap: wrap;
}
.deduction-clearing-page .deduction-clearing-list-search {
  display: flex;
  flex: 1 1 240px;
  min-width: 180px;
  align-items: center;
  position: relative;
}
.deduction-clearing-page .deduction-clearing-list-search .search-input {
  width: 100%;
  min-width: 0;
}
.deduction-clearing-page .deduction-clearing-export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.deduction-clearing-export [data-export-error] {
  order: 1;
  flex-basis: 100%;
  margin: 0;
  color: var(--danger);
}
.deduction-clearing-page .deduction-clearing-export .modal-actions {
  margin-top: 0;
}
.deduction-clearing-export-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.deduction-clearing-export-range-label {
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.deduction-clearing-page .date-filter-group {
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--border);
}
.deduction-clearing-page .date-filter-group:last-child {
  border-bottom: none;
}
.deduction-clearing-page .deduction-clearing-date-filter > .filter-dropdown-panel {
  left: auto;
  right: 0;
}
.deduction-clearing-page .date-filter-group-label {
  padding: 4px 12px 2px;
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.deduction-clearing-page .date-filter-basis-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 600;
}
.deduction-clearing-page .date-filter-basis {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}
@media (max-width: 900px) {
  .deduction-clearing-page > .page-header .page-header-left,
  .deduction-clearing-page > .page-header .page-header-actions {
    width: 100%;
  }
  .deduction-clearing-page > .page-header .page-header-actions {
    justify-content: flex-start;
  }
}
.documents-scroll-area::-webkit-scrollbar {
  width: 12px;
}
.documents-scroll-area::-webkit-scrollbar-track {
  background: var(--bg-muted);
  border-radius: var(--r-lg);
}
.documents-scroll-area::-webkit-scrollbar-thumb {
  background: var(--fg-faint);
  border-radius: var(--r-lg);
  border: 2px solid var(--bg-muted);
}
.documents-scroll-area::-webkit-scrollbar-thumb:hover {
  background: var(--fg-subtle);
}

/* Document list table styling */
#document-list .table,
#doc-mgmt-list {
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}
.documents-scroll-area thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
#document-list thead,
#doc-mgmt-list thead,
#history-list thead {
  background: var(--surface);
}
#document-list thead th,
#doc-mgmt-list thead th,
#history-list thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#document-list tbody tr:last-child td,
#doc-mgmt-list tbody tr:last-child td,
#history-list tbody tr:last-child td {
  border-bottom: none;
}

/* Imported History (/records/history): AP's list shell with a single
   Filters panel, since the source filters are free text rather than option
   lists. */
.history-toolbar .filter-dropdown-trigger iconify-icon:first-child {
  color: var(--fg-muted);
}
.history-toolbar .filter-dropdown-trigger.has-selection iconify-icon:first-child {
  color: inherit;
}
.history-filter-panel {
  width: min(440px, calc(100vw - 32px));
  min-width: 0;
  max-width: none;
  max-height: min(560px, 75vh);
}
/* Date basis (Transactions only), the Amount group, the short pickers two per row,
   then Include replaced versions; an odd last picker takes the whole row. */
.history-filter-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  min-height: 0;
  overflow-y: auto;
}
.history-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
.history-filter-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.history-filter-amount {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.history-filter-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
}
.history-filter-group-hint {
  margin-left: 6px;
  font-weight: 500;
  color: var(--fg-subtle);
}
.history-filter-amount-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.history-filter-amount-row .history-filter-field { font-size: 11px; }
.history-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
.history-filter-input {
  height: 32px;
  box-sizing: border-box;
  width: 100%;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
}
.history-filter-input:focus {
  outline: none;
  border-color: var(--brand);
}
.history-filter-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--fg);
}
.history-filter-check small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--fg-subtle);
}
/* On narrow screens the search box gives way first; when the toolbar still wraps, the
   pills move to a second row together and the actions stay on the first. */
.history-toolbar { align-items: flex-start; }
.history-toolbar .page-header-left { flex: 1 1 auto; flex-wrap: wrap; row-gap: 8px; }
.history-toolbar-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.history-toolbar .search-container { flex: 1 1 160px; min-width: 150px; max-width: 240px; }
.history-toolbar .search-input { width: 100%; }
/* The toolbar form carries the live-search state; its spinner sits inside the search container. */
.history-toolbar[data-search-state="searching"] .search-container > .search-icon { visibility: hidden; }
.history-toolbar[data-search-state="searching"] .search-container > .list-search-spinner { display: block; }
.history-panel-scope { display: flex; flex-direction: column; min-height: 0; }
.history-accounting .filter-dropdown-panel {
  min-width: min(320px, calc(100vw - 32px));
  max-width: min(360px, calc(100vw - 32px));
  max-height: min(460px, 75vh);
}
.history-accounting .filter-category-detail:not([hidden]) { display: flex; min-height: 0; }
.history-accounting .filter-dropdown-options { flex: 1 1 auto; min-height: 0; max-height: 300px; overflow-y: auto; }
.history-accounting .option-number { display: inline-block; min-width: 64px; font-family: var(--font-mono); color: var(--fg); }
.history-accounting .option-name { color: var(--fg-muted); }
.history-date .filter-dropdown-panel { min-width: 260px; max-height: min(480px, 75vh); }
.history-date .filter-dropdown-options { flex: 1 1 auto; min-height: 0; }
.history-panel-title { margin: 0; padding: 8px 12px 2px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-muted); }
.history-panel-loading, .history-panel-note { margin: 0; padding: 8px 12px; font-size: 12px; color: var(--fg-muted); }
.history-toolbar .nav-arrow iconify-icon {
  font-size: 16px;
}
#history-list .history-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
#history-list tbody tr:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
#history-list th.history-amount-col,
#history-list td.cell-amount {
  text-align: right;
}
#history-list {
  table-layout: fixed;
  /* Below this the fixed columns leave the text columns too narrow for their
     sort and filter controls; the scroll area scrolls instead. */
  min-width: 1040px;
}
/* Posting lines add two fixed columns: their fixed columns are a little narrower and the
   table a little wider, so Counterparty and Description keep room for their controls. */
#history-list.history-list-postings { min-width: 1200px; }
#history-list.history-list-postings .history-col-date { width: 112px; }
#history-list.history-list-postings .history-col-reference { width: 152px; }
#history-list.history-list-postings .history-col-cost { width: 156px; }
#history-list.history-list-postings .history-amount-col { width: 132px; }
#history-list.history-list-postings .history-col-source { width: 124px; }
#history-list .history-col-date { width: 124px; }
#history-list .history-col-reference { width: 168px; }
#history-list .history-col-posting { width: 176px; }
#history-list .history-amount-col { width: 148px; }
#history-list .history-col-source { width: 128px; }
#history-list .history-col-status { width: 144px; }
#history-list td.history-cost-cell { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#history-list td.history-cost-cell .cell-mono + .cell-muted { margin-left: 6px; }
#history-list td.cell-truncate {
  max-width: none;
}
#history-list td.cell-truncate .truncate-inner {
  overflow: hidden;
  text-overflow: ellipsis;
}
#history-list td.cell-mono {
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-source-pill {
  --table-status-pill-width: 84px;
}
.history-detail-fields .table-status-pill {
  width: auto;
  min-width: 72px;
}
.history-replaced-badge {
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
#history-list .history-empty-row td {
  padding: 48px;
  text-align: center;
  color: var(--fg-subtle);
  white-space: normal;
}
#history-list tbody tr.is-selected td { background: var(--brand-tint); }
#history-list .ap-selection-note { color: var(--danger-strong); white-space: normal; }
/* The bar fits inside the column row's height, so swapping the rows moves nothing. */
#history-list .ap-selection-row th { padding-top: 4px; padding-bottom: 4px; }
.history-export-btn {
  box-sizing: border-box;
  flex-shrink: 0;
  gap: 6px;
  height: 32px;
  padding-block: 0;
  line-height: normal;
  white-space: nowrap;
}
.history-export-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.history-export-feedback { font-size: 12px; color: var(--fg-subtle); white-space: normal; }
.history-missing {
  color: var(--fg-subtle);
}
.history-restart {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 24px;
  background: var(--surface);
  text-align: center;
  color: var(--fg-muted);
}
.history-restart p {
  margin: 0;
  font-size: 14px;
}

/* Imported History source detail: rendered into the shared History modal,
   or on its own page when opened directly. A source record is often short,
   so the modal fits its content up to the shared modal height. */
dialog#history-detail.history-modal {
  height: fit-content;
  max-height: min(720px, 85vh);
}
#history-detail .history-modal-content {
  height: auto;
}
#history-detail .history-source-detail {
  max-height: min(720px, 85vh);
}
.history-source-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--surface);
}
.history-detail-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--fg-subtle);
}
.history-detail-note {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--fg-muted);
}
.history-detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 24px;
  margin: 0 0 8px;
}
.history-detail-fields dt {
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
.history-detail-fields dd {
  margin: 0;
  font-size: 14px;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.history-detail-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.history-detail-section h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.history-detail-empty {
  margin: 0;
  font-size: 13px;
  color: var(--fg-subtle);
}
.history-detail-table {
  overflow-x: auto;
}
.history-code {
  display: flex;
  flex-direction: column;
}
.history-code-number {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.history-code-name {
  font-size: 12px;
  color: var(--fg-muted);
}
/* Account and cost codes keep both lines but clip each to the cell. */
.history-detail-table .table td.cell-truncate {
  max-width: 200px;
}
.history-code > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-detail-table .table td.history-wrap-cell {
  min-width: 220px;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.history-detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.history-detail-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
/* With a PDF original the detail mirrors the AP document view: record data
   scrolls on the left, the original fills the right. */
dialog#history-detail.history-modal:has(.history-detail-split) {
  width: min(1480px, 96vw);
  height: min(900px, 92vh);
  max-height: none;
}
#history-detail:has(.history-detail-split) .history-modal-content,
#history-detail .history-source-detail:has(.history-detail-split) {
  height: 100%;
  max-height: none;
}
.history-modal-body.history-detail-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 24px;
  overflow: hidden;
  padding-right: 20px;
}
.history-detail-split .history-detail-main {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.history-detail-original {
  min-height: 0;
  display: flex;
}
.history-original-viewer {
  display: block;
  flex: 1;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-muted);
}
/* Stacked below 1100px: the record data takes its full content height and
   the original follows at a fixed viewer height; the body scrolls both. */
@media (max-width: 1100px) {
  .history-modal-body.history-detail-split {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    overflow-y: auto;
  }
  .history-detail-split .history-detail-main {
    min-height: auto;
    overflow: visible;
    padding-right: 0;
  }
  .history-detail-original {
    height: min(80vh, 760px);
    min-height: 480px;
  }
}
.history-file-icon {
  font-size: 16px;
  color: var(--fg-muted);
}
.history-file-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.history-detail-table .table td.cell-amount,
.history-detail-table .table td.cell-mono {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
}
.history-detail-table .table tbody tr[hx-get]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* Deduction Clearing overview keeps the whole row readable in its own
   horizontal scroller; optional columns reduce the minimum when hidden. */
.deduction-table {
  table-layout: fixed;
  min-width: calc(2415px
    - var(--deduction-document-type-hidden, 0px)
    - var(--deduction-document-number-hidden, 0px)
    - var(--deduction-provider-hidden, 0px)
    - var(--deduction-transaction-type-hidden, 0px)
    - var(--deduction-condition-hidden, 0px)
    - var(--deduction-brand-hidden, 0px)
    - var(--deduction-unit-rate-hidden, 0px)
    - var(--deduction-matches-hidden, 0px)
    - var(--deduction-settlement-number-hidden, 0px));
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-document-type {
  --deduction-document-type-hidden: 120px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-document-number {
  --deduction-document-number-hidden: 140px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-provider {
  --deduction-provider-hidden: 140px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-transaction-type {
  --deduction-transaction-type-hidden: 150px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-condition {
  --deduction-condition-hidden: 150px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-brand {
  --deduction-brand-hidden: 100px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-unit-rate {
  --deduction-unit-rate-hidden: 110px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-matches {
  --deduction-matches-hidden: 110px;
}
#ap-column-preferences[data-preference-view="deductions"].ap-hide-settlement-number {
  --deduction-settlement-number-hidden: 150px;
}
.deduction-table th,
.deduction-table td {
  padding-right: 8px;
  padding-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Widths by position; hidden optional columns still count as children. */
.deduction-table th:nth-child(1),
.deduction-table td:nth-child(1) { width: 105px; } /* Date */
.deduction-table th:nth-child(2),
.deduction-table td:nth-child(2) { width: 120px; } /* Document type */
.deduction-table th:nth-child(3),
.deduction-table td:nth-child(3) { width: 140px; } /* Document no. */
.deduction-table th:nth-child(4),
.deduction-table td:nth-child(4) { width: 140px; } /* Provider */
.deduction-table th:nth-child(5),
.deduction-table td:nth-child(5) { width: 180px; } /* Counterparty */
.deduction-table th:nth-child(6),
.deduction-table td:nth-child(6) { width: 160px; } /* Reason */
.deduction-table th:nth-child(7),
.deduction-table td:nth-child(7) { width: 100px; } /* Team */
.deduction-table th:nth-child(8),
.deduction-table td:nth-child(8) { width: 110px; } /* Work status */
.deduction-table th:nth-child(9),
.deduction-table td:nth-child(9) { width: 150px; } /* Transaction type */
.deduction-table th:nth-child(10),
.deduction-table td:nth-child(10) { width: 150px; } /* Condition */
.deduction-table th:nth-child(11),
.deduction-table td:nth-child(11) { width: 100px; } /* Brand */
.deduction-table th:nth-child(12),
.deduction-table td:nth-child(12) { width: 110px; } /* Unit rate */
.deduction-table th:nth-child(13),
.deduction-table td:nth-child(13) { width: 130px; } /* Claim amount */
.deduction-table th:nth-child(14),
.deduction-table td:nth-child(14) { width: 130px; } /* Cash effect */
.deduction-table th:nth-child(15),
.deduction-table td:nth-child(15) { width: 110px; } /* Matches */
.deduction-table th:nth-child(16),
.deduction-table td:nth-child(16) { width: 150px; } /* Settlement no. */
.deduction-table th:nth-child(17),
.deduction-table td:nth-child(17) { width: 150px; } /* Financial state */
.deduction-table th:nth-child(18),
.deduction-table td:nth-child(18) { width: 180px; } /* Validation */
/* Let the final validation badge extend beyond its cell rather than clip. */
.deduction-table th:last-child,
.deduction-table td:last-child {
  overflow: visible;
}

main.content {
  min-width: 0;
}

.accounting-page,
.banking-page,
.deduction-clearing-page,
.payable-review-page {
  min-width: 0;
}

.accounting-page .documents-scroll-area,
#deduction-clearing-page-body,
.payable-review-page > .documents-scroll-area {
  min-width: 0;
  overflow: auto;
}

.accounting-page .documents-scroll-area::-webkit-scrollbar,
.banking-page-body::-webkit-scrollbar,
#deduction-clearing-page-body::-webkit-scrollbar,
.payable-review-page > .documents-scroll-area::-webkit-scrollbar {
  height: 12px;
}

/* Document navigation arrows */
.document-navigation {
  display: flex;
  gap: 8px;
}
.nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 18px;
  transition: all 0.15s ease;
  cursor: pointer;
}
.nav-arrow:hover {
  background: var(--bg-muted);
  color: var(--fg);
  text-decoration: none;
}
.nav-arrow.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--fg-muted);
}
.empty-state p {
  margin: 8px 0;
}

/* File upload */
.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: normal;
  transition: background 0.15s;
}
.file-upload-label:not([aria-disabled="true"]):hover {
  background: var(--brand-hover);
}

/* Upload trigger button (AP / Document Management page headers) */
.upload-trigger-btn {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  gap: 8px;
  height: 32px;
  padding: 8px 16px;
  border-radius: var(--r-lg);
  background: var(--brand);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: normal;
  transition: background 0.15s;
}
.upload-trigger-btn:not([aria-disabled="true"]):hover {
  background: var(--brand-hover);
}

.ar-create-invoice-button {
  height: 32px;
  padding-top: 4px;
  padding-bottom: 4px;
}

/* Sidebar pipeline activity indicator */
.sidebar-activity-row {
  display: flex;
  align-items: center;
  gap: clamp(4px, calc(100% - 100px), 6px);
  margin: 12px 18px 10px;
  flex: none;
}
.sidebar-activity-row > .pipeline-indicator { flex: 1 1 auto; min-width: 0; }
.pipeline-indicator { position: relative; }
.sidebar-activity-row .pipeline-indicator-label { white-space: nowrap; }

/* Sized to sit level with a .nav-items row (6px + 24px + 6px + 2px border =
   38px), so the pill reads as part of the sidebar rather than a card looming
   over it. */
.pipeline-indicator-btn {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--fg);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: box-shadow 0.15s, transform 0.15s;
}
.pipeline-indicator-btn.visible {
  display: inline-flex;
}
.pipeline-indicator-btn:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.pipeline-indicator-btn:focus { outline: none; }
.pipeline-indicator-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.pipeline-indicator-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--brand);
}
.pipeline-indicator-chip iconify-icon {
  font-size: 12px;
}
.pipeline-indicator-chip.done {
  background: var(--success-tint);
  color: var(--success);
}
.pipeline-indicator-label {
  flex: 1;
  text-align: left;
  color: var(--fg);
  font-weight: 500;
}

/* The popover's own header/body/pop-file rules (below) are unchanged — only
   its anchor changes: it drops down from the pill and fills the sidebar's
   own width (same left/right inset the pill already has via
   .pipeline-indicator's margin), rather than flowing out to the right. */
.pipeline-indicator .upload-popover {
  /* .sidebar has overflow-y:auto for its own scrolling, which per the CSS
     overflow spec forces overflow-x to clip too — an absolutely-positioned
     popover can never visually escape the sidebar's bounds no matter what
     left/width it's given. position:fixed escapes that clipping (it's
     positioned against the viewport, not a scrolling ancestor); JS
     (orchaUpload.openPopover) sets top/left inline to sit just below the
     pill and flush with the sidebar's left edge, then this extends well
     past the sidebar's right edge into the content area for reading room.
     Overlapping the page below is intentional; the raised z-index on
     .sidebar keeps it on top. */
  position: fixed;
  right: auto;
  width: min(420px, calc(100vw - 20px));
}
.pipeline-indicator .upload-popover::before {
  top: -6px;
  left: var(--caret-left, 30px);
  right: auto;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-bottom: none;
}
/* Corner badge on the activity chip. */
.status-count {
  position: absolute;
  top: -6px;
  right: -7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--r-pill);
  box-shadow: 0 0 0 2px var(--surface);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
/* Idle/all-done state carries no count — the chip's own check icon and
   tint color signal "done" instead of a badge with nothing in it. */
.status-count:empty {
  display: none;
}

/* Upload popover */
@keyframes popover-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.upload-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 380px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  z-index: 100;
  animation: popover-enter 0.15s ease-out;
}
.upload-popover.visible {
  display: flex;
}
.upload-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  transform: rotate(45deg);
  z-index: 1;
}
.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  border-radius: 7px 7px 0 0;
  background: var(--bg-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.popover-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pop-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.pop-close:hover {
  color: var(--fg);
  background: var(--bg-muted);
}
.popover-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Empty state — rendered unconditionally as the body's last child and hidden
   the instant a row exists, so an upload swapped in `afterbegin` needs no JS
   to clear it (see `pipeline-indicator` in ui/components.clj). */
.popover-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 28px 24px;
}
.popover-body:has(.pop-file) .popover-empty {
  display: none;
}
.popover-empty iconify-icon {
  font-size: 24px;
  color: var(--fg-subtle);
}
.popover-empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.popover-empty-text {
  max-width: 260px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-muted);
}

/* Footer — the popover only holds the last few days of pipeline events, so it
   always offers the Audit Trail as the place to look further back. */
.popover-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 7px 7px;
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 500;
  color: var(--brand);
  text-decoration: none;
}
.popover-footer:hover {
  background: var(--bg-muted);
  text-decoration: none;
}
.popover-footer iconify-icon {
  font-size: 14px;
}

/* Batch separator */
.batch-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--bg-muted);
}
.batch-separator:first-child {
  border-top: none;
  margin-top: 0;
}
.batch-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--bg-muted);
}

/* Popover file items */
.pop-file {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  color: var(--fg);
  text-decoration: none;
  transition: background 0.1s;
  border-bottom: 1px solid var(--bg-muted);
}
.pop-file:last-child {
  border-bottom: none;
}
.pop-file:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}
.pop-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-lg);
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 1px;
}
.pop-file-icon.uploading {
  background: rgba(10, 109, 189, 0.15);
  color: var(--brand);
}
.pop-file-icon.classifying {
  background: rgba(191, 135, 0, 0.15);
  color: var(--warning);
}
.pop-file-icon.routing {
  background: rgba(10, 109, 189, 0.15);
  color: var(--brand);
}
.pop-file-icon.extracting,
.pop-file-icon.validating,
.pop-file-icon.accounting,
.pop-file-icon.finishing,
.pop-file-icon.processing {
  background: rgba(130, 80, 223, 0.15);
  color: var(--accent-violet);
}
.pop-file-icon.completed {
  background: rgba(26, 127, 55, 0.15);
  color: var(--success);
}
.pop-file-icon.failed {
  background: rgba(207, 34, 46, 0.15);
  color: var(--danger);
}
.pop-file-icon.skipped {
  background: rgba(121, 115, 107, 0.15);
  color: var(--fg-muted);
}
.pop-file-info {
  flex: 1;
  min-width: 0;
}
.pop-file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Status/type and source/tenant, each a label+value pair on one grid row --
   two rows share one grid so "Outgoing Invoice" and the tenant name line up
   under each other regardless of which label ("Completed" vs "Uploaded by
   Max") is longer; column 1 auto-sizes to the longer of the two. */
.pop-file-meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 10px;
  row-gap: 2px;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 500;
}
.pop-file-meta-label {
  color: var(--fg-muted);
  white-space: nowrap;
}
.pop-file-meta-value {
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.pop-file-meta-value.fade-in {
  opacity: 0;
  transition: opacity 0.3s;
}
.pop-file-meta-value.fade-in.visible {
  opacity: 1;
}

/* Activity bar */
.pop-activity {
  height: 2px;
  margin-top: 6px;
  border-radius: 1px;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.4s ease;
  background: var(--bg-muted);
}
.pop-activity-bar {
  height: 100%;
  width: 40%;
  border-radius: 1px;
  animation: activity-slide 1.2s ease-in-out infinite;
}
.pop-activity-bar.uploading {
  background: var(--brand);
}
.pop-activity-bar.classifying {
  background: var(--warning);
}
.pop-activity-bar.routing {
  background: var(--brand);
}
.pop-activity-bar.extracting,
.pop-activity-bar.validating,
.pop-activity-bar.accounting,
.pop-activity-bar.finishing,
.pop-activity-bar.processing {
  background: var(--accent-violet);
}
@keyframes activity-slide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(200%); }
  100% { transform: translateX(-100%); }
}
.pop-activity.done {
  opacity: 0;
}

/* Popover backdrop */
.popover-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: transparent;
}
.popover-backdrop.visible {
  display: block;
}

/* Drag-and-drop upload overlay (AP overview) */
.upload-drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
  pointer-events: none;
}
.upload-drop-overlay.visible {
  display: flex;
}
.upload-drop-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 64px;
  border: 2px dashed var(--brand);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--fg);
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-popover);
}
.upload-drop-panel iconify-icon {
  font-size: 40px;
  color: var(--brand);
}

/* Rejected-drop notice (centered modal: too many / unsupported files) */
.upload-reject-dialog {
  margin: auto; /* dead-center horizontally + vertically */
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-popover);
  width: 380px;
  max-width: 92vw;
}
.upload-reject-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.upload-reject-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 28px 28px 24px;
}
.upload-reject-icon {
  font-size: 36px;
  color: var(--danger);
}
.upload-reject-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.upload-reject-msg {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted);
  white-space: pre-line; /* render the \n before "Supported:" as a line break */
}
.upload-reject-ok {
  margin-top: 8px;
  padding: 8px 28px;
  border: none;
  border-radius: var(--r-md);
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.upload-reject-ok:hover {
  opacity: 0.92;
}

/* Popover item entrance animation */
@keyframes items-enter {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.batch-enter {
  animation: items-enter 0.2s ease-out;
}

/* Spinner */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.spinner-message {
  color: var(--fg-muted);
}

/* Detail page layout */
.content:has(.detail-container) {
  overflow: hidden;
  padding-bottom: 0;
}
/* Full-bleed detail page: no content gutter, white top-bar, flush panes divided
   by a single hairline (design: .detail-topbar / .detail-split gap:0 /
   .pdf-pane border-right). Matches the AP list's full-bleed treatment. */
.content:has(.detail-container) {
  padding: 0;
  overflow: hidden;
}
/* The global command header bleeds through the content gutter with a negative
   margin. A full-bleed detail page has no gutter, so the same margin would pull
   the header off the top of the viewport and past both edges. */
.content:has(.detail-container) > .global-command-header {
  margin: 0;
}
/* The command bar belongs beside the back link, not stranded in the middle by
   space-between; the navigation arrows keep the right edge. */
.detail-topbar > .search-toolbar {
  margin-right: auto;
  margin-left: var(--space-3);
}

/* In a narrow window the back button keeps its one-line label and the search
   field gives way, instead of the button wrapping into a two-line block. */
.detail-topbar .page-header-left {
  flex-wrap: nowrap;
  min-width: 0;
}
.detail-topbar > .btn,
.detail-topbar .page-header-left > .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.detail-topbar > .search-toolbar,
.detail-topbar .page-header-left > :not(.btn),
.detail-topbar .search-container,
.detail-topbar .search-input {
  min-width: 0;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Match the sidebar logo row + single-row list page-header (51px) so the
     bottom hairline lines up when navigating list <-> detail (AP/AR/contracts). */
  min-height: 51px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
/* The processing-pause banner has a fixed height, so pages that size
   themselves to the viewport can subtract it (--pause-chrome, 0 without it). */
:root { --pause-chrome: 0px; }
body:has(#processing-pause-banner:not([hidden])) { --pause-chrome: 62px; }
#processing-pause-banner {
  box-sizing: border-box;
  height: 46px;
  margin-bottom: 16px;
  padding: 0 16px;
  line-height: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff3cd;
  border: 1px solid #e4c76b;
  border-radius: 6px;
}

.detail-container {
  display: flex;
  gap: 0;
  /* Explicit height (topbar 51 + fixed footer 26) so the data-panel is bounded
     and owns the scroll — flex:1 here does not resolve reliably in this chain.
     --elevated-chrome is 0 unless the elevated-context banner is present. */
  height: calc(100vh - 77px - var(--elevated-chrome) - var(--pause-chrome));
  min-height: 0;
}
.pdf-panel {
  flex: 45;
  min-width: 300px;
  max-width: 900px;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  resize: horizontal;
  display: flex;
  flex-direction: column;
}
.pdf-panel iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  flex: 1;
  display: block;
  object-fit: contain;
}
.pdf-panel:has(> img) {
  /* Unlike the PDF iframe, which scrolls its own content internally, a
     receipt photo taller than the panel needs the panel itself to scroll —
     the iframe rule leaves overflow: hidden since double scrollbars would
     otherwise appear inside an embedded PDF viewer. */
  overflow-y: auto;
}
.pdf-panel:has(> img) .pdf-tabs-bar {
  /* Keep the filename/tab bar visible while a tall receipt scrolls past it,
     rather than it scrolling away as just another flex child. */
  position: sticky;
  top: 0;
  z-index: 1;
}
.pdf-panel img {
  width: 100%;
  height: auto;
  /* Fill the panel's width and let height flow from the image's own aspect
     ratio, rather than shrinking a tall receipt to fit the panel's height
     (object-fit: contain) and wasting horizontal space either side of it. */
  image-orientation: from-image;
  background: var(--surface);
}

/* Drag handles (resizable.js): a divider between every split page's document
   pane and its data, and a grip on each resizable table header's right edge.
   The divider replaces the pane's native resize corner. */
.pane-resizer {
  flex: 0 0 6px;
  margin-left: -3px;
  margin-right: -3px;
  position: relative;
  z-index: 2;
  cursor: col-resize;
  touch-action: none;
}
.pane-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 1px;
  width: 4px;
  height: 40px;
  margin-top: -20px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background 0.12s;
}
.pane-resizer:hover::after,
.pane-resizer:focus-visible::after,
.is-resizing > .pane-resizer::after { background: var(--brand); }
.pane-resizer:focus-visible { outline: none; }
[data-pane-resizer-ready] > .pdf-panel { resize: none; }
.detail-container.has-pane-width > .pdf-panel {
  flex: 0 0 var(--pane-width);
  width: var(--pane-width);
  max-width: none;
}
.is-resizing { user-select: none; cursor: col-resize; }
.is-resizing iframe { pointer-events: none; }
table[data-resizable-columns] thead th { position: sticky; }
/* A column header row standing aside for a selection row (AP Received) stays
   in the table's layout, so the widths it carries hold while rows are ticked. */
table[data-resizable-columns] > thead > tr[hidden]:not(.ap-selection-row) {
  display: table-row;
  visibility: collapse;
}
.column-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}
.column-resizer:hover,
.is-resizing .column-resizer:active { background: var(--border); }
/* Stacked panes take the full width whatever width was dragged. */
@media (max-width: 900px) {
  .pane-resizer { display: none; }
  .detail-container.has-pane-width > .pdf-panel { width: 100%; }
}

/* Deduction Clearing detail page
   Keep the shared document split shell, but give this page the same deliberate
   hierarchy as AP detail instead of relying on browser-default flow styles. */
.deduction-clearing-detail-page {
  background: var(--surface);
}
.deduction-clearing-detail-split {
  min-height: 0;
}
.deduction-clearing-source-pane {
  background: var(--surface);
}
.deduction-clearing-source-selector {
  display: flex;
  align-items: stretch;
  min-height: 46px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.deduction-clearing-source-selector .document-selector-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
  max-width: min(100%, 520px);
  min-height: 46px;
  padding: 0 14px;
  border-right: 0;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.deduction-clearing-source-selector .document-selector-tab:not(.is-disabled):hover,
.deduction-clearing-source-selector .document-selector-tab:not(.is-disabled):focus-visible {
  color: var(--fg);
}
.deduction-clearing-source-selector .document-selector-tab.is-active {
  background: var(--surface);
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.deduction-clearing-source-selector .document-selector-tab-label {
  white-space: nowrap;
}
.deduction-clearing-source-selector .document-selector-tab-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deduction-clearing-source-pane .filename-bar {
  min-height: 34px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: 11px;
}
.deduction-clearing-source-pane:has(.document-selector-tab) > .filename-bar {
  display: none;
}
.deduction-clearing-source-pane .empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 24px;
  color: var(--fg-muted);
  text-align: center;
}
.deduction-clearing-detail-navigation {
  display: flex;
  gap: 8px;
}
.deduction-clearing-detail-column {
  min-width: 0;
  background: var(--bg-muted);
}
.deduction-clearing-detail-sections-content {
  --deduction-panel-inset: 20px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 16px var(--deduction-panel-inset) 28px;
}
.deduction-clearing-detail-sections {
  display: flex;
  gap: 4px;
  position: sticky;
  top: -16px;
  z-index: 1;
  margin: -16px -20px 16px;
  padding: 0 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
/* The nav also carries the shared `.section-tabs` (sticky at `top: 0`, later in
   this file); its offset must cancel the scroll container's top padding, or the
   scrolled content shows through the strip above it. */
.deduction-clearing-detail-sections.section-tabs {
  top: -16px;
}
/* The Archive action sits beside "Audit trail" and reads like it. */
.deduction-clearing-detail-sections > button.btn {
  align-self: center;
  flex: 0 0 auto;
  height: 30px;
  margin: 3px 0 3px 2px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  box-shadow: none;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 400;
}
.deduction-clearing-detail-sections > button.btn:hover,
.deduction-clearing-detail-sections > button.btn:active {
  background: var(--bg-muted);
  color: var(--fg);
}
.deduction-clearing-detail-sections a {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.deduction-clearing-detail-sections a:hover,
.deduction-clearing-detail-sections a:focus-visible {
  color: var(--fg);
}
.deduction-clearing-detail-sections a:target,
.deduction-clearing-detail-sections a[aria-current="true"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.deduction-clearing-detail-sections + .detail-section {
  margin-top: 0;
}
.deduction-clearing-detail-column .detail-section {
  /* Clears the sticky section tabs when a tab or link jumps here. */
  scroll-margin-top: 40px;
  margin: 10px 0 0;
  padding: 10px 14px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.deduction-clearing-detail-column .detail-section h2 {
  margin: 0 0 14px;
  color: var(--fg);
  font-size: 15px;
  font-weight: 650;
}
.deduction-clearing-detail-column .detail-section h3 {
  margin: 18px 0 8px;
  color: var(--fg);
  font-size: 12px;
  font-weight: 650;
}
.deduction-clearing-history .history-summary {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
}
.deduction-clearing-history .history-summary time {
  color: var(--fg);
  font-weight: 600;
}
.deduction-clearing-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Each of Parties / Financial Summary / Line Items renders as its own
   bordered card -- previously these lived as unbordered sub-sections split
   across two columns by *where the data came from* (the case projection vs.
   the raw document) rather than by what a reader actually needs together. */
.detail-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 10px 18px 16px;
}
.detail-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}
.detail-card-head iconify-icon {
  /* Matches the reference .invoice-section .section-header icon: same
     colour as the heading text (not a muted tint), same downward nudge to
     center the glyph against the text's cap-height rather than its full
     line box. */
  color: var(--fg);
  font-size: 15px;
  position: relative;
  top: 2px;
}
/* lucide:banknote and lucide:receipt carry more empty space above their own
   glyph than lucide:building-2 does, inside the same 1em icon box -- the
   shared nudge above reads correctly for Parties but leaves these two
   sitting visibly higher than the heading, so they get an extra push. */
.detail-card-head iconify-icon[icon="lucide:banknote"],
.detail-card-head iconify-icon[icon="lucide:receipt"] {
  top: 4px;
}
.detail-card-head h3 {
  margin: 0;
  color: var(--fg);
  font-size: 14px;
  font-weight: 650;
}
.detail-card-head .data-check-badge {
  margin-left: auto;
}

/* Marke/Variante/Größe brought the table to seven columns -- wrap it so a
   narrow viewport scrolls the table horizontally instead of forcing the
   whole page wider (same pattern as .skonto-opportunity-table-scroll). */
.claim-positions-table-scroll {
  overflow-x: auto;
}
.claim-positions-table {
  min-width: 640px;
}
.claim-positions-table tbody tr:last-child td {
  border-bottom: none;
}
.claim-positions-table .cell-truncate.claim-positions-cell-attribute {
  max-width: 140px;
}
.claim-positions-table td.claim-positions-cell-description {
  min-width: 12rem;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.settlement-source-table .cell-truncate.settlement-cell-provider {
  max-width: 180px;
}
.settlement-source-table .cell-truncate.settlement-cell-batch-reference {
  max-width: 200px;
}
.line-items-totals {
  margin-top: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}
.line-items-total-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 2px;
  font-size: 12.5px;
  color: var(--fg-muted);
}
.line-items-total-row span:last-child {
  font-weight: 600;
  color: var(--fg);
}
.line-items-total-row.is-difference {
  border-top: 1px solid var(--border-subtle);
  margin-top: 2px;
}
.line-items-total-row.is-difference.has-gap {
  color: var(--danger-strong);
  border-top-color: var(--danger-border);
}
.line-items-total-row.is-difference.has-gap span:last-child {
  color: var(--danger-strong);
}
.deduction-clearing-matching .section-header {
  margin: 0 0 10px;
  padding-bottom: 8px;
}
.deduction-clearing-matching .section-header > span {
  gap: 8px;
}
.deduction-clearing-matching .section-header > span > iconify-icon {
  color: var(--fg);
  font-size: 16px;
}
.deduction-clearing-matching .matching-count-badge {
  display: inline-block;
  min-width: 22px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}
.deduction-clearing-matching .section-body {
  overflow: visible;
  opacity: 1;
  transition: opacity 0.2s ease-out;
}
.deduction-clearing-matching.collapsed .section-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}
.deduction-clearing-matching.collapsed .chevron {
  transform: rotate(-90deg);
}
.deduction-clearing-matching .detail-facts {
  margin-bottom: 10px;
}
.deduction-clearing-matching .matches-list {
  margin-top: 2px;
}
.deduction-clearing-matching .matching-review-intro {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.deduction-clearing-matching .matching-review-intro-icon {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 5px;
  border-radius: 50%;
  background: var(--success-tint);
  color: var(--success-strong);
  font-size: 18px;
}
.deduction-clearing-matching .matching-review-intro.is-review .matching-review-intro-icon {
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.deduction-clearing-matching .matching-review-intro.is-mismatch .matching-review-intro-icon {
  background: var(--danger-tint);
  color: var(--danger-strong);
}
.deduction-clearing-matching .matching-review-intro h3 {
  margin: 0 0 3px;
  color: var(--fg);
  font-size: 15px;
  font-weight: 650;
}
.deduction-clearing-matching .matching-review-intro p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.4;
}
.deduction-clearing-matching .matching-review-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.deduction-clearing-matching .matching-review-check {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.deduction-clearing-matching .matching-review-check.is-context {
  background: var(--bg-muted);
}
.deduction-clearing-matching .matching-review-check.is-different {
  border-color: var(--danger);
}
.deduction-clearing-matching .matching-review-check-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--success-tint);
  color: var(--success-strong);
  font-size: 14px;
}
.deduction-clearing-matching .matching-review-check.is-context .matching-review-check-icon {
  background: var(--bg-muted-strong);
  color: var(--fg-muted);
}
.deduction-clearing-matching .matching-review-check.is-different .matching-review-check-icon {
  background: var(--danger-tint);
  color: var(--danger);
}
.deduction-clearing-matching .matching-review-check-content {
  min-width: 0;
}
.deduction-clearing-matching .matching-review-check-content h4 {
  margin: 0 0 3px;
  color: var(--fg);
  font-size: 12px;
  font-weight: 650;
}
.deduction-clearing-matching .matching-review-check-content p {
  margin: 0;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.deduction-clearing-matching .matching-review-check-content small {
  display: block;
  margin-top: 3px;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.35;
}
.deduction-clearing-matching .matching-review-check-status {
  padding-top: 2px;
  color: var(--success-strong);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.deduction-clearing-matching .matching-review-check.is-context .matching-review-check-status {
  color: var(--fg-muted);
}
.deduction-clearing-matching .matching-review-check.is-different .matching-review-check-status {
  color: var(--danger);
}
td.has-copies {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
td.has-copies .deduction-copies-badge {
  display: flex;
  width: max-content;
  margin-top: 4px;
  white-space: nowrap;
}
.deduction-clearing-source-selector .document-selector-tab-note {
  color: var(--fg-muted);
  font-size: 11px;
  white-space: nowrap;
}
.deduction-clearing-detail-column .deduction-copies-section .section-description {
  margin: -4px 0 12px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.4;
}
.deduction-clearing-detail-column .deduction-copies {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.deduction-clearing-detail-column .deduction-copy {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-muted);
}
.deduction-clearing-detail-column .deduction-copy.is-archived {
  background: var(--bg-subtle);
}
.deduction-clearing-detail-column .deduction-copy-main {
  display: grid;
  flex: 1 1 220px;
  gap: 2px;
  min-width: 0;
}
.deduction-clearing-detail-column .deduction-copy-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--fg);
  font-size: 12px;
  font-weight: 650;
}
.deduction-clearing-detail-column a.deduction-copy-name {
  color: var(--link);
}
.deduction-clearing-detail-column span.deduction-copy-name {
  color: var(--fg);
}
.deduction-clearing-detail-column .deduction-copy-received {
  color: var(--fg-muted);
  font-size: 11px;
}
.deduction-clearing-detail-column .deduction-copy-work {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
}
.deduction-clearing-detail-column .deduction-copy-note {
  min-width: 0;
  overflow: hidden;
  color: var(--fg);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deduction-clearing-detail-column .deduction-copy-note.is-empty {
  color: var(--fg-muted);
}
.work-timeline-copy {
  display: block;
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: 11px;
}
.work-timeline-copy a {
  color: var(--link);
}
.deduction-clearing-detail-column .deduction-copy-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.deduction-clearing-detail-column .deduction-copy-current-badge {
  color: var(--success-strong);
  background: var(--success-tint);
  border-color: var(--success-border);
}
.deduction-clearing-detail-column .deduction-copy-archived-badge {
  color: var(--fg-muted);
  background: var(--bg-muted);
  border-color: var(--border);
}
.deduction-clearing-detail-column .deduction-keep-copy {
  margin: 0 0 0 auto;
}
.deduction-clearing-detail-column .deduction-copies-consequence {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.4;
}
.deduction-clearing-detail-column .deduction-copies-consequence {
  color: var(--warning-strong);
}
.deduction-clearing-detail-column .deduction-copies-consequence iconify-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.deduction-clearing-detail-column .deduction-copies-callout {
  margin: 0 0 12px;
  font-size: 13px;
}
.deduction-clearing-detail-column .settlement-deduction-groups {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}
.deduction-clearing-detail-column .settlement-deduction-group {
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.deduction-clearing-detail-column .settlement-deduction-group:first-child {
  padding-top: 0;
  border-top: 0;
}
.deduction-clearing-detail-column .settlement-deduction-group-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.deduction-clearing-detail-column .settlement-deduction-group-heading h3 {
  margin: 0;
  color: var(--fg);
  font-size: 13px;
  font-weight: 650;
}
.deduction-clearing-detail-column .settlement-deduction-group-heading p {
  margin: 2px 0 0;
  color: var(--fg-muted);
  font-size: 11px;
}
.deduction-clearing-detail-column .settlement-deduction-group-count {
  min-width: 22px;
  color: var(--fg-muted);
  background: var(--bg-muted);
  border-color: var(--border);
}
.deduction-clearing-detail-column .settlement-deductions {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.deduction-clearing-detail-column .settlement-deduction {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--border-subtle);
}
/* The whole row is the navigation target, same convention as every other
   list row in the app (`.table tbody tr[data-row-href]`) -- not just the title
   or filename inside it. */
.deduction-clearing-detail-column .settlement-deduction[data-row-href] {
  cursor: pointer;
}
.deduction-clearing-detail-column .settlement-deduction[data-row-href]:hover {
  background: var(--bg-subtle);
}
.deduction-clearing-detail-column .settlement-deduction[role="link"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.deduction-clearing-detail-column .settlement-deduction-number {
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
}
.deduction-clearing-detail-column .settlement-deduction-main {
  min-width: 0;
}
.deduction-clearing-detail-column .settlement-deduction-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
/* The whole row is the click target (see `.settlement-deduction[data-row-href]`
   below), so the title and filename are plain text rather than their own
   separate links -- one clickable target reads more clearly than several
   independent ones inside the same row. */
.deduction-clearing-detail-column .settlement-deduction-title-text {
  color: var(--fg);
  font-size: 13px;
  font-weight: 650;
}
.deduction-clearing-detail-column .settlement-deduction-document-text {
  color: var(--fg-muted);
}
.deduction-clearing-detail-column .settlement-deduction-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
}
.deduction-clearing-detail-column .settlement-deduction-source-badge.is-missing {
  border-color: var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.deduction-clearing-detail-column .settlement-deduction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 14px;
  margin-top: 3px;
  color: var(--fg-muted);
  font-size: 11px;
}
.deduction-clearing-detail-column .settlement-deduction-meta strong {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 550;
}
.deduction-clearing-detail-column .settlement-deduction-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 92px;
}
.deduction-clearing-detail-column .settlement-deduction-status {
  margin-top: 6px;
  color: var(--success-strong);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}
.deduction-clearing-detail-column .settlement-deduction-status.is-missing {
  color: var(--warning-strong);
}
.deduction-clearing-detail-column .settlement-deduction-amount {
  color: var(--fg);
  font-size: 12px;
  font-weight: 650;
  text-align: right;
  white-space: nowrap;
}
/* A remittance's own list adds each deduction's work status and claim amount;
   the rows share the list's columns so they line up under one header. */
.deduction-clearing-detail-column .settlement-deductions.has-work-columns {
  grid-template-columns: 18px minmax(0, 1fr) auto auto minmax(92px, auto);
  column-gap: 14px;
}
.deduction-clearing-detail-column .settlement-deductions.has-work-columns > li {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  column-gap: inherit;
}
.deduction-clearing-detail-column .settlement-deduction-columns {
  padding: 0 0 4px;
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.deduction-clearing-detail-column .settlement-deduction-columns span:nth-child(n + 4) {
  text-align: right;
}
.deduction-clearing-detail-column .settlement-deduction-claim {
  color: var(--fg);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 760px) {
  .deduction-clearing-detail-column .settlement-deductions.has-work-columns {
    grid-template-columns: 16px minmax(0, 1fr);
  }
  .deduction-clearing-detail-column .settlement-deduction-columns { display: none; }
  .deduction-clearing-detail-column .settlement-deduction-work-status,
  .deduction-clearing-detail-column .settlement-deduction-claim {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: left;
  }
  .deduction-clearing-detail-column .settlement-deductions.has-work-columns .settlement-deduction-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 6px;
  }
  .deduction-clearing-detail-column .settlement-deductions.has-work-columns .settlement-deduction-checks,
  .deduction-clearing-detail-column .settlement-deductions.has-work-columns .settlement-deduction-status {
    flex-basis: 100%;
  }
  .deduction-clearing-detail-column .settlement-deduction-work-status::before,
  .deduction-clearing-detail-column .settlement-deduction-claim::before,
  .deduction-clearing-detail-column .settlement-deductions.has-work-columns .settlement-deduction-side::before {
    content: attr(data-label);
    color: var(--fg-muted);
    font-size: 11px;
  }
}
@media (max-width: 760px) {
  .deduction-clearing-detail-column .settlement-deduction {
    grid-template-columns: 16px minmax(0, 1fr);
  }
  .deduction-clearing-detail-column .settlement-deduction-side {
    grid-column: 2;
    align-items: flex-start;
    min-width: 0;
  }
  .deduction-clearing-detail-column .settlement-deduction-status,
  .deduction-clearing-detail-column .settlement-deduction-amount {
    text-align: left;
  }
}
.deduction-clearing-detail-column .detail-facts {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 0.65fr);
  gap: 9px 18px;
  margin: 0;
}
.deduction-clearing-detail-column .detail-facts dt {
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 550;
}
.deduction-clearing-detail-column .detail-facts dd {
  min-width: 0;
  margin: 0;
  color: var(--fg);
  font-size: 12px;
  overflow-wrap: anywhere;
}
/* The deduction detail's data panel follows the document data panel: sections
   are full width without a frame, separated by a divider and opened by a
   header band, and facts read like the party card's rows (uppercase label,
   value in a text box). Sections reach past the content's side padding
   (`--deduction-panel-inset`) so the divider runs the panel's full width. */
.deduction-clearing-detail-column {
  background: var(--surface);
}
.deduction-clearing-detail-column .detail-section {
  margin: 10px calc(-1 * var(--deduction-panel-inset, 20px)) 0;
  padding: 0 var(--deduction-panel-inset, 20px) 14px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.deduction-clearing-detail-column .detail-section > :is(h2, .section-header) {
  margin: 0 calc(-1 * var(--deduction-panel-inset, 20px)) 14px;
  padding: 10px var(--deduction-panel-inset, 20px);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 15px;
  font-weight: 600;
}
/* Cards inside a section are the panel's containers, as in the invoice's
   Payment section: tight padding and a bold title. */
.deduction-clearing-detail-column .detail-card {
  padding: 8px;
}
.deduction-clearing-detail-column .detail-card-head {
  margin-bottom: 8px;
}
.deduction-clearing-detail-column .detail-card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.deduction-clearing-detail-column .detail-facts {
  align-items: center;
  gap: 6px 18px;
}
.deduction-clearing-detail-column .detail-facts dt {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.deduction-clearing-detail-column .detail-facts dd {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13px;
}
/* A fact without a value keeps its box at full height, like the others' "—". */
.deduction-clearing-detail-column .detail-facts dd:empty::before {
  content: "—";
  color: var(--fg-subtle);
}
.deduction-clearing-canonical-fields {
  display: grid;
  gap: 8px;
}
.deduction-clearing-canonical-field {
  display: grid;
  grid-template-columns: minmax(130px, 0.35fr) minmax(0, 0.65fr);
  gap: 6px 16px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-muted);
}
.deduction-clearing-canonical-field > dt {
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 550;
}
.deduction-clearing-canonical-field > dd {
  min-width: 0;
  margin: 0;
  color: var(--fg);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.deduction-clearing-canonical-field .field-provenance {
  grid-column: 1 / -1;
  max-height: 92px;
  margin-top: 3px;
  padding: 7px 8px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.deduction-clearing-canonical-field .field-conflicts {
  grid-column: 1 / -1;
  color: var(--danger);
  font-size: 11px;
}
.deduction-clearing-detail-column .empty-state {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
}
.deduction-clearing-detail-column .matching-candidates,
.deduction-clearing-detail-column .source-revisions,
.deduction-clearing-detail-column .case-revisions,
.deduction-clearing-detail-column .case-aliases {
  margin: 0;
  padding-left: 18px;
  color: var(--fg-muted);
  font-size: 11px;
}
.deduction-clearing-detail-column .case-revisions li + li,
.deduction-clearing-detail-column .case-aliases li + li {
  margin-top: 7px;
}
.deduction-clearing-detail-column .case-revisions small {
  display: block;
  margin-top: 2px;
  color: var(--fg-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .deduction-clearing-detail-sections-content {
    --deduction-panel-inset: 14px;
    padding: 12px var(--deduction-panel-inset) 22px;
  }
  .deduction-clearing-detail-sections,
  .deduction-clearing-detail-sections.section-tabs {
    top: -12px;
    margin: -12px -14px 12px;
    padding: 0 10px;
  }
  .deduction-clearing-detail-column .detail-section {
    padding: 0 14px 14px;
  }
  .deduction-clearing-detail-column .detail-facts,
  .deduction-clearing-canonical-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .deduction-clearing-canonical-field .field-provenance,
  .deduction-clearing-canonical-field .field-conflicts {
    grid-column: auto;
  }
}

@media (max-width: 600px) {
  .deduction-clearing-matching .matching-review-check {
    grid-template-columns: 25px minmax(0, 1fr);
  }
  .deduction-clearing-matching .matching-review-check-status {
    grid-column: 2;
    padding-top: 0;
  }
}

/* Source tabs: the document, then one Attachments tab per email it arrived in.
   Tabs share the bar evenly down to a minimum width; past that the bar scrolls.
   Inside an Attachments tab a second row switches between the message and its
   related files. */
.pdf-tabs-bar.source-tabs {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
/* Tabs carry no padding or border of their own (spacing sits on the copy
   button, the divider is a shadow), so flex splits the bar evenly and the
   dividers line up with the viewer's own tabs below. */
.source-tabs .pdf-tab-item {
  flex: 1 1 0;
  min-width: 160px;
  padding: 0;
}
.source-tabs .pdf-tab-item[data-source-kind="document"] > .copy-btn {
  margin-right: 10px;
}
.source-tabs .pdf-tab-item[data-source-kind="attachments"] {
  box-shadow: inset 1px 0 0 var(--border-subtle);
}
.source-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.source-tab:focus-visible,
.source-subtab:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.source-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 600;
}
.source-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber-500);
}
.source-panel,
.source-subpanel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.source-panel[hidden],
.source-subpanel[hidden] {
  display: none;
}
.source-panel > .document-viewer,
.source-subpanel > .document-viewer {
  flex: 1;
  width: 100%;
}
/* Wraps rather than scrolls: a scrolling row would clip the tooltips that hang
   below an unavailable file. */
.source-subtabs {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 7px 12px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}
.source-subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  max-width: 260px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.source-subtab:hover:not([aria-disabled="true"]) {
  background: var(--bg-hover);
  color: var(--fg);
}
.source-subtab.active {
  background: var(--bg-muted);
  color: var(--fg);
  font-weight: 600;
}
.source-subtab[aria-disabled="true"] {
  color: var(--fg-subtle);
  cursor: help;
}
/* A file near the panel's right edge opens its tooltip leftwards, so the
   panel's overflow does not cut it off (`document-source-tabs.js`). */
.source-subtab[data-tip-align="end"]::after {
  right: 0;
  left: auto;
}
.source-subtab-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.source-subtab-tag {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 500;
}
.source-email-header {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.source-email-subject {
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.source-email-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--fg-muted);
  font-size: 13px;
}
.source-email-sender {
  overflow-wrap: anywhere;
}
.source-email-date {
  margin-left: auto;
  white-space: nowrap;
}
.source-file-note {
  display: flex;
  flex: none;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 13px;
}
.source-file-note iconify-icon {
  flex: none;
  margin-top: 2px;
}

/* PDF Panel Tabs Bar (combined filename + email tab) — 49px including its
   border, so its bottom line runs level with the status row across the split
   and the sidebar's entity picker; white to match the data panel's header strip. */
.pdf-tabs-bar {
  display: flex;
  flex-shrink: 0;
  min-height: 49px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.pdf-tab-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 14px;
  color: var(--fg-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  min-width: 0;
  user-select: none;
}
.pdf-tab-item:hover {
  color: var(--fg);
  background: var(--surface);
}
.pdf-tab-item.active {
  color: var(--fg);
  border-bottom-color: var(--brand);
}
.pdf-tab-item iconify-icon {
  font-size: 15px;
  flex-shrink: 0;
}
.pdf-tab-item.active iconify-icon {
  color: var(--brand);
}
.pdf-tab-item .pdf-tab-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* AR autosave status: pinned to the right of the preview tab row, with a small
   status dot whose color tracks data-state (set by ar-editor.js). */
.ar-save-status {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.ar-save-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-muted);
  flex-shrink: 0;
}
.ar-save-status[data-state="saved"]::before    { background: var(--success); }
.ar-save-status[data-state="unsaved"]::before  { background: var(--warning); }
.ar-save-status[data-state="saving"]::before   { background: var(--brand); animation: ar-save-pulse 1s ease-in-out infinite; }
.ar-save-status[data-state="invalid"]::before  { background: var(--danger); }
.ar-save-status[data-state="conflict"]::before { background: var(--danger); }
.ar-save-status[data-state="error"]::before    { background: var(--danger); }
.ar-save-status-reload {
  color: var(--danger-strong);
  text-decoration: underline;
  cursor: pointer;
}
@keyframes ar-save-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* AR editor — required-field marking. The asterisk flags a field the invoice
   needs before it can be sent; `.ar-field-invalid` + `.ar-field-error` mark the
   inputs the live autosave reports as blank. */
.ar-required-marker {
  margin-left: 3px;
  color: var(--danger);
  font-weight: 600;
}
#ar-invoice-form input.ar-field-invalid,
#ar-invoice-form select.ar-field-invalid,
#ar-invoice-form textarea.ar-field-invalid {
  border-color: var(--danger);
  background: var(--danger-tint);
}
#ar-invoice-form input.ar-field-invalid:focus,
#ar-invoice-form select.ar-field-invalid:focus,
#ar-invoice-form textarea.ar-field-invalid:focus {
  outline: 2px solid var(--danger);
  outline-offset: -1px;
}
.ar-field-error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger-strong);
}

.pdf-tab-item .copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.pdf-tab-item .copy-btn:hover {
  background: var(--bg-muted);
  color: var(--fg);
  border-color: var(--border-strong);
}
.pdf-tab-item .copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* Excel Preview Banner */
.excel-preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--brand-tint) 0%, var(--brand-tint) 100%);
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
}
.excel-preview-banner .banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.excel-preview-banner iconify-icon {
  color: var(--success);
}
.excel-preview-banner .banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.excel-preview-banner .banner-title {
  font-weight: 500;
  color: var(--fg);
}
.excel-preview-banner .banner-subtitle {
  font-size: 12px;
}
.excel-preview-banner .btn {
  display: flex;
  align-items: center;
  gap: 6px;
}
.excel-preview-banner .btn iconify-icon {
  color: inherit;
}

/* Original Filename Bar */
.filename-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 49px;            /* match .pdf-tabs-bar so the PDF strip is uniform across doc types */
  padding: 8px 14px;
  background: var(--surface);  /* white, like the AP .pdf-tabs-bar (was sand --bg-canvas) */
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 13px;
}
.filename-bar iconify-icon {
  color: var(--brand);
  font-size: 15px;
  flex-shrink: 0;
}
.filename-bar .filename-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  color: var(--fg);
}
.filename-bar .copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.filename-bar .copy-btn:hover {
  background: var(--bg-muted);
  color: var(--fg);
  border-color: var(--border-strong);
}
.filename-bar .copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

.data-panel {
  /* Reference mock (app.css:264 `.detail-split`) is an even 50/50 split, but
     the data panel carries the dense tables (line items have many columns), so
     we deliberately weight it 45/55 toward the data panel. PDF pane stays
     resizable. Flush, no border/radius. */
  flex: 55;
  background: var(--surface);
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.data-panel-content {
  position: relative;
  flex: 1;
  min-height: 0;
}
.data-panel-scroll {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: var(--fg-faint) var(--bg-muted);
}
.data-panel-scroll::-webkit-scrollbar {
  width: 12px;
}
.data-panel-scroll::-webkit-scrollbar-track {
  background: var(--bg-muted);
  border-radius: var(--r-lg);
}
.data-panel-scroll::-webkit-scrollbar-thumb {
  background: var(--fg-faint);
  border-radius: var(--r-lg);
  border: 2px solid var(--bg-muted);
}
.data-panel-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--fg-subtle);
}
.document-status-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(1px);
}
.document-status-overlay .spinner-container {
  padding: 24px 32px;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.document-status-overlay .spinner-message {
  color: var(--fg);
  font-weight: 600;
}
.document-status-overlay-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  padding: 32px;
  color: var(--fg-muted);
  text-align: center;
}
.document-status-overlay-message iconify-icon {
  font-size: 32px;
  color: var(--danger);
}
.document-status-overlay-message p {
  margin: 0;
}
.document-status-overlay-message .document-status-overlay-title {
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 6px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.panel-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.panel-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.data-panel > .panel-header .panel-header-meta {
  flex-wrap: nowrap;
}
.panel-header-meta > .badge-subtype {
  flex: 0 0 auto;
  margin-left: 0;
}
/* Same 49px as .pdf-tabs-bar across the split. */
.data-panel > .panel-header {
  min-height: 49px;
  padding-top: 4px;
  padding-bottom: 4px;
}
.e-invoice-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-canvas);
  color: var(--fg-muted);
  font: var(--text-label);
  white-space: nowrap;
  cursor: pointer;
}
.e-invoice-source-badge iconify-icon {
  font-size: 14px;
  color: var(--brand);
}
.e-invoice-preview-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0 13px;
  color: var(--fg-muted);
  font: var(--text-label);
}
.e-invoice-source-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-canvas);
  font: var(--text-sm);
}
.e-invoice-source-strip > iconify-icon {
  flex-shrink: 0;
  margin-top: 3px;
  font-size: 17px;
  color: var(--brand);
}
.e-invoice-source-strip strong {
  color: var(--fg);
  font-weight: 600;
}
.e-invoice-source-strip p {
  margin: 2px 0 0;
  color: var(--fg-muted);
  font: var(--text-label);
  font-weight: 400;
}
.document-source-list {
  display: grid;
  gap: 16px;
}
.document-source-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}
.document-source-step {
  position: relative;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  column-gap: 12px;
  padding-bottom: 14px;
  font: var(--text-sm);
}
.document-source-step:last-child {
  padding-bottom: 0;
}
.document-source-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 2px;
  left: 5px;
  width: 2px;
  background: var(--border);
}
.document-source-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: var(--r-pill);
  background: var(--fg-faint);
}
.document-source-step-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.document-source-value {
  font-weight: 600;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.document-source-label {
  font: var(--text-label);
  color: var(--fg-muted);
}
.document-source-time {
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-subtle);
  white-space: nowrap;
}

/* Document status strip: Source / Validation / Matches / Supplier comms on an
   incoming invoice, Source / Validation / Matches on a purchase
   order, and so on. One card: the segments are its header, the open segment's
   drawer its body. One column per segment where the data panel is wide, two
   columns where it is not. */
.status-card {
  margin-top: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.status-card:has(> .status-drawer:not(.collapsed)) {
  border-color: var(--info-border);
  box-shadow: 0 4px 14px rgba(28, 24, 19, 0.08);
}
.status-strip-wrap {
  container-type: inline-size;
  container-name: status-strip;
}
.status-strip {
  display: grid;
  grid-template-columns: repeat(var(--status-segments, 4), minmax(0, 1fr));
  gap: 1px;
  background: var(--bg-muted);
}
@container status-strip (max-width: 919px) {
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-strip > .status-segment:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}
.status-segment {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  padding: 10px 12px 11px;
  border: 0;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.status-segment:hover {
  background: var(--sand-canvas);
}
.status-segment[aria-expanded="true"] {
  background: var(--brand-tint);
  box-shadow: inset 0 -2px 0 var(--brand);
}
.status-segment[aria-expanded="true"] .status-segment-label {
  color: var(--brand);
}
.status-segment:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
/* Same type and icon size as `.section-header`, so the strip reads as a row of
   section headings. */
.status-segment-label {
  display: flex;
  align-self: stretch;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}
.status-segment-label iconify-icon {
  font-size: 16px;
}
/* The chevron every collapsible section uses, so a segment reads as
   something that opens. */
.status-segment-label .status-segment-chevron {
  margin-left: auto;
  font-size: 18px;
  color: var(--fg-subtle);
  transition: transform 0.15s ease, color 0.15s ease;
}
.status-segment:hover .status-segment-chevron {
  color: var(--fg);
}
.status-segment[aria-expanded="true"] .status-segment-chevron {
  transform: rotate(180deg);
  color: var(--brand);
}
@media (prefers-reduced-motion: reduce) {
  .status-card,
  .status-segment-label .status-segment-chevron {
    transition: none;
  }
}
.status-segment-value {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.status-segment-value iconify-icon {
  flex-shrink: 0;
  font-size: 13px;
}
.status-segment-value.tone-success { color: var(--success-strong); }
.status-segment-value.tone-warning { color: var(--warning-strong); }
.status-segment-value.tone-danger  { color: var(--danger-strong); }
.status-segment-value.tone-brand   { color: var(--brand); }
.status-segment-value.tone-muted   { color: var(--fg-subtle); }
.status-segment-value.tone-faint   { color: var(--fg-faint); }
.status-segment-badges {
  gap: 3px;
}
.status-segment-badges .match-count-badge {
  min-width: 0;
  margin-right: 0;
  padding: 2px 4px;
}
/* The strip's cross badge uses the light danger tint so it sits with the
   amber and green tints around it. */
.status-segment-badges .match-count-mismatch {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border-color: var(--danger-border);
}
/* A segment's flag beside its label: a small status pill in its tone's tint,
   border and strong text, saying the drawer needs a look. */
.status-segment-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px 0 6px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: var(--text-caption);
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}
.status-segment-flag:empty { display: none; }
.status-segment-label .status-segment-flag iconify-icon { font-size: 11px; }
.status-segment-flag.is-warning { background: var(--warning-tint); border-color: var(--warning-border); color: var(--warning-strong); }
.status-segment-flag.is-info    { background: var(--info-tint);    border-color: var(--info-border);    color: var(--brand); }
.status-segment-flag.is-danger  { background: var(--danger-tint);  border-color: var(--danger-border);  color: var(--danger-strong); }
.status-segment-flag-spinner,
.matches-check-spinner {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: workflow-spin .7s linear infinite;
}
/* The card heading the Matches drawer while matching is not up to date. Its
   icon tile lines up with the match rows' tiles below it. */
.matches-check-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.matches-check-notice.is-warning { background: var(--warning-tint); border-color: var(--warning-border); }
.matches-check-notice.is-info    { background: var(--info-tint);    border-color: var(--info-border); }
.matches-check-notice.is-danger  { background: var(--danger-tint);  border-color: var(--danger-border); }
.matches-check-notice-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 18px;
}
.matches-check-notice.is-warning .matches-check-notice-icon { color: var(--warning-strong); }
.matches-check-notice.is-info    .matches-check-notice-icon { color: var(--brand); }
.matches-check-notice.is-danger  .matches-check-notice-icon { color: var(--danger-strong); }
.matches-check-notice-icon .matches-check-spinner { width: 14px; height: 14px; border-width: 2px; }
.matches-check-notice-text {
  display: flex;
  flex: 1 1 18em;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.matches-check-notice-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg);
}
.matches-check-notice-detail {
  font: var(--text-sm);
  color: var(--fg-muted);
}
.matches-check-notice .matches-check-button {
  flex: none;
  margin-left: auto;
  white-space: nowrap;
}
.matches-check-button .matches-check-spinner { display: none; margin-right: 6px; }
.matches-check-button.htmx-request .matches-check-spinner { display: inline-block; }
.matches-check-button.htmx-request { cursor: progress; opacity: .85; }
@media (prefers-reduced-motion: reduce) {
  .status-segment-flag-spinner,
  .matches-check-spinner { animation-duration: 2s; }
}
.status-drawer {
  padding: 12px 14px 14px;
  background: var(--surface);
  border-top: 1px solid var(--info-border);
}
.status-drawer.collapsed {
  display: none;
}
.status-drawer-note {
  margin: 0;
  font: var(--text-sm);
  color: var(--fg-muted);
}
.status-drawer > .invoice-section.supplier-comms-section {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.status-drawer .supplier-comms-head {
  display: none;
}
/* Inside the status card the validation checks read as headed lists, like the
   other drawers' content, instead of five nested boxes. */
.status-drawer .validation-box,
.status-drawer .supplier-verification-box {
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.status-drawer .validation-grid {
  column-gap: 28px;
  row-gap: 18px;
}
.status-drawer .verification-grid {
  column-gap: 28px;
  row-gap: 18px;
  margin-top: 18px;
}
.status-drawer .validation-box-title {
  margin-bottom: 4px;
  padding-bottom: 6px;
  color: var(--fg);
  font-weight: 700;
}
.status-drawer .sv-header {
  padding: 0 0 6px;
  border-bottom-color: var(--bg-muted);
}
.status-drawer .sv-checks,
.status-drawer .supplier-verification-box > .reasoning-container,
.status-drawer .supplier-known-note {
  padding-right: 0;
  padding-left: 0;
}
#validation-banner .validation-issues-banner {
  margin: 10px 0 0;
}

/* Approval footer: the last child of the invoice view, a raised card pinned
   just above the bottom of the data panel so it never reads as part of the
   page footer below it. */
.approval-footer,
.approval-workflow-footer {
  margin-top: 10px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
/* Only the status strip layout renders the footer last, where it can float. */
.invoice-status-layout > .approval-workflow-footer {
  position: sticky;
  bottom: 10px;
  z-index: 6;
  max-height: 60vh;
  overflow-y: auto;
  margin: 16px 0 14px;
  border-color: var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: 0 10px 28px rgba(28, 24, 19, 0.18), 0 2px 6px rgba(28, 24, 19, 0.08);
}
.approval-workflow-footer > .approval-footer {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.approval-workflow-footer > #section-datev-export.invoice-section {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.approval-workflow-footer > .approval-footer + #section-datev-export.invoice-section {
  border-top: 1px solid var(--border);
}
.approval-workflow-footer #section-datev-export > .section-header {
  padding: 10px 0;
}
.approval-workflow-footer #section-datev-export > .section-body {
  padding: 0 0 12px;
}
.approval-footer-heading {
  padding-top: 10px;
}
.approval-export-note {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--fg-muted);
}
.approval-footer-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}
.approval-footer .approval-callout {
  margin-top: 10px;
}
.approval-footer-list {
  max-height: 40vh;
  overflow-y: auto;
  border-top: 1px solid var(--bg-muted);
  padding-bottom: 4px;
}
.approval-revoke-note,
.approval-rate-note {
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--bg-muted);
}
.approval-footer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.approval-footer-summary {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px 6px 2px 0;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.approval-footer-summary:hover .approval-footer-title {
  color: var(--brand);
}
.approval-footer-summary:focus-visible,
.approval-footer-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.approval-footer-toggle {
  display: flex;
  flex: none;
  align-items: center;
  width: 16px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  cursor: pointer;
}
.approval-footer-avatars {
  display: flex;
  flex: none;
}
.approval-footer-avatars .approver-avatar {
  width: 30px;
  height: 30px;
  border: 2px solid var(--surface);
}
.approval-footer-avatars .approver-avatar + .approver-avatar {
  margin-left: -7px;
}
.approval-footer-avatars .approver-avatar.is-approved {
  background: var(--success-tint);
  color: var(--success-strong);
}
.approval-footer-avatars .approver-avatar.is-pending {
  background: var(--brand-tint);
  color: var(--brand);
}
.approval-footer-avatars .approver-avatar.is-rejected {
  background: var(--danger-tint);
  color: var(--danger-strong);
}
.approval-footer-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.approval-footer-title {
  font-size: 14px;
  font-weight: 700;
}
.approval-footer-meta {
  font-size: 12px;
  color: var(--fg-subtle);
}
.approval-footer-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}
.approval-footer-actions .btn[hx-post$="/approve"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--fg-on-brand);
}
.document-source-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  color: var(--fg-muted);
  font: var(--text-label);
}
.document-source-note iconify-icon {
  flex-shrink: 0;
  font-size: 14px;
}
.e-invoice-check-source {
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-muted);
  font: var(--text-caption);
  white-space: nowrap;
}
.e-invoice-source-dialog {
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-popover);
}
.e-invoice-source-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.e-invoice-source-dialog h3 {
  margin: 0 0 12px;
  font: var(--text-h3);
}
.e-invoice-source-dialog p {
  margin: 0 0 14px;
  color: var(--fg-muted);
  font: var(--text-body);
}
.panel-invoice-number {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  font-family: var(--font-mono);
  margin-left: 8px;
  max-width: 50%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-supplier {
  flex: 1;
  color: var(--fg-muted);
  font-size: 13px;
  max-width: 220px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
#document-actions-menu {
  /* Keep the open menu above the sticky section tabs. */
  z-index: 101;
}
#document-actions-menu > .btn {
  padding-right: 12px;
}
#document-actions-menu > .btn iconify-icon {
  margin-right: 0;
}
#document-actions-menu > .filter-dropdown-panel {
  left: auto;
  right: 0;
  width: 260px;
  min-width: 0;
  max-width: calc(100vw - 32px);
  padding: 4px;
  overflow-y: auto;
}
#document-actions-menu .document-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}
#document-actions-menu .document-action-item iconify-icon {
  flex-shrink: 0;
  width: 16px;
  font-size: 16px;
  color: var(--fg-muted);
}
#document-actions-menu .document-action-item:hover:not(:disabled),
#document-actions-menu .document-action-item:focus-visible {
  background: var(--brand-tint-hover);
  color: var(--brand);
}
#document-actions-menu .document-action-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
#document-actions-menu .document-action-item:disabled {
  color: var(--fg-faint);
  cursor: not-allowed;
}
#document-actions-menu .document-action-item:disabled iconify-icon {
  color: inherit;
}
#document-actions-menu .document-action-explanation {
  padding: 0 10px 8px 36px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
}
#document-actions-menu > .filter-dropdown-panel > div {
  display: flex;
  flex-direction: column;
}
.panel-actions .btn iconify-icon {
  margin-right: 4px;
}
#datev-export-area {
  display: flex;
  gap: 8px;
  align-items: center;
}
#datev-export-area > * {
  flex-shrink: 0;
  white-space: nowrap;
}
.panel-body {
  /* Design `.detail-panel-body { padding: 10px 12px 24px }` (app.css:331) — tighter
     top/sides, looser bottom for scroll runout. */
  padding: 10px 12px 24px;
}

/* Data list */
.data-list {
  display: grid;
  gap: 12px;
}
.data-list dt {
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-list dd {
  margin: 4px 0 0 0;
  color: var(--fg);
}

/* HTMX loading indicator */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator {
  display: inline-block;
}
.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Invoice detail components */
/* Depth model: sand panel body -> white section CARDS -> flat-white sub-content.
   Each section is a self-contained white card with a hairline + soft shadow,
   so it separates cleanly on the sand panel without competing nested boxes. */
.invoice-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  /* Design `.section-header { padding: 10px 14px }` + `.section-body { padding:
     0 14px 13px }` (app.css:335,341) — header is taller (10px) than body bottom
     gap (13px), achieved here with asymmetric card padding. */
  padding: 10px 14px 13px;
  /* Design `.section { margin-bottom: 10px }` (app.css:334). */
  margin-top: 10px;
  margin-bottom: 0;
}
.invoice-section:first-child {
  margin-top: 0;
}
.invoice-section:last-child {
  margin-bottom: 0;
}
/* The approvers section, when the viewer has a decision to make right now
   (see approval.clj's approvers-section) — the same info-tint treatment
   `.banking-awaiting-account-notice` uses elsewhere, so it reads as the
   page's primary action rather than one more card among the others. */
.invoice-section.invoice-section-priority {
  background: var(--info-tint);
  border-color: var(--info-border);
}
.invoice-section.invoice-section-priority .section-header {
  border-bottom-color: var(--info-border);
}
/* Purchase orders, GRNs and other type views render below the matches card in
   an unstyled wrapper whose first section has no margin of its own; the
   wrapper owns the gap to the matches card. */
#section-matches + div:not(.invoice-section) { margin-top: 10px; }
#section-invoice-details,
#section-validation,
#section-parties,
#section-cost-center,
#section-line-items,
#section-payment-summary {
  margin-top: 10px;
}
/* Contract type-adaptive middle: its first section is :first-child of the
   unstyled .panel-middle wrapper, so the :first-child reset above zeroes its
   top margin. Restore the gap so it matches every other container. */
.panel-middle > .invoice-section:first-child {
  margin-top: 10px;
}

/* In a data panel (the document view, the AR editor, partner approvals),
   sections are full width without a frame of their own: one thin divider separates a section from the one above, and
   the bordered containers inside a section (Payment's Status, Reference,
   Method and Terms; Invoice Details' VAT treatment, Classification and
   Delivery) are the only boxes — one level of containers. Tinted sections
   that call for attention (a pending approval decision, supplier
   communication, a duplicate review) stay boxed as callouts. */
:is(#document-content, .partner-approval-review, .ar-editor, .routing-review) .data-panel .invoice-section:not(.invoice-section-priority, .supplier-comms-section, .payable-review-alert) {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  /* Reach past the panel body's 12px side padding so the divider runs the
     panel's full width; the content keeps its 12px inset. */
  margin-left: -12px;
  margin-right: -12px;
  padding: 0 12px 14px;
}
/* A collapsed section is only its header band. */
:is(#document-content, .partner-approval-review, .ar-editor, .routing-review) .data-panel .invoice-section.collapsed:not(.invoice-section-priority, .supplier-comms-section, .payable-review-alert) {
  padding-bottom: 0;
}
/* The header is a full-width band in the subtle tone, so the start of each
   section stands out while scrolling; the band is also the collapse toggle. */
:is(#document-content, .partner-approval-review, .ar-editor, .routing-review) .data-panel .invoice-section:not(.invoice-section-priority, .supplier-comms-section, .payable-review-alert) > .section-header {
  margin: 0 -12px 14px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 15px;
}
:is(#document-content, .partner-approval-review, .ar-editor, .routing-review) .data-panel .invoice-section.collapsed:not(.invoice-section-priority, .supplier-comms-section, .payable-review-alert) > .section-header {
  margin-bottom: 0;
  border-bottom: none;
}
/* A section inside a status-strip drawer (a purchase order's validation,
   a contract's formal checks) is the drawer's content: the
   segment above is its heading, so it drops its own frame and header band. */
#document-content .data-panel .status-drawer .invoice-section {
  margin: 0;
  padding: 0;
  border: none;
}
#document-content .data-panel .status-drawer .invoice-section > .section-header {
  display: none;
}
#document-content .data-panel .status-drawer .invoice-section > .section-body {
  display: block;
}

.section-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  text-transform: none;
  letter-spacing: normal;
  /* Design `.section-header { padding: 10px 14px }` (app.css:335) is a flat header
     with no divider; here the card already pads 10px top, so the header only needs
     a tight gap to the body. Tightened 12/10 -> 10/8 for the dense rhythm. */
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-muted);
}
.invoice-section .section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.invoice-section .section-header iconify-icon {
  /* Flex `align-items: center` centers the icon's own box against the
     text's full line box, but the line box carries descender/leading space
     the glyphs don't use, so the icon (its viewBox glyph fills its box top-
     to-bottom, no such padding) reads as sitting a couple pixels low next
     to the text's visual cap-height. Nudged up — confirmed against six
     section headers (Totals, Cash Discount, Accounting Impact, Notes,
     Approval & Sending, Recipient) via zoomed screenshots. */
  transform: translateY(-2px);
}

/* Invoice metadata box — flat white sub-content (no border), delineated only by
   its uppercase micro-label title and the field dividers. */
.invoice-metadata-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 16px;
}

/* The "INVOICE" headline is redundant — the Invoice Number / Date fields below
   already label the block. Hidden to match the design. */
.invoice-metadata-box-title {
  display: none;
}

/* Metadata box values are all machine values (invoice number, dates) -> mono. */
.invoice-metadata-box .field-value {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
/* A name or sentence placed among them keeps the text font. */
.invoice-metadata-box .is-prose .field-value {
  font-family: inherit;
  font-size: inherit;
}

/* Invoice header grid.
   auto-fit/minmax instead of a @media breakpoint: this panel's actual width
   is decoupled from the viewport (it sits beside a resizable PDF pane), so a
   viewport-keyed breakpoint could still be "wide" by its own metric while
   this panel is squeezed narrow. Reflows straight from 4 down to 1 column as
   space shrinks, rather than jumping straight from 4 to 2. */
.invoice-header-grid {
  display: grid;
  /* Wide enough for an invoice number or a date on one line: with the service
     period the fields take a second row rather than wrapping mid-value. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  /* Design `.header-grid { gap: 11px 16px }` (app.css:346) — tighter row gap than
     column gap. */
  gap: 11px 16px;
}
/* A contract's legal facts are sentences (liability cap, insurance), so they
   keep the wider columns they had as detail fields. */
.invoice-header-grid.contract-legal-facts {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

/* A grid cell is narrow: an identifier that does not fit (an invoice or PO
   number) wraps onto a second line inside its box instead of being cut off. */
.invoice-header-grid .field-value-row-boxed :is(.field-value, .editable-value) {
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

/* Full-page review screens (a bank transaction, a duplicate review) keep their
   cards, but a card opens with the same header band as a data-panel section
   and its facts sit in text boxes. Transaction cards pad 16px, review cards
   20px; the band reaches the card's edges. */
.banking-transaction-page :is(.banking-detail-card, .accounting-detail-card):not(.banking-detail-card-warning) > :is(h2, .banking-detail-card-header):first-child {
  margin: -16px -16px 14px;
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.banking-transaction-page .banking-overview-facts {
  gap: 8px 16px;
}
.banking-transaction-page .banking-overview-fact {
  padding: 0;
  border-bottom: none;
}
.banking-transaction-page .banking-overview-fact dt {
  margin-bottom: 3px;
}
.banking-transaction-page .banking-overview-fact dd {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-canvas);
}
/* No bottom margin: the content below already keeps 16px (the resolution
   panel's flex gap, the evidence summary's top margin). */
.payable-review-detail-page :is(.payable-review-evidence > .payable-review-evidence-header, .payable-review-resolution-panel > h2) {
  margin: -20px -20px 0;
  padding: 12px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.payable-review-document-card > .panel-header {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

/* Parties grid — wider gutter replaces the box borders as the separator.
   Same auto-fit/minmax reasoning as the header grid above. The floor stays
   modest despite each party card carrying several rows of content: its
   fields already truncate with an ellipsis rather than force extra width
   (min-width: 0 throughout), so a lower floor degrades by truncating more
   eagerly instead of overflowing the grid at the panel's most extreme
   widths (see .payment-grid's comment on why that matters here). */
.parties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}

/* Party card — flat white (Issuer / Recipient), no border. Separated by the
   uppercase title, the field dividers, and the column gap. */
.party-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.party-card-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fg-muted);
  /* Design `.party-card-title { margin-bottom: 7px }` (app.css:363). */
  margin-bottom: 7px;
}
.party-card-name-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  /* Design `.party-row { padding: 5px 0 }` (app.css:364) — tight party block rows. */
  margin-bottom: 5px;
}
.party-card-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.party-card-name-row .editable-value {
  font-size: 15px;
  font-weight: 600;
}
.party-card-address-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  /* Design `.party-row { padding: 5px 0 }` (app.css:364). */
  margin-bottom: 5px;
}
.party-card-address {
  flex: 1;
  color: var(--fg);
  font-size: 13px;
  white-space: pre-line;
}
.party-card-address-row .editable-value {
  font-size: 13px;
  line-height: 1.4;
}
.party-card-field {
  display: flex;
  gap: 8px;
  /* Design `.party-field { padding: 5px 0 }` (app.css:368). */
  padding: 5px 0;
  margin-bottom: 0;
  font-size: 13px;
}
.party-card-field:first-of-type {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--bg-muted);
}
.party-card-field-label {
  /* Design `.pf-label { font: var(--text-caption); color: var(--fg-subtle);
     text-transform: uppercase; letter-spacing: .04em }` (app.css:370) — uppercase
     caption micro-label for VAT / EMAIL / PHONE. */
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-subtle);
  min-width: 70px;
}
.party-card-field-value-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Lets a long value (an email address) shrink to the card's width and
     truncate instead of pushing its box past the card's edge. */
  min-width: 0;
}
.party-card-field-value {
  flex: 1;
  min-width: 0;
  color: var(--fg);
}
/* A value row with a note under it (a value taken from the supplier record). */
.party-card-field-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.party-card-field-body .field-hint {
  margin: 3px 0 0;
}
/* The same note under a bank field taken from the supplier record. */
.field-group > .field-record-hint {
  font-size: 12px;
  color: var(--fg-muted);
  margin: 3px 0 0;
}
/* A read-only value truncates with its full text on hover; an editable one
   wraps inside its box instead, so its inline editor is never clipped. */
span.party-card-field-value:not(.editable-value) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.party-card-field-value.editable-value {
  overflow-wrap: anywhere;
}
.party-card-field-value.monospace {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* Field styling */
.field-group {
  margin-bottom: 12px;
}
.field-group:last-child {
  margin-bottom: 0;
}
.field-label {
  /* Design `.field-label { font: var(--text-label); text-transform: uppercase;
     letter-spacing: .5px; color: var(--fg-muted) }` (app.css:348) — uppercase
     micro-label (sans 12px 500) is the structural cue that replaces sub-box
     borders. Was 13px fg-subtle Title-case; aligned to the design token. */
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
.field-value {
  color: var(--fg);
  font-size: 14px;
}
.field-value.monospace {
  font-family: var(--font-mono);
  font-size: 13px;
}
/* A read-only value among the header grid's boxed fields (Uploaded) sits on the
   same line as the text inside their boxes: past the box's border and padding. */
.invoice-header-grid > .field-group > .field-value {
  padding-top: 6px;
  font-size: 14px;
}
:where(#document-content) .data-panel-scroll .invoice-header-grid > .field-group > .field-value {
  padding-top: 4px;
}
.field-value.pre-wrap {
  white-space: pre-wrap;
}
.field-value.na {
  color: var(--fg-subtle);
  font-style: italic;
}

.payable-resolution-form {
  display: grid;
  gap: 16px;
  max-width: 720px;
}

.payable-resolution-group {
  display: grid;
  gap: 8px;
}

.payable-resolution-heading {
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
}

.payable-resolution-options {
  display: grid;
  gap: 8px;
}

.payable-resolution-option {
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 12px;
}

.payable-resolution-option:has(input:checked) {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.payable-resolution-option input {
  accent-color: var(--brand);
  margin-top: 3px;
}

.payable-resolution-option span {
  display: grid;
  gap: 2px;
}

.payable-resolution-option small {
  color: var(--fg-muted);
}
.field-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Copy controls stay at the field edge even for short read-only values. */
:is(.field-value-row, .party-card-name-row, .party-card-address-row, .party-card-field-value-row, .field-copy-row) > .copy-btn {
  margin-left: auto;
  flex-shrink: 0;
}
.field-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.field-copy-content {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.field-copy-content > .editable-value {
  width: 100%;
  box-sizing: border-box;
}
.field-copy-row > .copy-btn {
  border: none;
  background: transparent;
}
.field-value-row-boxed:has([data-field-type="multiline"]) {
  align-items: flex-start;
}
.field-value-row-boxed .editable-value[data-field-type="multiline"] {
  white-space: pre-wrap;
}
:is(.field-value-row, .party-card-name-row, .party-card-address-row, .party-card-field-value-row, .field-copy-row):has(.editable-value[data-raw-value=""]:not([data-copy-value])) > .copy-btn {
  display: none;
}
/* Boxed variant (opt-in via labeled-field's :boxed?, Bank Details is the
   first user) — persistent bordered box filling the field's full width,
   copy button blended in at the right edge, matching the AP line-items
   table's boxed editable fields and the euro-sign-inside-the-box currency
   pattern. The box lives on .field-value-row, not on .editable-value
   itself: boxing the editable-value directly would nest two "this is
   editable" affordances inside each other (same reasoning as
   .account-pill .editable-value). */
.field-value-row-boxed {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.field-value-row-boxed .editable-value {
  display: block;
  flex: 1;
  min-width: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  transition: none;
}
.field-value-row-boxed .editable-value:hover,
.field-value-row-boxed .editable-value.is-editing,
.field-value-row-boxed .editable-value.is-saving,
.field-value-row-boxed .editable-value.is-human-edited {
  outline: none;
  box-shadow: none;
  background: transparent;
}
.field-value-row-boxed .field-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The value takes the box's free width, so its copy button sits at the right
   edge whether the value is plain text or an editable. */
.field-value-row-boxed > .field-value {
  flex: 1;
  min-width: 0;
}
/* Sentences (reasoning, payment terms) wrap instead of truncating. */
.field-value-row-boxed.is-wrapping {
  align-items: flex-start;
}
.field-value-row-boxed.is-wrapping .field-value {
  white-space: pre-wrap;
  overflow: visible;
  overflow-wrap: anywhere;
}
/* Plain text that wraps like running prose, collapsing its line breaks. */
.field-value-row-boxed.is-wrapping.is-flowing .field-value {
  white-space: normal;
}
/* The copy button keeps its own hover/copied feedback but drops its
   standalone border/background at rest, so it reads as part of the box
   (like the currency suffix) rather than a separate control glued on. */
.field-value-row-boxed .copy-btn {
  border: none;
  background: transparent;
}
.field-value-row-boxed .copy-btn:hover {
  background: var(--bg-muted);
}
/* No copy button to hang the box on for this one — the editable-value
   itself is the box, same as the line-items table's own fields. Used by
   labeled-field's non-:copy? case. */
.editable-value.field-value-boxed {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  outline: none;
  box-shadow: none;
  transition: none;
}
.editable-value.field-value-boxed:hover,
.editable-value.field-value-boxed.is-editing,
.editable-value.field-value-boxed.is-saving,
.editable-value.field-value-boxed.is-human-edited {
  outline: none;
  box-shadow: none;
}
.editable-value.field-value-boxed .field-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Multiline (Terms) grows with its content — never clip or single-line it. */
.editable-value.field-value-boxed textarea,
.editable-value.field-value-boxed .field-value.pre-wrap {
  white-space: pre-wrap;
  overflow: visible;
}

/* Party card (Issuer/Recipient): same boxed treatment, on its own row
   classes (different names, identical shape to .field-value-row-boxed
   above) since these rows already carry their own flex/spacing rules. */
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) {
  box-sizing: border-box;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .editable-value {
  display: block;
  flex: 1;
  min-width: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  transition: none;
}
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .editable-value:hover,
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .editable-value.is-editing,
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .editable-value.is-saving,
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .editable-value.is-human-edited {
  outline: none;
  box-shadow: none;
  background: transparent;
}
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .copy-btn {
  border: none;
  background: transparent;
  flex-shrink: 0;
}
:is(.party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) .copy-btn:hover {
  background: var(--bg-muted);
}
/* The address box can legitimately wrap to several lines (multiline field)
   — keep the copy button pinned to the first line instead of stretching
   to the box's full height. */
.party-card-address-row-boxed {
  align-items: flex-start;
}
.party-card-address-row-boxed .copy-btn {
  margin-top: 1px;
}

/* Read-only values sit in a white box. A value you can edit sits in a tinted
   box with a stronger border; on hover or while editing the box turns white
   with a brand border, and on hover a pencil appears at its end. The pencil's
   slot is always reserved, so hovering never moves the value or the copy
   button. */
:is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed):has(.editable-value),
.editable-value.field-value-boxed {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--bg-muted) 50%, var(--bg-canvas));
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
:is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed):has(.editable-value:hover, .editable-value.is-editing),
.editable-value.field-value-boxed:is(:hover, .is-editing) {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
:is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed):has(.editable-value)::after,
.editable-value.field-value-boxed::after {
  content: "";
  flex-shrink: 0;
  align-self: center;
  width: 13px;
  height: 13px;
  background-color: transparent;
  pointer-events: none;
  -webkit-mask: var(--icon-edit-pencil) center / contain no-repeat;
  mask: var(--icon-edit-pencil) center / contain no-repeat;
}
:is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed):has(.editable-value:hover):not(:has(.editable-value.is-editing))::after,
.editable-value.field-value-boxed:hover:not(.is-editing)::after {
  background-color: var(--brand);
}
/* The copy button keeps the box's right edge, editable or not; the edit
   pencil sits just before it. */
:is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed):has(.editable-value)::after {
  order: 1;
}
:is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) > .copy-btn {
  order: 2;
}
.editable-value.field-value-boxed {
  position: relative;
  padding-right: 26px;
}
.editable-value.field-value-boxed::after {
  position: absolute;
  top: 50%;
  right: 8px;
  margin-top: -6.5px;
}
:root {
  --icon-edit-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M11 2.5l2.5 2.5L6 12.5H3.5V10z'/%3E%3C/svg%3E");
}

.field-list {
  margin: 0;
  padding-left: 18px;
  color: var(--fg);
  font-size: 14px;
}
.field-list li {
  margin-bottom: 2px;
}
.field-list li:last-child {
  margin-bottom: 0;
}

/* Copy button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  /* Design small icon button `.pdf-iconbtn { border-radius: var(--r-sm) }`
     (app.css:272) — 3px on the chip scale, not an off-grid 4px. */
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover {
  background: var(--bg-muted);
  color: var(--fg);
}
.copy-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.copy-btn svg {
  width: 14px;
  height: 14px;
}
.copy-btn .check-icon {
  display: none;
}
.copy-btn.copied .copy-icon {
  display: none;
}
.copy-btn.copied .check-icon {
  display: block;
}

/* Confidence badge */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
/* Design `.confidence-badge.high { background: var(--success-tint); color:
   var(--success-strong) }` (app.css:232-234) — pale tint fill + strong text
   token, not ad-hoc rgba. */
.confidence-badge.high {
  background: var(--success-tint);
  color: var(--success-strong);
}
.confidence-badge.medium {
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.confidence-badge.low {
  background: var(--danger-tint);
  color: var(--danger-strong);
}
.confidence-badge.manual {
  background: var(--bg-muted);
  color: var(--fg-muted);
}

/* Inline confidence percentage (no box, just colored text next to label).
   Matches the label's own font-size/line-height (--text-caption: 11px/1.3)
   instead of a smaller, differently-leaded size — the mismatch made it read
   as smaller than the label and vertically off, not just a plain number
   sitting next to it. */
.confidence-pct {
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--success);
}
.confidence-pct.high { color: var(--success); }
.confidence-pct.medium { color: var(--warning); }
.confidence-pct.low { color: var(--danger); }

/* Line items table.
   The table scrolls inside its own container: beside the PDF preview the
   editor is narrow enough that the row would otherwise widen the document and
   scroll the whole page sideways. */
.line-items-scroll {
  margin-top: 8px;
  overflow-x: auto;
}
.line-items-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
  /* Fixed layout + explicit widths on every column below (set on <th>,
     which a fixed table always uses regardless of body content) keeps
     every column's width stable no matter what's typed into a row —
     Description is the only column without an explicit width, so it's the
     only one that grows or shrinks with the table. */
  table-layout: fixed;
}
.line-items-table td {
  /* Columns can no longer grow to fit content (table-layout: fixed), so
     anything too long to fit truncates with an ellipsis instead of forcing
     the row (and every sibling column) wider than its assigned width. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line-items-table th.li-col-article-code,
.line-items-table td.li-col-article-code {
  width: 90px;
}
.line-items-table th.li-col-qty,
.line-items-table td.li-col-qty {
  width: 55px;
}
.line-items-table th.li-col-unit,
.line-items-table td.li-col-unit {
  width: 108px;
}
.line-items-table th.li-col-unit-price,
.line-items-table td.li-col-unit-price {
  width: 95px;
}
.line-items-table th.li-col-amount,
.line-items-table td.li-col-amount {
  width: 95px;
}
.line-items-table th {
  text-align: left;
  padding: 6px 7px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Design `.line-items thead th { font: var(--text-caption); text-transform:
     uppercase; letter-spacing: .02em; color: var(--fg-muted) }` (app.css:391-393)
     — uppercase caption table header, fg-muted not fg-subtle. */
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.line-items-table th.numeric {
  text-align: right;
}
.line-items-table td {
  padding: 7px 7px;
  /* Design `.line-items tbody td { border-bottom: 1px solid var(--border-subtle) }`
     (app.css:397) — the subtle hairline divider token, not bg-muted. */
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg);
}
.line-items-table td.numeric {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
/* Amount rule (DESIGN_DECISIONS.md §3): dark mono number + lighter EUR suffix.
   Design `.li-eur .cur { color: var(--fg-faint) }` (app.css:404). */
.line-items-table .currency-suffix {
  color: var(--fg-faint);
  font-size: 10px;
}
.line-items-table .amount {
  color: var(--fg);
}
/* Design `.line-items` uses hairline row dividers + hover only — no zebra striping
   (app.css:397-418). Rows are separated by `border-bottom: 1px var(--border-subtle)`
   and lifted on hover with `var(--bg-subtle)`. Removed the nth-child stripe. */
.line-items-table tbody tr:hover {
  background: var(--bg-subtle);
}
.line-items-table tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 45px;
}

/* Icon-only columns (drag handle, delete): sized to the icon plus minimal
   padding, not shared proportionally with the flexible/numeric columns. */
.line-items-table th.drag-handle,
.line-items-table td.drag-handle {
  width: 28px;
}
.line-items-table th.line-item-actions,
.line-items-table td.line-item-actions {
  width: 36px;
  padding-left: 0;
}

/* Row action and "add another item" affordance reuse the shared .btn-icon/
   .btn-icon-danger and .add-period classes directly (see their hiccup) —
   .line-item-delete/.add-line-item are functional hooks only (JS targeting,
   hx-* attributes), not styled separately, so a future token change to
   either shared pattern doesn't need to be duplicated here. */

/* Line items (basic table): every editable field reads as a persistent input
   box at rest, matching the Accounts Receivable line-items table, instead of
   the app-wide hover-reveal/click-to-expand treatment used elsewhere (see
   ".editable-value" below) — Max found the latter unclear on this table
   specifically. The click-to-edit behavior itself is unchanged; only the
   at-rest appearance is overridden here, scoped to this table. */
.line-items-table td:not(.drag-handle):not(.line-item-actions) {
  padding: 4px 4px;
}
.line-items-table .editable-value {
  /* !important: editable-fields.js sets style.display = 'inline-block' the
     moment a field enters edit mode (needed elsewhere so a plain inline
     span can take an explicit pixel width). Here the box is already block
     at rest, and inline-block's baseline-based sizing shifts it a couple
     px within the row on edit — the "text box moves up" Max saw. Forcing
     block keeps the box's position identical whether editing or not. */
  display: block !important;
  box-sizing: border-box;
  width: 100%;
  padding: 5px 7px;
  background: color-mix(in srgb, var(--bg-muted) 50%, var(--bg-canvas));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  outline: none;
  box-shadow: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: none;
}
.line-items-table .editable-value:hover {
  border-color: var(--brand);
  background: var(--surface);
}
.line-items-table .editable-value.is-editing {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: none;
}
/* Neither the save-flash pulse nor the permanent human-edited underline
   (both defined generically above for the app-wide hover-reveal treatment)
   apply here — Max wants a static box with no animation and no bottom-border
   provenance indicator on this table specifically. */
.line-items-table .editable-value.is-saving {
  animation: none;
}
.line-items-table .editable-value.is-human-edited {
  box-shadow: none;
}

/* ===================================================== * Enhanced (dense) line-items table — DESIGN `LineItemsTable`
 * (detail.jsx:186-257). Compact accounting rows with Debit /
 * Credit / Cost-Center pill COLUMNS; each row expands in place
 * to reveal per-field confidence + reasoning (DESIGN_DECISIONS §5).
 * Ported from design app.css:386-515.
 * ============================================================ */

/* Wrap + table (app.css:387-388) */
.line-items-wrap {
  /* Full-height table — rows scroll with the page, never an inner vertical
     scrollbar. Horizontal overflow is scrollable, but the visible control is the
     floating .li-hscroll bar (below), so it stays reachable without scrolling to
     the bottom of a long table. */
  max-width: 100%;
  min-width: 0;
  container-type: inline-size;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
/* Floating horizontal scrollbar: sticks to the bottom of the visible panel and
   mirrors the table's horizontal scroll (synced in JS). Shown by JS only when
   the table actually overflows. */
.li-hscroll {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: 4;
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
}
.li-hscroll-track { height: 1px; }
.li-hscroll::-webkit-scrollbar { height: 11px; }
.li-hscroll::-webkit-scrollbar-thumb {
  background: var(--fg-faint);
  border-radius: var(--r-lg);
  border: 2px solid var(--surface);
}
/* With the floating bar active, hide the wrapper's own (far-down) scrollbar.
   Absent JS, the class is never added, so the native bar remains as a fallback. */
.line-items-wrap.has-proxy { scrollbar-width: none; }
.line-items-wrap.has-proxy::-webkit-scrollbar { height: 0; }
/* Shown by the document-preview `object` when the file cannot be rendered as a
   PDF (deleted object, or an expired presigned URL). Replaces the storage
   provider's raw XML error, which leaked the bucket name and a request id. */
.file-download-placeholder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.pdf-tab-item[href] {
  text-decoration: none;
}

/* Subtle Expand all / Collapse all toggle above the line-items table. */
.li-bulk-toggle {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 6px;
}
.li-bulk-btn {
  background: none;
  border: none;
  cursor: pointer;
  font: var(--text-sm);
  color: var(--fg-muted);
  padding: 2px 8px;
  border-radius: var(--r-sm);
}
.li-bulk-btn:hover {
  color: var(--brand);
  background: var(--bg-muted);
}
.line-items {
  width: max(100%, 940px);
  border-collapse: collapse;
  font-size: 12px;
  /* True content width of all columns; below this the .line-items-wrap
     scroller takes over instead of starving columns into overlap. */
  min-width: 940px;
  table-layout: fixed;
}
.line-items col.li-description-column { width: 240px; }
/* Header (app.css:389-396) */
.line-items thead th {
  position: sticky;
  top: 0;
  background: var(--bg-inset);
  z-index: 1;
  text-align: left;
  padding: 6px 7px;
  border-bottom: 1px solid var(--border);
  font: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  white-space: normal;
  line-height: 1.25;
  vertical-align: bottom;
}
/* Header label left-aligned, values right-aligned — the two aren't meant
   to line up; the header just names the column. Covers every current and
   future .num column (Qty/Unit Price/Tax/Amount today) without needing a
   per-column rule. */
.line-items th.num { text-align: left; }
.line-items td.num { text-align: right; }
.line-items th.pos,
.line-items td.pos {
  width: 26px;
  text-align: center;
  color: var(--fg-faint);
  /* Freeze # + Description so they stay visible while the numeric columns
     scroll horizontally within .line-items-wrap on narrow panels. */
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}
/* The row number sits at the generic td padding-top (4px); the boxed
   cells' own text sits lower, below their box's border + padding on top
   of that same 4px — pushed the number down to match. */
.line-items td.pos {
  padding-top: 10px;
}
.line-items thead th.pos { z-index: 3; background: var(--bg-inset); }
.line-items thead th:nth-child(2),
.line-items td.desc {
  position: sticky;
  left: 26px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.line-items thead th:nth-child(2) { z-index: 3; background: var(--bg-inset); }
.line-items td.desc { z-index: 1; }
.line-items tr.li-row:hover td.pos,
.line-items tr.li-row:hover td.desc { background: var(--bg-subtle); }
.line-items tr.li-row.open td.pos,
.line-items tr.li-row.open td.desc { background: var(--brand-tint); }
/* Body cells (app.css:397-401) */
.line-items tbody td {
  padding: 7px 7px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg);
  vertical-align: top;
}
.line-items td.num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  /* `nowrap` under `table-layout: fixed` would otherwise paint an over-long
     number across the next column. Clip it instead, so an unexpectedly wide
     value degrades to a visible ellipsis rather than silently colliding. */
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-items td.desc { min-width: 150px; font-size: 13px; overflow-wrap: anywhere; }
/* width:100% here (not just max-width) matters once editing starts: the
   input inside inherits its size from THIS span, not from the outer boxed
   .editable-value two levels up — without an explicit width, inline-block's
   shrink-to-fit left the input at barely half the box. */
.line-items td.desc .editable { display: inline-block; width: 100%; max-width: 100%; overflow-wrap: anywhere; }

/* Amount: dark mono number + lighter EUR suffix (app.css:402-407;
   DESIGN_DECISIONS §3). `.amount` is the existing editable number span. */
.line-items .li-eur {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--fg);
  white-space: nowrap;
}
.line-items .li-eur .amount { color: var(--fg); }
.line-items .li-eur .cur {
  color: var(--fg-faint);
  margin-left: 4px;
  font-size: 10px;
}
.line-items td.amount .li-eur { font-weight: 600; }

/* Tax %: the boxed number + its static "%" suffix, side by side. Isolated
   from .li-eur/.amount/.cur on purpose — those are currency's, replaced
   wholesale during editing by buildCurrencyInput; reusing them here (a
   different, generic edit path) would risk the suffix vanishing the same
   way the box itself used to. */
.line-items td.num .li-tax {
  display: flex;
  align-items: center;
  gap: 2px;
}
/* Booking tax code (DATEV BU / BMD Steuercode): an account pill sized to its
   code, followed directly by the read-only rate it sets. */
.line-items td.num .li-tax-code.account-pill {
  display: inline-block;
  flex-shrink: 0;
  width: auto;
  min-width: 40px;
  text-align: center;
}
/* A Xero tax code shows its name: the pill takes the room the rate leaves and
   ellipsizes; the full name is its title. */
.line-items td.num .li-tax-code-named.account-pill {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 64px;
  text-align: left;
}
.line-items td.num .li-tax-rate {
  margin-left: 4px;
  white-space: nowrap;
}
.line-items td.num .li-tax-suffix {
  flex-shrink: 0;
  color: var(--fg-faint);
  font-size: 10px;
}

/* Qty / Unit split + cost-center / expand affordance (app.css:410-421) */
.line-items td.qn {
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.line-items td.unit {
  color: var(--fg-muted);
  font-size: 11px;
  /* Textual units (e.g. "Arbeitszeit-Std") must wrap, not overflow the cell
     and paint over the Unit Price column. */
  white-space: normal;
  overflow-wrap: anywhere;
}
.line-items td.cc-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The expand chevron used to sit in its own column at the row's right
   edge — routinely scrolled out of view on this table's full width. It
   now lives in the "#" column instead, swapped in for the row number on
   hover: same click target either way, just relocated to where the
   cursor already is, and visible without needing to scroll first. */
.line-items td.pos .pos-chevron {
  display: none;
}
.line-items tr.li-row:hover td.pos .pos-number {
  display: none;
}
.line-items tr.li-row:hover td.pos .pos-chevron {
  display: inline-block;
}
.li-open-ico {
  font-size: 15px;
  color: var(--fg-faint);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.line-items tr.li-row {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.line-items tr.li-row:hover { background: var(--bg-subtle); }
.line-items tr.li-row:hover .li-open-ico { color: var(--brand); }
.line-items tr.li-row.open { background: var(--brand-tint); }
.line-items tr.li-row.open .li-open-ico {
  color: var(--brand);
  transform: rotate(180deg);
}

/* Account pills, number-first (app.css:513-515; DESIGN_DECISIONS §2).
   Debit = azure, Credit = green, Cost Center = violet. The pill wraps
   the master-data picker so click-to-edit is preserved. */
.account-pill {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--azure-50);
  color: var(--azure-700);
  font: var(--text-caption);
  font-family: var(--font-mono);
  font-size: 10.5px;
  white-space: nowrap;
}
.account-pill.credit {
  background: var(--success-tint);
  color: var(--success-strong);
}
.account-pill.cc {
  background: var(--accent-violet-tint);
  color: var(--accent-violet);
}
.account-pill.tax {
  background: var(--stone-100);
  color: var(--stone-700);
}
/* Not yet coded — muted rather than colour-coded (matches the AR
   accounting-impact table's .account-pill.empty treatment), so "+ Add"
   doesn't compete with an assigned account's colour. Matched via :has()
   on the placeholder rather than a class on .account-pill itself: picking
   a value only swaps the inner .editable-value (htmx targets that element
   directly), so a class here would still say "empty" after a real value
   is picked — :has() re-evaluates live against whatever's actually inside. */
.account-pill:has(.pill-placeholder) {
  background: var(--bg-muted);
  color: var(--fg-muted);
}
/* The picker swap renders an .editable-value inside the pill; keep it
   inheriting the pill's mono/colour so the at-rest pill stays compact. */
.account-pill .editable-value,
.account-pill .master-data-picker {
  font: inherit;
  color: inherit;
}
/* Strip the app-wide hover-reveal treatment (outline, underline, animated
   transition — see .editable-value's own rules) from the pill's inner
   element: the pill's own background/border-radius already says "this is a
   control," and that treatment was designed for plain text sitting directly
   on the row, not for something already rendered as a coloured chip — left
   in place it showed through as a stray underline/glow on top of the pill,
   never actually looking like a proper dropdown until the picker opened. */
.line-items .account-pill .editable-value {
  outline: none;
  box-shadow: none;
  background-color: transparent;
  transition: none;
}
/* Match the boxed scalar fields' footprint exactly: same padding, same
   1px border (transparent here — the pill's own background tint plays the
   border's visual role), same box-sizing — the base .account-pill rule's
   padding:1px 6px was sized for the old inline-chip look, well under half
   the boxed cells' height, and never grew past its own text either. */
.line-items td .account-pill {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  /* The base rule's font-size:10.5px (with the caption token's 1.3
     line-height ratio) is well under half of the ~13.65px it needs to be
     for a full row's worth of border+padding to add back up to the same
     height as the numeric boxes (11.5px font, 1.5 ratio, 17.25px line) —
     matched here directly rather than chasing the inherited ratio. */
  font-size: 11.5px;
  line-height: 17.25px;
}
.line-items td .account-pill .editable-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Number first and never cut; the account name follows in the body face,
   one step quieter, and is the only part the ellipsis eats; the full label
   is the pill's `data-tip`. The grouping table's account columns are sized to
   show the first letters of the name. */
.line-items td .account-pill > span {
  display: block;
  min-width: 0;
}
.account-pill :has(> .pill-number),
.line-items td .account-pill :has(> .pill-number) {
  display: flex;
  gap: 0.35em;
  min-width: 0;
}
.account-pill .pill-number {
  flex: none;
}
.account-pill .pill-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-sans);
  opacity: 0.8;
}
/* A supplier account pill links to supplier master data but reads as a pill. */
.account-pill a,
.account-pill a:hover {
  color: inherit;
  text-decoration: none;
}

/* Scalar fields (Qty/Unit/Unit Price/Tax/Description) get the same boxed,
   static-at-rest treatment as the Simple Table's .line-items-table — see
   that block's comment for the full rationale. Excludes .master-data-picker
   (the account/cost-dimension pills keep their own compact pill look;
   boxing those too would double up two different "this is editable"
   affordances in the same row). */
.line-items tbody td {
  padding: 4px 4px;
}
.line-items td .editable-value:not(.master-data-picker),
.line-items td .grouping-name,
.line-items td .grouping-name-input,
.editable-value.prepayment-description,
.editable-value.prepayment-description.is-editing {
  display: block !important;
  box-sizing: border-box;
  width: 100%;
  padding: 5px 7px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  box-shadow: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: none;
}
.line-items td .editable-value:not(.master-data-picker):hover,
.line-items td .grouping-name:hover,
.line-items td .grouping-name:focus-visible,
.line-items td .grouping-name-input:focus,
.editable-value.prepayment-description.is-editing {
  border-color: var(--brand);
  background: var(--bg-canvas);
}
/* The base rule above sets overflow:hidden unconditionally, which would
   otherwise clip the currency overlay's own dropdown at this box's
   original (narrow, pre-overlay) edge — same failure mode as the td.num
   fix above, one level in. */
.line-items td .editable-value[data-field-type="currency"].is-editing {
  overflow: visible;
}
/* Currency fields (Unit Price/Amount) excluded here: while editing they pop
   into the absolute-positioned overlay defined below ("Line-items currency
   edit"), which owns box-shadow for its pop-out elevation — this rule's own
   `td` element bumps its specificity just high enough to silently win that
   tie-break and flatten the overlay's shadow otherwise. */
.line-items td .editable-value:not(.master-data-picker):not([data-field-type="currency"]).is-editing {
  border-color: var(--brand);
  box-shadow: none;
}
.line-items td .editable-value:not(.master-data-picker).is-saving {
  animation: none;
}
.line-items td .editable-value:not(.master-data-picker).is-human-edited {
  box-shadow: none;
}

/* Expandable detail row (app.css:488-507). Hidden until the row is
   clicked (.open); the React reference conditionally renders it. */
.line-items tr.li-detail-row { display: none; }
.line-items tr.li-detail-row.open { display: table-row; }
.line-items .li-detail-row > td {
  padding: 0;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.li-detail {
  box-sizing: border-box;
  width: calc(100cqw - 28px);
  min-width: 0;
  max-width: calc(100cqw - 28px);
  padding: 14px 16px 16px;
  overflow-wrap: anywhere;
}
.li-detail-grid {
  display: grid;
  /* auto-fit/minmax, not a @media breakpoint keyed to the viewport — see
     .invoice-header-grid's comment above for why. */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 28px;
}
.li-detail-grid > [id^="accrual-cell-"] {
  grid-column: 1 / -1;
}
.li-acct-label {
  font: var(--text-caption);
  color: var(--fg-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
}
/* Confidence % sits next to its label (DESIGN app.css:497 margin-left:6px). */
.li-acct-label .confidence-pct { margin-left: 6px; }
.li-acct-val {
  font: var(--text-sm);
  color: var(--fg);
  line-height: 1.5;
}
.li-acct-code {
  font-family: var(--font-mono);
  font-weight: 600;
}
/* Period allocation pill + period (app.css:501-502) */
.alloc-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: var(--text-caption);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-right: 8px;
}
.alloc-period {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
}
/* Detail footer: article / BU code + reasoning toggle (app.css:503-507) */
.li-detail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.li-article {
  font: var(--text-sm);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.li-article .lbl {
  font-family: var(--font-sans);
  color: var(--fg-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-right: 8px;
}
.li-reason {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.li-reason:not(.expanded) { display: none; }
.li-reason strong {
  color: var(--fg);
  font-family: var(--font-mono);
  font-weight: 600;
}
.li-detail .reasoning-toggle { flex-shrink: 0; }

/* Payment summary container (merged section) */
.payment-summary-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Financial summary */
.financial-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.summary-row-label {
  color: var(--fg-muted);
}
.summary-row-value {
  color: var(--fg);
  font-family: var(--font-mono);
}
.summary-row-value.discount {
  color: var(--success);
}
.summary-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
}
.summary-row.total .summary-row-label {
  font-weight: 600;
  color: var(--fg);
}
.summary-row.total .summary-row-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand);
}
.summary-row.vat-breakdown {
  font-size: 12px;
}
.summary-row.vat-breakdown .summary-row-label {
  color: var(--fg-muted);
}
/* Prepayment rows in comparison grid */
.comparison-row.prepayment .comparison-label {
  color: var(--fg-muted);
  font-size: 12px;
}
.comparison-row.prepayment .comparison-original.discount {
  color: var(--success);
}
.summary-row.amount-due {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
}
.summary-row.amount-due .summary-row-label {
  font-weight: 600;
  color: var(--fg);
}
.summary-row.amount-due .summary-row-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--warning);
}

/* Comparison view for financial verification */
.financial-summary.comparison-view {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.comparison-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 8px 0 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}

.comparison-header .comparison-original,
.comparison-header .comparison-verified {
  text-align: right;
}

.comparison-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 6px 0;
  font-size: 13px;
  align-items: center;
}

.comparison-label {
  color: var(--fg-muted);
}

.comparison-original {
  text-align: right;
  color: var(--fg);
  font-family: var(--font-mono);
}

.comparison-verified {
  text-align: right;
  font-family: var(--font-mono);
}

/* Verification states */
.comparison-verified.verified {
  color: var(--success);
}

.comparison-verified.verified .check-mark {
  font-weight: 600;
}

.comparison-verified.unverified {
  color: var(--fg-muted);
}

.comparison-verified.unverified .unverified-value {
  font-style: italic;
}

.comparison-verified.discrepancy {
  color: var(--fg);
}

.delta-badge {
  display: inline-block;
  /* Warning status tint per DESIGN_DECISIONS.md §2 (pale tint + strong text),
     chip radius `--r-sm`; was ad-hoc rgba. */
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  margin-left: 6px;
  font-weight: 500;
}

/* Total row in comparison view */
.comparison-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
}

.comparison-row.total .comparison-label {
  font-weight: 600;
  color: var(--fg);
}

.comparison-row.total .comparison-original {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand);
}

.comparison-row.total .comparison-verified {
  font-size: 16px;
  font-weight: 600;
}

.comparison-row.total .comparison-verified.verified {
  color: var(--success);
}

.comparison-row.total .comparison-verified.discrepancy {
  color: var(--fg);
}

/* Verified breakdown (when computed VAT breakdown shown in right column only) */
.verified-breakdown {
  grid-column: 3;
  text-align: right;
  font-size: 12px;
  color: var(--fg-muted);
  padding-left: 16px;
}

.verified-breakdown .breakdown-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 2px 0;
}

.verified-breakdown .breakdown-label {
  color: var(--fg-subtle);
}

.verified-breakdown .breakdown-value {
  font-family: var(--font-mono);
  color: var(--fg-muted);
}


/* Responsive: stack columns on small screens */
@media (max-width: 600px) {
  .comparison-header {
    display: none;
  }
  .comparison-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-muted);
  }
  .comparison-original,
  .comparison-verified {
    text-align: left;
  }
  .comparison-original::before {
    content: "Original: ";
    color: var(--fg-subtle);
    font-size: 11px;
    font-family: inherit;
  }
  .comparison-verified::before {
    content: "Verified: ";
    color: var(--fg-subtle);
    font-size: 11px;
    font-family: inherit;
  }
}

/* Payment details.
   auto-fit/minmax instead of a @media breakpoint: this panel sits beside a
   resizable PDF pane, so its actual width is decoupled from the viewport
   width a @media query would key off — the panel can be narrow on a wide
   window (or vice versa as the PDF pane is dragged). The floor stays below
   the Cash Discount card's own width (it has none of its own — each tier's
   fields are a grid that stacks on its own, see .skonto-tier-grid)
   on purpose: at the most extreme panel widths (PDF pane dragged toward its
   900px cap) even one column can't reach 300px, and minmax's explicit floor
   would rather overflow the grid than shrink below it. The column floor is
   at least half the row, so the cards form at most two columns: four
   columns made the Cash Discount card too narrow and tall. */
.payment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(240px, calc((100% - 16px) / 2)), 1fr));
  gap: 16px;
}
.payment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  /* A grid item's default min-width is auto — the width of its widest
     unbreakable content, not 0 — so .field-value-row-boxed's white-space:
     nowrap (needed for its ellipsis truncation) was forcing this whole
     column wider than its 1fr share to fit an unbroken bank name/IBAN,
     unbalancing the 50/50 split with the facts column next to it. */
  min-width: 0;
}
.payment-card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.payment-card-pending {
  margin-bottom: 12px;
}
.payment-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
/* Each clearing that settled the invoice: when, the cash and any Skonto or
   write-off, and the clearing itself. */
.payment-settlement-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}
.payment-settlement-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 4px 0;
}
.payment-settlement-list li + li {
  border-top: 1px solid var(--border-subtle);
}

/* Payment section: Status | Method, a full-width schedule, then Reference | Terms. Grid rows stretch, so the containers sharing a row always
   match in height; a narrow data panel stacks them. Every value is a boxed
   field; what qualifies a value (its evidence, a link to the run holding it)
   sits on the field's label row, never inside the box. */
.payment-summary-container {
  container-type: inline-size;
}
.payment-summary-container > .payment-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 6px;
}
@container (max-width: 560px) {
  .payment-summary-container > .payment-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.payment-container {
  display: flex;
  flex-direction: column;
  padding: 8px;
}
.payment-container-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
}
.payment-container > .field-group:last-child,
.payment-container-fields > .field-group:last-child,
.payment-container .payment-method-fields > .field-group:last-child {
  margin-bottom: 0;
}
/* Split containers (Status, Method, Delivery) lay their fields out in two
   columns once they are wide enough, using the horizontal space of a wide data
   panel. Short values pair up; sentences (wrapping fields), an open edit form
   and anything that is not a single field (notices, lists, the undecided
   method form) span both columns. Wrappers that group fields (the method's
   decision fields, the pending amount) pass their fields through to the grid. */
.payment-container.is-split {
  container-type: inline-size;
}
@container (min-width: 340px) {
  .is-split > .payment-container-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    align-items: start;
  }
  .is-split > .payment-container-fields > *,
  .is-split > .payment-container-fields > .payment-method-fields > * {
    grid-column: 1 / -1;
  }
  .is-split > .payment-container-fields > .payment-method-fields,
  .is-split > .payment-container-fields > .payment-card-pending {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    align-items: start;
  }
  .is-split > .payment-container-fields > .field-group:not(.is-wide, :has(.is-wrapping, details[open])),
  .is-split > .payment-container-fields > .payment-method-fields > .field-group:not(.is-wide, :has(.is-wrapping, details[open])),
  .is-split > .payment-container-fields > .payment-card-pending > .field-group {
    grid-column: auto;
  }
}
.payment-container .payment-method-fields {
  margin-bottom: 12px;
}
.payment-container .payment-method-fields:last-child {
  margin-bottom: 0;
}
/* The method card's swap wrapper carries the gap to the bank fields below. */
.payment-container-fields > #invoice-payment-handling:has(> *):not(:last-child) {
  margin-bottom: 12px;
}

.payment-method-review > summary,
.payment-bank-details > summary {
  width: fit-content;
  margin-top: 8px;
  color: var(--fg-muted);
  font-size: 13px;
  cursor: pointer;
}
.payment-bank-detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 8px 12px;
  margin-top: 8px;
}
.payment-bank-detail-fields > .is-wide {
  grid-column: 1 / -1;
}

/* One block per bank account the invoice prints, each spanning the container. */
.payment-container-fields > .payment-bank-account {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.payment-bank-account + .payment-bank-account {
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.payment-bank-account-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.payment-bank-account-title {
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
}
.payment-bank-account-remove {
  margin-left: auto;
}
.payment-container-fields > .payment-bank-account-add {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 4px;
}

/* The schedule is a full-width row between Status/Method and Reference/Terms. */
.payment-summary-container > .payment-grid > .payment-schedule-card {
  grid-column: 1 / -1;
}
.payment-schedule-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.payment-schedule-heading .btn {
  font-weight: 500;
}
.payment-schedule-fields,
.payment-schedule-single-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}
.payment-schedule-fields > .field-group {
  margin-bottom: 0;
}
.payment-schedule-card > .installment-footing-note:not([hidden]) {
  margin-top: 8px;
  scroll-margin-top: 170px;
  padding: 6px 10px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 13px;
}
.payment-schedule-dialog {
  margin: auto;
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-popover);
}
.payment-schedule-dialog::backdrop {
  background: rgba(18, 16, 11, 0.45);
  backdrop-filter: blur(3px);
}
.payment-schedule-dialog form {
  display: flex;
  flex-direction: column;
  max-height: calc(90vh - 2px);
}
.payment-schedule-dialog [hidden] {
  display: none !important;
}
.payment-schedule-dialog .modal-header,
.payment-schedule-dialog .modal-actions {
  flex-shrink: 0;
}
.payment-schedule-dialog .modal-close {
  flex-shrink: 0;
}
.payment-schedule-dialog .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.payment-schedule-context,
.payment-schedule-note {
  margin: 6px 0 0;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}
.payment-schedule-dialog .payment-schedule-terms-note {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
}
.payment-schedule-dialog .payment-schedule-terms-note iconify-icon {
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 16px;
}
.payment-schedule-dialog .payment-schedule-terms-note .btn {
  margin-top: 8px;
}
.payment-schedule-dialog #payment-schedule-description {
  margin: 0;
}
.payment-schedule-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 18px 0;
  border: 0;
}
.payment-schedule-mode {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
}
.payment-schedule-mode:has(input:checked) {
  background: var(--brand-tint);
  border-color: var(--brand);
}
.payment-schedule-mode input {
  margin-top: 3px;
}
.payment-schedule-mode strong,
.payment-schedule-mode small {
  display: block;
}
.payment-schedule-mode small {
  margin-top: 4px;
  color: var(--fg-muted);
  line-height: 1.4;
}
.payment-schedule-dialog input:not([type=radio], [type=hidden], .european-date-native) {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
}
.payment-schedule-dialog input[readonly] {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border-color: var(--border);
  cursor: default;
}
.payment-schedule-dialog input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.payment-schedule-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}
.payment-schedule-row label,
.payment-schedule-single-fields label {
  position: relative;
  min-width: 0;
}
.payment-schedule-row .european-date-picker,
.payment-schedule-single-fields .european-date-picker {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 30px;
  height: 30px;
  border-color: transparent;
  background: transparent;
}
.payment-schedule-dialog input[data-european-date-display] {
  padding-right: 40px;
}
.payment-schedule-row-number {
  padding-bottom: 10px;
  color: var(--fg-muted);
  font-size: 13px;
}
.payment-schedule-remove {
  align-self: end;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-size: 24px;
  cursor: pointer;
}
.payment-schedule-remove:hover {
  color: var(--danger);
}
.payment-schedule-total {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.payment-schedule-dialog [data-payment-schedule-validation] {
  color: var(--warning-strong);
}
.payment-schedule-dialog [data-payment-schedule-validation].is-valid {
  color: var(--success-strong);
}
.payment-schedule-dialog .payment-schedule-preserve {
  padding: 12px;
  margin: 20px 0 12px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  font-size: 13px;
  line-height: 1.5;
}
.payment-schedule-dialog [data-payment-schedule-error] {
  margin-top: 12px;
}
@media (max-width: 480px) {
  .payment-schedule-modes {
    grid-template-columns: minmax(0, 1fr);
  }
  .payment-schedule-dialog .modal-body,
  .payment-schedule-dialog .modal-header,
  .payment-schedule-dialog .modal-actions {
    padding: 14px;
  }
  .payment-schedule-row {
    grid-template-columns: 16px minmax(0, 1fr) 26px;
    gap: 6px;
  }
  .payment-schedule-row label:first-of-type {
    grid-column: 2;
  }
  .payment-schedule-row label:last-of-type {
    grid-column: 2;
    grid-row: 2;
  }
  .payment-schedule-remove {
    grid-column: 3;
    grid-row: 1;
  }
}

/* Document data panel density: fields, containers and boxed values sit closer
   together than in forms elsewhere. The gap between section cards stays, so a
   new section still reads as one. Scoped to the document detail view
   (`#document-content`) without adding specificity, so pages that reuse
   `.data-panel-scroll` (AR editor, partner approvals) keep their spacing. */
:where(#document-content) .data-panel-scroll .field-group:not(:last-child) {
  margin-bottom: 8px;
}
:where(#document-content) .data-panel-scroll .invoice-header-grid {
  row-gap: 8px;
}
:where(#document-content) .data-panel-scroll .invoice-header-grid > .field-group {
  margin-bottom: 0;
}
:where(#document-content) .data-panel-scroll .detail-fields {
  gap: 8px 16px;
}
:where(#document-content) .data-panel-scroll .detail-fields > .field-group {
  margin-bottom: 0;
}
:where(#document-content) .data-panel-scroll :is(.field-label, .field-label-row) {
  margin-bottom: 3px;
}
:where(#document-content) .data-panel-scroll :is(.field-value-row-boxed, .party-card-name-row-boxed,
                                                 .party-card-address-row-boxed, .party-card-field-value-row-boxed) {
  padding-top: 3px;
  padding-bottom: 3px;
}
:where(#document-content) .data-panel-scroll .payment-container-title {
  margin-bottom: 6px;
}
:where(#document-content) .data-panel-scroll .invoice-metadata-box {
  margin-bottom: 12px;
}
:where(#document-content) .data-panel-scroll .invoice-totals .value-row:not(.total, .amount-due-adjustment .value-row) {
  padding-top: 7px;
  padding-bottom: 7px;
}
:where(#document-content) .data-panel-scroll .invoice-totals .value-row.total {
  margin-top: 6px;
  padding-top: 9px;
  padding-bottom: 7px;
}
.payment-container .payment-card-pending {
  margin-bottom: 0;
}
.payment-container .payment-card-actions {
  margin: auto 0 0;
  padding-top: 4px;
}
.payment-container .field-hint {
  font-size: 13px;
  color: var(--fg-subtle);
  margin: 0 0 12px;
}
.payment-container .field-hint-warning {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--warning-strong);
}
.payment-container .field-hint-warning iconify-icon {
  flex: none;
  margin-top: 2px;
  color: var(--warning);
}
.payment-container .skonto-card-head {
  margin-top: 4px;
}
.payment-container .skonto-card-head .field-label {
  margin-bottom: 0;
}
.field-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 8px;
  margin-bottom: 4px;
}
.field-label-row .field-label {
  margin-bottom: 0;
  white-space: nowrap;
}
/* The aside keeps its own width rather than squeezing beside the label; a row
   too narrow for both drops it below the label, and an aside wider than the
   whole row (a long legal basis, an "Other: …" source) wraps within it. */
.field-label-aside {
  display: inline-flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  justify-content: flex-end;
  gap: 4px 12px;
  margin-left: auto;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: var(--fg-subtle);
  text-align: right;
}
.field-label-link,
.link-arrow {
  color: var(--link);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.field-label-link {
  font-size: 13px;
}
.link-arrow {
  font-size: 14px;
}
.field-label-link:hover,
.link-arrow:hover {
  text-decoration: underline;
}

/* Invoice Details: VAT treatment, classification and delivery as one row of
   three containers (the Payment section's `.payment-container`), stacking in a
   narrow data panel. */
.invoice-details-row-wrap {
  container-type: inline-size;
  margin-top: 16px;
}
.invoice-details-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
}
/* Delivery holds the most fields, so it takes a row of its own (and its
   own two-column split) well before the row gets too narrow for three. */
@container (max-width: 960px) {
  .invoice-details-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .invoice-details-row > :nth-child(3) {
    grid-column: 1 / -1;
  }
}
@container (max-width: 640px) {
  .invoice-details-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* A container that follows a row of containers takes the row's own gap. */
.invoice-details-row-wrap + .payment-container {
  margin-top: 6px;
}
.invoice-details-row .inclusion-badge {
  background: var(--bg-muted);
  color: var(--fg-muted);
}

/* The invoice's totals close the Line Items section, the way a paper invoice
   sums its lines. The summary's own bordered box sets them apart from the item
   rows, so no rule separates them. */
.invoice-totals {
  margin-top: 16px;
}
/* Totals labels sit at the left of their box; amounts line up with the line
   amounts above. Each table kind sets its own right inset. */
.line-items-footer {
  --totals-inset-right: 0px;
}
.line-items-footer.is-editable-table {
  --totals-inset-right: 38px;
}
.line-items-footer.is-plain-table {
  --totals-inset-right: 8px;
}
.line-items-footer.is-grouped-table {
  --totals-inset-right: 3px;
}
.invoice-totals .value-row {
  align-items: center;
  padding-left: 2px;
  padding-right: calc(2px + var(--totals-inset-right, 0px));
}
/* With a prepayment, fee or installment, the amount due is what gets paid:
   it carries the accent, and the total reads as an ordinary sum. */
.invoice-totals.has-amount-due .value-row.total .value-amount {
  font-size: 14px;
  color: var(--fg);
}
.invoice-totals .value-row.amount-due .value-label {
  font-weight: 700;
  color: var(--fg);
}
.invoice-totals .value-row.amount-due .value-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}
/* An invoice without lines shows only its totals; nothing above to separate. */
.section-body > .invoice-totals:first-child {
  margin-top: 0;
}

/* Cash Discount card. A Percentage | Amount switch picks how each tier's
   saving is set; rows are a five-column grid (label, main input, deadline,
   calculated share or saving, payable). The source badge sits left of the
   switch so switching modes never moves the switch. Inside a narrow card the
   grid stacks into two columns and each calculated value carries its own
   label (the header row is hidden). */
.skonto-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.skonto-card-head .payment-card-title {
  margin-bottom: 0;
}
.skonto-card-actions {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}
.skonto-mode {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  overflow: hidden;
}
.skonto-mode button {
  border: 0;
  background: var(--surface);
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--fg-muted);
  cursor: pointer;
}
.skonto-mode button + button {
  border-left: 1px solid var(--border-strong);
}
.skonto-mode button[aria-pressed="true"] {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
}
.skonto-source,
.skonto-part {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 1px 8px;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.skonto-source {
  background: var(--brand-tint);
  color: var(--brand);
}
.skonto-source.is-edited {
  background: var(--warning-tint);
  color: var(--warning);
}
.skonto-part {
  border: 1px dashed var(--border-strong);
  color: var(--fg-muted);
}
.skonto-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.skonto-confirm {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  font-size: 14px;
}
.skonto-confirm[hidden] {
  display: none;
}
.skonto-confirm span {
  flex: 1;
  min-width: 180px;
}
/* One row per tier: label, percentage, saving, date. */
.skonto-tier-grid {
  display: grid;
  grid-template-columns: 44px minmax(64px, 0.8fr) minmax(88px, 1fr) minmax(124px, 1.2fr);
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.skonto-tier-grid .is-number {
  text-align: right;
}
/* The browser opens the calendar at the hidden native input, so it sits in
   the row's date cell instead of at the bottom of the page. */
.skonto-tier-grid:not(.is-head) {
  position: relative;
}
.skonto-tier-deadline.european-date-native {
  grid-column: 4;
  grid-row: 1;
  bottom: 0;
  left: 0;
}
.skonto-tier-deadline + [data-european-date-display],
.skonto-tier-deadline + [data-european-date-display] + .european-date-picker {
  grid-column: 4;
  grid-row: 1;
}
.skonto-tier-deadline + [data-european-date-display] {
  box-sizing: border-box;
  padding-right: 30px;
}
/* The calendar sits inside the date field as an icon, not as a second box. */
.skonto-tier-deadline + [data-european-date-display] + .european-date-picker {
  z-index: 1;
  justify-self: end;
  min-width: 0;
  height: 26px;
  margin-right: 3px;
  padding: 0 5px;
  border: 0;
  background: transparent;
}
.skonto-tier-deadline + [data-european-date-display] + .european-date-picker:hover {
  color: var(--fg);
}
.skonto-tier-field {
  position: relative;
  display: block;
  min-width: 0;
}
.skonto-tier-field .skonto-tier-input {
  box-sizing: border-box;
  padding-right: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.skonto-tier-field .skonto-tier-input::-webkit-inner-spin-button,
.skonto-tier-field .skonto-tier-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.skonto-tier-suffix {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  color: var(--fg-subtle);
  font-size: 12px;
  pointer-events: none;
}
/* The value the other one sets: read-only, like a calculated field. */
.skonto-tier-computed {
  box-sizing: border-box;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 21px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Labels match .field-label and values the 14px field text of the other
   payment cards. */
.skonto-tier-grid.is-head,
.skonto-tier-label,
.skonto-field-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.skonto-tier-grid.is-head {
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.3px;
}
.skonto-tier-grid:not(.is-head) > span:not([class]),
.skonto-tier-grid:not(.is-head) > .is-number {
  font-size: 14px;
  line-height: 21px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.skonto-note {
  margin: 2px 0 8px;
  font-size: 14px;
  color: var(--fg-muted);
}
.skonto-field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.skonto-applies {
  min-height: 54px;
  resize: vertical;
}
.skonto-check {
  margin-top: 10px;
}
/* Whole invoice / Some lines: what the cash discount covers. */
.skonto-scope {
  display: flex;
  margin: 4px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  overflow: hidden;
}
.skonto-scope button {
  flex: 1 1 0;
  border: 0;
  background: var(--surface);
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
}
.skonto-scope button + button {
  border-left: 1px solid var(--border-strong);
}
.skonto-scope button[aria-pressed="true"] {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
}
.skonto-scope button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--brand);
}
.skonto-scope-text {
  margin: 6px 0;
  font-size: 13px;
  color: var(--fg-muted);
}
/* Some lines: one row per invoice line item (checkbox, number, description,
   VAT rate, amount). A read-only row shows whether the discount applies. */
.skonto-line {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.skonto-line.is-editable {
  grid-template-columns: 18px 20px minmax(0, 1fr) auto auto;
  min-height: 32px;
  cursor: pointer;
}
.skonto-line.is-editable input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.skonto-line:last-child {
  border-bottom: 0;
}
.skonto-line-number {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.skonto-line-description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.skonto-line-amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.skonto-line-rate,
.skonto-line-source,
.skonto-line-status {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.skonto-line-source {
  margin-left: 6px;
}
.skonto-line-status {
  text-align: right;
}
.skonto-tier-input {
  width: 100%;
  padding: 5px 7px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 14px;
  line-height: 21px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.skonto-tier-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 109, 189, 0.1);
}
.skonto-tier-input::placeholder {
  color: var(--fg-faint);
}

/* Math check badge (shown in Payment Summary title) */
.math-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
}
.math-badge.math-pass {
  background-color: var(--success-tint);
  color: var(--success-strong);
}
.math-badge.math-warning {
  background-color: var(--warning-tint);
  color: var(--warning-strong);
}
.math-badge.math-error {
  background-color: var(--danger-tint);
  color: var(--danger-strong);
}
.math-badge.math-uncertain {
  background-color: var(--warning-tint);
  color: var(--warning-strong);
}
.math-badge.math-review {
  background-color: var(--info-tint);
  color: var(--azure-700);
}

/* Value row (single column display for payment summary) */
.value-row {
  display: flex;
  justify-content: space-between;
  /* Design `.pay-row { padding: 9px 2px }` (app.css:522) — rows sit flush in the
     section body, so only a hair of horizontal inset. */
  padding: 9px 2px;
  border-bottom: 1px solid var(--bg-muted);
}
.value-row:last-child {
  border-bottom: none;
}
.value-row .value-label {
  /* Design `.pay-row .pr-label { color: var(--fg-muted) }` (app.css:524) — pay
     labels read at fg-muted (stone-600), not the fainter fg-subtle. */
  color: var(--fg-muted);
  font-size: 13px;
}
.value-row .value-amount {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
}
.value-row .value-amount.discount {
  color: var(--success);
}
/* Payment Summary's amounts sit at the row's right edge via
   justify-content: space-between, not stretched across a wide container
   the way Bank Details' fields are — so the box here is sized to its own
   content (like .account-pill), not to 100% of some outer width. */
.value-row .editable-value.value-amount-boxed {
  display: inline-block;
  box-sizing: border-box;
  /* editWidth() locks the box to its at-rest (read-only) width when editing
     starts, which only needs to fit static text. Once editing splits the
     box into an amount input + currency <select> (60px incl. padding) plus
     a 4px gap, a narrow at-rest width squeezes the input enough to clip
     digits — this floor keeps room for both. */
  min-width: 150px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-canvas);
  /* Numbers read right-aligned everywhere else (line-items' `td.num`) — the
     box's min-width otherwise leaves the figure stranded at the left edge. */
  text-align: right;
  outline: none;
  box-shadow: none;
  transition: none;
}
.value-row .editable-value.value-amount-boxed:hover,
.value-row .editable-value.value-amount-boxed.is-editing,
.value-row .editable-value.value-amount-boxed.is-saving,
.value-row .editable-value.value-amount-boxed.is-human-edited {
  outline: none;
  box-shadow: none;
}
.value-row.sum .value-label,
.value-row.sum .value-amount {
  font-weight: 600;
}
.value-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
}
/* Avoid a double hairline above the Total: drop the row-divider on the row
   immediately preceding it, leaving only the Total's own border-top. */
.value-row:has(+ .value-row.total) {
  border-bottom: none;
}
.value-row.total .value-label {
  font-weight: 600;
  color: var(--fg);
}
.value-row.total .value-amount {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand);
}
.value-row.prepayment .value-label {
  color: var(--fg-muted);
  font-size: 12px;
}
.value-row.prepayment .value-amount.discount {
  color: var(--success);
}
.value-row.fee .value-label,
.value-row.installment .value-label {
  color: var(--fg-muted);
  font-size: 12px;
}

/* Collapsible sections */
.collapsible-section .section-body {
  overflow: visible;
  opacity: 1;
  transition: opacity 0.2s ease-out;
}
.collapsible-section.collapsed > .section-body {
  display: none;
}
.section-header-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.section-header-toggle:hover {
  color: var(--fg);
}
.section-header-toggle > span {
  display: inline-flex;
  align-items: center;
}
#section-datev-export .section-header-toggle {
  gap: 10px;
  margin: 0;
  padding: 12px 0;
  border: 0;
}
#section-datev-export .delivery-section-heading {
  flex: 1;
  min-width: 0;
  gap: 10px;
  line-height: inherit;
}
#section-datev-export .section-header-toggle:hover .approval-footer-title {
  color: var(--brand);
}
#section-datev-export .section-header-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-md);
}
.workflow-chevron,
#section-datev-export .chevron {
  flex: none;
  width: 16px;
  height: 16px;
  margin-left: auto;
  font-size: 16px;
  color: var(--fg-subtle);
  transition: transform 0.2s ease-out;
}
.approval-footer-toggle[aria-expanded="false"] .workflow-chevron {
  transform: rotate(-90deg);
}
#section-datev-export .section-header .workflow-export-avatar iconify-icon {
  transform: none;
}
.workflow-export-avatar iconify-icon {
  font-size: 15px;
}
.workflow-export-details {
  border-top: 1px solid var(--bg-muted);
}
.approval-footer-list .approvers-list,
.workflow-export-details .workflow-detail-list {
  margin-left: 40px;
}
.approval-footer-list .approver-avatar,
.workflow-detail-list .approver-avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
.workflow-detail-list .workflow-export-avatar iconify-icon {
  font-size: 13px;
}
.workflow-detail-content {
  margin-left: 74px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.workflow-detail-content p {
  margin: 0 0 8px;
}
.workflow-detail-content > :last-child {
  margin-bottom: 0;
}
.workflow-detail-list .workflow-delivery-meta {
  white-space: normal;
  overflow-wrap: anywhere;
}
/* A release hold's description says what holds it and what to do; it wraps
   rather than being cut to one line. */
.workflow-release-panel .workflow-detail-list .approver-meta {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.section-header-toggle .chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease-out;
  color: var(--fg-subtle);
}
.collapsible-section.collapsed .chevron {
  transform: rotate(-90deg);
}

/* Section inline badges */
.matches-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--fg);
  font-size: 11px;
  font-weight: 600;
}
.section-ok-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  /* Design `.section-header .sec-check` success check (app.css:338); success tint
     fill token, not ad-hoc rgba. */
  background: var(--success-tint);
  color: var(--success);
}
.section-count {
  color: var(--fg-muted);
  font-weight: 400;
  margin-left: 4px;
}

/* Empty state placeholder */
.empty-placeholder {
  color: var(--fg-subtle);
  font-style: italic;
  padding: 12px 0;
}
.party-card.empty {
  min-height: 80px;
}

/* Email connection banner */
.email-connection-banner {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-subtle) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}
.email-connection-banner.warning {
  border-color: var(--warning);
  background: linear-gradient(135deg, var(--warning-tint) 0%, var(--warning-tint) 100%);
}
.email-connection-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.email-connection-banner-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: var(--bg-muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
}
.email-connection-banner.warning .email-connection-banner-icon {
  background: rgba(191, 135, 0, 0.2);
  color: var(--warning);
}
.email-connection-banner-text {
  flex: 1;
}
.email-connection-banner-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
}
.email-connection-banner-description {
  color: var(--fg-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.email-connection-banner-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-outlook {
  background: var(--brand);
  color: white;
}
.btn-outlook:hover {
  background: var(--brand-hover);
  text-decoration: none;
}
.btn-gmail {
  background: var(--brand);
  color: white;
}
.btn-gmail:hover {
  background: var(--brand-hover);
  text-decoration: none;
}

/* Master Data Sections */
.master-data-section {
  /* Inner content cards nested inside a white settings section: white with a
     border, no shadow (the border delineates them, like the data panel). */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 16px;
}
.master-data-section h2 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.master-data-section h2 + .section-description {
  margin-top: -8px;
}

/* Master Data Catalogue Sections (Settings -> Data). Each catalogue is a
   <details class="card master-data-catalogue">, matching the collapsed-card
   pattern .financial-account-card already established for saved bank
   accounts: a clickable <summary class="card-header"> with the native
   disclosure marker hidden, a bordered/rounded .card body. */
details.master-data-catalogue > summary.card-header {
  display: flex;
  /* `wrap` let "Last updated" drop to its own line at narrow widths, which
     is what made it read as misaligned/"too high" against the chevron —
     this is one summary row, never two. */
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  list-style: none;
}
details.master-data-catalogue > summary.card-header::-webkit-details-marker {
  display: none;
}
details.master-data-catalogue[open] > summary.card-header {
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
/* Breathing room between the stacked catalogue cards (and after the section
   heading), instead of their borders touching. */
details.master-data-catalogue ~ details.master-data-catalogue,
.settings-section-title + details.master-data-catalogue {
  margin-top: var(--space-3);
}
/* Disclosure affordance: a caret at the trailing edge of every header that
   points down when collapsed and flips up when the card is open. */
details.master-data-catalogue > summary.card-header::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: var(--space-1);
  border-right: 2px solid var(--fg-subtle);
  border-bottom: 2px solid var(--fg-subtle);
  transform: rotate(45deg);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
details.master-data-catalogue[open] > summary.card-header::after {
  transform: rotate(-135deg);
}
details.master-data-catalogue > summary.card-header:hover::after {
  border-color: var(--fg);
}
.master-data-catalogue-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.master-data-catalogue-label {
  font-weight: 600;
}
.master-data-catalogue-count {
  color: var(--fg-muted);
  font-size: 13px;
}
.custom-dataset-catalogue .master-data-catalogue-count {
  flex: 1;
}
.custom-dataset-catalogue .custom-dataset-value {
  min-width: 10rem;
  max-width: 320px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* Dataset values wrap, so the table fits its card and scrolls only when even
   wrapped columns do not fit (the shared .table-container rule keeps tables at
   their unwrapped width). */
.custom-dataset-catalogue .table-container .table {
  min-width: 0;
}
.custom-dataset-catalogue .custom-dataset-compact-heading,
.custom-dataset-catalogue .custom-dataset-value-compact {
  min-width: 0;
  white-space: nowrap;
}
.custom-dataset-catalogue .custom-dataset-more {
  color: var(--fg-muted);
  white-space: nowrap;
}
.master-data-catalogue-updated {
  margin-left: auto;
  color: var(--fg-subtle);
  font-size: 12px;
  white-space: nowrap;
}
.master-data-catalogue-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
/* `form.` — `.form-group`'s own `margin-bottom: 20px` (same 0,1,0
   specificity) is declared later in the file and would otherwise win on
   source order, leaving a lopsided margin box that threw off this row's
   `align-items: center` by the height of that margin. */
form.master-data-catalogue-search {
  position: relative;
  flex: 1 1 260px;
  max-width: 320px;
  margin-bottom: 0;
}
.master-data-catalogue-search > input[type="search"] { padding-right: 34px; }
.master-data-catalogue-search > .list-search-spinner { left: auto; right: 11px; top: 12px; }
.master-data-catalogue-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
/* Only scroll horizontally when the columns actually overflow — the shared
   .table-container forces an always-visible horizontal scrollbar. */
details.master-data-catalogue .table-container {
  overflow-x: auto;
}
/* Freeze the Actions column against the right edge so Edit/Delete stay visible
   while the rest of the columns scroll horizontally (mirrors the .line-items
   freeze). The sticky thead (z-index on .table-container thead) keeps the header
   above these cells when scrolling vertically; a positioned cell paints above
   the static cells scrolling under it, so no extra z-index is needed here. */
details.master-data-catalogue .table thead th:last-child,
details.master-data-catalogue .table td.master-data-catalogue-row-actions {
  position: sticky;
  right: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  /* Shrink the Actions column to its buttons' own width instead of sharing
     in table-layout: auto's leftover-space distribution — Name/Employee-style
     columns need that space far more than two nowrap buttons do. A PERCENTAGE
     width here (e.g. 1%) is a known footgun: table-layout: auto can inflate
     the whole table so that percentage still nets out to the column's real
     min-content width, blowing every other column out with it. A literal 0
     doesn't have that failure mode — it just means "as small as your content
     allows," which nowrap already pins to the two buttons' width. */
  width: 0;
  white-space: nowrap;
}
details.master-data-catalogue .table tbody tr:hover td.master-data-catalogue-row-actions {
  background: var(--bg-subtle);
}
.custom-dataset-catalogue .table thead th:last-child:not(.custom-dataset-actions-heading) {
  position: static;
  width: auto;
  border-left: none;
  white-space: normal;
}
/* Import button loading state: while the multipart POST is in flight htmx puts
   .htmx-request on the .upload-inline form, so swap the icon and "Import" label
   for a spinner and "Importing…", and lock the control against re-triggering.
   The spinner and loading label are the shared .htmx-indicator, revealed by the
   global `.htmx-request .htmx-indicator` rule. */
.htmx-request .catalogue-import-btn {
  pointer-events: none;
}
.htmx-request .catalogue-import-icon,
.htmx-request .catalogue-import-label {
  display: none;
}
/* The Edit/Delete pair inside the Actions `<td>` — a nested `<div>`, not the
   `<td>` itself: giving a table cell `display: flex` pulls it out of the
   table's own column-width algorithm (its `width: 0` above then collapses
   the cell to near-nothing instead of "shrink to fit the two buttons",
   squeezing the buttons into a thin sliver with the header column left
   sized to the "Actions" label alone). */
.catalogue-row-actions-buttons {
  display: flex;
  gap: var(--space-2);
  white-space: nowrap;
}

/* Shared add/edit/import dialog — one native <dialog> per catalogue section.
   Sized/framed like the app's other native dialogs (.upload-reject-dialog,
   .qa-dataset-dialog); capped height + its own scroll so a long field list or
   the import wizard never grows taller than a narrow viewport. */
.master-data-dialog {
  margin: auto;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-popover);
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.master-data-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
/* The import conflict step's two-column Existing/Incoming comparison table
   is cramped at the shared dialog's default width; add/edit forms (the only
   other content this dialog ever holds) are unaffected. */
.master-data-dialog:has(.master-data-import-conflict) {
  width: min(640px, calc(100vw - var(--space-6)));
}
.master-data-dialog h3 {
  margin: 0 0 var(--space-4);
  font-size: 18px;
}

/* Supplier payment terms. The mode picker is the app's radio option buttons
   (.payment-schedule-mode) compacted to one line each, three side by side; the
   terms line follows on its own row. The mode decides what shows: From invoice
   hides the terms line, and only Custom shows the days field. */
.payment-terms-block {
  margin-top: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.payment-terms-block .payment-terms-modes {
  grid-template-columns: repeat(3, max-content);
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
}
/* Inside a form group, `.form-group label` (block) and the settings caption
   style (small grey capitals) would win over the option button: `display: flex`
   keeps the radio apart from its words, and the caption style is reset. */
.payment-terms-block .payment-terms-modes .payment-schedule-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 12px;
  color: var(--fg);
  font-size: 13px;
  letter-spacing: normal;
  line-height: 1.3;
  text-transform: none;
}
.payment-terms-block .payment-terms-modes .payment-schedule-mode input[type="radio"] {
  width: auto;
  margin: 0;
}
.payment-terms-block .payment-terms-modes .payment-schedule-mode strong {
  display: inline;
  font-weight: 500;
}
.payment-terms-block .payment-terms-modes .payment-schedule-mode:has(input:checked) strong {
  font-weight: 600;
}
.payment-terms-help {
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 400;
  cursor: help;
}
.payment-terms-modes .payment-terms-help {
  margin-left: 0;
}
.payment-terms-help:hover,
.payment-terms-help:focus-visible {
  color: var(--fg);
}
.payment-terms-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-3);
}
.payment-terms-block:has(input[name="payment-terms-mode"][value="invoice"]:checked) .payment-terms-row {
  display: none;
}
.payment-terms-row .form-group {
  margin: 0;
}
.payment-terms-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.payment-terms-row .payment-terms-inline label {
  display: inline-flex;
  align-items: center;
  margin: 0;
  white-space: nowrap;
}
.payment-terms-row .payment-terms-inline select {
  width: auto;
  min-width: 170px;
}
.payment-terms-row .payment-terms-custom input {
  width: 72px;
}
.payment-terms-row:not(:has(option[value="custom"]:checked)) .payment-terms-custom {
  display: none;
}

/* The step after saving a supplier's terms: which open invoices the terms
   reach and which they leave alone. */
.payment-terms-apply p {
  margin: 0 0 var(--space-3);
  font-size: 14px;
}
.payment-terms-apply-heading {
  display: block;
  margin-top: var(--space-3);
  font-size: 13px;
}
.payment-terms-apply-list {
  margin: var(--space-2) 0 0;
  padding-left: 18px;
  max-height: 168px;
  overflow-y: auto;
  font-size: 13px;
}
.payment-terms-apply-list li {
  margin: 2px 0;
}
.payment-terms-apply-skipped {
  color: var(--fg-muted);
}
.payment-terms-apply .form-actions {
  margin-top: var(--space-4);
}

/* The identity field on an edit: shown as static text (never offered for
   editing), styled like a disabled/read-only input rather than a plain label
   + value pair. */
.form-static-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  color: var(--fg);
}
.form-static-value {
  display: block;
  padding: 10px 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--fg-muted);
}

/* Edited-by provenance marker: a focusable pill (button, not span) so the
   shared [data-tip] tooltip below shows on hover AND keyboard focus. Reuses
   .badge-subtype's info palette rather than inventing a new one. */
.master-data-edited-marker {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-2);
  padding: 1px 8px;
  border: 1px solid var(--info-border);
  border-radius: var(--r-pill);
  background: var(--info-tint);
  color: var(--azure-700);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  cursor: default;
}
.master-data-edited-marker:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Free-text catalogue columns clip at a per-column cap (see
   `catalogue-text-cell-classes`); the full value stays on hover via title. The
   "Edited" marker sits beside the clipped text in a `.truncate-row` and keeps its
   natural width. */
details.master-data-catalogue .cell-truncate.md-cell-160 { max-width: 160px; }
details.master-data-catalogue .cell-truncate.md-cell-220 { max-width: 220px; }
details.master-data-catalogue .cell-truncate.md-cell-240 { max-width: 240px; }
details.master-data-catalogue .cell-truncate.md-cell-280 { max-width: 280px; }
details.master-data-catalogue .cell-truncate.md-cell-320 { max-width: 320px; }
details.master-data-catalogue .cell-truncate > .truncate-row > .master-data-edited-marker {
  flex: 0 0 auto;
  margin-left: 0;
}
#routing-aliases-section .cell-truncate.routing-alias-cell { max-width: 280px; }
#routing-aliases-section .cell-truncate.routing-alias-confirmed-cell { max-width: 220px; }

/* Import conflict comparison: the existing/incoming table reuses .table +
   .table-container as-is; only the per-field "this will change" highlight
   and the apply-to-remaining checkbox row are catalogue-specific. */
/* The comparison wraps instead of clipping so the user sees both full values. */
.table.master-data-conflict-table td.master-data-conflict-cell {
  min-width: 9rem;
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.master-data-diff-row {
  background: var(--warning-tint);
}
.master-data-diff-row th,
.master-data-diff-row td {
  border-color: var(--warning-border);
}
.master-data-apply-remaining {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
}
.master-data-apply-remaining input[type="checkbox"] {
  accent-color: var(--brand);
}
.master-data-import-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* next-window-sentinel's failed state (master-data-catalogue.js's
   htmx:responseError handler) — a plain text-button retry, not a full
   .btn, so it reads as inline recovery rather than a competing action. */
.master-data-next-window-error button {
  background: none;
  border: none;
  padding: 0;
  color: var(--danger-strong);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

/* Upload Zone */
.upload-zone {
  margin-bottom: 20px;
}
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-dropzone:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}

/* Upload spinner (HTMX indicator) */
.upload-spinner {
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 16px;
}
.htmx-request .upload-spinner.htmx-indicator,
.upload-spinner.htmx-indicator.htmx-request {
  display: flex;
}

/* Dataset info */
.dataset-info {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.dataset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dataset-header .dataset-meta {
  margin-bottom: 0;
}
.dataset-meta {
  margin-bottom: 16px;
  color: var(--fg-muted);
  font-size: 13px;
}

/* Error section */
.master-data-section.error {
  border-left: 3px solid var(--danger-strong);
  background: var(--danger-tint);
}
.validation-errors p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.validation-errors ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.validation-errors li {
  padding: 8px 12px;
  margin-bottom: 6px;
  background: var(--danger-tint);
  border-left: 2px solid var(--danger-strong);
  border-radius: var(--r-sm);
  font-size: 13px;
}

/* Success toast */
.success-toast {
  background: var(--success-tint);
  border: 1px solid var(--success-border);
  padding: 16px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--success-strong);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

/* Hidden visually only: the checkbox stays reachable by keyboard and
   announced by screen readers; the slider shows its state and focus. */
.toggle-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  opacity: 0;
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.toggle-slider {
  position: relative;
  width: 38px;
  height: 22px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: var(--r-pill);
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
}

/* Section description */
.section-description {
  color: var(--fg-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

/* Connection row — one compact row per connector (email, DATEV, Google
   Drive, Teams, Agicap, BigQuery, ...): icon, name/detail, one actions
   column on the right. State reads through the icon's tint, not a filled
   row background — a page of many connectors stays calm rather than
   turning into a strip of colored blocks. */
.connection-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}
.connection-row-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.connection-row-main {
  flex: 1;
  min-width: 0;
}
.connection-row-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--fg);
}
.connection-row-status {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: middle;
}
.connection-row-status.tone-success {
  background: var(--success-tint);
  color: var(--success-strong);
}
.connection-row-status.tone-warning {
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.connection-row-status.tone-info {
  background: var(--info-tint);
  color: var(--azure-700);
}
.connection-row-status.tone-neutral {
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.connection-row-subtitle {
  color: var(--fg-muted);
  font-size: 12.5px;
  margin-top: 2px;
}
.connection-row-description {
  color: var(--fg-subtle);
  font-size: 12.5px;
  margin-top: 2px;
}
.connection-expiry,
.connection-ledger {
  color: var(--fg-subtle);
  font-size: 12px;
  margin-top: 2px;
  font-family: var(--font-mono);
}
/* The DATEV Rechnungswesen shareable link: the URL and its copy button sit
   on one row, copy to the right — not stacked, which is what a bare <code>
   + <button> render as with no layout of their own. */
.shareable-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  max-width: 420px;
}
.link-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--fg-muted);
}
/* A short value (an email address) keeps its copy button right beside it
   instead of at the far end of the row. */
.shareable-link.is-inline {
  gap: 4px;
}
.shareable-link.is-inline .link-url {
  flex: 0 1 auto;
}
.link-url.is-inactive {
  text-decoration: line-through;
  color: var(--fg-subtle);
}
.link-url-note {
  font-size: 12px;
  color: var(--fg-subtle);
}
.connection-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
/* Every connector action (Connect DATEV / Generate Link / Add to Microsoft
   Teams / ...) renders at this same fixed width — sized to fit the longest
   label ("Add to Microsoft Teams") — so a column of cards reads as one
   consistent control instead of a ragged mix of button sizes. */
.connection-row-actions .btn {
  width: 200px;
  justify-content: center;
  white-space: nowrap;
}

[data-connector="medius"] .connection-row {
  align-items: flex-start;
}
.medius-settings-form {
  margin-top: 14px;
  max-width: 560px;
}
.medius-settings-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
.medius-email-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.medius-email-controls .form-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
}
.medius-email-controls .form-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.medius-email-controls .form-input,
.medius-email-controls .btn {
  box-sizing: border-box;
  height: 34px;
}
.medius-email-controls .btn {
  flex-shrink: 0;
}
.medius-settings-form .form-hint {
  margin: 6px 0 0;
}
@media (max-width: 600px) {
  [data-connector="medius"] .connection-row {
    flex-wrap: wrap;
  }
  [data-connector="medius"] .connection-row-actions {
    margin-left: 44px;
  }
}

/* Ledger name configuration form */
.ledger-name-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.ledger-name-form .field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  /* Form input label, not a data micro-label — keep sentence case. */
  text-transform: none;
  letter-spacing: normal;
  color: var(--fg);
  margin-bottom: 6px;
}
.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.text-input {
  flex: 1;
  max-width: 300px;
  padding: 6px 10px;
  font-size: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
}
.text-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.text-input::placeholder {
  color: var(--fg-subtle);
}
.field-hint {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 6px;
}

/* Settings page sections — each panel of the Settings modal (see
   `.settings-modal-panels`) is already a dedicated white surface for its one
   category, so a top-level section inside it needs no card chrome of its own
   (background/border/shadow) — just the spacing to separate it from a
   sibling section stacked in the same panel (e.g. Master Data's catalogue
   list followed by Booking history). */
.settings-section {
  margin-bottom: 32px;
}
.settings-section:last-child {
  margin-bottom: 0;
}
.settings-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-section-title iconify-icon {
  font-size: 20px;
  color: var(--fg-muted);
}

/* A sub-heading inside a `.settings-section` card (e.g. routing aliases
   inside Legal Entity & Compliance) — one step down from
   `.settings-section-title`, no icon, no divider of its own. */
.settings-subsection {
  margin-top: 24px;
}
.settings-subsection h3 {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 4px;
}
/* The accounting-system choice heads Integrations; the divider keeps its save
   button apart from the connection cards below. */
#accounting-system {
  padding-bottom: 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Settings modal — a native <dialog> centered over the current page with a
   blurred backdrop, not a page of its own (see `layout/base`'s
   `#settings-modal` shell and `com.getorcha.app.http.settings.integrations`).
   `[open]` is what actually triggers `display: flex` — <dialog> is
   `display: none` until then, and layering `display` under `[open]` (rather
   than just setting it unconditionally) keeps that native behavior intact. */
dialog#settings-modal {
  width: min(1520px, 95vw);
  height: min(820px, 90vh);
  max-width: none;
  max-height: none;
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}
dialog#settings-modal[open] {
  display: flex;
}
dialog#settings-modal::backdrop {
  background: rgba(18, 16, 11, 0.45);
  backdrop-filter: blur(6px);
}
#settings-modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}
/* Fallback for `page`'s no-other-surface-enabled case (see its docstring) —
   the org has nothing else to land a direct request on, so Settings renders
   as a real standalone page instead of the bare htmx fragment. Same
   entitybar+sidebar+panels layout as the modal, framed as its own surface
   since it's sitting in normal page flow rather than a `<dialog>`. */
.settings-modal-standalone {
  display: flex;
  flex-direction: column;
  min-height: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
/* Identifies which tenant is being edited — the only cue inside the modal
   itself for a customer managing more than one legal entity. */
.settings-modal-entitybar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.settings-modal-entitybar > iconify-icon {
  font-size: 18px;
  color: var(--fg-muted);
  flex-shrink: 0;
}
.settings-modal-entity-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.settings-modal-entity-eyebrow {
  font: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-subtle);
}
.settings-modal-entity-name {
  font: 600 16px var(--font-serif);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-modal-entitybar .settings-modal-close {
  margin-left: auto;
}
.settings-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
}
.settings-modal-sidebar {
  width: 264px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  background: var(--bg-canvas);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.settings-modal-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin: 0 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.settings-modal-search iconify-icon {
  font-size: 15px;
  color: var(--fg-faint);
  flex-shrink: 0;
}
.settings-modal-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: 400 13px var(--font-sans);
  color: var(--fg);
}
/* `.settings-modal-nav`'s own visual styling comes entirely from
   `.nav-items` (shared verbatim with the app's own primary sidebar nav —
   see `layout/nav`), so the modal's rail links, hover, icon sizing, and
   active left-border-accent all look exactly the same. This class only
   gives settings-modal.js a scoped selector to toggle `.active` on and
   filter by. */
.settings-modal-panels {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 28px 28px 32px;
  background: var(--surface);
}
.settings-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}
.settings-modal-close:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.settings-modal-close iconify-icon {
  font-size: 18px;
}

#document-correction-modal .document-correction-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  cursor: pointer;
}
#document-correction-modal .document-correction-option input[type="radio"] {
  flex: none;
  width: auto;
  margin: 0;
}

/* History modal — com.getorcha.app.ui.history. Same <dialog> chrome as
   dialog#settings-modal (centered, blurred backdrop) minus its left
   sidebar: a page mounts its own instance, so the id is the caller's, not
   fixed here. Sized for a focused list rather than the Settings dialog's
   full sidebar+panels surface. */
dialog.history-modal {
  width: min(1280px, 94vw);
  height: min(720px, 85vh);
  max-width: none;
  max-height: none;
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}
dialog.history-modal[open] {
  display: flex;
}
dialog.history-modal::backdrop {
  background: rgba(18, 16, 11, 0.45);
  backdrop-filter: blur(6px);
}
.history-modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--surface);
}
.history-modal-head {
  position: relative;
  flex: none;
  padding: 22px 52px 16px 28px;
  border-bottom: 1px solid var(--border);
}
.history-modal-head h2 {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 600;
}
.history-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}
.history-modal-close:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.history-modal-close iconify-icon {
  font-size: 18px;
}
.history-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 28px 24px;
  /* Wider than .table-status-pill's 112px default (tuned for AP's short
     Exported/Rejected labels) -- "Filed as Outgoing Invoice" needs the room,
     matching #document-list's own override for the same reason. */
  --table-status-pill-width: 180px;
}
.history-modal-foot {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 28px;
  border-top: 1px solid var(--border);
  background: var(--stone-50);
  font-size: 12.5px;
  color: var(--fg-subtle);
}

.view-link {
  font-size: 12.5px;
  font-weight: 500;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Secondary/helper text utility (empty states, hints, position counters). */
.text-muted {
  color: var(--fg-muted);
}

/* Scrollable table container */
.table-container {
  max-height: 400px;
  overflow-x: scroll;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  /* Firefox scrollbar */
  scrollbar-width: auto;
  scrollbar-color: var(--fg-faint) var(--bg-muted);
}
/* Webkit scrollbar styling - always visible for accessibility */
.table-container::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}
.table-container::-webkit-scrollbar-track {
  background: var(--bg-muted);
  border-radius: var(--r-lg);
}
.table-container::-webkit-scrollbar-thumb {
  background: var(--fg-faint);
  border-radius: var(--r-lg);
  border: 2px solid var(--bg-muted);
}
.table-container::-webkit-scrollbar-thumb:hover {
  background: var(--fg-subtle);
}
.table-container::-webkit-scrollbar-corner {
  background: var(--bg-muted);
}
.table-container .table {
  margin: 0;
  border: none;
  min-width: max-content;
}
.table-container thead {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

/* Sortable table headers */
.table.sortable th {
  cursor: pointer;
  user-select: none;
}
.table.sortable th:hover {
  background: var(--bg-muted);
}
.table.sortable th iconify-icon {
  opacity: 0.5;
  margin-left: 4px;
}
.table.sortable th:hover iconify-icon,
.table.sortable th.sort-active iconify-icon {
  opacity: 1;
}
.table.sortable th.htmx-request {
  opacity: 0.6;
}

/* Active sort column indicator (for document list) */
.table th.sort-active {
  background: var(--brand-tint);
}

.table th.sort-active iconify-icon {
  opacity: 1;
}

/* Accounts & Cost Center Components */

/* Reasoning toggle */
.reasoning-container {
  margin-top: 8px;
}
.reasoning-toggle {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  font-size: 11px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--r-lg);
  font-weight: 500;
  transition: background 0.15s;
}
.reasoning-toggle:hover {
  background: var(--bg-muted);
  text-decoration: none;
}
.sv-reasoning-list {
  margin: 0;
  padding-left: 18px;
}
.sv-reasoning-list li { margin: 2px 0; }
.sv-sources {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.sv-sources-label {
  font-weight: 600;
  color: var(--fg-muted);
}
.sv-source-link {
  color: var(--brand);
  text-decoration: underline;
}
.reasoning-text {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.2s ease-out;
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.5;
  background: var(--bg-canvas);
  border-radius: 4px;
}
.reasoning-text.expanded {
  max-height: none;
  padding: 12px;
  margin-top: 8px;
  overflow-y: visible;
}

/* Account card (inline in line items) */
.account-card {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px 12px;
  min-width: 180px;
}
.account-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.account-number {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
}
.account-name {
  color: var(--fg);
  font-size: 13px;
}
.account-card .confidence-badge {
  margin-left: auto;
}

/* Cost center card */
.cost-center-card {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.cost-center-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.cost-center-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cost-center-number {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
  font-size: 16px;
}
.cost-center-name {
  color: var(--fg);
  font-size: 15px;
  font-weight: 500;
}
.cost-center-employee {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.cost-center-employee .label {
  color: var(--fg-subtle);
}
.cost-center-employee .employee-name {
  color: var(--fg);
}

/* Accrual badge */
.accrual-badge-container {
  min-width: 140px;
}
.accrual-badge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.accrual-type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
}
.accrual-type-badge.single-period {
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.accrual-type-badge.multi-month {
  background: var(--brand-tint);
  color: var(--brand);
}
.accrual-type-badge.multi-year {
  background: var(--accent-violet-tint);
  color: var(--accent-violet);
}
/* Editable: same outer-badge treatment as .country-badge/.incoterm-badge —
   strip the app-wide hover-reveal (outline + underline box-shadow), which
   otherwise shows through on top of the badge's own colour. The type's own
   background must be re-asserted too, not just left alone: .editable-value's
   own :hover background rule is equal specificity and comes later in the
   stylesheet, so it would otherwise win and flatten every type to the same
   generic blue tint. */
.editable-value.accrual-type-badge:is(:hover, .is-editing, .is-saving, .is-human-edited) {
  outline: none;
  box-shadow: none;
}
.editable-value.accrual-type-badge.single-period:is(:hover, .is-editing, .is-saving, .is-human-edited) {
  background: var(--bg-muted);
}
.editable-value.accrual-type-badge.multi-month:is(:hover, .is-editing, .is-saving, .is-human-edited) {
  background: var(--brand-tint);
}
.editable-value.accrual-type-badge.multi-year:is(:hover, .is-editing, .is-saving, .is-human-edited) {
  background: var(--accent-violet-tint);
}
.accrual-period-count {
  font-size: 12px;
  color: var(--fg-subtle);
}
.accrual-periods {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-canvas);
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
}
.accrual-period {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}
.period-label {
  color: var(--fg);
}
.period-amount {
  color: var(--fg);
  font-family: var(--font-mono);
}
.accrual-period.more {
  color: var(--fg-subtle);
  font-style: italic;
  grid-column: 1 / -1;
}

/* Service category badge */
.service-category-badge {
  display: inline-flex;
  align-items: center;
}
.service-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.service-category-header .reasoning-container {
  margin-top: 0;
}
/* The confidence % next to Classification reads as a stray text box with
   the shared .confidence-badge pill treatment — drop the background/padding
   so it's just the coloured number, nudged up slightly to sit level with
   the category field beside it. */
.service-category-header .confidence-badge {
  background: none;
  padding: 0;
  position: relative;
  top: -1px;
}
.category-label {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-muted);
  color: var(--fg);
}
/* Classification section content */
.classification-content {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}


/* Line Item Cards */
.line-items-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.line-item-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.line-item-card > .reasoning-container {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--bg-muted);
}
.line-item-card > .reasoning-container .reasoning-text div {
  margin-bottom: 6px;
}
.line-item-card > .reasoning-container .reasoning-text div:last-child {
  margin-bottom: 0;
}

.line-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}
.line-item-description {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--fg);
  line-height: 1.5;
}
.line-item-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.line-item-description .editable-value {
  font-size: 16px;
  font-weight: 600;
}

.line-item-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.line-item-meta-row .grid-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.line-item-accounts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 8px;
}
.line-item-accounts-grid .grid-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 13px;
  color: var(--fg-subtle);
}

.meta-value {
  font-size: 13px;
  color: var(--fg);
}

.meta-value.monospace {
  font-family: var(--font-mono);
}

.meta-value.discount {
  color: var(--fg);
}

/* VAT status label next to Tax headline */
.vat-status-label {
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  text-transform: none;
}
.vat-status-label.valid { color: var(--success); }
.vat-status-label.warning { color: var(--warning); }
.vat-status-label.invalid { color: var(--danger); }
.vat-expected-inline {
  font-size: 11px;
  color: var(--warning);
}

/* Account/cost-center numbers inline in meta-value */
.meta-value .account-number {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
}
.meta-value .account-name {
  color: var(--fg);
}
.meta-value .cost-center-number {
  font-family: var(--font-mono);
  color: var(--accent-violet);
  font-weight: 600;
}
.meta-value .cost-center-name {
  color: var(--fg);
}
.meta-value .cost-center-employee {
  color: var(--fg-muted);
  font-style: italic;
}

/* Line item surcharges */
.line-item-surcharges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}

.surcharges-label {
  font-size: 10px;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.surcharge-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  background: var(--bg-muted);
  border-radius: 4px;
}

.surcharge-desc {
  color: var(--fg-muted);
}

.surcharge-amount {
  color: var(--warning);
  font-weight: 500;
}

.surcharge-tax-code {
  color: var(--fg-subtle);
  font-size: 10px;
}

/* Line item enrichments (account + accrual) */
.line-item-enrichments {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.enrichment-badge {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 12px;
}

.enrichment-label {
  display: block;
  font-size: 10px;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.enrichment-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.enrichment-badge .account-number {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
}

.enrichment-badge .account-name {
  color: var(--fg);
  font-size: 13px;
}

/* Cost center badge in line items */
.enrichment-badge .cost-center-number {
  font-family: var(--font-mono);
  color: var(--accent-violet);
  font-weight: 600;
  font-size: 14px;
}

.enrichment-badge .cost-center-name {
  color: var(--fg);
  font-size: 13px;
}

.enrichment-badge .cost-center-employee {
  color: var(--fg-muted);
  font-size: 12px;
  font-style: italic;
}

.enrichment-badge .reasoning-container {
  flex-basis: 100%;
  margin-top: 4px;
}

/* Accrual specific styles in enrichment */
.accrual-single-period {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
  font-size: 12px;
}

.accrual-periods-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-basis: 100%;
  margin-top: 8px;
}

.accrual-editor-layout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: start;
  gap: 8px 16px;
}
.accrual-editor-layout > .accrual-periods-inline {
  grid-column: 2;
  margin-top: 0;
}
.accrual-editor-layout > .add-period {
  grid-column: 2;
  justify-self: start;
  margin-top: 0;
}
@container (max-width: 500px) {
  .accrual-editor-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .accrual-editor-layout > .accrual-type-badge {
    max-width: 160px;
  }
  .accrual-editor-layout > .accrual-periods-inline,
  .accrual-editor-layout > .add-period {
    grid-column: 1;
  }
}

.period-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.period-chip .period-label {
  color: var(--fg);
}

.line-items .period-chip .period-label .editable-value {
  width: 128px !important;
  min-width: 128px !important;
  max-width: 128px;
}

.line-items .period-chip .period-amount .editable-value {
  width: 104px !important;
  min-width: 104px !important;
  max-width: 104px;
}

.line-items .period-chip .editable-value {
  box-sizing: border-box;
  height: 30px;
  vertical-align: middle;
}

.line-items .period-chip .period-month-select {
  flex: 0 0 44px;
  width: 44px;
}

.line-items .period-chip .period-year-input {
  flex: 0 0 56px;
  width: 56px;
}

/* Blank month on a freshly added period: render the "Set month" placeholder
   muted/italic so it reads as a prompt yet stays a visible click target. */
.period-chip .period-label .editable-value.period-empty {
  color: var(--fg-subtle);
  font-style: italic;
}

/* Inline month editor: a numeric MM dropdown + YYYY input. A custom control
   because the native month picker rendered a black calendar icon and a
   locale month-name. */
.editable-value .period-month-select,
.editable-value .period-year-input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.4;
  padding: 0 2px;
  margin: 0;
}
.editable-value .period-year-input {
  width: 5ch;
  margin-left: 3px;
}
.editable-value .period-month-select:focus,
.editable-value .period-year-input:focus {
  outline: none;
  border-color: var(--brand);
}
/* Hide the number-input spinner so the year reads as a clean 4-digit field. */
.editable-value .period-year-input::-webkit-outer-spin-button,
.editable-value .period-year-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.period-chip .period-amount {
  color: var(--fg);
  font-family: var(--font-mono);
}

.period-chip.more {
  color: var(--fg-subtle);
  font-style: italic;
}

/* Period add/remove controls (accrual editing) */
.period-chip .period-remove {
  display: inline-flex;
  align-items: center;
  padding: 0;
  margin-left: 2px;
  border: none;
  background: transparent;
  color: var(--fg-subtle);
  cursor: pointer;
  line-height: 1;
}
.period-chip .period-remove:hover {
  color: var(--red-500);
}

.add-period,
.inline-add-control {
  font-family: inherit;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  padding: 4px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 11px;
  cursor: pointer;
}
.add-period:hover,
.inline-add-control:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* Line item amount (prominent, flex-aligned) */
.line-item-amount {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
}
.line-item-price {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand);
  font-family: var(--font-mono);
}
.line-item-amount .editable-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand);
  font-family: var(--font-mono);
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .line-item-top {
    flex-direction: column;
    gap: 8px;
  }

  .line-item-amount {
    text-align: right;
  }

  .enrichment-badge {
    min-width: 100%;
  }
}

/* Validation Semaphore (traffic light dots) */
.validation-semaphore {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.validation-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  transition: transform 0.15s;
}

.validation-dot:hover {
  transform: scale(1.3);
}

.validation-dot.pass {
  background: var(--success);
}

.validation-dot.warning {
  background: var(--warning);
}

.validation-dot.error {
  background: var(--danger);
}

.validation-dot.uncertain {
  background: transparent;
  border: 2px solid var(--fg-muted);
  width: 8px;
  height: 8px;
}

.validation-dot.missing {
  background: var(--border);
}

/* Validation Section */
.validation-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.validation-issues {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Validation issues banner (shown above boxes for non-pass items) */
.validation-issues-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

/* Per-revision findings that need an explicit reviewer decision. */
.invoice-finding-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invoice-finding-controls-intro,
.finding-review-card p {
  margin: 0;
}

.invoice-finding-controls-intro,
.finding-resolution-history {
  color: var(--fg-muted);
  font-size: 13px;
}

.finding-review-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.finding-review-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.finding-review-severity {
  flex: none;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.finding-review-severity.warning {
  color: var(--warning-strong);
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
}

.finding-review-severity.error {
  color: var(--danger-strong);
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
}

.finding-resolution-form,
.finding-explanation-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finding-explanation-label {
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
}

.finding-explanation-label input {
  width: 100%;
  padding: 8px 10px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font: inherit;
}

.finding-resolution-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.finding-resolution-actions > .finding-resolution-form {
  flex: 1 1 100%;
}

/* Validation grid (two-column layout: Formal Requirements | Fraud Signals).
   Flex wrapping keys the layout to the resizable data panel without creating
   extra empty columns when the PDF panel is collapsed. A container query is
   unsuitable because check-row's fixed-position tooltip must escape the
   panel's scroll clipping. */
.validation-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.validation-grid > .validation-box:not(.tax-compliance-box) {
  flex: 1 1 220px;
}

/* Validation box (container for formal requirements / tax compliance) */
.validation-box {
  background: var(--surface);
  /* Plain hairline border — same as the Supplier/Recipient verification boxes;
     status is carried by the header badge, not a coloured left edge. */
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}

.validation-box-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: none;
  letter-spacing: 0.01em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-muted);
}

.validation-box-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.validation-empty-note {
  color: var(--fg-subtle);
  font-style: italic;
  font-size: 13px;
}

.validation-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Validation Check Card (used in warning banner) */
.validation-check-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 16px;
}

.validation-check-card.warning {
  border-color: var(--warning-border);
  background: var(--warning-tint);
}

.validation-check-card.error {
  border-color: var(--danger-border);
  background: var(--danger-tint);
}

.validation-check-card.uncertain {
  border-color: var(--border);
  background: var(--bg-muted);
}

.validation-check-card.pass .validation-status-icon {
  color: var(--success);
}

.validation-check-card.warning .validation-status-icon {
  color: var(--warning);
}

.validation-check-card.error .validation-status-icon {
  color: var(--danger);
}

.validation-check-card.uncertain .validation-status-icon {
  color: var(--fg-muted);
}

/* Old chip icon colors removed - now handled by .validation-chip and .passed-check-chip variants below */

.validation-check-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.validation-check-label {
  font-weight: 500;
  color: var(--fg);
  font-size: 14px;
}

.inferred-badge {
  font-size: 10px;
  padding: 2px 6px;
  /* No exact design class; apply the info/azure status token (DESIGN_DECISIONS.md
     §2: info = brand-tint fill + azure-700 text) instead of ad-hoc rgba, and the
     chip radius `--r-sm` (3px). */
  background: var(--brand-tint);
  color: var(--azure-700);
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.validation-check-message {
  margin-top: 8px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.breakdown-download-btn,
.line-rate-web-search {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none;
  cursor: pointer;
}
.breakdown-download-btn:hover,
.line-rate-web-search:hover,
.line-rate-web-search:focus-visible {
  background: var(--brand-tint);
  border-color: var(--brand);
}

.line-rate-checks {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  white-space: normal;
}

.line-rate-check {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.line-rate-check-line {
  color: var(--fg);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.line-rate-check .line-rate-web-search {
  margin-top: 4px;
}

.validation-check-field {
  margin-top: 6px;
  font-size: 12px;
  display: flex;
  gap: 6px;
}

.validation-check-field .field-label {
  color: var(--fg-subtle);
}

.validation-check-field .field-name {
  color: var(--brand);
  font-family: var(--font-mono);
}

.validation-resolved-value {
  margin-top: 6px;
  font-size: 13px;
  display: flex;
  gap: 6px;
}

.validation-resolved-value .resolved-label {
  color: var(--fg-subtle);
}

.validation-resolved-value .resolved-value {
  color: var(--success);
  font-weight: 500;
}

.validation-details {
  margin-top: 8px;
}

.validation-details summary {
  font-size: 12px;
  color: var(--brand);
  cursor: pointer;
}

.validation-details summary:hover {
  text-decoration: underline;
}

.validation-details pre {
  margin: 8px 0 0 0;
  padding: 8px;
  background: var(--surface);
  border-radius: 4px;
  font-size: 11px;
  color: var(--fg-muted);
  overflow-x: auto;
}

/* Passed checks section (always expanded) */
.validation-passed-section {
  margin-top: 8px;
}

.validation-passed-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--success);
  margin-bottom: 8px;
}

.validation-passed-header iconify-icon {
  font-size: 14px;
}

.validation-passed-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Check row: fixed label + colored status text */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Design `.vchk-row { padding: 5px 0; border-bottom: 1px solid var(--border-subtle) }`
     with `:last-child { border-bottom: none }` (app.css:659-663). Was 6px pad with a
     top divider on subsequent rows; switched to bottom dividers + 5px to match. */
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.check-row:last-child {
  border-bottom: none;
}

.check-label {
  flex: 1;
  /* Design `.vchk-label { font: var(--text-sm); color: var(--fg-muted) }`
     (app.css:664) — 13px 400 muted, not subtle 500. */
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-muted);
}

.check-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  /* Design `.vchk-val { font: var(--text-sm); font-weight: 600 }` (app.css:667) —
     13px 600 (the verified value carries weight). Was 12px 500. */
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.check-status.pass { color: var(--success); }
.check-status.pass iconify-icon { color: var(--success); }

.check-status.warning { color: var(--warning); }
.check-status.warning iconify-icon { color: var(--warning); }

.check-status.error { color: var(--danger); }
.check-status.error iconify-icon { color: var(--danger); }

.check-status.not-applicable { color: var(--fg); }
.check-status.not-applicable iconify-icon { color: var(--fg-muted); }

.check-status.uncertain { color: var(--fg); }
.check-status.uncertain iconify-icon { color: var(--fg-muted); }

.check-status.info { color: var(--brand); }
.check-status.info iconify-icon { color: var(--brand); }

/* Validation check chips - status-based coloring */
.validation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

/* Pass state - green */
.validation-chip.pass {
  background: var(--success-tint);
  color: var(--success-strong);
  border-color: var(--success-border);
}
.validation-chip.pass iconify-icon {
  color: var(--success);
}

/* Warning state - yellow/orange */
.validation-chip.warning {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border-color: var(--warning-border);
}
.validation-chip.warning iconify-icon {
  color: var(--warning);
}

/* Error/Critical state - red */
.validation-chip.error {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border-color: var(--danger-border);
}
.validation-chip.error iconify-icon {
  color: var(--danger);
}

/* Uncertain state - gray */
.validation-chip.uncertain {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border-color: var(--border);
}
.validation-chip.uncertain iconify-icon {
  color: var(--fg-muted);
}

/* Info state - blue (for info-level fraud flags) */
.validation-chip.info {
  background: var(--info-tint);
  color: var(--azure-700);
  border-color: var(--info-border);
}
.validation-chip.info iconify-icon {
  color: var(--brand);
}

/* Legacy class - keep for backwards compatibility */
.passed-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}
.passed-check-chip.pass {
  background: var(--success-tint);
  color: var(--success-strong);
  border-color: var(--success-border);
}
.passed-check-chip.pass iconify-icon {
  color: var(--success);
}
.passed-check-chip.warning {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border-color: var(--warning-border);
}
.passed-check-chip.warning iconify-icon {
  color: var(--warning);
}
.passed-check-chip.error {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border-color: var(--danger-border);
}
.passed-check-chip.error iconify-icon {
  color: var(--danger);
}
.passed-check-chip.uncertain {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border-color: var(--border);
}
.passed-check-chip.uncertain iconify-icon {
  color: var(--fg-muted);
}
.passed-check-chip.info {
  background: var(--info-tint);
  color: var(--azure-700);
  border-color: var(--info-border);
}
.passed-check-chip.info iconify-icon {
  color: var(--brand);
}
.passed-check-chip.not-applicable {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border-color: var(--border);
}
.passed-check-chip.not-applicable iconify-icon {
  color: var(--fg-muted);
}

/* Info tooltip for validation checks */
.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
}

.info-tooltip iconify-icon {
  font-size: 12px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.info-tooltip:hover iconify-icon {
  opacity: 1;
}

.info-tooltip-content {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: -8px;
  width: 240px;
  padding: 10px 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--fg);
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  pointer-events: none;
}

.vat-status-label .info-tooltip-content {
  font-family: var(--font-sans);
  font-weight: 400;
  white-space: normal;
  overflow-wrap: anywhere;
}

.info-tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 12px;
  border: 6px solid transparent;
  border-top-color: var(--border);
}

.info-tooltip:hover .info-tooltip-content,
.info-tooltip:focus-within .info-tooltip-content {
  display: block;
}

/* Escape the scrollable .data-panel / .section-body / .content overflow: where
   the browser supports CSS anchor positioning, pin the tooltip to its own icon
   with position:fixed so it renders above every container and is never clipped.
   `anchor-scope` binds each row's tooltip to its own icon; `flip-block` drops it
   below when there's no room above (e.g. near the top of the panel). Browsers
   without anchor support keep the absolute-positioned fallback above. */
@supports (anchor-name: --a) {
  .info-tooltip {
    anchor-name: --info-tip;
    anchor-scope: --info-tip;
  }
  .info-tooltip-content {
    position: fixed;
    position-anchor: --info-tip;
    top: auto;
    right: anchor(right);
    bottom: calc(anchor(top) + 8px);
    position-try-fallbacks: flip-block;
  }
}

/* All passed state */
.validation-all-passed {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(26, 127, 55, 0.1);
  border: 1px solid rgba(26, 127, 55, 0.3);
  border-radius: var(--r-lg);
}

.validation-all-passed iconify-icon {
  color: var(--success);
  font-size: 20px;
}

.all-passed-text {
  color: var(--success);
  font-size: 14px;
  font-weight: 500;
}

/* Validation section header content */
.validation-header-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.validation-header-content iconify-icon {
  font-size: 14px;
}

/* Issue count badge in section header - subtle inline style */
.validation-issue-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  /* Danger status tint token (DESIGN_DECISIONS.md §2), was ad-hoc rgba. */
  background: var(--danger-tint);
  color: var(--danger-strong);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}

/* Validation status icon sizing */
.validation-status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
}

.validation-status-icon iconify-icon {
  font-size: 16px;
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 24px;
  /* Spans the full viewport width, including the strip under the fixed
     .sidebar's bottom-left corner -- must outrank the sidebar's z-index
     (200) there, or the sidebar's own background paints over the footer. */
  z-index: 201;
}

.footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.footer-link {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 10px;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--fg);
  text-decoration: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-content-large {
  max-width: 700px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--bg-muted);
  color: var(--fg);
}

.modal-body {
  padding: 24px;
}

.modal-body-scrollable {
  overflow-y: auto;
  flex: 1;
}

.modal-body p {
  margin: 0 0 16px 0;
  color: var(--fg-muted);
}

.modal-body h4 {
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 12px 0;
}

.modal-body h4:first-child {
  margin-top: 0;
}

.modal-body ul {
  margin: 0 0 16px 0;
  padding-left: 24px;
  color: var(--fg-muted);
}

.modal-body li {
  margin-bottom: 8px;
}

.modal-body a {
  color: var(--brand);
  text-decoration: none;
}

.modal-body a:hover {
  text-decoration: underline;
}

.email-copy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.email-address {
  flex: 1;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* Copy button animation (same as documents page) */
.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  width: 24px;
  height: 24px;
}

.copy-btn:hover {
  background: var(--bg-muted);
  border-color: var(--brand);
}

.copy-btn svg {
  width: 12px;
  height: 12px;
  color: var(--fg-muted);
  transition: opacity 0.2s, transform 0.2s;
}

.copy-btn .check-icon {
  position: absolute;
  opacity: 0;
  transform: scale(0.8);
}

.copy-btn.copied .copy-icon {
  opacity: 0;
  transform: scale(0.8);
}

.copy-btn.copied .check-icon {
  opacity: 1;
  transform: scale(1);
  color: var(--success);
}

.copy-btn.copied {
  background: rgba(26, 127, 55, 0.1);
  border-color: var(--success);
}

/* Section Navigation Tabs */
.ar-formal-corrections-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px 14px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.ar-formal-corrections-banner > iconify-icon {
  flex: 0 0 auto;
  margin-top: 2px;
}

.section-tabs {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 2px;
  padding: 0 14px;
  flex-wrap: wrap;
}

.tab-link {
  padding: 9px 13px;
  color: var(--fg-muted);
  text-decoration: none;
  border-radius: 0;
  font-size: 13px;
  /* Design `.detail-tab { font: var(--text-sm); font-weight: 600 }` (app.css:327) —
     tabs carry semibold weight, not 500. */
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-link:hover {
  color: var(--fg);
  background: transparent;
  text-decoration: none;
  border-bottom-color: transparent;
}

.tab-link:active,
.tab-link.active {
  color: var(--brand);
  background: transparent;
  border-bottom-color: var(--brand);
}

/* Smooth scrolling for the panel body */
html {
  scroll-behavior: smooth;
}
.panel-body {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html,
  .panel-body {
    scroll-behavior: auto;
  }
}

@media (max-width: 900px) {
  .content:has(#document-area .detail-container) {
    overflow-y: auto;
  }

  .detail-container {
    display: block;
    height: auto;
    min-height: calc(100vh - 77px - var(--elevated-chrome));
    overflow-y: auto;
  }

  .detail-container > .pdf-panel {
    width: 100%;
    min-width: 0;
    max-width: none;
    /* Stacked here, .pdf-panel has no definite height for its iframe's own
       height: 100% to resolve against, so it was collapsing to a bare
       <iframe>'s ~150px UA default — unusable for actually reading a
       document preview. Roughly triple that instead. */
    height: 450px;
    resize: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .accounting-open-item-page .detail-container > .pdf-panel,
  .banking-statement-page .detail-container > .pdf-panel {
    /* These two hide the panel's content entirely below (next rule) rather
       than showing it stacked, so the panel itself should collapse away
       instead of claiming height for nothing. */
    height: auto;
    border-bottom: 0;
  }

  .accounting-open-item-page .detail-container > .pdf-panel > iframe,
  .banking-statement-page .detail-container > .pdf-panel > iframe,
  .accounting-open-item-page .detail-container > .pdf-panel > .empty-state,
  .banking-statement-page .detail-container > .pdf-panel > .empty-state {
    display: none;
  }

  .detail-container > .data-panel {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }
}

/* Add scroll margin to sections so they don't hide under sticky tabs */
#section-header,
#section-validation, 
#section-parties,
#section-classification,
#section-line-items,
#section-payment-summary {
  scroll-margin-top: 60px;
}

/* Document Management section scroll margins */
#section-matches, #section-datev-export, #section-invoice-details,
#section-obligations, #contract-renewal,
#section-validation, #contract-parties,
#contract-scope, #contract-financial, #contract-legal,
#po-overview, #po-parties, #po-line-items,
#po-logistics, #po-commercial, #po-approval,
#grn-overview, #grn-references, #grn-parties,
#grn-line-items, #grn-logistics, #grn-inspection, #grn-signoff {
  scroll-margin-top: 60px;
}

/* Validation section: single collapsible containing banner, formal reqs,
   fraud signals, supplier/recipient verification in a 2x2 grid layout. */

/* Dissolve validation-overview so banner and verification-grid can be reordered */
#section-validation #validation-overview {
  display: contents;
}

/* Reorder within the section body (flex column): banner first, grid middle, verification last */
#section-validation > .section-body > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#section-validation .validation-issues-banner {
  order: 0;
}
.validation-details-grid {
  order: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Design `.vchk-grid { gap: 12px }` (app.css:641). */
  gap: 12px;
}
#section-validation .verification-grid {
  order: 2;
  /* Gap between the top row (Formal / Fraud) and the bottom row
     (Supplier / Recipient) of the 2×2. */
  margin-top: 16px;
}

/* Hide the inner collapsible headers — the outer "Validation" header is the only one */
.validation-details-grid .section-header-toggle {
  display: none;
}

/* Stretch all wrappers so both columns have equal height */
.validation-details-grid > *,
.validation-details-grid .collapsible-section,
.validation-details-grid .section-body,
.validation-details-grid .validation-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.validation-details-grid .validation-box {
  flex: 1;
}

/* Paid status in payment terms */
.paid-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.paid-badge {
  background: var(--success);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 0.75rem;
}
.paid-badge.partial {
  background: var(--warning);
}
.paid-date {
  color: var(--fg-muted);
  font-size: 0.875rem;
}.paid-amount-unreadable {
  margin-bottom: 0.75rem;
}
.paid-amount-unreadable-message {
  color: var(--warning-strong);
  font-size: 0.875rem;
  margin: 0 0 0.5rem;
}
.payment-status-correction {
  margin-top: 0;
}
.payment-status-correction-body {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.payment-status-correction-body .payment-method-override {
  margin-top: 0;
}
.payment-status-correction-body p {
  color: var(--fg-muted);
  font-size: 0.875rem;
  line-height: 1.45;
  margin: 0.65rem 0;
}
.payment-status-correction-body label {
  display: block;
  color: var(--fg-muted);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.payment-status-correction-body textarea {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  resize: vertical;
  margin-bottom: 0.65rem;
}

/* Incoterm inclusion badges */
.incoterm-inclusions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.inclusion-badge {
  background: rgba(26, 127, 55, 0.15);
  color: var(--success);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* Delivery section */
.delivery-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.delivery-field {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.delivery-label {
  color: var(--fg-subtle);
  font-size: 0.85rem;
  min-width: 70px;
}
.delivery-value {
  color: var(--fg);
  white-space: pre-line;
}
.country-badge {
  display: inline-block;
  box-sizing: border-box;
  background: var(--bg-muted);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--fg-muted);
}/* Classification and Delivery remain compact rows, but every editable value
   uses the same persistent border, padding, radius, and background as the
   other invoice fields. The class lives on the editable-value so it survives
   the generic post-save fragment redraw. */
.editable-value.invoice-inline-field {
  display: inline-block;
  box-sizing: border-box;
  min-width: 100px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-canvas);
  color: var(--fg);
  font-size: 0.85rem;
  outline: none;
  box-shadow: none;
  transition: none;
}
.editable-value.invoice-inline-field:hover,
.editable-value.invoice-inline-field.is-editing,
.editable-value.invoice-inline-field.is-saving,
.editable-value.invoice-inline-field.is-human-edited {
  outline: none;
  box-shadow: none;
  background: var(--bg-canvas);
}
.field-copy-row:has(> .field-copy-content > .editable-value) {
  box-sizing: border-box;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-canvas);
}
.field-copy-row .field-copy-content > .editable-value:not(.master-data-picker) {
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
}
.incoterm-badge {
  display: inline-block;
  box-sizing: border-box;
  background: rgba(10, 109, 189, 0.15);
  color: var(--brand);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.85rem;
}
.incoterm-place {
  color: var(--fg-muted);
  font-size: 0.85rem;
}
/* The VAT-treatment row can carry several statements, each of which runs to
   a few hundred characters in practice, so unlike the other classification
   rows it wraps. */
/* Only the quoted text ellipsises; the legal basis is a sibling so it stays
   readable however long the statement is. */
/* Tax Compliance box — lives inside .validation-grid (Validation section),
   spanning both of its columns so it reads as its own row above Formal
   Requirements + Fraud Signals. */
.tax-compliance-box {
  flex: 1 0 100%;
}
/* auto-fit/minmax, not a @media breakpoint — same reasoning as
   .validation-grid above (this box lives inside it, and shares the same
   info-tooltip-vs-container-type conflict, so no @container query either).
   The bottom-row border removal can no longer key off a fixed 1-vs-2-column
   @media split once the column count itself becomes fluid — dropping it
   from the last item only is the width-independent approximation; the row
   above it may occasionally keep a border it didn't before, which is a
   cosmetic nit next to actually not overflowing the panel. */
.tax-compliance-checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 20px;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 4px;
}
.tax-compliance-checks-grid .check-row:last-child {
  border-bottom: none;
}

/* Fraud flag cards in warning banner */
.fraud-flag-card {
  padding: 12px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}
.fraud-flag-card.critical {
  background: var(--danger-tint);
  border-color: var(--danger-border);
}
.fraud-flag-card.warning {
  background: var(--warning-tint);
  border-color: var(--warning-border);
}
.fraud-flag-card.info {
  background: var(--info-tint);
  border-color: var(--info-border);
}
.fraud-flag-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.fraud-severity-icon {
  display: flex;
  align-items: center;
}
.fraud-severity-icon.critical {
  color: var(--danger);
}
.fraud-severity-icon.warning {
  color: var(--warning);
}
.fraud-severity-icon.info {
  color: var(--brand);
}
.fraud-flag-type {
  font-weight: 500;
  color: var(--fg);
  font-size: 14px;
}
.fraud-flag-message {
  margin-top: 8px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}
.fraud-flag-suggestion {
  margin-top: 0.5rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.fraud-flag-suggestion iconify-icon {
  color: var(--warning);
  flex-shrink: 0;
  margin-top: 2px;
}

.legal-disclaimer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--fg-subtle);
  font-size: 0.75rem;
  font-style: italic;
  line-height: 1.4;
}
.legal-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: capitalize;
  border: 1px solid var(--border);
  color: var(--fg-muted);
}
.legal-chip.critical { color: var(--danger); border-color: var(--danger-border); background: var(--danger-tint); }
.legal-chip.warning  { color: var(--warning); border-color: var(--warning-border); background: var(--warning-tint); }
.legal-chip.info     { color: var(--info); border-color: var(--info-border); background: var(--info-tint); }
/* The Legal review drawer's informational findings: the toggle is a button
   like the "Show reasoning" toggle (`.reasoning-toggle`), and the cards keep
   the list's 8px rhythm (a <details> body does not take a flex gap). */
.legal-info-toggle {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  list-style: none;
  transition: background 0.15s;
}
.legal-info-toggle::-webkit-details-marker { display: none; }
.legal-info-toggle:hover { background: var(--bg-muted); }
.legal-info-toggle .legal-info-hide,
.legal-info-collapse[open] .legal-info-toggle .legal-info-show { display: none; }
.legal-info-collapse[open] .legal-info-toggle .legal-info-hide { display: inline; }
.legal-info-collapse > .fraud-flag-card { margin-top: 8px; }

/* High-risk overall badge — distinct red (vs amber 'needs attention') */
.check-status.high-risk { color: var(--danger); }
.check-status.high-risk iconify-icon { color: var(--danger); }

/* Contract Legal review drawer: the executive summary, filter chips and one
   list of findings (status-strip drawer `#status-drawer-legal`). */
.legal-review [hidden] { display: none; }
.legal-card-list { display: flex; flex-direction: column; gap: 8px; }
.legal-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.legal-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.legal-filter-chip:hover { color: var(--fg); border-color: var(--border-strong); }
.legal-filter-chip.active { color: var(--surface); background: var(--fg); border-color: var(--fg); }
.legal-filter-count { font-variant-numeric: tabular-nums; opacity: 0.75; }

/* On-demand legal-analysis CTA (shown when no analysis exists) and the running
   state, inside the drawer. The running state reuses the shared .spinner-* (no
   new keyframes). */
.legal-run-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 20px 16px;
}
.legal-run-cta-title { font-size: 15px; font-weight: 600; color: var(--fg); }
.legal-run-cta-sub   { font-size: 13px; color: var(--fg-muted); max-width: 46ch; line-height: 1.5; }
.legal-run-cta .btn  { margin-top: 6px; }

/* Running state: the shared spinner with its single message cycling through the
   review phrases (driven by the inline script in legal-running-pane) — an
   activity indicator only; the run itself is one background LLM call. */
.legal-running { padding: 24px 16px; gap: 12px; }

/* Executive summary — the headline assessment as a structured callout at the
   top of the Legal review drawer: a neutral box (no verdict accent — the verdict
   is shown by the badge in the head) whose concerns/recommendations render as
   labelled bullet lists rather than one prose block. */
.legal-exec-summary {
  margin: 2px 0 12px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.legal-exec-summary-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.legal-exec-summary-icon { font-size: 16px; color: var(--fg-muted); }
.legal-exec-summary-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.legal-exec-summary-body { color: var(--fg); font-size: 0.875rem; line-height: 1.55; }
.legal-exec-summary-text { margin: 0 0 8px; }
.legal-exec-summary-text:last-child { margin-bottom: 0; }
.legal-exec-summary-sublabel { font-weight: 600; color: var(--fg); margin: 10px 0 5px; }
.legal-exec-summary-list {
  margin: 0 0 8px;
  padding-left: 1.15rem;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.legal-exec-summary-list li { line-height: 1.5; }
.legal-exec-summary-list:last-child { margin-bottom: 0; }

/* VAT badge on line items */
.vat-badge {
  border-color: var(--border);
}
.vat-badge.valid {
  border-color: rgba(26, 127, 55, 0.5);
}
.vat-badge.warning {
  border-color: rgba(191, 135, 0, 0.5);
}
.vat-badge.invalid {
  border-color: rgba(207, 34, 46, 0.5);
}
.vat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.vat-status-dot.valid {
  background: var(--success);
}
.vat-status-dot.warning {
  background: var(--warning);
}
.vat-status-dot.invalid {
  background: var(--danger);
}
.vat-rate {
  font-size: 0.85rem;
  color: var(--fg);
  font-family: var(--font-mono);
}
.vat-expected-rate {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}
.vat-expected-rate.mismatch {
  color: var(--warning);
}
.bu-code-chip {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-sm);
  background: rgba(10, 109, 189, 0.15);
  color: var(--brand);
}
.vat-suggestion {
  flex-basis: 100%;
  margin-top: 6px;
  color: var(--fg-muted);
  font-size: 0.8rem;
}

/* Delivery section scroll margin */
#section-delivery {
  scroll-margin-top: 60px;
  margin-top: 50px;
}

/* Tax compliance section scroll margin */
#section-tax-compliance {
  scroll-margin-top: 60px;
}

/* DATEV error modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.datev-error-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.datev-message {
  padding: 12px;
  border-radius: var(--r-lg);
  border-left: 3px solid;
}

.datev-message-error {
  background: rgba(207, 34, 46, 0.08);
  border-color: var(--danger);
}

.datev-message-warning {
  background: rgba(191, 135, 0, 0.08);
  border-color: var(--warning);
}

.datev-message-info {
  background: rgba(10, 109, 189, 0.08);
  border-color: var(--brand);
}

.message-type {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: inherit;
  opacity: 0.8;
}

.message-text {
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

/* DATEV Export Logs (inline section) — spacing comes from the shared
   .invoice-section rules; scroll-margin is set with the other sections above. */

.section-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
  text-transform: none;
  letter-spacing: 0;
}

.datev-logs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.datev-log-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--r-lg);
  border-left: 3px solid;
  background: var(--bg-subtle);
}

.datev-log-entry.information {
  border-color: var(--info-border);
  background: var(--info-tint);
}

.datev-log-entry.error {
  border-color: var(--danger-border);
  background: var(--danger-tint);
}

.datev-log-entry.warning {
  border-color: var(--warning-border);
  background: var(--warning-tint);
}

.datev-log-entry .log-message {
  color: var(--fg);
  font-size: 13px;
  line-height: 1.5;
}

.datev-log-entry .log-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--fg-muted);
}

.datev-log-entry .log-filename {
  font-family: var(--font-mono);
}

/* FVR Explanation Banner - for reasoning-only false positive explanations */
.fvr-explanation-banner {
  padding: 16px;
  border-radius: 8px;
  background: rgba(10, 109, 189, 0.08);
  border: 1px solid var(--brand);
  margin-bottom: 16px;
}

.fvr-explanation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.fvr-explanation-header iconify-icon {
  color: var(--brand);
  font-size: 16px;
}

.fvr-explanation-title {
  flex: 1;
  font-weight: 500;
  color: var(--fg);
}

.fvr-dismiss-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.fvr-dismiss-btn:hover {
  background: rgba(121, 115, 107, 0.2);
  color: var(--fg);
}

.fvr-explanation-body p {
  margin: 0 0 8px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}

.fvr-reasoning-list {
  margin: 12px 0 0;
  padding-left: 20px;
}

.fvr-reasoning-list li {
  margin-bottom: 8px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}

.fvr-reasoning-list li:last-child {
  margin-bottom: 0;
}

.fvr-reasoning-list li strong {
  color: var(--fg);
}

/* Price-per indicator (for bulk pricing like /100, /1000) */
.price-per-indicator {
  font-size: 11px;
  color: var(--fg-subtle);
  font-weight: normal;
}

/* Tenant Sections (for multi-tenant organizations) */
.tenant-section {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}

.tenant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tenant-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.tenant-content {
  padding: 24px;
}

.tenant-content .master-data-section {
  margin-bottom: 20px;
}

.tenant-content .master-data-section:last-child {
  margin-bottom: 0;
}

/* Tenant Cell in Document Table */
.tenant-cell {
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Form styles for Tenant Edit */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--fg);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--fg);
  font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 109, 189, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #6e7681;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.sap-cpi-form {
  max-width: 420px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Tenants List */
.tenants-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tenant-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.tenant-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tenant-name {
  font-weight: 500;
  color: var(--fg);
}

/* Compact Tenant Cards (Master Data Page) */
.tenant-card-compact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.tenant-card-compact-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.tenant-card-compact-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.tenant-card-compact-subtitle {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 2px;
  display: block;
}

.tenant-card-compact-ids {
  font-size: 12px;
  color: var(--fg-subtle);
  margin-top: 2px;
  display: block;
  font-family: var(--font-mono);
}

.tenant-edit-btn {
  flex-shrink: 0;
}

.tenant-card-compact-datasets {
  display: flex;
  gap: 12px;
}

/* Dataset Chips */
.dataset-chip {
  flex: 1;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  min-width: 0;
}

.dataset-chip.loaded {
  background: rgba(26, 127, 55, 0.1);
  border-color: rgba(26, 127, 55, 0.4);
}

.dataset-chip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dataset-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--fg);
}

.dataset-status {
  font-size: 12px;
  color: var(--fg-muted);
}

.dataset-chip.loaded .dataset-status {
  color: var(--success);
}

.dataset-chip-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--bg-muted);
  border-color: var(--fg-faint);
  color: var(--fg);
}

.btn-icon-danger:hover {
  background: rgba(207, 34, 46, 0.15);
  border-color: var(--danger-strong);
  color: var(--danger);
}

.btn-icon:disabled:hover {
  background: transparent;
  border-color: var(--border);
  color: var(--fg-muted);
  cursor: not-allowed;
}

.upload-inline {
  display: inline-flex;
  position: relative;
}

.chip-spinner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(28, 24, 19, 0.9);
  border-radius: 4px;
}

.chip-spinner.htmx-request {
  display: flex;
}

.spinner-small {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.modal-content {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--r-lg);
  color: var(--fg-muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg-muted);
  color: var(--fg);
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body .table-container {
  max-height: none;
}

/* Dataset Modal Table Enhancements */
.dataset-modal .modal-body {
  padding: 0;
  overflow: hidden;
}

.dataset-modal .table-container {
  overflow-y: auto;
  max-height: calc(80vh - 70px);
}

.dataset-modal .table {
  font-size: 13px;
}

.dataset-modal .table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.dataset-modal .table th {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.dataset-modal .table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-muted);
  color: var(--fg);
}

.dataset-modal .table tbody tr:nth-child(even) {
  background: var(--bg-subtle);
}

.dataset-modal .table tbody tr:hover {
  background: var(--bg-subtle);
}

.modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.modal-record-count {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 400;
}

/* Generic htmx-confirm replacement (see htmx-confirm.js) — a single shared
   dialog standing in for every `hx-confirm` in the app, so destructive
   actions get the app's own styling instead of the browser's native
   confirm() popup. */
.htmx-confirm-dialog {
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-popover);
  width: 380px;
  max-width: 92vw;
}
.htmx-confirm-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.htmx-confirm-dialog .htmx-confirm-body {
  padding: 24px;
}
.htmx-confirm-dialog .htmx-confirm-message {
  margin: 0 0 20px;
  color: var(--fg);
  font-size: 14px;
}
.htmx-confirm-dialog .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast Messages */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 500;
  /* Solid surface card (never see-through), hairline border on all sides, dark
     readable text; the level is conveyed by a leading colored icon (no colored
     edge accent — that pattern is not used elsewhere). Orcha light-mode tokens. */
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}
.toast .toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--brand); }

/* Legacy toast class */
.error-toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: rgba(207, 34, 46, 0.1);
  border: 1px solid rgba(207, 34, 46, 0.4);
  border-radius: var(--r-lg);
  color: var(--danger);
  font-size: 14px;
}

/* Floating toast stack (top-right), populated by toasts.js from HX-Trigger events */
.toast-stack {
  position: fixed;
  top: 64px;          /* just below the page header / "Create Invoice" button */
  right: 24px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}
/* Native modal dialogs are painted in the browser's top layer, above body
   content. Move the stack into the dialog for feedback from modal actions. */
.toast-stack-in-dialog {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 1;
}
.toast-stack > .toast-floating {
  pointer-events: auto;
  cursor: pointer;
  margin-bottom: 0;
  box-shadow: var(--shadow-popover);
  /* Enter: slide in from the right. Exit (.is-dismissing): slide back out right. */
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.toast-stack > .toast-floating.is-shown {
  transform: translateX(0);
  opacity: 1;
}
.toast-stack > .toast-floating.is-dismissing {
  transform: translateX(calc(100% + 32px));
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .toast-stack > .toast-floating,
  .toast-stack > .toast-floating.is-dismissing {
    transform: none;
    transition: none;
  }
}

.error-toast .error-list {
  margin: 0;
  padding-left: 16px;
}

.error-toast .error-list li {
  margin-bottom: 2px;
}


/* ===================================================================   Notification Channels
   ========================================================================== */

/* Grid layout for notification subsections */
.notifications-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Notifications grid layout */
.notifications-management {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1100px) {
  .notifications-management {
    grid-template-columns: 1fr;
  }
}

/* Subsection styling */
.notifications-subsection {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  /* Match the vertical rhythm of the connection cards (.master-data-section). */
  margin-bottom: 16px;
}
.notifications-subsection h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.subsection-description {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--fg-muted);
}

/* Channel cards list */
.notification-channels-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* Individual channel card */
.notification-channel-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}
.notification-channel-card.channel-active {
  border-color: var(--success-border);
  background: var(--success-tint);
}
.notification-channel-card.channel-pending {
  border-color: var(--warning-border);
  background: var(--warning-tint);
}
.notification-channel-card.channel-disabled {
  border-color: var(--border);
}
.notification-channel-card.channel-disabled .channel-info {
  opacity: 0.7;
}

/* Channel icon */
.notification-channel-card .channel-icon {
  font-size: 20px;
  flex-shrink: 0;
  color: var(--fg-muted);
}
.notification-channel-card.channel-active .channel-icon {
  color: var(--success);
}
.notification-channel-card.channel-pending .channel-icon {
  color: var(--warning);
}

/* Channel info */
.notification-channel-card .channel-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.channel-address,
.channel-workspace {
  font-weight: 500;
  color: var(--fg);
}
.channel-target {
  color: var(--fg-muted);
  font-size: 13px;
}
.channel-hash {
  color: var(--fg-subtle);
}
.channel-warning {
  color: var(--warning);
  font-size: 13px;
  font-style: italic;
}

/* Channel actions */
.notification-channel-card .channel-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* An invoice with installments lays its fields out in two even columns: each
   installment's date and amount share a row, and the warning under them spans
   exactly the width of the boxes above it. */
.invoice-header-grid.has-installments {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* The parties grid below uses the same gutter, so both columns line up. */
  column-gap: 28px;
}
.field-group.is-derived .field-value-row-boxed {
  border-color: var(--warning-border);
  background: color-mix(in srgb, var(--warning-tint) 40%, var(--white));
}

/* A pill that shrinks to its own label, beside a value or a field label. */
.badge-compact {
  padding: 1px 8px;
}
/* Sits right beside the label; the auto margin keeps any aside at the far end.
   The pill is sized and offset to fit inside the label's own line, so it never
   makes the row taller and the value box below stays level with its neighbours. */
.field-label-badge {
  display: inline-flex;
  align-self: center;
  margin-block: -3px;
  margin-right: auto;
}
.field-label-badge .badge-compact {
  padding: 0 7px;
  font-size: 11px;
  line-height: 1.2;
}
/* The calendar popover under an inline date field (date-picker.js). */
.app-date-picker {
  position: absolute;
  z-index: 11000;
  width: 252px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--fg);
  user-select: none;
}
.app-date-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.app-date-picker-title {
  font-weight: 600;
}
.app-date-picker button {
  font: inherit;
  cursor: pointer;
}
.app-date-picker-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
}
.app-date-picker-nav:hover {
  background: var(--bg-muted);
  color: var(--fg);
}
.app-date-picker-weekdays,
.app-date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.app-date-picker-weekdays span {
  padding: 4px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.app-date-picker-day {
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.app-date-picker-day:hover {
  background: var(--bg-muted);
}
.app-date-picker-day.is-outside {
  color: var(--fg-faint);
}
.app-date-picker-day.is-today {
  border-color: var(--border-strong);
}
.app-date-picker-day.is-selected,
.app-date-picker-day.is-selected:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--fg-on-brand);
}
.app-date-picker-foot {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}
.app-date-picker-today {
  padding: 4px 8px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--link);
  font-weight: 500;
}
.app-date-picker-today:hover {
  background: var(--brand-tint);
}
.due-date-paid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.due-date-paid-date {
  color: var(--fg-subtle);
}
.due-date-suggested {
  border-bottom: 1px dashed var(--warning);
}
.due-date-more {
  color: var(--fg-subtle);
}
/* Under the installment fields when they do not add up to the invoice amount. */
.invoice-header-grid > .installment-footing-note {
  grid-column: 1 / -1;
  /* The footer's link scrolls here; keep the installment fields above in view. */
  scroll-margin-top: 170px;
  padding: 6px 10px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 13px;
}

/* Status badges for notifications */
.badge-warning {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.badge-success {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.badge-secondary {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

/* Add channel form (collapsible) */
.add-channel-form {
  margin-top: 12px;
}
.add-channel-form summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  list-style: none;
}
.add-channel-form summary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.add-channel-form summary::-webkit-details-marker {
  display: none;
}
.add-channel-form[open] summary {
  margin-bottom: 12px;
}
.add-channel-form form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.add-channel-form .form-row {
  display: flex;
  gap: 8px;
}
.add-channel-form .form-control {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
}
.add-channel-form .form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.form-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 4px;
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  color: var(--danger-strong);
}
/* The same message, sitting against the control it names rather than above the
   whole section: a refusal that says "turn it off for this account" is only
   actionable next to the box it means. */
.form-error-field {
  margin-top: 8px;
  align-items: flex-start;
}

.form-error iconify-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* `.form-error`'s amber sibling: the same shape, said as attention rather than
   failure, against the thing it names. */
.form-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 4px;
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--warning-border);
  color: var(--warning-strong);
  white-space: normal;
  overflow-wrap: anywhere;
}

.form-warning iconify-icon {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 16px;
}

.form-warning strong {
  font-weight: 600;
}

/* Add channel button (unified style for Slack, Teams, etc.) */
.btn-add-channel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.btn-add-channel iconify-icon {
  font-size: 18px;
}

/* Slack channel picker page */
.slack-channel-picker {
  max-width: 480px;
  margin: 40px auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.slack-channel-picker h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: var(--fg);
}
.slack-channel-picker > p {
  margin: 0 0 24px 0;
  color: var(--fg-muted);
}
.slack-channel-picker .form-group {
  margin-bottom: 24px;
}
.slack-channel-picker label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}
.slack-channel-picker select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--fg);
}
.slack-channel-picker select:focus {
  outline: none;
  border-color: var(--brand);
}
.slack-channel-picker .form-actions {
  display: flex;
  gap: 12px;
}
.slack-channel-picker .alert {
  padding: 16px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
}
.slack-channel-picker .alert-warning {
  background: rgba(191, 135, 0, 0.15);
  border: 1px solid rgba(191, 135, 0, 0.3);
  color: var(--warning);
}
.slack-channel-picker .alert p {
  margin: 0 0 8px 0;
}
.slack-channel-picker .alert p:last-child {
  margin: 0;
}
.slack-channel-picker code {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  font-family: monospace;
}

/* Channel select modal */
.channel-select-modal {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
}
.channel-select-modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}
.channel-select-modal h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
}
.channel-select-modal > p {
  margin: 0 0 16px 0;
  color: var(--fg-muted);
}
.channel-select-modal select {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--fg);
}
.channel-select-modal .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.channel-select-modal .loading {
  padding: 16px;
  text-align: center;
  color: var(--fg-muted);
  font-style: italic;
}
.channel-select-modal .no-channels-warning {
  margin-bottom: 16px;
}
.channel-select-modal .no-channels-warning .alert {
  margin-bottom: 12px;
}
.channel-select-modal .no-channels-warning ol {
  margin: 8px 0 0 20px;
  padding: 0;
}
.channel-select-modal .no-channels-warning li {
  margin-bottom: 4px;
}

/* QA Dataset dialog */
.qa-dataset-dialog {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
  max-width: 440px;
  width: 100%;
}
.qa-dataset-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}
.qa-dataset-dialog h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
}
.qa-dataset-dialog > form > p {
  margin: 0 0 16px 0;
  color: var(--fg-muted);
}
.qa-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.qa-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: background 0.15s;
}
.qa-radio:hover {
  background: var(--bg-muted);
}
.qa-radio input[type="radio"] {
  accent-color: var(--brand);
}
.qa-radio-label {
  font-size: 14px;
}
.qa-notes-field {
  margin-bottom: 16px;
}
.qa-notes-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--fg-muted);
}
.qa-dataset-dialog .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 4px;
}
.qa-notes-field textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--fg);
  resize: vertical;
  font-family: inherit;
}

.dismiss-dialog {
  border: none;
  border-radius: var(--r-lg);
  padding: 24px;
  max-width: 420px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.dismiss-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
.dismiss-dialog h3 {
  margin: 0 0 8px;
}
.dismiss-dialog > p {
  margin: 0 0 16px;
  color: var(--fg-muted);
}
.dismiss-dialog textarea {
  width: 100%;
  box-sizing: border-box;
}
.dismiss-dialog .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* Error page for verification */
.verify-error-page {
  max-width: 480px;
  margin: 80px auto;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.verify-error-page h1 {
  margin: 0 0 12px 0;
  font-size: 24px;
  color: var(--danger);
}
.verify-error-page p {
  margin: 0;
  color: var(--fg-muted);
}

/* Document Management - Type Icons */
.doc-type-cell {
  width: 48px;
  text-align: center;
}

.doc-type-icon {
  font-size: 20px;
  color: var(--fg-muted);
}

/* Document Management - Detail page additions */

/* Field grid inside a section card — FLAT per DESIGN_DECISIONS §1 (no nested box);
   the parent .invoice-section card already provides the border + padding, like the
   AP detail's flat metadata grid. */
.detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
/* Derived value shown alongside a field's extracted text, e.g. the computed
   deadline next to a notice period's prose. */
.field-value-annotation {
  color: var(--fg-muted);
  font-weight: 500;
}

.parties-grid {
  display: grid;
  /* Was a hardcoded 1fr 1fr with no floor, which silently overrode the
     auto-fit/minmax rule above (same selector, later in the stylesheet,
     equal specificity) — this is the definition Contract/PO/GRN views
     actually got, splitting unevenly by each side's own content and
     overflowing rather than ever dropping to one column. Kept in sync with
     the earlier rule instead of de-duplicating, since that's how this pair
     already was. */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  /* Design `.parties-grid { gap: 28px }` (app.css:360) — wider gutter is the
     separator between flat party blocks instead of box borders. */
  gap: 28px;
}

/* Party blocks (invoice Issuer/Recipient; contract/PO/GRN Principal/Counterparty)
   are FLAT white sub-content per DESIGN_DECISIONS §1 — no nested border/box. The
   28px grid gap is the only separator between blocks, matching the AP detail. */
.parties-grid > div {
  background: transparent;
  padding: 0;
}
/* The block heading is an uppercase micro-label (mirrors `.party-card-title`) —
   no underline divider. */
.parties-grid > div h4 {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

/* Supplier Verification Box
   ========================================================================== */

/* Verification sub-cards — plain hairline border (status is carried by the
   header badge, not a coloured left edge). */
.supplier-verification-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  /* Design `.vchk-card { overflow: hidden }` with no card padding — the head's
     bottom border runs edge-to-edge (app.css:643-668). Padding lives in the head
     (`.vchk-head 12px 16px`) and the rows (`.vchk-rows 2px 16px 8px`). */
  padding: 0;
  overflow: hidden;
  margin-top: 16px;
}

/* Verification grid: supplier + recipient side by side.
   auto-fit/minmax, not a @media breakpoint — same reasoning as
   .invoice-header-grid above. */
.verification-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  /* Design `.vchk-grid { gap: 12px }` (app.css:641). */
  gap: 12px;
  /* Sits below the validation-details-grid in the same flex column (gap 8px);
     drop the extra 16px so the rhythm stays on the 4px grid. */
  margin-top: 0;
}
.verification-grid .supplier-verification-box {
  margin-top: 0;
}

.sv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Design `.vchk-head { padding: 12px 16px; border-bottom: 1px solid
     var(--border-subtle) }` (app.css:649-652) — edge-to-edge divider since the box
     itself has no padding. Was margin-bottom 12px + inset divider. */
  margin-bottom: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.subsection {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.subsection h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

/* Type badge colors — neutral blue for all document types */
.badge-invoice,
.badge-contract,
.badge-purchase-order,
.badge-goods-received-note {
  background: var(--info-tint);
  color: var(--azure-700);
}

.badge-other {
  background: var(--info-tint);
  color: var(--azure-700);
  border: 1px solid var(--info-border);
}

.badge-info {
  background: var(--border);
  color: var(--fg);
}

/* Workflows page: who receives each notification kind. Same full-bleed white
   shell as the document lists; the table stays narrow instead of spanning the
   page, because a row is a switch, a name and one recipients cell. */
.workflows-page {
  overflow: auto;
  background: var(--surface);
}
.workflows-page > .page-header {
  flex-shrink: 0;
}
/* workflows.js hides chips and picker options with `hidden`; the flex display
   rules below would otherwise override it. */
.workflows-page [hidden] {
  display: none !important;
}
.workflows-body {
  /* 14px left matches the toolbar's padding, so the table lines up under the tabs. */
  padding: var(--space-5) var(--space-5) var(--space-6) 14px;
}
.wf-delivery {
  padding: 10px 12px;
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--fg-muted);
}
.wf-delivery-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg);
}
.wf-delivery-status img {
  flex-shrink: 0;
}
.workflows-readonly {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 1100px;
  margin-bottom: var(--space-3);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
  font-size: 13px;
  color: var(--fg-muted);
}
.wf-readonly-delivery {
  margin: 6px 0 0;
  line-height: 1.5;
}
.workflows-table {
  max-width: 1100px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
/* Below the grid's minimum the page (.workflows-page) scrolls sideways; no
   inner scroll box, which would clip the recipients popovers. */
@media (max-width: 760px) {
  .workflows-table {
    min-width: 560px;
  }
}
.wf-head,
.wf-row {
  display: grid;
  grid-template-columns: 64px minmax(200px, 1fr) minmax(280px, 1.35fr);
  align-items: center;
}
.wf-head {
  min-height: 40px;
}
.wf-head-cell {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.wf-head-cell.wf-cell-toggle {
  text-align: center;
}
.wf-head-cell.wf-cell-recipients {
  align-self: stretch;
  display: flex;
  align-items: center;
  padding-left: 16px;
  border-left: 1px solid var(--border-subtle);
}
.wf-table-empty {
  margin: 0;
  padding: 32px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--fg-subtle);
}

.wf-section > .wf-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  cursor: pointer;
  list-style: none;
}
.wf-section > .wf-section-head::-webkit-details-marker { display: none; }
.wf-section-chevron {
  font-size: 14px;
  color: var(--fg-muted);
  transform: rotate(-90deg);
  transition: transform var(--dur-fast) ease;
}
.wf-section[open] .wf-section-chevron {
  transform: none;
}
.wf-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.wf-section-count {
  font-size: 12px;
  color: var(--fg-subtle);
}

.wf-row {
  min-height: 48px;
  border-top: 1px solid var(--border-subtle);
}
.wf-row:hover {
  background: var(--bg-subtle);
}
.wf-cell-toggle {
  display: flex;
  justify-content: center;
}
.wf-row .toggle-switch input:disabled + .toggle-slider {
  cursor: not-allowed;
  opacity: 0.6;
}
.wf-cell-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding-right: 12px;
  font-size: 14px;
}
.wf-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wf-row.is-off .wf-name {
  color: var(--fg-subtle);
}
.wf-name-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 6px 0;
}
.wf-description {
  font-size: 12px;
  line-height: 1.4;
  color: var(--fg-muted);
}
.wf-row.is-off .wf-description {
  color: var(--fg-subtle);
}
.wf-cell-recipients {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0 8px 0 16px;
  border-left: 1px solid var(--border-subtle);
  font-size: 13px;
}

/* Recipients are plain chips; the visible pencil opens the picker. */
.wf-picker {
  position: relative;
  flex-shrink: 0;
}
.wf-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  color: var(--fg-muted);
  cursor: pointer;
  list-style: none;
}
.wf-edit::-webkit-details-marker { display: none; }
.wf-edit iconify-icon {
  font-size: 15px;
}
.wf-edit:hover {
  background: var(--bg-muted);
  color: var(--fg);
}
.wf-edit:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.wf-picker[open] > .wf-edit {
  background: var(--bg-muted);
  color: var(--brand-pressed);
}
.wf-recipients {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}
/* workflows.js measures chips at full width before hiding those that overflow. */
.wf-recipients.is-measuring .wf-chip {
  flex-shrink: 0;
}
.wf-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 190px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--brand-border);
  border-radius: var(--r-sm);
  background: var(--brand-tint);
  font-size: 12px;
  color: var(--fg);
  flex: 0 1 auto;
}
.wf-chip iconify-icon {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--brand-hover);
}
.wf-chip-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wf-chip.is-pending {
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--surface);
}
.wf-chip.is-pending .wf-chip-text,
.wf-chip.is-pending iconify-icon {
  color: var(--fg-subtle);
}
.wf-more {
  flex-shrink: 0;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}
.wf-empty {
  font-size: 13px;
  color: var(--fg-subtle);
}
.wf-empty.is-warning {
  color: var(--warning-strong);
}

/* Picker popover */
.wf-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 340px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}
.wf-popover-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px;
  padding: 0 10px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-subtle);
}
.wf-popover-search:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.wf-popover-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--fg);
}
.wf-popover-body {
  max-height: 380px;
  overflow-y: auto;
  padding-bottom: 6px;
  border-top: 1px solid var(--border-subtle);
}
/* The picker's options sit in one fieldset that htmx disables while a change
   saves; it keeps them legible and only shows a busy cursor. */
.wf-options {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.wf-options:disabled .wf-option {
  cursor: progress;
}
.wf-options:disabled .wf-option input {
  opacity: 1;
}
.wf-group-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.wf-group-label:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid var(--border-subtle);
}
.wf-group-label span {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-subtle);
}
.wf-group-empty {
  margin: 0;
  padding: 4px 12px 8px;
  font-size: 12px;
  color: var(--fg-subtle);
}
.wf-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
}
.wf-option:not(.is-locked):hover {
  background: var(--bg-subtle);
}
.wf-option:has(input:checked),
.wf-option:has(input:checked):hover {
  background: var(--brand-tint);
}
.wf-option:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.wf-option input {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
}
.wf-option iconify-icon {
  flex-shrink: 0;
  font-size: 15px;
  color: var(--fg-subtle);
}
.wf-option-text {
  flex: 1;
  min-width: 0;
}
.wf-option-text small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  line-height: 1.3;
  color: var(--fg-subtle);
}
/* A picker near the bottom of the viewport opens upward (workflows.js). */
.wf-picker.opens-up .wf-popover {
  top: auto;
  bottom: calc(100% + 4px);
}
.wf-option.is-locked {
  cursor: default;
}
.wf-option.is-locked .wf-option-text small {
  overflow: visible;
  white-space: normal;
}
.wf-option.is-pending .wf-option-text small {
  color: var(--warning-strong);
}
.wf-option-actions {
  display: flex;
  gap: 12px;
  margin-top: 2px;
}
.wf-option-actions .btn {
  height: auto;
  padding: 0;
  font-size: 12px;
  color: var(--link);
}
.wf-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 8px;
}
.wf-add input,
.wf-add select {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 13px;
}
.wf-add-error {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--danger-strong);
}
.wf-add-error:empty {
  display: none;
}
.wf-no-match {
  margin: 0;
  padding: 16px 12px;
  font-size: 13px;
  color: var(--fg-subtle);
}
.wf-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--fg-subtle);
}

/* Custom tooltip for disabled notification toggles */
.toggle-wrapper {
  position: relative;
  flex-shrink: 0;
}

.toggle-wrapper.has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-hover);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 10;
}

.toggle-wrapper.has-tooltip:hover::after {
  opacity: 1;
}

/* Contract lifecycle badges */
.badge-contract-active { background: var(--success-tint); color: var(--success-strong); }
.badge-contract-expiring-soon { background: var(--warning-tint); color: var(--warning-strong); }
.badge-contract-expired { background: var(--danger-tint); color: var(--danger-strong); }
.badge-contract-pending { background: var(--bg-muted); color: var(--fg-muted); }

/* Signature state — a separate question from lifecycle: a contract can be
   inside its term and still be missing a party's signature. */
.badge-contract-unsigned { background: var(--danger-tint); color: var(--danger-strong); }
.badge-contract-partial { background: var(--warning-tint); color: var(--warning-strong); }

/* Contract sub-type badge */
.badge-contract-subtype { background: var(--info-tint); color: var(--azure-700); }

/* Legal Review status badges (document list) */
.badge-legal-not-run { background: var(--bg-muted); color: var(--fg-muted); }
.badge-legal-running { background: var(--info-tint); color: var(--info); }
.badge-legal-failed { background: var(--danger-tint); color: var(--danger-strong); }
.badge-legal-pass { background: var(--success-tint); color: var(--success-strong); }
.badge-legal-warning { background: var(--warning-tint); color: var(--warning-strong); }
.badge-legal-high-risk { background: var(--danger-tint); color: var(--danger-strong); }

/* Recurring contract badge */
.badge-recurring { background: var(--info-tint); color: var(--info); }

/* Alert banner */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  font-size: 14px;
}
/* On the full-bleed document list (no content gutter) the banner would sit flush
   to the edges — give it equal breathing room on all four sides. */
.documents-page > .alert-banner {
  margin: 16px;
}
.alert-banner iconify-icon { font-size: 18px; flex-shrink: 0; }
.alert-banner span { flex: 1; }
.alert-banner a {
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  white-space: nowrap;
}
.alert-warning {
  background: rgba(191, 135, 0, 0.1);
  border: 1px solid rgba(191, 135, 0, 0.3);
  color: var(--warning);
}
.alert-banner.alert-danger {
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  color: var(--danger-strong);
}

/* Key Dates Timeline (horizontal) — flat stepper: hairline track, small dots,
   no heavy circle widget (design replaced the loud icon-circles). */
.timeline-h {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding: 14px 4px 6px;
  background: transparent;
  border: none;
  border-radius: 0;
}
.timeline-h-segment {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
}
.timeline-h-event {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 90px;
  text-align: center;
}
/* Outlined by default — only Today is filled, so the current position reads
   at a glance and every other milestone stays a waypoint. */
.timeline-h-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
}
/* flat dots, not icon-circles */
.timeline-h-dot iconify-icon {
  display: none;
}
.timeline-h-event.today .timeline-h-dot {
  background: var(--brand);
}
.timeline-h-event.urgent .timeline-h-dot {
  border-color: var(--warning);
  background: var(--surface);
  color: transparent;
}
.timeline-h-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  white-space: nowrap;
}
.timeline-h-event.urgent .timeline-h-label { color: var(--warning); font-weight: 700; }
.timeline-h-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  white-space: nowrap;
}
.timeline-h-event.urgent .timeline-h-date { color: var(--warning); }
/* A contract deadline carries the shared info tooltip; keep its dot at full
   strength like every other milestone, and show focus for keyboard users. */
.timeline-h-event.info-tooltip iconify-icon { opacity: 1; }
.timeline-h-event.info-tooltip:focus-visible,
.contract-deadline-row:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-md);
}
.contract-deadline-row { display: flex; }
.timeline-h-delta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 4px;
  min-width: 60px;
  padding-top: 5px;
}
.timeline-h-line {
  width: 100%;
  height: 2px;
  background: var(--border-strong);
  margin-top: 2px;
}
.timeline-h-delta-text {
  font-size: 10px;
  color: var(--fg-subtle);
  white-space: nowrap;
  margin-top: 4px;
}

/* Status filter tabs */
.status-filter-tabs {
  display: flex;
  gap: 4px;
  margin-right: 12px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}

/* Contract Hero Card */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
}
.status-card + .hero-card {
  margin-top: 16px;
}

.hero-card .section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Sub-content inside the hero card is FLAT WHITE — the uppercase micro-label
   above each value is the structural cue (matches .field-label/.parties-grid),
   not boxed dividers (DESIGN_DECISIONS §1: no nested sand boxes). */
.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 26px;
  margin-bottom: 16px;
}

.hero-metric {
  background: transparent;
  text-align: left;
}

.hero-metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.hero-metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
}

/* Boxed like .validation-box — a bordered sub-block inside the flat hero card. */
.hero-timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}

/* Obligations */
.obligations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.obligation-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-muted);
}

.obligation-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.obligation-item:first-child {
  padding-top: 0;
}

.obligation-priority {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg-muted);
  min-width: 20px;
}

.obligation-content {
  flex: 1;
}

.obligation-description {
  font-size: 14px;
  color: var(--fg);
  display: block;
  margin-bottom: 4px;
}

.obligation-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--fg-muted);
}

.obligation-party,
.obligation-deadline {
  display: flex;
  align-items: center;
}

/* Compliance regulation expandable rows */
.compliance-reg {
  border-top: 1px solid var(--bg-muted);
}

.compliance-reg:first-child {
  border-top: none;
}

.compliance-reg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
}

.compliance-reg-header:hover {
  background: rgba(28, 24, 19, 0.03);
}

.compliance-chevron {
  margin-left: auto;
  transition: transform 0.2s;
}

.compliance-reg.expanded .compliance-chevron {
  transform: rotate(180deg);
}

.compliance-reg-details {
  display: none;
  padding: 4px 0 8px 4px;
  border-top: 1px solid var(--bg-muted);
}

.compliance-reg.expanded .compliance-reg-details {
  display: block;
}

/* Formal Checks expandable groups — mirrors .compliance-reg* above */
.formal-check-group {
  border-top: 1px solid var(--bg-muted);
}

.formal-check-group:first-child {
  border-top: none;
}

.formal-check-group-header {
  display: grid;
  grid-template-columns: 1fr 110px 18px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
}

.formal-check-group-header:hover {
  background: rgba(28, 24, 19, 0.03);
}

.formal-check-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.formal-check-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}

.formal-check-group-details {
  display: none;
  padding: 4px 0 8px 4px;
  border-top: 1px solid var(--bg-muted);
}

.formal-check-group.expanded .formal-check-group-details {
  display: block;
}

.compliance-findings {
  list-style: none;
  padding: 4px 0;
  margin: 0;
}

.compliance-findings li.compliance-finding {
  padding: 6px 0;
  font-size: 12px;
  line-height: 1.5;
}

.compliance-finding .finding-headline {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.compliance-finding .finding-text {
  color: var(--fg-muted);
}

/* Empty state for not-yet-analyzed */
.empty-state {
  color: var(--fg-muted);
  font-style: italic;
  padding: 12px;
  text-align: center;
}

.sv-title {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Design `.vchk-title { font-family: sans; font-weight: 600; font-size: 13px;
     color: var(--fg); letter-spacing: .01em }` (app.css:653) — a functional card
     title in dark fg, Title Case (NOT an uppercase micro-label). Was uppercase
     muted with 0.5px tracking. */
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0.01em;
}
.rating-green .sv-title iconify-icon { color: var(--success); }
.rating-yellow .sv-title iconify-icon { color: var(--warning); }
.rating-red .sv-title iconify-icon { color: var(--danger); }

.sv-checks {
  /* Design `.vchk-rows { padding: 2px 16px 8px }` (app.css:658) — rows sit inside
     the (now unpadded) card with their own side padding so the head divider above
     spans full width. */
  padding: 2px 16px 8px;
  margin-bottom: 0;
}

/* "Show reasoning" footer inside a verification card — the card itself is now
   unpadded, so the foot carries the design's `.vchk-foot { padding: 4px 16px 14px }`
   (app.css:669). Scoped so the shared `.reasoning-container` elsewhere is untouched. */
.supplier-verification-box > .reasoning-container {
  margin-top: 0;
  padding: 4px 16px 14px;
}

.sv-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin: 12px 0;
  background: var(--success-tint);
  border: 1px solid var(--success-border);
  /* Controls scale: design `--r-md: 5px` (app.css:26). */
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--success-strong);
}
.sv-verified-badge iconify-icon {
  font-size: 16px;
}

.supplier-known-status {
  border: 1px solid var(--success-border);
}

.supplier-known-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 16px 14px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.4;
}

.supplier-known-note iconify-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--success);
  font-size: 14px;
}

/* Document Matches */
.matches-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Matches — one category row per document type (DESIGN matches container).
   Coloured icon tile + title ("Contract · 1 match") + comma-separated clickable
   document numbers + the strongest-link confidence badge. */
.match-group {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.matches-list > .match-group:last-child {
  border-bottom: none;
}
.match-group-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.match-group-body {
  flex: 1;
  min-width: 0;
}
.match-group-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
  line-height: 1.3;
}
.match-group-count {
  font-weight: 400;
  color: var(--fg-muted);
}
.match-group-docs {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.4;
}
.match-doc-link {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.match-doc-link:hover {
  color: var(--brand);
  text-decoration: underline;
}
.match-group-more {
  color: var(--fg-faint);
  font-style: italic;
}
.match-group-conf {
  flex-shrink: 0;
}
.match-group-docs.match-no-result {
  font-family: var(--font-sans);
  font-style: italic;
}
.match-group-empty {
  opacity: 0.6;
}

/* Per-type icon-tile colours — design-system document-type tokens */
.match-group-invoice  .match-group-icon { background: var(--doctype-invoice-tint);  color: var(--doctype-invoice-fg); }
.match-group-contract .match-group-icon { background: var(--doctype-contract-tint); color: var(--doctype-contract-fg); }
.match-group-purchase .match-group-icon { background: var(--doctype-purchase-tint); color: var(--doctype-purchase-fg); }
.match-group-goods    .match-group-icon { background: var(--doctype-goods-tint);    color: var(--doctype-goods-fg); }
.match-group-other    .match-group-icon { background: var(--doctype-other-tint);    color: var(--doctype-other-fg); }

/* Reconciliation Issues */
.reconciliation-issues {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* Tinted warning card, matching .validation-check-card.warning — an unmatched
   or mismatched document is an open task, so it reads as a warning rather than
   a neutral card with a coloured edge. Severity shows in the icon, not the
   surface: both severities share the same yellow box. */
.reconciliation-issue {
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  padding: 12px 16px;
}

.reconciliation-issue .issue-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.reconciliation-issue .issue-header > iconify-icon {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--warning);
}
.reconciliation-issue .issue-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.reconciliation-issue .issue-summary {
  font-size: 13px;
  color: var(--fg);
}
.reconciliation-issue .issue-documents {
  font-size: 12px;
  color: var(--fg-muted);
}
.reconciliation-issue .issue-documents a {
  color: var(--brand);
  text-decoration: none;
}
.reconciliation-issue .issue-documents a:hover {
  text-decoration: underline;
}
.reconciliation-issue .current-doc {
  font-style: italic;
}

/* Expandable field comparison details */
.reconciliation-issue .issue-details {
  margin-top: 8px;
}
.reconciliation-issue .issue-details summary {
  font-size: 12px;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
}
.reconciliation-issue .issue-details summary:hover {
  color: var(--fg);
}
.reconciliation-issue .details-table {
  width: 100%;
  margin-top: 6px;
  border-collapse: collapse;
  font-size: 12px;
}
.reconciliation-issue .details-table th {
  text-align: left;
  color: var(--fg-muted);
  font-weight: 500;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.reconciliation-issue .details-table td {
  padding: 4px 8px;
  color: var(--fg);
  border-bottom: 1px solid var(--bg-muted);
}

/* ── Login page ── */

/* Remove padding from .content wrapper on login page */
.content:has(.login-split) {
  padding: 0;
  overflow: hidden;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes border-rotate {
  0% { --border-angle: 0deg; }
  100% { --border-angle: 360deg; }
}

@property --border-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

.login-split {
  display: flex;
  height: 100vh;
}

.login-marketing {
  flex: 0 0 60%;
  background: var(--surface-ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 3.5rem;
  position: relative;
  overflow: hidden;
}

.login-marketing .orb-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.login-marketing-content {
  position: relative;
  z-index: 2;
}

.login-marketing h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 2.5rem;
}

.gradient-text {
  background: linear-gradient(270deg, var(--brand), #00b4d8, var(--brand), #0053a6);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 6s ease infinite;
}

/* Tip card with animated rotating border glow */
.login-tip {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  max-width: 28rem;
  border: 1px solid transparent;
  background-clip: padding-box;
}

.login-tip::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 0.75rem;
  padding: 1px;
  background: conic-gradient(
    from var(--border-angle),
    rgba(255, 255, 255, 0.08) 0%,
    rgba(10, 109, 189, 0.6) 12%,
    rgba(0, 180, 216, 0.4) 20%,
    rgba(255, 255, 255, 0.08) 35%,
    rgba(255, 255, 255, 0.08) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  animation: border-rotate 4s linear infinite;
  pointer-events: none;
}

.login-tip-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin-bottom: 0.5rem;
}

.login-tip-text {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--fg-faint);
}

.login-form {
  flex: 0 0 40%;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem 2.5rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card .login-logo {
  max-width: 140px;
  margin-bottom: 2rem;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-card .login-subtitle {
  font-size: 0.9375rem;
  color: var(--fg-muted);
  margin-bottom: 2rem;
}

.login-error {
  background: var(--danger-tint);
  border: 1px solid var(--danger);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  color: var(--danger);
  font-size: 0.875rem;
  line-height: 1.5;
}

.login-notice {
  background: var(--success-tint);
  border: 1px solid var(--success-border);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  color: var(--success-strong);
  font-size: 0.875rem;
  line-height: 1.5;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--fg);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.login-btn:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.login-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--fg-faint);
  font-size: 0.8125rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.login-email-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
}

.login-email-form label {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--fg-muted);
}

.login-email-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.login-email-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.login-email-submit {
  justify-content: center;
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  border-radius: 0.5rem;
}

/* The welcome panel and the check-your-email panel swap in place: the old one
   fades up and out while htmx waits (`swap:150ms`), the new one fades in. */
.login-panel {
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.login-panel.htmx-swapping {
  opacity: 0;
  transform: translateY(-6px);
}

.login-panel.htmx-added {
  opacity: 0;
  transform: translateY(6px);
}

@media (prefers-reduced-motion: reduce) {
  .login-panel {
    transition: none;
  }

  .login-panel.htmx-swapping,
  .login-panel.htmx-added {
    transform: none;
  }
}

/* Email sign-in pages show the login card alone, without the marketing panel. */
.login-form.email-login-page {
  flex: 1;
}

.login-code-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.login-code-input::placeholder {
  color: #d6d3cd;
}

.login-code-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.login-code-input.login-code-input-error {
  border-color: var(--danger);
}

.email-login-help {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.email-login-inline-form {
  display: inline;
}

.email-login-link-button {
  padding: 0;
  font: inherit;
  color: var(--brand);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.email-login-code-row {
  /* The code sits in the centre column, so the copy button beside it does not
     pull it off centre. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.email-login-code-row .email-login-copy {
  justify-self: start;
}

.email-login-code-row .email-login-code {
  grid-column: 2;
  margin: 0;
}

.email-login-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--fg-muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.email-login-copy:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.email-login-copy:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.email-login-copy svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.email-login-copy .email-login-check-icon,
.email-login-copy.copied .email-login-copy-icon {
  display: none;
}

.email-login-copy.copied .email-login-check-icon {
  display: block;
}

.email-login-copy.copied {
  color: var(--success-strong);
  border-color: var(--success-border);
  background: var(--success-tint);
}

.email-login-code {
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--fg);
}

.login-website-link {
  display: block;
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--fg-faint);
  text-decoration: none;
  transition: color 0.2s ease;
}

.login-website-link:hover {
  color: var(--brand);
  text-decoration: none;
}

@media (max-width: 768px) {
  .login-marketing {
    display: none;
  }
  .login-form {
    flex: 1;
  }
}


/* ── Not-found detail pages ── */

.not-found-page {
  background: var(--surface);
  overflow-y: auto;
}

/* `margin: auto` centres the card both ways in the space below the top bar. */
.not-found-card {
  max-width: 480px;
  margin: auto;
  padding: var(--space-6);
  text-align: center;
}

.not-found-card__icon {
  font-size: 28px;
  color: var(--fg-muted);
}

.not-found-card__title {
  margin: var(--space-3) 0 var(--space-2);
  font: var(--text-h3);
  color: var(--fg);
}

.not-found-card__message {
  margin: 0 0 var(--space-4);
  font: var(--text-sm);
  color: var(--fg-muted);
}

.not-found-card__requested {
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-1);
  max-width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.not-found-card__requested-label {
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.not-found-card__requested-id {
  font: var(--text-mono);
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

.not-found-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.not-found-card__actions .btn:hover {
  text-decoration: none;
}


/* ── Error pages ── */

.app-container:has(.error-page) {
  display: block;
}

.content:has(.error-page) {
  padding: 0;
  padding-bottom: 0;
  overflow: hidden;
  margin: 0;
  margin-left: 0;
  max-width: none;
  width: 100%;
}

.error-page {
  position: fixed;
  inset: 0;
  background: var(--surface-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 9999;
}

.error-page .orb-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.error-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 32rem;
  padding: 2rem;
}

.error-code {
  font-size: 8rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 1rem;
  color: #fff;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--border);
  margin-bottom: 0.75rem;
}

.error-message {
  font-size: 1rem;
  color: var(--fg-faint);
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* Tip card — reuses the login-tip rotating border animation */
.error-tip {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid transparent;
  background-clip: padding-box;
  text-align: left;
}

.error-tip::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 0.75rem;
  padding: 1px;
  background: conic-gradient(
    from var(--border-angle),
    rgba(255, 255, 255, 0.08) 0%,
    rgba(10, 109, 189, 0.6) 12%,
    rgba(0, 180, 216, 0.4) 20%,
    rgba(255, 255, 255, 0.08) 35%,
    rgba(255, 255, 255, 0.08) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  animation: border-rotate 4s linear infinite;
  pointer-events: none;
}

.error-tip-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin-bottom: 0.5rem;
}

.error-tip-text {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--fg-faint);
}

@media (max-width: 768px) {
  .error-code {
    font-size: 5rem;
  }
  .error-content {
    padding: 1.5rem;
  }
}


/* ===================================================================   Accounts Receivable — Editor & List
   ========================================================================== */


/* AR PDF preview — the bar itself reuses the AP .pdf-tabs-bar chrome.
   The Preview tab is a status indicator, not a switchable tab — EXCEPT on an
   externally-issued draft, where a second "Original PDF" tab is a real,
   clickable switch (see `arPdfSwitchTab` in ar.clj). */
.ar-editor .pdf-tab-item {
  cursor: default;
}
.ar-editor .pdf-tabs-bar:has(.pdf-tab-item[data-target="original"]) .pdf-tab-item {
  cursor: pointer;
}

/* AR PDF preview — double-buffer iframes for flicker-free updates */
.ar-pdf-active {
  z-index: 2;
  visibility: visible;
}
.ar-pdf-buffer {
  z-index: 1;
  visibility: hidden;
}

/* AR editor — compact form density to match AP detail view */
.ar-editor .form-group {
  margin-bottom: 10px;
}
.ar-editor .form-group label {
  margin-bottom: 4px;
  font-size: 12px;
}
.ar-editor .form-group input,
.ar-editor .form-group textarea,
.ar-editor .form-group select {
  padding: 6px 10px;
  font-size: 13px;
}
/* Same editable/read-only language as the data panels' boxed values: an
   input you can type in is tinted with a stronger border and turns white
   with a brand border on hover or focus; a read-only one is white. */
.ar-editor .form-group :is(input:not([type="checkbox"], [type="radio"], .ar-accounting-compact-input, .ar-accounting-bu-input), textarea, select) {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--bg-muted) 50%, var(--bg-canvas));
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
.ar-editor .form-group :is(input:not([type="checkbox"], [type="radio"], .ar-accounting-compact-input, .ar-accounting-bu-input), textarea, select):is(:hover, :focus):not([readonly], :disabled) {
  border-color: var(--brand);
  background: var(--surface);
}
.ar-editor .form-group :is(input, textarea, select):is([readonly], :disabled) {
  border-color: var(--border);
  background: var(--surface);
}
.ar-editor .invoice-section {
  /* Match the AP data panel's card rhythm (was 16/12). */
  margin-top: 10px;
}
/* Inherit the AP .section-header (14px + bottom divider); add flex so the
   leading icon aligns, matching the AP collapsible-section headers. */
.ar-editor .section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ar-editor .section-header iconify-icon {
  font-size: 16px;
  color: var(--fg-muted);
}
/* AR editor section anchors clear the sticky section-tabs when jumped to. */
.ar-send-panel, #ar-sec-details, #ar-sec-recipient, #ar-sec-items,
#ar-sec-totals, #ar-sec-skonto, #ar-sec-accounting, #ar-sec-settlement,
#ar-sec-notes {
  scroll-margin-top: 56px;
}
/* Item 6 — totals summary rendered in the AP Payment-Summary value-row style. */
.ar-totals-summary {
  margin-top: 14px;
}
/* Item 4 — tighten the AR line-items table toward the AP dense rhythm. */
.ar-editor .line-items-table { font-size: 12px; }
.ar-editor .line-items-table th { font-size: 11px; }
.ar-editor .line-items-table td { padding-top: 4px; padding-bottom: 4px; }
/* Item 5 — recipient name is the prominent, full-width field (like AP party-card-name). */
.ar-editor .ar-recipient-grid .form-group:first-child { grid-column: 1 / -1; }
.ar-editor .ar-recipient-grid .form-group:first-child input {
  font-size: 15px;
  font-weight: 600;
}
.ar-editor .invoice-metadata-box {
  padding: 12px;
  margin-bottom: 10px;
}
/* Settlement holds a single row, so it drops the match list's row separator
   and row padding. */
.ar-editor #ar-sec-settlement .invoice-metadata-box {
  padding-top: 4px;
  padding-bottom: 4px;
  margin-bottom: 0;
}
.ar-editor #ar-sec-settlement .match-group {
  padding: 0;
  border-bottom: none;
}
.match-group-transaction .match-group-conf {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* A compact Match button whose negative margins cancel its extra height, so
   the title line keeps the height it has in rows without the button. */
.match-group-action.btn-sm {
  padding: 2px 10px;
  line-height: 1.3;
  margin-block: -3px;
}
.ar-editor .invoice-header-grid {
  gap: 10px;
}
.ar-editor .party-card {
  padding: 12px;
}
.ar-editor .form-actions {
  margin-top: 16px;
  padding-top: 16px;
}

/* AR recipient — 2-column grid for name + email, address below */
.ar-recipient-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Inline inputs for line items table (compact, no form-group spacing) */
.ar-line-input {
  padding: 6px 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.ar-line-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 109, 189, 0.1);
}

.ar-line-input::placeholder {
  color: var(--fg-faint);
}

.ar-line-input-full {
  width: 100%;
}

.ar-line-input-number {
  width: 100%;
  text-align: right;
  -moz-appearance: textfield;
}

.ar-line-input-number::-webkit-inner-spin-button,
.ar-line-input-number::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Line item editable table overrides for line-items-table.
   Cells align to the top so every input in a row shares a baseline: the
   description cell also holds the generated-detail disclosure, and centring
   would re-centre the whole row around it whenever it is open. */
.line-items-table .ar-line-item td {
  padding: 4px 4px;
  vertical-align: top;
}

/* Drag handle & drag states.
   vertical-align is set on the qualified selector, not `.ar-drag-handle`
   alone: `.line-items-table .ar-line-item td` above outranks a single-class
   selector, so an unqualified override here would be silently ignored. */
.line-items-table .ar-line-item td.ar-drag-handle,
.line-items-table .ar-line-item td.ar-line-remove-cell {
  vertical-align: middle;
}
.ar-drag-handle {
  width: 24px;
  cursor: grab;
  color: var(--fg-faint);
  text-align: center;
  padding: 0 2px !important;
  user-select: none;
}
.ar-drag-handle:active {
  cursor: grabbing;
}
.ar-drag-handle iconify-icon {
  font-size: 14px;
}
.ar-line-item:hover .ar-drag-handle {
  color: var(--fg-muted);
}
.ar-dragging {
  opacity: 0.4;
  background: var(--bg-muted) !important;
}
.ar-line-item {
  transition: opacity 0.15s;
}

.ar-line-breakdown {
  margin-top: 4px;
  color: var(--fg-muted);
  font-size: 12px;
}

.ar-line-breakdown summary {
  cursor: pointer;
}

.ar-line-breakdown-entry {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 3px;
}

.ar-line-breakdown-values {
  white-space: nowrap;
}

.ar-line-amount {
  text-align: right;
  color: var(--fg-muted);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  padding-right: 8px !important;
  white-space: nowrap;
}

.ar-btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  line-height: 1;
}

.ar-btn-remove:hover {
  background: var(--danger-tint);
}

/* Totals discount row */
.ar-totals-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 400px;
}

.ar-totals-row .field-label {
  flex-shrink: 0;
}

/* Cash Discount renders three stacked .ar-totals-row tiers with no space
   between them — scoped to that section since .ar-totals-row is also the
   Totals tab's single invoice-level-discount row, which needs no vertical
   rhythm of its own. 10px matches this form's usual row spacing
   (`.ar-editor .form-group`). */
#ar-sec-skonto .ar-totals-row {
  margin-bottom: 10px;
}

#ar-sec-skonto .ar-totals-row:last-child {
  margin-bottom: 0;
}

.ar-totals-row .ar-line-input {
  max-width: 160px;
}

/* AR status badges (list page) — same tint/strong/border recipe and
   min-width as the AP unified document status badges. */
.ar-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  min-width: 112px;
}
.ar-badge-draft {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.ar-badge-sending {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.ar-badge-issued {
  background: var(--info-tint);
  color: var(--info);
  border: 1px solid var(--info-border);
}
.ar-badge-paid {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.ar-badge-recorded {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}


/* ===================================================================   AR editor — Sending card (advisory approvals + send status, merged)
   ========================================================================== */
.ar-send-panel .section-header .header-chip {
  margin-left: auto;
}

/* Advisory approvals sub-block */
.ar-subhead {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.ar-subhead-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.ar-subhead-hint {
  font-size: 11px;
  color: var(--fg-faint);
}
.ar-subhead .ar-count-chip {
  margin-left: auto;
}
.ar-count-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.ar-count-chip.is-complete {
  background: var(--success-tint);
  color: var(--success-strong);
  border-color: var(--success-border);
}
.ar-approvers-notice {
  font-size: 12px;
  color: var(--fg-muted);
  margin: 8px 0 0;
}

.ar-approvers-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.ar-approvers-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-muted);
}
.ar-approvers-list li:last-child {
  border-bottom: none;
}
/* The viewer's own row — the one they can act on — bleeds a faint tint to the
   card edges (the card pads 14px) so it reads as "this is yours". */
.ar-approvers-list li.is-you {
  background: var(--azure-50);
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
  border-bottom-color: transparent;
}
/* AP's sequential approvers list (approval.clj's approvers-section). Reuses
   .approver-name/.approver-state from the AR list below; needs its own
   list-style reset since it's a plain <ol>, not AR's <ul>. */
.approvers-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.approvers-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-muted);
}
.approvers-list li:last-child {
  border-bottom: none;
}
.approver-position {
  flex: none;
  min-width: 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}
.approver-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  background: var(--azure-50);
  color: var(--brand);
  border: 1px solid var(--info-border);
}
.approver-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.approver-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.approver-meta {
  font-size: 11px;
  color: var(--fg-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.approver-rejection-comment {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--fg);
}
.approver-rejection-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.approver-rejection-text em { color: var(--fg-muted); }
.approval-footer .approval-footer-title.is-rejected { color: var(--danger); }
.approval-reject-dialog { width: 480px; }
.approval-reject-dialog h2 { margin: 0 0 20px; font-size: 18px; }
.approval-reject-dialog .field-group { margin-bottom: 20px; }
.approval-reject-dialog textarea { width: 100%; max-width: none; resize: vertical; min-height: 110px; font: inherit; }
.edit-draft-save-dialog { width: 480px; }
.edit-draft-save-dialog h2 { margin: 0 0 20px; font-size: 18px; }
.edit-draft-save-dialog .field-group { margin-bottom: 16px; }
.edit-draft-save-dialog .field-group label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.edit-draft-save-dialog .field-group p { margin: 0; }
.edit-draft-save-dialog .edit-draft-asked { margin: 0; padding-left: 18px; }
.edit-draft-save-dialog textarea { width: 100%; max-width: none; resize: vertical; min-height: 90px; font: inherit; }
.you-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--info-border);
  vertical-align: 1px;
  margin-left: 6px;
}
/* Deciding on behalf adds a reason field to the buttons; on a narrow footer the
   controls move under the name and wrap instead of running off the row. */
.approver-trailing {
  flex: none;
  max-width: 100%;
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.approver-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.approver-state.is-pending {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.approver-state.is-approved {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}
.approver-state.is-rejected {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
}
.approver-state.is-revoked {
  background: var(--bg-muted);
  color: var(--fg-faint);
  border: 1px solid var(--border);
}
.approver-state.is-not-needed {
  background: transparent;
  color: var(--fg-faint);
  border: 1px dashed var(--border);
}
.approver-state.is-on-hold {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px dashed var(--border);
}
.approver-state iconify-icon {
  font-size: 12px;
}
.ar-approvers-empty {
  font-size: 13px;
  color: var(--fg-muted);
  padding: 6px 0 0;
}
.ar-approvers-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.add-approver-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  max-width: 420px;
}
.add-approver-form select {
  flex: 1;
  min-width: 0;
  padding: 6px 32px 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--fg);
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

/* Divider between advisory approvals and the send action */
.ar-issue-divider {
  border-top: 1px solid var(--border);
  margin: 13px 0;
}

/* Send action + notes */
.ar-send-action {
  margin-top: 13px;
}
/* A generated invoice with email enabled offers Book and Book & Send side by
   side; every other case renders a single .ar-send-action. */
.ar-send-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
/* Armed Send confirm prompt — mirrors #ar-bulk-actions' visual weight so the
   single-invoice and batch send guards read as the same interaction. */
.ar-send-confirm {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-radius: 8px;
}

.ar-send-confirm[hidden] {
  display: none;
}
.ar-send-confirm-prompt {
  font-weight: 600;
  font-size: 13px;
}
.ar-send-error {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--danger-strong);
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.ar-send-error iconify-icon {
  font-size: 16px;
  flex: none;
}

/* Pre-send EN-16931 blockers — why the Send action is disabled */
.ar-send-blockers {
  margin-top: 13px;
  font-size: 13px;
  color: var(--danger-strong);
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.ar-send-blockers-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.ar-send-blockers-head iconify-icon {
  font-size: 16px;
  flex: none;
}
.ar-send-blockers ul {
  margin: 7px 0 0;
  padding-left: 28px;
  list-style: disc;
}
.ar-send-blockers li {
  margin-top: 2px;
}
/* Client-populated "required fields still empty" summary next to the Send
   button. Matches .ar-send-blockers; entries link to the offending field. */
.ar-required-summary {
  margin-top: 13px;
  font-size: 13px;
  color: var(--danger-strong);
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.ar-required-summary-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.ar-required-summary-head iconify-icon {
  font-size: 16px;
  flex: none;
}
.ar-required-summary ul {
  margin: 7px 0 0;
  padding-left: 28px;
  list-style: disc;
}
.ar-required-summary li {
  margin-top: 2px;
}
.ar-required-summary a.ar-required-jump {
  color: var(--danger-strong);
  text-decoration: underline;
  cursor: pointer;
}
.ar-required-summary a.ar-required-jump:hover {
  text-decoration: none;
}
.ar-send-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--fg-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.ar-send-note iconify-icon {
  font-size: 16px;
  color: var(--fg-faint);
  flex: none;
}

/* Per-step send outcomes (email / datev) */
.ar-send-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.ar-send-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--bg-muted);
  font-size: 13px;
}
.ar-send-steps li:last-child {
  border-bottom: none;
}
.ar-step-icon {
  flex: none;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.ar-step-icon.ok { color: var(--success-strong); }
.ar-step-icon.run { color: var(--info); }
.ar-step-icon.fail { color: var(--danger); }
.ar-step-icon.idle { color: var(--fg-faint); }
.ar-step-name {
  font-weight: 600;
  color: var(--fg);
}
.ar-step-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-muted);
}
.ar-step-status.run { color: var(--info); }
.ar-step-status.fail { color: var(--danger); }

/* Quiet historical footnote on a locked invoice */
.ar-issue-footer {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--bg-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--fg-faint);
}
.ar-issue-footer iconify-icon {
  font-size: 14px;
}

/* View Transitions — htmx animates the Sending card via hx-swap "... transition:true":
   the card resizes while its contents crossfade and the status badge morphs in place. */
::view-transition-group(ar-send-card) {
  animation-duration: 0.34s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) { animation: none !important; }
}


/* AR list table — reuse document list table styles */
#ar-invoice-list .table {
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}
#ar-invoice-list thead {
  background: var(--surface);
}
#ar-invoice-list thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#ar-invoice-list tbody tr:last-child td {
  border-bottom: none;
}


/* ===================================================== * Inline editable values — hover to reveal, click to edit.
 * Critical rule: every state must be pixel-identical at rest.
 * `outline` and `box-shadow` live outside the box model; they
 * never shift layout. No borders, no padding, no margin on
 * .editable-value itself — it inherits everything from parent.
 * ============================================================ */

.editable-value {
  cursor: pointer;
  outline: 1px solid transparent;
  outline-offset: 3px;
  background-color: transparent;
  border-radius: var(--r-sm);
  transition: outline-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
  box-shadow: inset 0 -1px 0 rgba(10, 109, 189, 0.3);
}

/* Once editing, inputs/textareas get a text caret; selects stay pointer. */
.editable-value.is-editing input,
.editable-value.is-editing textarea {
  cursor: text;
}

.editable-value:hover {
  outline-color: rgba(10, 109, 189, 0.35);
  background-color: rgba(10, 109, 189, 0.08);
}

.editable-value.is-editing {
  outline-color: var(--brand);
  background-color: rgba(10, 109, 189, 0.12);
  box-shadow: 0 0 0 3px rgba(10, 109, 189, 0.1);
}

.editable-value.is-saving {
  animation: orcha-edit-flash 400ms ease-out;
}

/* An inline edit whose save is in flight (editable-fields.js). The animation
   overrides the field's static box colours wherever it sits. */
.editable-value.is-pending {
  animation: orcha-edit-pending 900ms ease-in-out infinite alternate;
}
/* The value reads as entered, not as an open input, while it saves. */
.editable-value.is-pending :is(input, select, textarea) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  outline: none;
  pointer-events: none;
}

@keyframes orcha-edit-pending {
  from {
    outline-color: var(--border);
    border-color: var(--border);
    background-color: var(--bg-canvas);
  }
  to {
    outline-color: var(--brand);
    border-color: var(--brand);
    background-color: var(--brand-tint);
  }
}

/* The regions a save in flight re-renders are dimmed until they are
   replaced; every field stays open to editing. */
.detail-container.is-saving-edit :is(#invoice-financial-summary, #invoice-math-status, #status-validation-summary) {
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

@keyframes orcha-edit-flash {
  0% {
    outline-color: var(--success);
    background-color: rgba(26, 127, 55, 0.20);
  }
  100% {
    outline-color: transparent;
    background-color: transparent;
  }
}

/* Inputs within an editable-value inherit typography exactly.
   The input is placed inside the original child element (e.g.
   span.field-value) so it inherits that element's font styling.
   `all: unset` strips browser chrome; `inherit` restores typography. */
.editable-value input,
.editable-value textarea,
.editable-value select {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  color: inherit;
  text-align: inherit;
  white-space: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.editable-value textarea {
  display: block;
  resize: none;
  overflow: hidden;
  min-height: 1em;
}

/* Currency fields split amount + suffix; only .amount becomes editable.
   `.currency-wrapper` is a child of `.editable-value`, not the same element. */
/* Amount treatment: dark mono number + lighter currency suffix, so the figure
   reads first and the unit recedes (consistent across the app). */
.currency-suffix {
  color: var(--fg-faint);
  font-weight: 400;
}
.editable-value .currency-suffix {
  pointer-events: none;
}

/* During currency editing, the wrapper becomes a flex row so the
   amount input and currency select share the available width. */
.editable-value.is-editing .currency-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.editable-value.is-editing .currency-wrapper input.amount {
  flex: 1;
  min-width: 0;         /* allow shrinking inside flex */
  width: auto !important;
}
.editable-value .currency-select {
  all: unset;
  flex-shrink: 0;
  font: inherit;
  font-size: 12px;
  color: var(--fg-muted);
  cursor: pointer;
  color-scheme: light;
  background: var(--brand-tint);
  border-radius: var(--r-sm);
  padding: 2px 4px;
  /* `all: unset` breaks the <select>'s own intrinsic-width calculation in a
     flex row — without a floor it can render under 22px, too narrow to
     show a 3-letter code. Same fix as the line-items table's currency
     overlay, generalised here since it's not specific to that context. */
  min-width: 52px;
}

/* Line-items currency edit (Unit Price / Amount): the amount input + currency
   dropdown are wider than the dense column, so editing pops a compact in-panel
   overlay. Fixes the dropdown clipped on the right (Amount), overlapping the
   next column (Unit Price), and the number being cut. */
.line-items tbody td.num { position: relative; }
.line-items tbody td.num:has(.editable-value[data-field-type="currency"].is-editing) {
  z-index: 30;
  /* td.num otherwise clips overflow (below) so a too-long number doesn't
     paint over its neighbour — but that same clip was cutting the overlay
     itself off at the column's original (narrow) edge, hiding the
     currency dropdown entirely. Only the actively-editing cell opens up. */
  overflow: visible;
}
/* Only the compact accounting-row editors are overlays. Currency editors in
   expanded details (for example accrual period amounts) stay in their local
   flow so their width is owned by the detail cell rather than the panel. */
.line-items tbody > tr.li-row > td.num > .editable-value[data-field-type="currency"].is-editing {
  position: absolute !important;
  top: 50% !important;
  left: auto;
  transform: translateY(-50%);
  width: 170px !important;
  max-width: none !important;
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 1.5px var(--brand), 0 6px 18px rgba(10, 16, 28, 0.16);
  border-radius: var(--r-sm);
  padding: 5px 8px;
}
/* Unit Price (and any non-rightmost currency cell) grows rightward; the Amount
   column is rightmost, so it grows leftward and never runs off the panel edge. */
.line-items tbody > tr.li-row > td.num:not(.amount) > .editable-value[data-field-type="currency"].is-editing { left: 2px; }
.line-items tbody > tr.li-row > td.amount > .editable-value[data-field-type="currency"].is-editing { right: 2px; }
/* Detail editors keep their local flow position, but need room for both the
   amount input and the currency select after editWidth() freezes their width. */
.line-items tbody > tr.li-detail-row .li-detail-line-fields .editable-value[data-field-type="currency"].is-editing {
  min-width: 170px !important;
}
/* Share the available width between the amount input and the currency select, and
   left-align so the start of the number is never cut. */
.line-items .editable-value[data-field-type="currency"].is-editing .li-eur {
  display: flex;
  align-items: center;
  gap: 6px;
}
.line-items .editable-value[data-field-type="currency"].is-editing .li-eur input.amount {
  flex: 1;
  min-width: 0;
  width: auto !important;
  text-align: left;
}

/* Enum fields: the select overlays the badge, invisible but clickable. */
.editable-value.enum-wrapper {
  position: relative;
}
.editable-value.enum-wrapper > select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  color-scheme: light;
  background-color: var(--surface);
  color: var(--fg);
}


.editable-value.is-human-edited {
  box-shadow: inset 0 -1px 0 rgba(26, 127, 55, 0.6);
}

/* Reset-all button: disabled state */
.btn#reset-all-edits:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.edit-error-banner {
  display: block;
  margin-top: 4px;
  padding: 6px 8px;
  background-color: rgba(207, 34, 46, 0.1);
  border: 1px solid rgba(207, 34, 46, 0.4);
  border-radius: 4px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

.line-items-sortable .drag-handle {
  cursor: grab;
  color: var(--fg-subtle);
  padding: 0 8px;
}

.line-items-sortable .drag-handle:active {
  cursor: grabbing;
}

/* Diagnostic section state styling */

.diagnostic-section {
  position: relative;
  transition: opacity 0.2s ease;
}

.diagnostic-section.is-recomputing,
.diagnostic-section.is-stale,
.supplier-verification-box.is-recomputing,
.supplier-verification-box.is-stale {
  opacity: 0.55;
}

.diagnostic-section.is-failed,
.supplier-verification-box.is-failed {
  opacity: 0.85;
}

/* Placeholder shown in place of a verification box whose analysis did not
   complete. Keeps the card outline so the check does not silently disappear. */
.sv-unavailable {
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-muted);
}

.diagnostic-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  /* More than the .validation-issue-count/.fraud-detector-badge-style count
     pill's own padding alone gives it — the two otherwise read as touching
     when a section has both a live issue count and a recompute badge. */
  margin-left: 14px;
  vertical-align: middle;
}

.diagnostic-badge.is-recomputing {
  background: var(--brand-tint);
  color: var(--brand);
  border: 1px solid var(--info-border);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.diagnostic-badge.is-recomputing .spinner-small {
  width: 11px;
  height: 11px;
  border-width: 1.5px;
  border-top-color: var(--brand);
}

.diagnostic-badge.is-stale {
  background: var(--warning-tint);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.diagnostic-badge.is-failed {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* --- Recomputing banner (inline in nav bar) --- */
.stale-edits-banner {
  display: none;
  margin-inline-end: 8px;
  align-items: center;
  background: var(--brand-tint);
  color: var(--brand);
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--info-border);
  border-radius: var(--r-lg);
}

.stale-edits-banner.is-visible {
  display: inline-flex;
}

/* --- Checks not re-run after data-panel edits (inline in nav bar) --- */
.unchecked-edits-warning {
  display: none;
  gap: 6px;
  margin-inline-end: 8px;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 13px;
  cursor: help;
}

.unchecked-edits-warning.is-visible {
  display: inline-flex;
}

/* The triangle carries its weight at the base, so centring it geometrically
   reads low next to the label; lifting it 1px puts its base on the baseline. */
.unchecked-edits-warning iconify-icon {
  display: block;
  position: relative;
  top: -1px;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  font-size: 14px;
}

/* --- Inline "recomputing" label in validation section header --- */
.stale-validation-label {
  display: none;
  font-size: 12px;
  color: var(--brand);
  margin-left: 8px;
  font-weight: 400;
}
.stale-validation-label .spinner-small {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

.detail-container.is-recomputing-validation .stale-validation-label {
  display: inline;
}

/* --- Gray out all validation containers while recomputing --- */
.detail-container.is-recomputing-validation .validation-content,
.detail-container.is-recomputing-validation .verification-grid,
.detail-container.is-recomputing-validation .validation-issues-banner {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
/* Override per-section diagnostic opacity when the parent is already grayed */
.detail-container.is-recomputing-validation .diagnostic-section.is-stale,
.detail-container.is-recomputing-validation .diagnostic-section.is-recomputing,
.detail-container.is-recomputing-validation .supplier-verification-box.is-stale,
.detail-container.is-recomputing-validation .supplier-verification-box.is-recomputing {
  opacity: 1;
}

.diagnostic-badge.is-never-run {
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

/* ===================================================== * Master data picker (GL accounts / cost centers)
 *
 * Uses the HTML5 popover API (`popover="manual"`) so the panel
 * renders in the top layer. That's the only way to escape the
 * `contain: paint` that `content-visibility: auto` applies to
 * `.line-item-card` — neither `position: absolute` nor `fixed`
 * break out of a paint-contained ancestor.
 *
 * Scoped to `[popover]` so the at-rest `<span
 * class="editable-value master-data-picker">` is untouched.
 * JS sets `top`/`left` inline after `showPopover()` based on
 * the anchor's bounding rect.
 * ============================================================ */

/* Reserve the vertical space of the value text while the popover is
   open. The at-rest trigger span (e.g. "4000 Travel Expense") is
   swapped out for the picker div, whose popover top-layer rendering
   contributes nothing to flow — the .meta-value span would otherwise
   collapse to zero height and the fields below would jump up. */
.meta-value:has(> .master-data-picker[popover]),
.account-pill:has(> .master-data-picker[popover]) {
  display: inline-block;
  min-height: 1.5em;
}

.master-data-picker[popover] {
  /* UA popover default is margin:auto;inset:0 (centered in viewport).
     Override so our JS-supplied top/left win. */
  inset: auto;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-popover);
  width: 320px;
  max-height: 320px;
  overflow: hidden;
  /* Opened from right-aligned mono table cells; it reads like the app's other
     dropdowns (.filter-dropdown-panel): left-aligned UI sans. */
  text-align: left;
  font-family: var(--font-sans);
}

.master-data-picker[popover]:popover-open {
  display: flex;
  flex-direction: column;
}

.master-data-picker-input {
  padding: 8px 12px;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.master-data-picker-input::placeholder {
  color: var(--fg-faint);
}

.master-data-picker-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
}

.master-data-picker-option {
  display: block;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
}

.master-data-picker-option:hover,
.master-data-picker-option.is-active {
  background: var(--brand-tint-hover);
  color: var(--fg);
}

.master-data-picker-option.is-selected {
  background: var(--brand-tint);
  box-shadow: inset 3px 0 0 var(--brand);
}

.master-data-picker-option[hidden] {
  display: none;
}

.master-data-picker-group[hidden] {
  display: none;
}

.master-data-picker-group-label {
  padding: 8px 12px 2px;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 600;
}

.master-data-picker-group:not([hidden]) ~ .master-data-picker-group:not([hidden]) .master-data-picker-group-label {
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.master-data-picker-clear {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.master-data-picker-clear:hover {
  color: var(--danger-strong);
}

.master-data-picker-empty,
.master-data-picker-no-matches {
  padding: 12px;
  color: var(--fg-muted);
  font-size: 13px;
  text-align: center;
  white-space: normal;
}
.master-data-picker-empty a {
  color: var(--link);
}

.master-data-picker-manual-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  text-align: left;
  color: var(--brand);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.master-data-picker-manual-entry:hover:not(:disabled) {
  background: var(--brand-tint-hover);
}

.master-data-picker-manual-entry:disabled {
  color: var(--fg-subtle);
  cursor: not-allowed;
}

/* ====================================================================   Document data panel — type-adaptive middle + trust overlays (Phase 1/2)
   coverage view, interpretation callouts, per-fact source chips.
   =========================================================================== */

/* Source chip: a small, non-interactive "p. N" page label sitting inline after
   a fact (display-only; navigation was intentionally dropped). */
.source-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--fg-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Trust overlays group (coverage + callouts), rendered after the
   Validation & Compliance section. */
.trust-overlays {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

/* Coverage view: the found / not-found expected-terms checklist. Card matches
   the validation-box look; found = green check, not-found = muted minus (the
   icon + text make it color-independent — absence reads as thoroughness, not
   an error). */
.coverage-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.coverage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-muted);
}
.coverage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.coverage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.coverage-item iconify-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.coverage-item.found iconify-icon {
  color: var(--success);
}
.coverage-item.not-found iconify-icon {
  color: var(--fg-faint);
}
.coverage-term {
  color: var(--fg);
  flex: 1;
}
.coverage-status {
  font-size: 12px;
  font-weight: 500;
}
.coverage-item.found .coverage-status {
  color: var(--success);
}
.coverage-item.not-found .coverage-status {
  color: var(--fg-muted);
}

/* Interpretation callout: a plain-language note on a nuanced/risky term.
   Severity drives the tint (warning amber, info neutral) — a plain border
   all around, never a colored left accent (we don't use that pattern
   anywhere in the app). */
.panel-callouts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
}
.panel-callout.callout-warning {
  background: var(--warning-tint);
}
.panel-callout.callout-info {
  background: var(--bg-subtle);
}
.partner-approval-notice {
  margin-bottom: 16px;
}
.panel-callout.callout-danger {
  background: var(--danger-tint);
}
.callout-text {
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}
.payment-not-paid-by-orcha {
  flex-wrap: wrap;
}
.payment-not-paid-by-orcha > iconify-icon {
  flex: none;
  margin-top: 3px;
  font-size: 14px;
  line-height: 1;
}
.payment-not-paid-by-orcha .callout-text {
  flex: 1 1 0;
  min-width: 0;
}
.payment-not-paid-by-orcha .callout-text p {
  margin: 0;
}
.payment-not-paid-by-orcha .callout-action {
  flex: 0 0 100%;
  margin-top: 4px;
}
.payment-not-paid-by-orcha .callout-action .btn {
  max-width: 100%;
  white-space: nowrap;
}

/* Inline table fields (e.g. payment schedule, penalties) span the full width of
   the type-adaptive middle grid instead of being squeezed into one column. */
.detail-fields .field-table {
  grid-column: 1 / -1;
}
.field-table .table td,
.payment-schedule .table td {
  white-space: normal;
  overflow-wrap: anywhere;
}
.field-table .table td + td,
.payment-schedule .table td + td {
  min-width: 7rem;
}

/* Section header: keep the leading icon and the title text on the same vertical
   center (the icon box is taller than the 14px text, so collapse the text's
   line-box and center both as flex items). */
.section-header-toggle > span {
  line-height: 1;
}
.section-header-toggle > span > iconify-icon {
  flex: 0 0 auto;
}
/* With the line box collapsed, the two boxes' centres coincide, so the
   title icon takes no optical nudge here (see `.invoice-section
   .section-header iconify-icon`, kept for headers with a full line box). */
.invoice-section .section-header-toggle > span > iconify-icon {
  transform: none;
}

/* AR list Status pill: combined approval-progress + lifecycle state */
.ar-pill { display:inline-flex; align-items:center; padding:2px 10px; border-radius:999px; font-size:12px; font-weight:600; white-space:nowrap; }
.ar-pill-draft { background:#f1f5f9; color:#64748b; }
.ar-pill-partial { background:#fef3c7; color:#92400e; }
.ar-pill-full    { background:#dcfce7; color:#166534; }
.ar-pill-processing { background:var(--warning-tint); color:var(--warning-strong); }
.ar-pill-failed  { background:var(--danger-tint); color:var(--danger-strong); }
.ar-pill-sent    { background:#dbeafe; color:#1e40af; }
.ar-pill-paid    { background:#ccfbf1; color:#0f766e; }
.ar-pill-recorded { background:#ccfbf1; color:#0f766e; }
.ar-pill-approved-check { opacity:0.8; }

/* AR list Source pill: whether the invoice was created, imported, emailed, or generated; informational
   not severity-graded, so a single neutral treatment for every value. */
.ar-source-pill { display:inline-flex; align-items:center; gap:5px; padding:2px 10px; border-radius:999px; font-size:12px; font-weight:600; background:#f1f5f9; color:#64748b; }
.ar-source-pill iconify-icon { font-size:13px; }

/* Active-tenant selector (sidebar dropdown); reuses .tenant-select, distinct wrapper from the org .tenant-switcher */
.active-tenant-selector {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.active-tenant-selector form { margin: 0; }
.active-tenant-selector .filter-dropdown-trigger {
  width: 100%;
  justify-content: space-between;
}
.active-tenant-selector .filter-dropdown-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.active-tenant-dropdown > .filter-dropdown-panel {
  position: fixed;
  top: auto;
  left: auto;
  z-index: 1001;
  width: 300px;
  min-width: 0;
  max-width: calc(100vw - 16px);
}
.active-tenant-dropdown .filter-dropdown-option {
  text-align: left;
  white-space: normal;
}
/* Expanded: dropdown shows, building icon hidden */
.tenant-select-icon { display: none; }

/* Date pill custom-range footer */
.date-range-custom {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-range-custom-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}
.date-range-custom-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-range-custom-inputs input[type="date"],
.date-range-custom-inputs [data-european-date-display] {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  height: 32px;
  color-scheme: light;
}
.date-range-custom-inputs input[type="date"]:focus,
.date-range-custom-inputs [data-european-date-display]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.date-range-custom .filter-dropdown-apply {
  border-top: none;
  border-radius: var(--r-md);
}
.ar-cb-cell { width: 36px; text-align: center; }
.ar-cb-placeholder { color: var(--fg-muted); opacity: .4; }
#ar-bulk-actions { display: none; align-items: center; gap: 12px; padding: 8px 12px;
  margin-bottom: 8px; background: var(--bg-subtle); border-radius: 8px; }
#ar-bulk-actions.visible { display: flex; }
#ar-selected-count { font-weight: 600; }
#ar-bulk-actions .btn { flex-shrink: 0; white-space: nowrap; }
#ar-bulk-actions .ar-select-matching { color: var(--link); font-weight: 500; }
#ar-bulk-actions .ar-select-matching:hover { color: var(--link); }

/* Supplier-comms: days-waiting aging cue on AP list rows */
.outreach-days-waiting {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 2px;
  white-space: nowrap;
}

/* Supplier-comms: action-needed count badge in the status filter dropdown */
.action-needed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 9px;
  background: var(--warning, #f59e0b);
  color: #fff;
  vertical-align: middle;
}

/* Entity review — the queue of documents routing could not attribute to a legal
   entity, and the page where a person names one. The queue is an ordinary list
   page (.documents-page/.table); the review is the AP detail's two-pane split
   (.detail-container/.pdf-panel/.data-panel), so only what is unique to it lives
   here. */
.badge-routing-not-ours {
  background: var(--danger-tint);
  color: var(--danger-strong);
}
.badge-routing-undetermined {
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.badge-routing-dismissed {
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.badge-severity-business {
  background: var(--accent-violet-tint);
  color: var(--accent-violet);
  border: 1px solid #c9b3f0;
}
.badge-severity-system {
  background: var(--danger-tint);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
}
.badge-waiting {
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.badge-waiting-urgent {
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.tenant-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Entity Assignment stacks two radio groups (legal entities, then which
   side) back to back with no wrapping .field-group -- without this, the
   second group's label sits flush against the first group's last option. */
.tenant-options + .field-label {
  margin-top: 16px;
}
.tenant-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tenant-option:hover {
  background: var(--bg-muted);
}
.tenant-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
}
.tenant-option input[type="radio"] {
  accent-color: var(--brand);
}
.tenant-option-name {
  font-size: 14px;
  color: var(--fg);
}
.routing-entity-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}
.routing-entity-select:focus {
  outline: none;
  border-color: var(--brand);
}
.badge-suggested {
  margin-left: auto;
  background: var(--brand-tint);
  color: var(--brand);
}
.tenant-confirm-actions {
  justify-content: space-between;
  margin-top: 14px;
}
/* The bill-to block, collapsed to one line under the reason in the queue. Full
   text on hover; the whole of it on the review page. */
.routing-evidence-line {
  display: block;
  max-width: 420px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

/* AR keeps bookkeeping separate from commercial line editing while following
   the dense, expandable AP line-items table language. */
.ar-accounting-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.ar-accounting-table {
  /* Fixed-pixel column widths (a prior fix) stopped the description column
     from swallowing the whole row on a wide screen, but then left the table
     itself narrower than its container — a bare gap on the right, since
     `table-layout: fixed` has nowhere else to put unclaimed width. Percentage
     colgroup widths (below) plus `width: 100%` fill the container exactly
     while keeping every column's share fixed; `min-width` plus the wrap's
     `overflow-x: auto` still handle a viewport narrower than columns can
     shrink to. */
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.ar-accounting-table thead th {
  padding: 6px 7px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  font: var(--text-caption);
  letter-spacing: 0.02em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.ar-accounting-table td {
  padding: 7px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg);
  vertical-align: middle;
}

.ar-accounting-row {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.ar-accounting-row:hover,
.ar-accounting-row.open {
  background: var(--bg-subtle);
}

.ar-accrual-imbalanced .ar-accounting-row {
  background: var(--danger-tint);
  box-shadow: inset 3px 0 0 var(--danger);
}

.ar-accounting-description {
  min-width: 190px;
  overflow: hidden;
  white-space: nowrap;
}

.ar-accounting-description-name {
  display: inline-block;
  max-width: calc(100% - 66px);
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.ar-accounting-vat {
  display: inline-block;
  margin-left: 8px;
  color: var(--fg-muted);
  font: var(--text-caption);
  vertical-align: middle;
}

.ar-accounting-compact-cell {
  overflow: hidden;
  white-space: nowrap;
}

.ar-accounting-compact-cell .account-pill {
  display: block;
  box-sizing: border-box;
  width: 100%;
  /* .account-pill's usual caption-scale sizing (10.5px font, 1px padding)
     reads as a cramped, oddly-short control next to the BU-code input in
     this same row. The BU input's own rule (`.ar-accounting-bu-input`)
     looks like the effective sizing, but a higher-specificity generic rule
     (`.ar-editor .form-group input`, since the BU cell's <td> also carries
     `.form-group`) actually wins and renders it at padding 6px/10px,
     font-size 13px (confirmed via computed-style — 31.6px tall). Match that
     directly instead of the shadowed rule. */
  padding: 6px 10px;
  font-size: 13px;
  line-height: 18px;
}

.ar-accounting-compact-cell .account-pill.empty {
  background: var(--bg-muted);
  color: var(--fg-muted);
}

.ar-accounting-compact-cell .editable-value.master-data-picker {
  display: block;
  overflow: hidden;
  outline: none;
  text-overflow: ellipsis;
}

.ar-accounting-compact-cell .editable-value.master-data-picker:hover,
.ar-accounting-compact-cell .editable-value.master-data-picker:focus {
  color: var(--brand);
}

.ar-accounting-compact-input,
.ar-accounting-bu-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 18px;
  white-space: nowrap;
}

.ar-accounting-compact-cell .ar-field-invalid {
  outline: 1px solid var(--danger);
  outline-offset: 3px;
}

.ar-accounting-bu-cell {
  overflow: hidden;
}

.ar-accounting-bu-input {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-canvas);
  font-family: var(--font-mono);
}

.ar-accounting-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right !important;
  white-space: nowrap;
}

.ar-accounting-expand {
  color: var(--fg-faint);
  text-align: center;
}

.ar-accounting-expand iconify-icon {
  font-size: 15px;
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.ar-accounting-row:hover .ar-accounting-expand iconify-icon,
.ar-accounting-row.open .ar-accounting-expand iconify-icon {
  color: var(--brand);
}

.ar-accounting-row.open .ar-accounting-expand iconify-icon {
  transform: rotate(180deg);
}

.ar-accounting-detail-row[hidden],
.ar-accounting-detail-row .li-reason[hidden] {
  display: none;
}

.ar-accounting-detail-row > td {
  padding: 0;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.ar-accounting-table .li-detail-grid {
  grid-template-columns: 1fr 1fr;
}

.ar-revenue-recognition {
  grid-column: 1 / -1;
}

.ar-revenue-type {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: var(--text-caption);
  font-weight: 700;
}

.ar-revenue-periods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ar-revenue-period {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  background: var(--surface);
}

.ar-revenue-period-month,
.ar-revenue-period-amount {
  box-sizing: border-box;
  min-height: 26px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-canvas);
  color: var(--fg);
  font: var(--text-caption);
}

.ar-revenue-period-month {
  width: 124px;
}

/* Wide enough for a grouped signed amount in the profile, -99,999,999.99:
   14 monospace characters plus padding and border. */
.ar-revenue-period-amount {
  width: calc(14ch + 14px);
  font-family: var(--font-mono);
}

span.ar-revenue-period-month,
span.ar-revenue-period-amount {
  width: auto;
  border: 0;
  background: transparent;
}

.ar-revenue-period-remove,
.ar-revenue-period-add {
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}

.ar-revenue-period-remove {
  display: inline-flex;
  padding: 2px;
}

.ar-revenue-period-remove:hover {
  color: var(--danger);
}

.ar-revenue-period-add {
  margin-top: 8px;
  padding: 3px 0;
  font: var(--text-caption);
}

.ar-revenue-period-add:hover {
  color: var(--brand);
}

@media (max-width: 700px) {
  .ar-accounting-table .li-detail-grid {
    grid-template-columns: 1fr;
  }

  .ar-revenue-recognition {
    grid-column: auto;
  }
}

/* Audit trail v2
   -------------------------------------------------------------------------- */
.audit-op-row {
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.audit-op-row:hover,
.audit-op-row.is-expanded {
  background: var(--bg-subtle);
}
.audit-op-row.is-expanded td {
  border-bottom-color: transparent;
}
.audit-scroll-area {
  overflow-x: auto;
}
.audit-table {
  min-width: 980px;
  table-layout: fixed;
}
.audit-table thead,
.audit-table thead th {
  background: var(--surface);
}
.audit-col-timestamp {
  width: 170px;
}
.audit-col-user {
  width: 150px;
}
.audit-col-action {
  width: 170px;
}
.audit-col-record {
  width: 240px;
}
.audit-col-source {
  width: 110px;
}
.audit-table th,
.audit-table td {
  white-space: normal;
}
.audit-table thead th:first-child,
.audit-table thead th:last-child,
.audit-op-row > td:first-child,
.audit-op-row > td:last-child {
  white-space: nowrap;
}
.audit-row-toggle {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.audit-row-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.audit-timestamp {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
.audit-user,
.audit-record,
.audit-record-link,
.audit-summary {
  overflow-wrap: anywhere;
}
.audit-summary {
  color: var(--fg-muted);
}
.audit-detail-row[hidden] {
  display: none;
}
.audit-detail-row,
.audit-detail-row:hover {
  background: var(--bg-subtle);
}
.audit-detail-row > td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  white-space: normal;
}
.audit-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 22px 20px;
}
.audit-detail-panel h4 {
  margin: 0 0 10px;
  color: var(--fg);
  font-size: 12px;
  font-weight: 650;
}
.audit-detail-section {
  min-width: 0;
}
.audit-detail-section + .audit-detail-section {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.audit-change-list {
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  list-style: none;
}
.audit-change {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
}
.audit-change:last-child {
  border-bottom: 0;
}
.audit-change-field {
  color: var(--fg);
  font-weight: 600;
}
.audit-change-before {
  overflow-wrap: anywhere;
  color: var(--fg-muted);
  text-decoration: line-through;
}
.audit-change-arrow {
  color: var(--fg-muted);
}
.audit-change-after {
  grid-column: 4;
  overflow-wrap: anywhere;
  color: var(--success);
  font-weight: 600;
}
.audit-change-redacted .audit-change-field {
  grid-column: 1 / -1;
  color: var(--fg-muted);
  font-weight: 500;
}
.audit-no-changes {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg-muted);
}
.audit-evidence {
  padding: 0;
  border: 0;
  background: transparent;
}
.audit-evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 24px;
}
.audit-evidence-item {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
  color: var(--fg-muted);
}
.audit-evidence-item strong {
  overflow-wrap: anywhere;
  color: var(--fg);
  font-weight: 600;
  text-align: right;
}
.audit-source-provenance-list {
  display: grid;
  gap: 10px;
}
.audit-source-provenance-item {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.audit-source-provenance-item dt {
  color: var(--fg-muted);
}
.audit-source-provenance-item dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--fg);
  font-weight: 600;
}
.audit-evidence-records {
  margin: 0;
  color: var(--fg-muted);
}
.audit-evidence-records ul {
  padding-left: 18px;
  margin: 0;
}
.audit-record-link {
  color: var(--brand);
  font-family: var(--font-mono);
  font-weight: 600;
}
.audit-record-link:hover {
  text-decoration: underline;
}
.audit-technical {
  margin: 0;
  color: var(--fg-muted);
}
.audit-technical-identifiers {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  margin: 10px 0;
}
.audit-technical-identifiers dt,
.audit-technical-identifiers dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.audit-technical-identifiers dd {
  color: var(--fg);
  font-family: var(--font-mono);
}
.audit-technical table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.audit-technical th,
.audit-technical td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  text-align: left;
}
.audit-empty-row td {
  padding: 48px;
  color: var(--fg-muted);
  text-align: center;
}
.audit-table-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: 12px;
}
.audit-table-footer-notice {
  margin: 4px 0 0;
  color: var(--warning);
}
.audit-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
}
.audit-page-link {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--brand);
}
.audit-page-link.is-disabled {
  color: var(--fg-muted);
  opacity: 0.65;
}
.audit-page-status {
  color: var(--fg-muted);
}

@media (max-width: 900px) {
  .audit-evidence-grid {
    grid-template-columns: 1fr;
  }
}

/* ===================================================================   Payment runs
   Only what the payment surfaces need beyond the shared tokens, cards, tables
   and buttons: the AP selection column, the compositional amount chips, the
   Invoices/Payment runs switch, and the draft editor's grouping.
   ========================================================================== */

.ap-module-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.ap-module-tab {
  padding: 8px 12px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}

.ap-module-tab.is-active {
  color: var(--fg);
  border-bottom-color: var(--brand);
}

.payment-select-cell {
  width: 32px;
  padding-left: 12px;
  padding-right: 0;
}

/* Skonto opportunities stay part of the run history rather than competing
   with it as a second dashboard. The dates and amounts carry the urgency; the
   surfaces remain deliberately neutral. */
.skonto-opportunity-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.skonto-opportunity-dialog-header h2 {
  margin: 0;
  color: var(--fg);
  font: var(--text-body-strong);
}

.skonto-opportunity-reference {
  margin: 2px 0 0;
  color: var(--fg-muted);
  font: var(--text-caption);
}

.skonto-manager-entry {
  box-sizing: border-box;
  height: 32px;
  padding-block: 0;
  line-height: normal;
  gap: var(--space-2);
  white-space: nowrap;
}

.skonto-manager-entry iconify-icon {
  font-size: 16px;
}

.skonto-manager-tab-controls {
  display: flex;
  align-items: stretch;
  gap: var(--space-5);
  margin-top: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.skonto-manager-tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skonto-manager-tab-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 42px;
  margin-bottom: -1px;
  padding: 0 var(--space-1);
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font: var(--text-sm);
  cursor: pointer;
}

.skonto-manager-tab-input:checked + .skonto-manager-tab-label {
  border-bottom-color: var(--brand);
  color: var(--fg);
  font-weight: 600;
}

.skonto-manager-tab-input:focus-visible + .skonto-manager-tab-label {
  border-radius: var(--r-sm);
  box-shadow: var(--focus-ring);
}

.skonto-manager-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--fg-muted);
  font: var(--text-caption);
  font-variant-numeric: tabular-nums;
}

.skonto-manager-panels {
  padding-top: var(--space-3);
}

.skonto-manager-panel {
  display: none;
}

.skonto-manager-tab-controls:has(#skonto-manager-tab-ready:checked) + .skonto-manager-panels #skonto-manager-ready-panel,
.skonto-manager-tab-controls:has(#skonto-manager-tab-pending:checked) + .skonto-manager-panels #skonto-manager-pending-panel {
  display: block;
}

.skonto-manager-panel > .skonto-horizon-list {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

.skonto-manager-panel-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.skonto-manager-panel-intro p {
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-caption);
}

.skonto-manager-sort {
  flex: 0 0 auto;
  color: var(--fg-muted);
  font: var(--text-caption);
}

.skonto-pending-callout {
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--fg-muted);
  font: var(--text-caption);
}

.skonto-pending-callout strong {
  color: var(--fg);
}

.skonto-pending-table-scroll {
  margin-top: 0;
  overflow-x: auto;
}

.skonto-pending-table {
  min-width: 850px;
}

.skonto-pending-table td {
  vertical-align: top;
}

.skonto-pending-invoice > span,
.skonto-pending-tier {
  display: block;
}

.skonto-pending-tier + .skonto-pending-tier {
  margin-top: var(--space-1);
}

.skonto-pending-partial {
  display: inline-block;
  margin-left: var(--space-1);
  padding: 1px var(--space-1);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  font: var(--text-caption);
}

.skonto-pending-progress {
  color: var(--fg-muted);
  white-space: nowrap;
}

.skonto-pending-review {
  white-space: nowrap;
}

.skonto-horizon-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) minmax(140px, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.skonto-horizon-custom {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  font: var(--text-caption);
  text-align: left;
}

.skonto-horizon-custom.is-active {
  border-color: var(--border-strong);
  background: var(--bg-muted);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.skonto-horizon-custom-header {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: 2px;
}

.skonto-horizon-custom-input {
  flex: 1 1 auto;
  min-width: 3ch;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px var(--space-1);
  font: var(--text-body-strong);
  text-align: right;
}

.skonto-horizon-custom-suffix {
  flex: 0 0 auto;
  color: var(--fg-muted);
  font: var(--text-caption);
  white-space: nowrap;
}

.skonto-horizon {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  cursor: pointer;
  font: var(--text-caption);
  text-align: left;
}

.skonto-horizon:not(:disabled):hover,
.skonto-horizon:not(:disabled):focus-visible {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.skonto-horizon:focus-visible {
  outline: 2px solid var(--border-strong);
  outline-offset: 2px;
}

.skonto-horizon.is-active {
  border-color: var(--border-strong);
  background: var(--bg-muted);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.skonto-horizon:disabled {
  cursor: default;
}

.skonto-horizon-label {
  color: var(--fg);
  font: var(--text-body-strong);
}

.skonto-horizon-count,
.skonto-horizon-money {
  white-space: nowrap;
}

#skonto-opportunity-region:empty {
  display: none;
}

.skonto-opportunity-dialog {
  width: min(1100px, calc(100vw - var(--space-6)));
  max-width: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.skonto-opportunity-dialog::backdrop {
  background: rgba(28, 24, 19, 0.45);
}

.skonto-opportunity-dialog-frame {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Fixed, not max — a shorter result set must not shrink the dialog around
     it. `.skonto-opportunity-dialog-body`'s own overflow-y:auto is what
     makes a longer table scroll instead of growing the frame. */
  height: min(860px, calc(100vh - var(--space-6)));
}

.skonto-opportunity-dialog-header {
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.skonto-opportunity-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
}

.skonto-opportunity-dialog-body > .page-notice {
  width: auto;
  max-width: none;
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  text-align: left;
}

.skonto-opportunity-preview {
  min-height: 0;
}

.skonto-opportunity-table-scroll {
  margin-top: var(--space-3);
  overflow-x: auto;
}

.skonto-opportunity-table {
  min-width: 720px;
}

.skonto-opportunity-table td {
  vertical-align: top;
}

.skonto-opportunity-invoice > span,
.skonto-opportunity-warning {
  display: block;
}

.skonto-opportunity-row-item {
  display: none;
}

.skonto-opportunity-warning {
  max-width: 250px;
  margin-top: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-caption);
  white-space: normal;
}

.skonto-opportunity-transfer,
.skonto-opportunity-current-saving {
  color: var(--fg-muted);
}

.skonto-opportunity-totals {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  color: var(--fg-muted);
  font: var(--text-sm);
}

.skonto-opportunity-selected-count {
  color: var(--fg);
  font-weight: 600;
}

.skonto-opportunity-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.skonto-opportunity-dialog-footer .skonto-opportunity-totals {
  flex: 1;
}

.skonto-opportunity-pending-footer {
  display: none;
  flex: 1;
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-caption);
}

.skonto-opportunity-dialog-body:has(#skonto-manager-tab-pending:checked) + .skonto-opportunity-dialog-footer .skonto-opportunity-totals,
.skonto-opportunity-dialog-body:has(#skonto-manager-tab-pending:checked) + .skonto-opportunity-dialog-footer .skonto-opportunity-create {
  display: none;
}

.skonto-opportunity-dialog-body:has(#skonto-manager-tab-pending:checked) + .skonto-opportunity-dialog-footer .skonto-opportunity-pending-footer {
  display: block;
}

.skonto-opportunity-create {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 700px) {
  .skonto-horizon-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: var(--space-1);
  }

  .skonto-horizon,
  .skonto-horizon-custom {
    flex: 0 0 150px;
  }

  .skonto-opportunity-dialog {
    width: calc(100vw - (2 * var(--space-2)));
    height: calc(100vh - (2 * var(--space-2)));
  }

  .skonto-opportunity-dialog-frame {
    height: calc(100vh - (2 * var(--space-2)));
  }

  .skonto-opportunity-dialog-header,
  .skonto-opportunity-dialog-body,
  .skonto-opportunity-dialog-footer {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .skonto-opportunity-table-scroll {
    overflow: auto;
  }

  .skonto-manager-panel-intro {
    flex-direction: column;
    gap: var(--space-1);
  }

  .skonto-manager-sort {
    flex: 0 1 auto;
    white-space: normal;
  }

  .skonto-opportunity-dialog-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .skonto-opportunity-pending-footer {
    flex: none;
  }

  .skonto-opportunity-create .btn {
    width: 100%;
  }
}

/* The stable wrapper every payment-select checkbox renders inside, whether or
   not it is currently blocked — `orchaPaymentSelection` toggles
   `.payment-select-blocked` and `data-tooltip` on this same element as the
   user's selection changes, rather than replacing the checkbox itself. */
.payment-select-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  /* Room to hover: the box itself is the trigger, and it is small. */
  padding: 4px;
  margin: -4px;
}

/* Why an invoice cannot join a payment run. The native `title` answers after a
   second of hovering a control that already looks inert; this answers at once,
   and beside the row rather than under it, so a row near the bottom of the
   scroll area is not clipped. */

/* A disabled control swallows the pointer without ever hovering, so the hit has
   to reach the wrapper that carries the reason. */
.payment-select-blocked input:disabled {
  pointer-events: none;
}

.payment-select-blocked:focus-visible {
  outline: none;
  border-radius: var(--r-sm);
  box-shadow: var(--focus-ring);
}

.payment-select-blocked::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  z-index: 20;
  width: max-content;
  max-width: 280px;
  padding: 7px 10px;
  transform: translateY(-50%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--fg);
  font: var(--text-sm);
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease;
}

.payment-select-blocked:hover::after,
.payment-select-blocked:focus-within::after {
  opacity: 1;
}

/* AP list selection: ticking a row swaps the column headers for this row, so
   the actions sit on the table they act on and nothing above it moves. */
.table .ap-selection-row th {
  padding-top: 6px;
  padding-bottom: 6px;
  background: var(--brand-tint);
  border-bottom-color: var(--brand-border);
  color: var(--fg);
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* The selection cell spans the whole table, which scrolls sideways on narrow
   screens; `orchaFitSelectionBar` caps the bar at the visible width so its
   actions wrap instead of running under the column picker. */
.ap-selection-bar {
  position: sticky;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 32px;
}

.ap-selection-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.ap-selection-count {
  font-weight: 600;
}

.ap-selection-total {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.ap-selection-actions,
.ap-selection-confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ap-selection-actions[hidden],
.ap-selection-confirm[hidden],
.ap-selection-confirm .btn[hidden] {
  display: none;
}

/* Selected invoices whose stated account their payment file cannot pay. */
.ap-batch-payee-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--warning-strong);
  font: var(--text-sm);
  line-height: 1;
  white-space: nowrap;
}

.ap-batch-payee-note[hidden] {
  display: none;
}

/* The summary aligns its texts by baseline; this note's own baseline is its
   icon's, so it is centred on the line instead. */
.ap-selection-summary .ap-batch-payee-note {
  align-self: center;
}

/* A bare iconify-icon sits on the text baseline; as a flex box of its own it
   centres on the label instead. */
.ap-batch-payee-note iconify-icon {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
}

.ap-batch-payee-note iconify-icon svg {
  display: block;
}

/* The gap reads as the space between the count and the sentence. */
.ap-batch-payee-note-label {
  margin-left: -2px;
}

/* Count only, when the sentence would wrap the selection bar; the tooltip and
   the accessible label still carry it. */
.ap-batch-payee-note.is-compact .ap-batch-payee-note-label {
  display: none;
}

.ap-selection-question {
  font-weight: 600;
}

/* Every bulk action carries the same weight; the count says how many of the
   ticked invoices it acts on. */
.btn.ap-bulk-action {
  position: relative;
  background: var(--surface);
}

.btn.ap-bulk-action:hover {
  background: var(--bg-muted);
}

.ap-bulk-action iconify-icon {
  font-size: 15px;
  color: var(--fg-muted);
}

.ap-bulk-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--brand-tint);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The button's contents fade, not the button: the shared disabled-button
   opacity and greyscale would also fade the tooltip its ::after draws. */
.btn.ap-bulk-action[aria-disabled="true"] {
  opacity: 1;
  filter: none;
  border-color: var(--border-subtle);
  cursor: not-allowed;
}

.btn.ap-bulk-action[aria-disabled="true"] > * {
  opacity: 0.5;
  filter: grayscale(1);
}

.btn.ap-bulk-action[aria-disabled="true"]:hover {
  background: var(--surface);
}

.btn.ap-bulk-action[aria-disabled="true"] .ap-bulk-count {
  background: var(--bg-muted);
  color: var(--fg-muted);
}

/* Why an action is off, or what it leaves out, answered at once on hover. */
.ap-bulk-action[data-tooltip]::after,
.ap-row-action[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  z-index: 20;
  display: none;
  width: max-content;
  max-width: 260px;
  padding: 7px 10px;
  transform: translateX(-50%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--fg);
  font: var(--text-sm);
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.ap-bulk-action[data-tooltip]::after {
  position: fixed;
  top: var(--ap-bulk-tooltip-top, 0);
  left: var(--ap-bulk-tooltip-left, 12px);
  width: var(--ap-bulk-tooltip-width, 260px);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  transform: none;
}

.ap-row-action[data-tooltip]::after {
  bottom: calc(100% + 6px);
}

.ap-bulk-action[data-tooltip]:hover::after,
.ap-bulk-action[data-tooltip]:focus-visible::after,
.ap-row-action[data-tooltip]:hover::after,
.ap-row-action[data-tooltip]:focus-visible::after {
  display: block;
}

/* Row actions: the invoice's own actions take the status's place on hover or
   keyboard focus, and step aside while any row is ticked. Keyboard focus is
   `:focus-visible`, not `:focus-within`: a mouse click leaves the row's
   checkbox focused, which would keep the actions showing after the pointer
   has left. */
.ap-status-cell.has-row-actions {
  position: relative;
}

.ap-row-actions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-inline: inherit;
  opacity: 0;
  pointer-events: none;
}

.table tbody tr:hover .ap-status-cell.has-row-actions .ap-row-actions,
.table tbody tr:has(:focus-visible) .ap-status-cell.has-row-actions .ap-row-actions {
  opacity: 1;
  pointer-events: auto;
}

.table tbody tr:hover .ap-status-cell.has-row-actions .ap-status-content,
.table tbody tr:has(:focus-visible) .ap-status-cell.has-row-actions .ap-status-content {
  visibility: hidden;
}

#payment-run-selection.has-selection .ap-row-actions {
  display: none;
}

#payment-run-selection.has-selection tbody tr .ap-status-cell .ap-status-content {
  visibility: visible;
}

.ap-row-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}

.ap-row-action:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--fg);
}

.ap-row-action:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.ap-row-action iconify-icon {
  font-size: 16px;
}

.accounting-clearings .ap-selection-row th {
  padding-top: 4px;
  padding-bottom: 4px;
}

.accounting-clearings td.payment-select-cell {
  overflow: visible;
}

.clearing-export-bulk-count {
  font-size: 13px;
  color: var(--fg-muted);
}

.clearing-export-link {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--fg-muted);
  text-decoration: none;
}

#document-list td[data-ap-column="export"] .clearing-export-link {
  max-width: 260px;
}
/* The AP cell leads with the export's time, set like the row's other dates;
   the monospace filename style belongs to the Accounting clearings list. */
#document-list td[data-ap-column="export"] .clearing-export-filename {
  font-family: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.clearing-export-link iconify-icon {
  flex: 0 0 auto;
  font-size: 14px;
}

/* Why an invoice cannot be exported yet, answered at once on hover or
   keyboard focus. Export is the table's last column, so the reason opens
   beside the chip towards the row: never past the table's right edge, and
   never above the first row into the sticky header. */
.ap-export-state {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: default;
}

.ap-export-state iconify-icon {
  font-size: 12px;
}

.ap-export-state.is-blocked {
  border-color: var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.ap-export-state::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 50%;
  right: calc(100% + 8px);
  z-index: 20;
  display: none;
  width: max-content;
  max-width: 280px;
  transform: translateY(-50%);
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--fg);
  font: var(--text-sm);
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.ap-export-state:hover::after,
.ap-export-state:focus-visible::after {
  display: block;
}

.clearing-export-filename {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}

.payment-amount-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--fg-subtle);
}

.payment-amount-value {
  font-weight: 600;
  color: var(--fg-muted);
}

.payment-amount-label {
  margin-left: 3px;
}

.payment-amount-separator {
  color: var(--fg-faint);
}

.payment-amount-run {
  color: var(--link);
  text-decoration: none;
}


#document-list .ap-payment-cell {
  white-space: normal;
}

#ap-column-preferences:not(.ap-hide-payment) #document-list .skonto-gutter:empty {
  display: none !important;
}

#document-list .ap-payment-cell .payment-amount-chips {
  justify-content: flex-start;
  margin-top: 0;
  min-width: 128px;
  max-width: 240px;
  font-size: 12px;
}

#document-list .ap-payment-cell .payment-amount-chip {
  white-space: normal;
}

#document-list .ap-payment-cell .ap-payment-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

#document-list .ap-payment-cell .ap-payment-method-needed {
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
  white-space: nowrap;
}


/* A refused action, as its own page — a bounded card in the middle of the
   content column rather than a bare message flush against the corner. Mirrors
   `.accounting-error`, the other full-page refusal in the app. */
.page-notice {
  max-width: 560px;
  margin: var(--space-6) auto;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.page-notice > iconify-icon {
  font-size: 26px;
  color: var(--fg-subtle);
}

.page-notice-error {
  border-color: var(--danger-border);
}

.page-notice-error > iconify-icon {
  color: var(--danger);
}

.page-notice-title {
  /* Sans, not the serif `--text-h2`: the app's headings are all sans. */
  margin: 10px 0 6px;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
}

.page-notice-message {
  margin: 0 0 var(--space-4);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted);
}

/* The invoice detail's payment-method card
   -------------------------------------------------------------------------- */

.payment-method-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 24px;
}

.payment-method-summary .field-group,
.payment-method-explanation .field-group {
  margin-bottom: 0;
}

.payment-method-explanation {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bg-muted);
}

.payment-method-explanation .field-value {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The boxed "Payment method" value doubles as a <details> toggle: the whole
   row is the summary, the override form is its (initially closed) content —
   a decided invoice reads as quietly as Bank Details until the pencil is
   clicked, so nothing implies a decision is still needed by default. */
.payment-method-value > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

/* Payment-method summaries are compact value pills. The shared boxed-field
   rule fills a field's row by default, but this summary only needs the space
   its label, provenance badge, and edit affordance use. Keep the editor below
   it free to use the card width. */
.payment-method-summary .field-value-row-boxed,
.payment-status-correction > summary.field-value-row-boxed {
  width: fit-content;
  max-width: 100%;
}

/* The manual confirmation can include both a long account name and an actor.
   Keep the complete audit detail readable inside the invoice card. */
.reported-payment-status .field-value-row-boxed .field-value {
  min-width: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.reported-payment-status {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.reported-payment-status > .alert-danger {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  background: var(--danger-tint);
  color: var(--danger-strong);
  font-size: 13px;
  line-height: 1.5;
}

.reported-payment-status .payment-status-correction > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  margin-bottom: 0;
}
.reported-payment-status .payment-status-correction > summary:hover {
  background: var(--bg-muted);
}

.reported-payment-status .payment-status-correction-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--bg-muted);
}

.reported-payment-status .payment-status-correction-body p {
  margin: 0 0 12px;
}

.reported-payment-status .payment-method-override {
  display: grid;
  gap: 12px;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.reported-payment-status .payment-method-override textarea {
  margin-bottom: 0;
}

.reported-payment-status .payment-method-override .form-actions {
  padding-top: 4px;
}

.payment-method-value > summary::-webkit-details-marker {
  display: none;
}

.payment-method-value[open] > summary {
  margin-bottom: 12px;
}

.payment-method-value > .payment-method-override {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.payment-method-edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  border-radius: var(--r-md);
  color: var(--fg-muted);
  flex-shrink: 0;
}

.payment-method-value > summary:hover .payment-method-edit-icon {
  background: var(--bg-muted);
  color: var(--fg);
}

.payment-method-edit-icon iconify-icon {
  font-size: 14px;
}

/* Payment status that can no longer be corrected: the pencil stays in place,
   greyed out, and its tooltip says why. */
.payment-status-locked {
  width: fit-content;
  max-width: 100%;
}

.payment-status-edit-blocked {
  cursor: not-allowed;
  color: var(--fg-subtle);
}

.payment-status-edit-blocked iconify-icon,
.payment-status-edit-blocked:hover iconify-icon {
  opacity: 0.45;
}

.payment-status-edit-blocked:focus-visible {
  outline: 2px solid var(--border-strong);
  outline-offset: 1px;
}

.payment-status-edit-blocked:focus-visible .info-tooltip-content {
  display: block;
}

.badge-method-auto,
.badge-method-human {
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-method-auto {
  background: var(--info-tint);
  color: var(--azure-700);
  border: 1px solid var(--info-border);
}

.badge-method-human {
  background: var(--success-tint);
  color: var(--success-strong);
  border: 1px solid var(--success-border);
}

.payment-method-undecided {
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
}

.payment-method-undecided-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg);
}

.payment-method-undecided-title iconify-icon {
  flex-shrink: 0;
  font-size: 15px;
  color: var(--warning);
}

.payment-method-undecided .payment-method-override {
  margin-top: 12px;
  padding-top: 0;
  border-top: none;
}

.payment-method-override {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bg-muted);
}
.payment-method-override-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

/* `.form-group` is the settings-page form rhythm — too tall for a dense detail
   card, so the controls are tightened and the labels become the same uppercase
   micro-label the facts above them use. */
.payment-method-override .form-group {
  margin-bottom: 0;
}

.payment-method-override .form-group label {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}

.payment-method-override .form-group textarea,
.payment-method-override .form-group select,
.payment-method-override .form-group input[type="text"] {
  padding: 6px 9px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
}

.payment-method-override textarea {
  resize: vertical;
}

.payment-method-override .form-actions {
  justify-content: flex-end;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.payment-method-override .form-actions .btn {
  white-space: nowrap;
}

/* Payment runs (AP module). List and detail share one white full-bleed surface,
   one toolbar row (module tabs + command bar + filters/identity) and the AP
   list's sans typography — mono is kept for the identifiers you compare or
   copy (IBAN, end-to-end id), not for amounts or dates. */
.documents-page.payment-runs-page,
.documents-page.payment-run-page {
  gap: 0;
  min-height: calc(100vh - 26px);
  background: var(--surface);
}

.payment-runs-page > .page-header,
.payment-run-page > .page-header {
  flex-wrap: nowrap;
  gap: var(--space-2);
}

.payment-runs-page > .page-header .page-header-left,
.payment-run-page > .page-header .page-header-left {
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}

.payment-runs-page .search-container,
.payment-run-page .search-container {
  flex: 0 0 auto;
  min-width: 0;
}

/* The run a detail page is about. Detail pages carry no headline, so the number
   and its status ride in the toolbar. */
.payment-run-identity {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.payment-run-identity-number {
  font: var(--text-body-strong);
  color: var(--fg);
  white-space: nowrap;
}

.payment-run-status {
  border: 1px solid transparent;
  white-space: nowrap;
}

.payment-run-status-open {
  background: var(--warning-tint);
  border-color: var(--warning-border);
  color: var(--warning-strong);
}

.payment-run-status-generated {
  background: var(--info-tint);
  border-color: var(--info-border);
  color: var(--brand-pressed);
}

.payment-run-status-partly-transferred {
  background: var(--warning-tint);
  border-color: var(--warning-border);
  color: var(--warning-strong);
}

.payment-run-status-transferred,
.payment-run-status-completed {
  background: var(--success-tint);
  border-color: var(--success-border);
  color: var(--success-strong);
}

.payment-run-status-abandoned {
  background: var(--bg-muted);
  border-color: var(--border);
  color: var(--fg-muted);
}

.payment-run-status-reversed {
  background: var(--danger-tint);
  border-color: var(--danger-border);
  color: var(--danger-strong);
}

/* A capability statement about export, not a fault in the run: quiet secondary
   text under the status badge rather than another coloured pill competing with
   it. */
.payment-run-export-unavailable {
  display: block;
  margin-top: var(--space-1);
  font: var(--text-caption);
  color: var(--fg-muted);
  white-space: nowrap;
}

/* Detail body: the scrolling white surface the cards sit on, matching the
   banking/accounting detail pages' 14px gutter. */
.payment-run-body {
  flex: 1;
  padding: var(--space-4) 14px var(--space-6);
  overflow-y: auto;
  background: var(--surface);
}

.payment-run-body > .form-error {
  margin-bottom: var(--space-3);
}

.payment-run-section .section-header {
  justify-content: flex-start;
}

.payment-run-section-count {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: var(--text-caption);
}

.payment-run-section-hint {
  margin: 0 0 var(--space-3);
  color: var(--fg-muted);
  font: var(--text-sm);
}

.payment-run-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 11px 16px;
}

.payment-run-fields .field-group {
  margin-bottom: 0;
}

/* Editable groups sit side by side instead of stacking one full-width control
   per row — a payment draft is a form, not a column of paragraphs. */
.payment-run-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3) var(--space-4);
  max-width: 900px;
}

.payment-run-form-grid .form-group,
.payment-run-checkbox-group {
  margin-bottom: 0;
}

/* A date needs a date's width; the account and the format carry names and
   IBANs, so they take what is left — up to a line length still readable. */
.payment-run-source-grid {
  grid-template-columns: minmax(128px, 168px) minmax(280px, 1.5fr) minmax(220px, 1fr);
  max-width: 1120px;
}

/* The calendar sits inside the date field as an icon, not as a second box —
   as in the invoice's cash-discount and payment-schedule dates. */
.payment-run-date-field {
  position: relative;
  display: block;
  max-width: 168px;
}

.payment-run-date-field [data-european-date-display] {
  box-sizing: border-box;
  width: 100%;
  padding-right: 40px;
}

.payment-run-date-field .european-date-picker {
  position: absolute;
  top: 50%;
  right: 6px;
  min-width: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  transform: translateY(-50%);
}

.payment-run-date-field .european-date-picker:hover {
  color: var(--fg);
}

/* The payment run's dropdowns draw the app's own chevron at a fixed inset,
   as the banking forms do, instead of the browser's edge-hugging arrow. */
.payment-run-page select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* The payee column is narrow and its IBAN must stay whole: a tighter inset. */
.payment-run-page .payment-run-payee-cell select {
  padding-right: 24px;
  background-position: right 8px center;
}

@media (max-width: 900px) {
  .payment-run-source-grid {
    grid-template-columns: 1fr;
  }
}

.payment-run-form-grid + .payment-run-checkbox-group,
.payment-run-items + .payment-run-form-grid,
.payment-run-section .form-group + .payment-run-totals {
  margin-top: var(--space-4);
}

.payment-run-field input,
.payment-run-field textarea {
  max-width: 520px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}

.payment-run-field input {
  height: 32px;
  padding: 0 10px;
}

.payment-run-field textarea {
  padding: 6px 10px;
}

.payment-run-field input:focus,
.payment-run-field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* The blocker for the execution date: a field error on the grid itself, so its
   sentence runs the width of the source row instead of the date's column. */
.payment-run-form-grid > .payment-run-hint-warning {
  grid-column: 1 / -1;
  width: fit-content;
  margin-top: 0;
  align-items: center;
}

.payment-run-source-grid:has(> .payment-run-hint-warning) #execution_date-display {
  border-color: var(--danger-border);
}

.payment-run-files a.btn:hover { text-decoration: none; }

/* A transfer that would reach the supplier without a reference: named above
   the draft and in the generation dialog, and marked on its own row. */
.payment-run-remittance-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font: var(--text-sm);
}

/* In the draft's sticky actions row and the dialog's footer the warning takes
   its own full-width line below the totals and buttons, so it never squeezes
   them. */
.payment-run-actions-row:has(> .payment-run-remittance-warning),
.payment-run-footer:has(> .payment-run-remittance-warning) {
  flex-wrap: wrap;
}

.payment-run-actions-row > .payment-run-remittance-warning,
.payment-run-footer > .payment-run-remittance-warning {
  flex: 1 0 100%;
  order: 1;
}

.payment-run-remittance-warning > iconify-icon {
  flex: none;
  margin-top: 2px;
}

/* The invoice number standing in for a payment reference the invoice does
   not state, marked as on the invoice page's Payment reference field. */
.payment-run-remittance-source {
  display: inline-flex;
  align-items: center;
}

.payment-run-remittance-source .payment-run-help {
  margin-left: 4px;
}

/* In the draft it takes its own line under the remittance field, and the
   field itself carries the invoice page's "filled in by Orcha" frame. */
.payment-run-remittance-cell .payment-run-remittance-source {
  display: flex;
  width: fit-content;
  margin-top: 4px;
}

.payment-run-remittance-cell input.payment-run-remittance-derived {
  border-color: var(--warning-border);
  background: color-mix(in srgb, var(--warning-tint) 40%, var(--white));
}

.payment-run-cell-wrap .payment-run-remittance-source {
  margin-top: 0;
  margin-left: var(--space-2);
}

.payment-run-remittance-cell input.payment-run-remittance-missing {
  border-color: var(--warning-border);
  background: var(--warning-tint);
}

.payment-run-settlement-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

/* Every invoice in the run as one table: an installment line each, then the
   line that says where the money goes. A card per invoice made a two-invoice
   draft taller than the screen. */
.payment-run-settlements tbody.payment-run-settlement {
  border-bottom: 1px solid var(--border);
}

.payment-run-settlements tbody.payment-run-settlement:last-child {
  border-bottom: none;
}

.payment-run-settlements td {
  border-bottom: none;
  padding-top: 8px;
  padding-bottom: 8px;
}

.payment-run-invoice-cell {
  display: table-cell;
  white-space: nowrap;
}

.payment-run-invoice-cell .payment-run-issuer {
  margin-left: var(--space-2);
}

.payment-run-settlement-detail td {
  padding-top: 0;
  padding-bottom: 10px;
}

.payment-run-settlement-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.payment-run-inline-field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-weight: 400;
}

.payment-run-inline-label {
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.payment-run-inline-field input,
.payment-run-inline-field select {
  width: auto;
  min-width: 180px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}

.payment-run-inline-checkbox {
  color: var(--fg-muted);
  font: var(--text-sm);
}

.payment-run-settlement-arithmetic {
  margin: var(--space-2) 0 0;
  color: var(--fg-subtle);
  font: var(--text-caption);
  font-variant-numeric: tabular-nums;
}

.payment-run-settlements {
  table-layout: fixed;
}

/* Percentages only, and they add to 100: mixing a fixed action column into a
   fixed table layout pushed the last column past the edge. The payee column is
   the widest of the text columns: its select must show a whole IBAN at the
   narrowest desktop width. */
.payment-run-col-invoice    { width: 18%; }
.payment-run-col-remittance { width: 17%; }
.payment-run-col-payee      { width: 28%; }
.payment-run-col-money      { width: 28%; }
.payment-run-col-action     { width: 9%; }

/* On narrower screens the payee column takes width from the money column, so
   a whole IBAN still fits beside its dropdown chevron. */
@media (max-width: 1400px) {
  .payment-run-col-payee { width: 24%; }
  .payment-run-col-money { width: 26%; }
}

/* Every figure for one invoice in one column, label left and amount right, so
   the arithmetic reads downwards instead of across seven columns. */
.payment-run-money-lines {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px var(--space-3);
  margin: 0;
  font: var(--text-sm);
}

.payment-run-money-lines dt {
  color: var(--fg-muted);
  white-space: nowrap;
}

.payment-run-money-lines dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.payment-run-money .payment-run-amount-input {
  width: 100%;
  max-width: 120px;
}

.payment-run-money .payment-run-inline-checkbox {
  margin-top: var(--space-2);
  align-items: flex-start;
  font: var(--text-caption);
}

.payment-run-remittance-cell input,
.payment-run-payee-cell input[type="text"],
.payment-run-payee-cell select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}

/* Selector carries `.table td`'s specificity: a middle-aligned cell beside a
   column of five lines floats away from the invoice it belongs to. */
.payment-run-settlements td {
  vertical-align: top;
}

.payment-run-settlement-error td {
  background: var(--danger-tint);
}

.payment-run-settlement-error select[aria-invalid="true"] {
  border-color: var(--danger);
}

/* An invoice whose chosen payee account this run's rail cannot pay: attention
   rather than failure, since removing it or choosing another account clears it. */
.payment-run-settlement-warning td {
  background: var(--warning-tint);
}

/* The full warning tone: the lighter warning border would read fainter than an
   ordinary field's on the tinted row. */
.payment-run-settlement-warning select[aria-invalid="true"] {
  border-color: var(--warning);
}

.payment-run-settlement-warning option.is-unpayable {
  color: var(--warning-strong);
}

/* That invoice's own line, across the row from the Invoice column, inside the
   same tbody so the group border stays one. */
.payment-run-settlements tr.payment-run-settlement-note td {
  padding-top: 0;
  padding-bottom: var(--space-3);
}

.payment-run-settlement-note .form-warning {
  margin-top: 0;
}

/* The run-level summaries above Payment source: which payees the rail cannot
   reach, why, and the one action that clears them; what a change to the account's
   payment files did; and which suppliers still lack what a file needs. */
.payment-run-payee-banner,
.payment-run-draft-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.payment-run-payee-banner > iconify-icon,
.payment-run-draft-banner > iconify-icon {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 18px;
}

.payment-run-left-out-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--info-border);
  border-radius: var(--r-lg);
  background: var(--info-tint);
}

.payment-run-left-out-notice p {
  margin: 0;
}

.payment-run-left-out-notice > iconify-icon {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 18px;
}

.payment-run-currency-choice-lead,
.payment-run-currency-choice-note {
  margin: 0 0 var(--space-3);
  color: var(--text-secondary);
}

.payment-run-currency-options {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.payment-run-currency-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  cursor: pointer;
}

.payment-run-currency-option:has(input:checked) {
  border-color: var(--border-strong);
  background: var(--info-tint);
}

.payment-run-currency-option.is-unavailable {
  cursor: not-allowed;
  opacity: 0.6;
}

.payment-run-currency-option-text {
  display: grid;
  gap: 2px;
}

.payment-run-currency-option-detail {
  color: var(--text-secondary);
  font-size: 0.875em;
}

.payment-run-currency-choice-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.payment-run-payee-banner-text {
  flex: 1;
  min-width: 0;
  font: var(--text-body);
}

.payment-run-payee-banner-title {
  display: block;
  margin-bottom: 2px;
  font: var(--text-body-strong);
}

.payment-run-payee-banner-text p {
  margin: 0;
}

.payment-run-payee-banner-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
}

.payment-run-payee-cell .form-error {
  align-items: flex-start;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The account, then the confirmation that would add one — stacked, because a
   select and a button side by side leave neither room to be read. */
.payment-run-payee-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}

.payment-run-payee-cell .payment-run-authorize {
  width: 100%;
  justify-content: center;
  /* An offer names its account, which may not fit a narrow column. */
  white-space: normal;
  text-align: center;
}

/* The account this draft pays is not the one the invoice states. */
.payment-run-stated-differs {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  color: var(--warning-strong);
  font: var(--text-caption);
}
.payment-run-stated-account {
  color: var(--fg);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* One compact control per payee cell; the forms it holds are the app's usual
   inputs, and its marker is the app's chevron rather than the browser's. */
.payment-run-add-account > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--brand);
  cursor: pointer;
  font: var(--text-caption);
  list-style: none;
}

.payment-run-add-account > summary::-webkit-details-marker {
  display: none;
}

.payment-run-add-account-chevron {
  font-size: 14px;
  transition: transform 0.15s ease;
}

.payment-run-add-account[open] > summary .payment-run-add-account-chevron {
  transform: rotate(180deg);
}

.payment-run-add-account-forms {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.payment-run-add-account-forms .payment-run-add-iban-controls {
  margin-top: 0;
}

.payment-run-add-account-kind {
  color: var(--fg-muted);
  font: 400 12px/1.4 var(--font-sans);
}

.payment-run-add-iban-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.payment-run-add-iban-controls .payment-run-manual-iban,
.payment-run-add-iban-controls .payment-run-add-iban {
  width: 100%;
}

.payment-run-add-iban-controls .payment-run-manual-iban {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.payment-run-add-iban-controls .payment-run-add-iban {
  height: 32px;
  padding: 0 13px;
  font-size: 13px;
  justify-content: center;
}

/* A question mark that answers itself on hover, for a choice whose options are
   two version numbers. */
.payment-run-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: help;
  vertical-align: middle;
}

.payment-run-help:hover {
  border-color: var(--brand);
  color: var(--brand);
}


.payment-run-invoice-cell .payment-run-issuer,
.payment-run-installment-count {
  display: block;
  margin: 2px 0 0;
  color: var(--fg-muted);
  font: var(--text-caption);
}

.payment-run-invoice-cell .payment-run-issuer {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Only the invoice column may trim: an amount or a button that ellipsises is
   a defect, not a fit. */
.payment-run-settlements .payment-run-invoice-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Every tier this invoice offers, on one line: the earned one carries the
   amount above it, the passed ones say what an earlier date was worth. */
.payment-run-tier {
  display: block;
  color: var(--fg-muted);
  font: 400 12px/1.4 var(--font-sans);
}

.payment-run-tier-earned {
  color: var(--fg-muted);
}

/* Controls of a run page are 32px with a 1px border, as the lists' are: the small
   buttons in its rows and the way back in its header too. */
.payment-run-page .btn.btn-sm,
.payment-run-page .payment-run-back {
  height: 32px;
  padding: 0 13px;
  font-size: 13px;
  justify-content: center;
}

.payment-run-tier-passed {
  text-decoration: line-through;
}

.payment-run-payee-field {
  flex-wrap: wrap;
}

.payment-run-payee-field .payment-run-authorize {
  margin: 0;
  white-space: nowrap;
}

.payment-run-invoice-number {
  font-weight: 600;
}

.payment-run-issuer {
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 400;
}

/* Machine values read in sans like the AP/AR lists; only the amount columns
   keep the right-aligned tabular treatment a money column needs. `td` only —
   a `th.cell-amount` column label is still a label, not a value, and keeps
   the ordinary `.table th` treatment every other header on the page gets. */
.payment-run-page td.cell-amount,
.payment-runs-page td.cell-amount,
.payment-run-number {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
}

.payment-run-page td.cell-amount,
.payment-runs-page td.cell-amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.payment-run-page th.cell-amount,
.payment-runs-page th.cell-amount {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

.payment-run-number {
  font-weight: 500;
}

.payment-runs-table .cell-truncate.payment-runs-cell-created-by { max-width: 180px; }
.payment-runs-table .cell-truncate.payment-runs-cell-payment-account { max-width: 220px; }
.payment-runs-table .cell-truncate.payment-runs-cell-bank-match { max-width: 320px; }

.payment-run-instructions .cell-truncate.payment-run-cell-creditor { max-width: 240px; }
.payment-run-dialog .payment-run-instructions .cell-truncate.payment-run-cell-invoice { max-width: 160px; }
.section-body:has(> .payment-run-instructions) {
  overflow-x: auto;
}
.payment-run-instructions td.payment-run-cell-wrap {
  min-width: 10rem;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.payment-run-file .section-header { gap: var(--space-2); }
.payment-run-download-all-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}
.payment-run-download-all-group .form-hint { margin: 0; }
.payment-run-file-name { display: flex; align-items: flex-start; gap: var(--space-2); }
.payment-run-file-name iconify-icon { color: var(--brand); margin-top: var(--space-1); }
.payment-run-file-name > span { display: flex; flex-direction: column; align-items: flex-start; }
.payment-run-file-filename {
  max-width: 24rem;
  color: var(--fg-muted);
  font: var(--text-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}
/* The files table fits its card: fixed column widths, the file column takes what is
   left, and a file's name, format and upload path wrap so the actions stay on the
   page. Below the minimum width the card scrolls instead of squeezing the file. */
.payment-run-files { table-layout: fixed; min-width: 56rem; }
.payment-run-files th { white-space: nowrap; }
.payment-run-files td { white-space: normal; overflow-wrap: anywhere; }
.payment-run-files .payment-run-files-col-format { width: 9rem; }
.payment-run-files .payment-run-files-col-count { width: 6.5rem; }
.payment-run-files .payment-run-files-col-total { width: 9.5rem; }
.payment-run-files .payment-run-files-col-upload { width: 10rem; }
/* The total is checked against the bank's portal: a figure never breaks mid-number. */
.payment-run-files td.cell-amount { white-space: nowrap; overflow-wrap: normal; }
.payment-run-files .payment-run-row-action { width: 12rem; }
.payment-run-instructions td.payment-run-cell-file { min-width: 6rem; white-space: normal; }
.payment-run-file-confirmed-pill { margin-top: var(--space-1); }
.payment-run-file-audit { margin: var(--space-1) 0 0; white-space: normal; }

/* A file's row carries its own actions: Download, and once the file is in the bank,
   Confirm transferred with its optional reason one click away. */
.payment-run-files .btn {
  height: 32px;
  padding: 0 13px;
  font-size: 13px;
  justify-content: center;
}
.payment-run-file-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}
/* Confirm sits under Download inside the cell; the reason opens downward beneath it. */
.payment-run-confirm-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
  margin: 0;
}
.payment-run-confirm-reason { width: 100%; }
.payment-run-file-unconfirmable { max-width: 100%; margin: 0; white-space: normal; text-align: left; }
.payment-run-confirm-reason > summary {
  color: var(--brand);
  cursor: pointer;
  font: var(--text-caption);
  list-style: none;
}
.payment-run-confirm-reason > summary::-webkit-details-marker { display: none; }
.payment-run-confirm-reason-popover {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  margin-top: var(--space-1);
  text-align: left;
  white-space: normal;
}
.payment-run-confirm-reason-popover label {
  color: var(--fg-muted);
  font: 400 12px/1.4 var(--font-sans);
}
.payment-run-confirm-reason-popover input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}
.payment-run-confirm-reason-popover input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* An action a transfer row offers is a plain link, not a button of its own. */
.payment-run-row-link {
  color: var(--brand);
  font: var(--text-sm);
}
.payment-run-file-confirmed .payment-run-file-name iconify-icon { color: var(--fg-muted); }

/* A draft's invoices, one section per file they land in. */
#payment-run-settlement-groups > .payment-run-group { margin-top: var(--space-2); }
.payment-run-group .section-header { gap: var(--space-2); }
.payment-run-group-format {
  color: var(--fg-muted);
  font: var(--text-sm);
}
.payment-run-group-total {
  margin-left: auto;
  color: var(--fg);
  font: var(--text-body-strong);
  font-variant-numeric: tabular-nums;
}
/* A row that moved to another file, and the two totals that changed with it, are
   marked for a moment where it landed. */
.payment-run-settlement td,
.payment-run-group-total {
  transition: background-color 0.8s ease;
}
.payment-run-settlement.is-moved td { background: var(--brand-tint); }
.payment-run-group-total.is-moved {
  border-radius: var(--r-sm);
  background: var(--brand-tint);
}
.payment-run-group.is-unpayable .section-header iconify-icon { color: var(--warning); }
.payment-run-group.is-unpayable .payment-run-group-total {
  color: var(--warning-strong);
  font: var(--text-body);
}
.payment-run-route-hints { margin: var(--space-2) 0 0; }
.payment-run-route-hints strong { color: var(--fg-muted); }
.payment-run-files-count { color: var(--fg-muted); }

/* What an international file carries of its payee, and which route pays it. */
.payment-run-payee-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  color: var(--fg-muted);
  font: var(--text-caption);
}
.payment-run-payee-facts b { color: var(--fg); font-weight: 600; }
.payment-run-pay-by {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-muted);
  font: var(--text-caption);
}
.payment-run-pay-by label { flex: 0 0 auto; }
.payment-run-pay-by select { flex: 1; min-width: 0; }

/* An invoice in a file whose format still lacks something of its supplier: the same
   attention as a refused one, on a line of its own wording. */
.payment-run-settlement-incomplete td {
  background: var(--warning-tint);
}
.payment-run-missing-details { align-items: center; flex-wrap: wrap; }
.payment-run-missing-details > span:first-of-type { flex: 1 1 20rem; }
.payment-run-missing-inputs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.payment-run-missing-inputs input,
.payment-run-missing-inputs select {
  width: 11rem;
  height: 32px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}
.payment-run-missing-inputs input:disabled {
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.payment-run-missing-error { flex-basis: 100%; }

/* Town and country keep a visible label once something is typed or chosen. */
.payment-run-missing-inputs { align-items: flex-end; }
.payment-run-missing-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}
.payment-run-missing-field > span {
  color: var(--fg-muted);
  font: 400 12px/1.4 var(--font-sans);
}

/* The draft's source fields are the same 32px, 13px white controls as the AP and
   runs pages carry; the select takes the app's chevron (shared rule above). */
.payment-run-source .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.payment-run-source .form-group select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}

.payment-run-source .form-group input:focus,
.payment-run-source .form-group select:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.payment-run-source .form-group input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* A draft its reader may only view: the source card sits where the editable
   one does, and its controls read as disabled, like the payee account. */
.payment-run-readonly {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.payment-run-readonly .payment-run-source .form-group :is(input, select):disabled:not([type="checkbox"]):not([type="radio"]),
.payment-run-page .payment-run-remittance-cell input[readonly] {
  background-color: var(--bg-muted);
  color: var(--fg-muted);
}

.payment-run-source .form-group select,
.payment-run-page .payment-run-payee-controls > select {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* An account number read, not typed: the grouped monospace the settings cards use. */
.payment-run-iban {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* The draft form's first submit button, which Enter in a field presses: present for the
   browser, never seen or reached. */
.payment-run-default-submit {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}

.payment-run-draft-actions .btn {
  flex: none;
  height: 32px;
  padding: 0 13px;
  font-size: 13px;
  white-space: nowrap;
}

/* The generation dialog: one block per file. */
.payment-run-file-block { margin-bottom: var(--space-4); }
.payment-run-file-block-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.payment-run-file-block-head iconify-icon { color: var(--brand); }
.payment-run-file-block-head .form-hint { margin: 0; }
.section-body:has(> .payment-run-files) {
  overflow-x: auto;
}

.payment-run-items .payment-run-invoice-cell { max-width: 280px; }

.skonto-pending-invoice,
.skonto-opportunity-invoice {
  max-width: 280px;
}

.skonto-pending-invoice > .payment-run-invoice-number,
.skonto-opportunity-invoice > .payment-run-invoice-number {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-run-empty {
  padding: var(--space-7);
  color: var(--fg-subtle);
  text-align: center;
}

.payment-run-row-action {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.payment-run-amount-input {
  width: 116px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.payment-run-section .table tbody tr:hover {
  background: transparent;
}

.payment-run-section .table tbody tr:last-child td {
  border-bottom: none;
}

.payment-run-totals {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: end;
  gap: 2px var(--space-4);
  margin: 0;
  font: var(--text-sm);
}

.payment-run-totals dt {
  color: var(--fg-muted);
}

.payment-run-totals dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.payment-run-total-strong {
  font-weight: 600;
}

.payment-run-grand-total {
  font-size: 15px;
  font-weight: 600;
}

/* The draft's opening row: what it will transfer and what may be done with it,
   held at the top of the scroll so a long draft never hides its own total. */
.payment-run-actions-row {
  position: sticky;
  top: calc(-1 * var(--space-4));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: calc(-1 * var(--space-4)) -14px var(--space-4);
  padding: var(--space-3) 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* The dialog's closing row: what it will transfer, and what may be done with it. */
.payment-run-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.payment-run-footer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* The draft's buttons, and under them the one place Generate's reason goes, kept
   whether or not there is one so the header never changes height or shape. */
.payment-run-draft-actions {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

/* The discount a later date loses: two short lines between the total and the buttons,
   so the buttons stay on one line, and the same two under the invoice's amounts. */
.payment-run-skonto-date-summary,
.payment-run-skonto-date-warning {
  min-width: 0;
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-caption);
  white-space: normal;
  overflow-wrap: anywhere;
}

.payment-run-skonto-date-summary { flex: 1 1 0; }
.payment-run-skonto-date-warning { max-width: 100%; margin-top: var(--space-1); }

.payment-run-skonto-date-summary span,
.payment-run-skonto-date-warning span {
  display: block;
}

.payment-run-generate-reason {
  min-height: 18px;
  max-width: 32rem;
  margin: 0;
  text-align: right;
}

/* One line: what the run transfers, and in how many files. */
.payment-run-header-total {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  font-size: 15px;
  white-space: nowrap;
}

.payment-run-header-total-label {
  color: var(--fg-muted);
  font: var(--text-sm);
}

.payment-run-header-total strong {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* The banner's way to the field it asks for. */
.payment-run-goto {
  white-space: nowrap;
}

.payment-run-generate-disabled {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* The generation confirmation: a step over the draft it is about, not a page of
   its own, so the run stays legible behind it. */
.payment-run-dialog .modal-content-large {
  width: min(1200px, calc(100vw - 2 * var(--space-5)));
  max-width: none;
}

.payment-run-dialog .modal-close {
  text-decoration: none;
}

.payment-run-dialog .payment-run-footer {
  margin-top: var(--space-5);
}

.payment-run-dialog .payment-run-instructions {
  width: 100%;
  table-layout: fixed;
}

/* What the file will state is shown whole: a grouped IBAN wraps at its group
   spaces and an unbroken id wraps anywhere, so no value is cut off. */
.payment-run-dialog .payment-run-instructions td.cell-mono {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The totals close the Transfer column: right-aligned to its figures, which sit
   one table-cell padding in from the edge. */
.payment-run-dialog-footer {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
}

.payment-run-dialog-footer .payment-run-totals {
  justify-content: end;
  padding-right: 12px;
}

.payment-run-dialog-footer .payment-run-footer-actions {
  justify-content: flex-end;
}

/* The file the run just generated, fetched by the page it landed on. */
.payment-run-download {
  display: none;
}

/* Selector carries `.form-group label`'s specificity: without it that rule's
   `display: block` wins and the box detaches from the words it labels. */
.payment-run-checkbox,
.financial-account-checkbox,
.form-group label.payment-run-checkbox,
.form-group label.financial-account-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-weight: 400;
}

/* `.form-group input` is width:100% for text fields; a checkbox inheriting it
   stretches away from the words it belongs to. */
.payment-run-checkbox input[type="checkbox"],
.financial-account-checkbox input[type="checkbox"],
.financial-account-checkbox input[type="radio"] {
  flex: none;
  width: auto;
  margin: 0;
}

/* The one either/or on the form: how an account is identified. Kept on one row
   so the two answers read as alternatives rather than as separate questions. */
.financial-account-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 6px;
}

/* The confirmation that turns the IBAN an invoice states into an account this
   creditor may be paid at — beside the account list it is missing from. */
.payment-run-authorize {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.form-hint,
.settings-section-hint {
  font-size: 12px;
  color: var(--fg-subtle);
  margin: 4px 0 0;
}

/* Matches the 16px rhythm .connection-group uses between integration cards. */
.financial-account-card + .financial-account-card {
  margin-top: 16px;
}

/* Archived accounts sort to the end of the list (see `accounts-of`'s
   order-by) and read as de-emphasized without needing to be opened. */
.financial-account-card.is-archived > summary.card-header {
  opacity: 0.6;
}
.financial-account-card.is-archived .financial-account-icon {
  color: var(--fg-faint);
}

/* Saved accounts collapse to their headline; the body is the edit surface. */
details.financial-account-card > summary.card-header {
  cursor: pointer;
  list-style: none;
}

details.financial-account-card > summary.card-header::-webkit-details-marker {
  display: none;
}

/* Absorbs the row's free space so everything after it (badges, IBAN, the
   chevron) sits flush at the right edge — the "Add a bank account" summary
   has none of those, so this alone is what pushes ITS chevron to the right
   instead of leaving it stuck right after the label. */
.financial-account-label {
  flex: 1 0 auto;
  white-space: nowrap;
}

.financial-account-card .card-header .badge {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.financial-account-card .card-header .badge-secondary,
.financial-account-summary-iban { flex: none; }
.financial-account-summary-iban {
  margin-left: auto;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.financial-account-chevron {
  flex: none;
  color: var(--fg-muted);
  font-size: 18px;
  transition: transform 0.15s ease;
}

details.financial-account-card[open] > summary .financial-account-chevron {
  transform: rotate(180deg);
}

details.financial-account-card[open] > summary.card-header {
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.financial-account-card .card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.financial-account-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--bg-muted);
  color: var(--fg-muted);
}

/* Settings forms use a flat, minimal field style — no filled input
   background, a hairline border, only the same weight as everything else on
   the page (scoped to the settings sections; `.form-group` is shared with
   AR / payment runs / the admin app and stays untouched there). */
.settings-section .form-group input,
.settings-section .form-group select,
.settings-section .form-group textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13.5px;
}
.settings-section .form-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 5px;
}
/* A checkbox or radio is an option, not a field caption: the section's caption
   style above would otherwise shout its sentence in small grey capitals. */
.settings-section .form-group label.financial-account-checkbox {
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--fg);
  margin-bottom: 0;
}
.settings-section .financial-account-fields,
.settings-section .financial-account-identity {
  max-width: none;
}
.tenant-identity-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  max-width: 720px;
}
.tenant-identity-form .form-group {
  margin-bottom: 12px;
}
.tenant-identity-form .form-group-wide {
  grid-column: 1 / -1;
}
.tenant-identity-form .form-actions {
  grid-column: 1 / -1;
}

.xero-sync-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  max-width: 720px;
  margin: 12px 0 16px;
}
.xero-settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  max-width: 720px;
}
.xero-settings-form .form-group {
  margin-bottom: 12px;
}
.xero-settings-form .form-group-wide,
.xero-settings-form .form-actions {
  grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .xero-sync-facts,
  .xero-settings-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

.financial-account-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
  max-width: 720px;
}

.financial-account-fields > .financial-account-field-wide {
  grid-column: 1 / -1;
}

.financial-account-fields > .form-group {
  margin-bottom: 12px;
}

.financial-account-fields .financial-account-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-weight: 400;
}

.financial-account-fields .financial-account-checkbox input[type="checkbox"],
.financial-account-fields .financial-account-checkbox input[type="radio"] {
  width: auto;
  flex: none;
}

/* The same two columns as the fields below it, so Currency sits above Account holder. */
.financial-account-identity {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
  font-size: 14px;
  margin: 10px 0 12px;
}

.financial-account-identity dd {
  margin: 0;
}

/* As tall as the 32px select beside it, so the IBAN lines up with its value. */
.financial-account-identifier {
  display: flex;
  align-items: center;
  min-height: 32px;
}

.financial-account-currency-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.financial-account-currency-selection {
  flex: 1 1 100%;
  margin: 0;
}

.financial-account-currency p {
  margin: 8px 0;
}

.financial-account-currency-help {
  flex: 1;
  min-width: 120px;
  color: var(--fg-muted);
  font-size: 12px;
}

.financial-account-currency-help summary {
  cursor: pointer;
  display: block;
  list-style: none;
}

.financial-account-currency-help summary::-webkit-details-marker {
  display: none;
}

.financial-account-currency-details-label {
  color: var(--brand);
  text-decoration: underline;
  white-space: nowrap;
}

.financial-account-currency-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.financial-account-identity dt {
  margin-bottom: 5px;
  color: var(--fg-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.financial-account-blocked {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--warning-strong);
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 8px 0;
}

.financial-account-actions {
  display: flex;
  gap: 8px;
}

/* Settings → Payments & Banking: the account's payment routes. */
.financial-account-routes {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.financial-account-routes-set {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.financial-account-routes-set[hidden] {
  display: none;
}

.financial-account-routes-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-1);
}

.financial-account-routes-title {
  font: var(--text-body-strong);
  color: var(--fg);
}

.financial-account-route {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--space-3);
}

/* A route that is off but can be switched on stays a normal white row; only a
   route this account cannot use is muted. */
.financial-account-route.is-unavailable {
  background: var(--bg-muted);
  opacity: 0.75;
}

.financial-account-route.is-unavailable .financial-account-route-name {
  color: var(--fg-muted);
}

.financial-account-route-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Inside a settings form group, `.form-group label` would make the switch a
   block with an inline (zero-width) slider. */
.financial-account-route .toggle-switch {
  display: flex;
  flex: 0 0 auto;
  margin: 0;
}

.financial-account-route .toggle-slider {
  display: block;
}

.financial-account-route .toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.financial-account-form .form-group label.financial-account-route-title {
  display: inline-flex;
  margin: 0;
  color: var(--fg);
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}

.financial-account-route-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.financial-account-route-title iconify-icon {
  color: var(--fg-muted);
  font-size: 16px;
}

.financial-account-route-name {
  font: var(--text-body-strong);
}

.financial-account-route-scheme {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: var(--text-caption);
}

.financial-account-route-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-left: 52px;
}

.financial-account-route-body[hidden] {
  display: none;
}

.financial-account-route-body .form-group {
  margin: 0;
}

.financial-account-route-body .financial-account-field-wide {
  grid-column: 1 / -1;
  margin: 0;
}

.financial-account-route-off {
  margin: var(--space-2) 0 0 52px;
}

.financial-account-route-off[hidden] {
  display: none;
}

/* Settings > Payments & Banking: every control on an account card is 32px
   high with the app's 13px text, and a select takes the app's chevron in place
   of the browser's. */
.financial-account-card .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.financial-account-card .form-group select {
  height: 32px;
  padding: 0 10px;
  color: var(--fg);
  font: var(--text-sm);
}

.financial-account-card .form-group select,
.payment-run-page .payment-run-source .form-group select,
.payment-run-page .payment-run-payee-cell select,
.payment-run-page .payment-run-pay-by select,
.payment-run-page .payment-run-missing-inputs select {
  padding-right: 32px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.financial-account-card .form-group select:disabled,
.payment-run-page .payment-run-payee-cell select:disabled {
  background-color: var(--bg-muted);
  color: var(--fg-muted);
}

.financial-account-card .form-group select[aria-invalid="true"] {
  border-color: var(--danger);
}

.financial-account-card .form-group input[name="iban"] {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* The how-is-this-account-identified answers, as the app's bordered options
   rather than the browser's bare radios. */
.financial-account-radio-group .financial-account-checkbox {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font: var(--text-sm);
  cursor: pointer;
}

.financial-account-radio-group .financial-account-checkbox:hover {
  background: var(--bg-muted);
}

.financial-account-radio-group .financial-account-checkbox:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.financial-account-radio-group .financial-account-checkbox input[type="radio"] {
  accent-color: var(--brand);
}

/* The card's one footer: Archive and the default switch on the left, the
   primary action on the right, under a single divider. */
.financial-account-actions {
  align-items: center;
  justify-content: flex-start;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
}

.financial-account-actions .financial-account-save {
  margin-left: auto;
}

/* The settings dialog's top bar carries its close button; a toast slides in
   below it instead of over it. */
dialog#settings-modal .toast-stack-in-dialog {
  top: 80px;
}

/* Accounting operations workspace. The shared light-mode tokens provide every
   visual value; these rules only compose the dense explorer and equation. */
.content-accounting {
  min-width: 0;
}

.accounting-page,
.accounting-detail,
.accounting-open-item-workbench-page,
.banking-detail-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.documents-page.accounting-page,
.documents-page.banking-page,
.documents-page.banking-statement-page,
.documents-page.banking-transaction-page,
.documents-page.accounting-open-item-page,
.documents-page.accounting-clearing-page {
  gap: 0;
  min-height: calc(100vh - 26px);
  background: var(--surface);
}

.documents-page.accounting-page,
.documents-page.banking-page {
  min-height: 0;
}

/* The Clearings table sits inside its selection wrapper; the wrapper takes the
   page's remaining height so the scroll area below it scrolls in place. */
.accounting-page > .accounting-clearing-selection {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.banking-page > .page-header,
.accounting-page > .page-header {
  flex-wrap: nowrap;
  gap: var(--space-2);
}

.banking-page > .page-header .page-header-left,
.accounting-page > .page-header .page-header-left {
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}

.banking-page-body {
  min-width: 0;
  overflow: auto;
  padding-right: 14px;
  padding-bottom: var(--space-6);
}

.banking-filter-exclusions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font: var(--text-sm);
}

.banking-filter-exclusions a {
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}

.banking-page-body:has(.banking-transactions) {
  overflow-x: auto;
}

.banking-transaction-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 14px;
  padding-bottom: var(--space-6);
}

.banking-review-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.banking-review-comparison > section {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-muted);
}

.banking-review-facts {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
}

.banking-review-facts > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr);
  gap: var(--space-3);
}

.statement-reingest-unavailable {
  align-self: center;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

@media (max-width: 720px) {
  .banking-review-comparison,
  .banking-review-facts > div {
    grid-template-columns: 1fr;
  }
}

/* Transaction details render directly inside the fixed-height documents shell.
   Give that body its own scroll, matching the data panel on statement details,
   so long allocation workbenches are not clipped by `.documents-page`. */
.banking-transaction-page > .banking-detail-page {
  flex: 1;
  min-height: 0;
  padding: var(--space-4) 14px var(--space-6);
  overflow-y: auto;
  background: var(--surface);
}

.accounting-open-item-page > .accounting-open-item-workbench-page,
.accounting-clearing-page > .account-sheet-page--clearing {
  flex: 1;
  min-height: 0;
  padding: var(--space-4) 14px var(--space-6);
  overflow-y: auto;
  background: var(--surface);
}

/* Statement and transaction views put source documents beside their Banking
   facts, using the same split shell as the document viewer. The page header is
   51px and the app footer 26px; --elevated-chrome is 0 unless the
   elevated-context banner is present. The data panel owns the scroll, so the
   card column below stays a plain single-column stack. */
.banking-statement-page > .detail-container,
.banking-transaction-page > .detail-container {
  height: calc(100vh - 77px - var(--elevated-chrome) - var(--pause-chrome));
}

/* Weighted further toward the data panel than the document viewer's 45/55: a
   statement source is one narrow column of entries, while the facts beside it
   carry the widest tables in the app (occurrence and history evidence). The
   source panel stays resizable for reading the raw file closely. */
.banking-statement-page .pdf-panel,
.banking-transaction-page .pdf-panel {
  flex: 38;
  min-width: 260px;
}

.banking-statement-page .data-panel,
.banking-transaction-page .data-panel {
  flex: 62;
}

@media (min-width: 901px) {
  .banking-statement-page .data-panel {
    min-height: 0;
    overflow-y: auto;
  }
}

.banking-statement-page .data-panel > .banking-detail-page,
.banking-transaction-page .data-panel > .banking-detail-page {
  padding: var(--space-4) 14px var(--space-6);
  background: var(--surface);
}

.banking-awaiting-account-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--info-border);
  border-radius: var(--r-lg);
  background: var(--info-tint);
}

.banking-awaiting-account-notice > iconify-icon {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--brand);
  font-size: 18px;
}

.banking-awaiting-account-notice h2 {
  margin: 0 0 var(--space-1);
  color: var(--fg);
  font: var(--text-h3);
}

.banking-awaiting-account-notice p {
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-sm);
}

.banking-attention-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-lg);
  background: var(--warning-tint);
}

.banking-replacement-facts {
  margin-bottom: var(--space-4);
}

.banking-replacement-summary {
  color: var(--fg-muted);
}

.banking-replacement-comparison {
  width: 100%;
  table-layout: fixed;
}

.banking-replacement-comparison th:first-child {
  width: 26%;
}

.banking-replacement-comparison th,
.banking-replacement-comparison td {
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}

.banking-replacement-line {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
}

.banking-replacement-reference,
.banking-replacement-none,
.banking-replacement-changed-fields {
  color: var(--fg-muted);
}

.banking-replacement-changed-fields {
  display: block;
  margin-top: var(--space-1);
}

.banking-replacement-consequences {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

.banking-replacement-blocked {
  color: var(--warning-strong);
}

.banking-statement-attention-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.banking-statement-attention-badges .badge {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banking-statement-attention-badges .badge:first-child {
  flex-shrink: 0;
  max-width: 100%;
}

.banking-attention-message h2 {
  margin: 0 0 var(--space-1);
  color: var(--warning-strong);
  font: var(--text-h3);
}

.banking-attention-message p {
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-sm);
}

.banking-attention-banner .btn {
  flex: 0 0 auto;
  border-color: var(--warning-border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.banking-attention-banner .btn:hover {
  background: var(--bg-subtle);
}

dialog.banking-attention-dialog {
  display: none;
  width: min(940px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 32px));
  max-width: none;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}

dialog.banking-attention-dialog[open] {
  display: flex;
}

dialog.banking-attention-dialog::backdrop {
  background: rgba(18, 16, 11, 0.45);
  backdrop-filter: blur(6px);
}

.banking-attention-dialog-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  min-height: 0;
}

.banking-attention-dialog-head,
.banking-attention-dialog-foot {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.banking-attention-dialog-head h2 {
  margin: 0;
  color: var(--fg);
  font: var(--text-h2);
}

.banking-attention-eyebrow {
  margin: 0 0 var(--space-1);
  color: var(--fg-subtle);
  font: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.banking-attention-close {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}

.banking-attention-close:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.banking-attention-close iconify-icon {
  font-size: 18px;
}

.banking-attention-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 24px;
}

.banking-rejected-occurrences-intro,
.banking-rejected-occurrences-truncated {
  margin: 0 0 var(--space-3);
  color: var(--fg-muted);
  font: var(--text-sm);
}

.banking-rejected-occurrences-truncated {
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.banking-rejected-occurrence {
  margin-bottom: var(--space-3);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.banking-rejected-occurrence-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 12px;
}

.banking-rejected-occurrence-head h3,
.banking-rejected-occurrence-reasons h4,
.banking-rejected-occurrences-guidance h3 {
  margin: 0;
  color: var(--fg);
  font: var(--text-h3);
}

.banking-rejected-occurrence-head > span {
  color: var(--fg-subtle);
  font: var(--text-sm);
}

.banking-rejected-occurrence-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 0;
}

.banking-rejected-occurrence-facts > div {
  min-width: 0;
}

.banking-rejected-occurrence-facts dt {
  margin-bottom: 3px;
  color: var(--fg-subtle);
  font: var(--text-xs);
}

.banking-rejected-occurrence-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--fg);
  font: var(--text-sm);
}

.banking-rejected-occurrence-facts .banking-rejected-occurrence-amount {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.banking-rejected-occurrence-reasons {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.banking-rejected-occurrence-reasons h4 {
  font-size: 13px;
}

.banking-rejected-occurrence-reasons ul {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--fg-muted);
  font: var(--text-sm);
}

.banking-rejected-occurrences-guidance {
  margin-top: var(--space-4);
  margin-bottom: var(--space-3);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--stone-50);
}

.banking-rejected-occurrences-guidance h3 {
  margin-bottom: 8px;
}

.banking-rejected-occurrences-guidance p {
  margin: 0 0 8px;
  color: var(--fg-muted);
  font: var(--text-sm);
}

.banking-rejected-occurrences-guidance p:last-child {
  margin-bottom: 0;
}

.banking-attention-dialog-actions {
  display: flex;
  gap: var(--space-2);
  margin-right: auto;
}

.banking-attention-dialog-actions {
  align-items: center;
}

.banking-attention-dialog-actions form {
  margin: 0;
}

.banking-attention-dialog-note {
  color: var(--warning-strong);
  font: var(--text-sm);
}

.banking-attention-dialog-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
  background: var(--stone-50);
}

@media (max-width: 600px) {
  .banking-attention-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .banking-rejected-occurrence-facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .banking-attention-dialog-head,
  .banking-attention-dialog-body,
  .banking-attention-dialog-foot {
    padding-right: 16px;
    padding-left: 16px;
  }
}

/* Clear the sticky section tabs when a tab scrolls its card into view. */
#statement-overview,
#statement-transactions,
#statement-history,
#statement-account,
#statement-account-create,
#statement-checkpoint,
#statement-prelinks,
#statement-corrections {
  scroll-margin-top: 60px;
}

.banking-statement-page .section-tabs {
  align-items: center;
  flex-wrap: nowrap;
  padding-right: 10px;
}

.statement-section-links {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.statement-section-links::-webkit-scrollbar {
  display: none;
}

.banking-checkpoint-heading {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.banking-checkpoint-help {
  display: inline-flex;
  color: var(--fg-muted);
  cursor: help;
}

.banking-checkpoint-help iconify-icon {
  font-size: 16px;
}

.banking-checkpoint-help[data-tip]::after {
  max-width: min(380px, calc(100vw - 48px));
}

.statement-reingest-action {
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: var(--space-2);
}

.statement-reingest-action form {
  margin: 0;
}

.statement-reingest-action button {
  min-height: 30px;
  padding: 5px 10px;
}

.statement-reingest-action button:disabled {
  pointer-events: none;
}

.statement-reingest-action[data-tip]::after {
  right: 0;
  left: auto;
}

.banking-overview-facts,
.banking-balance-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--space-4);
  margin: 0;
}

.banking-overview-fact,
.banking-balance-item {
  min-width: 0;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.banking-overview-fact dt,
.banking-balance-item dt {
  margin-bottom: 2px;
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.banking-overview-fact dd,
.banking-balance-item dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.banking-balance-pair {
  margin-top: var(--space-2);
  padding: 0 var(--space-3);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-md);
  background: var(--brand-tint);
}

.banking-balance-item {
  border-bottom: 0;
}

.banking-balance-item dd {
  font: var(--text-body-strong);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .banking-overview-facts,
  .banking-balance-pair {
    grid-template-columns: 1fr;
  }

  .banking-balance-item + .banking-balance-item {
    border-top: 1px solid var(--brand-border);
  }
}

/* The source panel's header sits beside the data panel's section tabs, so it
   takes their height rather than the 49px the document viewer's own filename
   bar uses; its download control shrinks to fit. */
.banking-statement-page .filename-bar,
.banking-transaction-page .filename-bar {
  min-height: 40px;
  padding: 4px 14px;
}

.filename-bar .filename-action {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

/* Reading the source over the page, for a statement too wide for half a split
   view. Sized to the viewport so the table gets the room it needs. */
.statement-source-dialog {
  width: 94vw;
  max-width: 94vw;
  height: 90vh;
  max-height: 90vh;
  padding: 0;
  border: none;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-modal, 0 24px 64px rgb(0 0 0 / 28%));
  overflow: hidden;
}

.statement-source-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.statement-source-dialog-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.statement-source-dialog-header .filename-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 13px;
}

.statement-source-dialog > iframe {
  width: 100%;
  height: calc(90vh - 41px);
  border: none;
  display: block;
}

.statement-source-dialog > .statement-source-image {
  /* The expanded view exists to read a statement large, so a photographed one
     fills the dialog's width and scrolls, rather than being fitted whole into
     the dialog's height the way the side-by-side panels do it. */
  width: 100%;
  height: auto;
  display: block;
  image-orientation: from-image;
}

.statement-source-dialog:has(> .statement-source-image) {
  overflow-y: auto;
}

.banking-statement-page .pdf-panel > .empty-state,
.banking-transaction-page .pdf-panel > .empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  text-align: center;
  color: var(--fg-muted);
}

.banking-statement-page > .page-header,
.banking-transaction-page > .page-header {
  height: 51px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.accounting-clearing-page > .page-header {
  height: 51px;
  padding-top: 5px;
  padding-bottom: 5px;
}

/* The open item's data panel carries accounting cards rather than the document
   viewer's own sections, so it supplies their spacing. */
.accounting-open-item-page .data-panel .panel-body > .accounting-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) 14px var(--space-6);
}

.accounting-open-item-page .data-panel .accounting-detail-card {
  scroll-margin-top: 52px;
}

.accounting-open-item-overview .accounting-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-5);
}

.accounting-current-remainder {
  color: var(--brand);
  font: var(--text-body-strong);
  font-variant-numeric: tabular-nums;
}

.accounting-processing-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}

.accounting-processing-status > iconify-icon {
  color: var(--fg-muted);
  font-size: 20px;
}

.accounting-processing-status-available {
  border-color: var(--success-border);
  background: var(--success-tint);
}

.accounting-processing-status-available > iconify-icon {
  color: var(--success);
}

.accounting-processing-status-partial {
  border-color: var(--warning-border);
  background: var(--warning-tint);
}

.accounting-processing-status-partial > iconify-icon {
  color: var(--warning);
}

.accounting-processing-copy {
  min-width: 0;
}

.accounting-processing-copy > strong {
  display: block;
  color: var(--fg);
  font: var(--text-body-strong);
}

.accounting-processing-copy > p {
  margin: var(--space-1) 0 0;
  color: var(--fg-muted);
  font: var(--text-sm);
  line-height: 1.45;
}

.accounting-settlement-summary {
  margin: 0 0 var(--space-3);
  color: var(--fg-muted);
  line-height: 1.5;
}

.accounting-settlement-summary > strong {
  color: var(--fg);
}

.accounting-settlement-empty {
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-muted);
}

@media (max-width: 720px) {
  .accounting-open-item-overview .accounting-facts {
    grid-template-columns: 1fr;
  }

  .accounting-processing-status {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .accounting-processing-status > .btn {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

.banking-search-state {
  display: none;
}

/* Once every filter has moved into More filters there is nothing left to give,
   and the row would start sliding under the page's actions. The search box
   yields the last of the space instead — narrower still reads as a search
   box, where a clipped one does not. */
.page-header:has([data-filter-overflow]) .search-toolbar {
  flex: 0 1 auto;
  min-width: 136px;
}

.page-header:has([data-filter-overflow]) .search-container {
  flex: 0 1 auto;
  min-width: 136px;
}

/* Accounting's search keeps room for its placeholder. Once Clear filters
   appears, the overflow moves a filter into More filters rather than clipping
   the search to "Search th…"; narrow viewports scale the floor down. */
.page-header.accounting-toolbar:has([data-filter-overflow]) .search-toolbar,
.page-header.accounting-toolbar:has([data-filter-overflow]) .search-container {
  min-width: clamp(136px, 16vw, 220px);
}

/* The input carries the container's fixed width, so the container cannot give
   any of it back until the input stops insisting on it. */
.page-header:has([data-filter-overflow]) .search-container > .search-input {
  width: 100%;
  min-width: 0;
}

.accounting-header,
.accounting-detail-header,
.banking-detail-header {
  margin-bottom: 0;
}

.accounting-header p,
.accounting-detail-header p,
.banking-detail-header p {
  margin: var(--space-1) 0 0;
  color: var(--fg-muted);
}

.accounting-tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
}

.accounting-tab {
  position: relative;
  padding: 8px 12px;
  color: var(--fg-muted);
  font: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}

.accounting-tab:hover {
  color: var(--fg);
  background: var(--brand-tint-hover);
  text-decoration: none;
}

.accounting-tab.active {
  color: var(--brand-pressed);
}

.accounting-tab.active::after {
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  background: var(--brand);
  content: "";
}

.accounting-filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: nowrap;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.accounting-filter-grid {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.accounting-toolbar > .page-header-left,
.accounting-toolbar .accounting-filter-grid {
  flex-wrap: nowrap;
}

/* Nothing has overflowed into it yet — an always-visible, always-empty
   "More filters" button would be dead weight in the row. */
.filter-overflow-menu:has(.filter-menu:empty) {
  display: none;
}

/* A page joins the collapse by marking its filter row `data-filter-overflow`
   and ending that row with the shared More filters bucket. These rules give
   the row the shape the collapse needs — one line, filters at their natural
   width, measurable against the page's own actions — so a page needs no class
   of its own to opt in. Without them the row simply wraps onto a second line
   and never reports the pressure the script looks for. */
[data-filter-overflow] {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  gap: var(--space-2);
  align-items: center;
  min-width: 0;
}

.page-header:has([data-filter-overflow]) {
  flex-wrap: nowrap;
}

.page-header:has([data-filter-overflow]) > .page-header-left {
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}

/* The row overflows rather than shrinking, so the actions win the paint order
   and stay whole and clickable while the collapse catches up. */
.page-header:has([data-filter-overflow]) > .page-header-actions {
  flex: none;
  position: relative;
  z-index: 2;
  padding-left: var(--space-3);
  background: var(--surface);
}

/* Nothing left to collapse and nothing left to shrink: only now do the actions
   take a line of their own. Wrapping earlier costs a whole band of the page
   while the row could still have held together, and it hands the filters the
   full width back — so a filter returns to a row whose action button has just
   been pushed below it, which reads as a fault rather than a fallback. */
@media (max-width: 740px) {
  .page-header:has([data-filter-overflow]) {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .page-header:has([data-filter-overflow]) > .page-header-left {
    flex: 1 1 100%;
    min-width: 0;
  }

  .page-header:has([data-filter-overflow]) > .page-header-actions {
    margin-left: auto;
    padding-left: 0;
  }

  /* AP and Banking put tabs, search, filters, and page actions in one shared
     header. At phone widths the tabs must get their own row; otherwise the
     search box and filter bucket paint beyond the viewport before the overflow
     script can move the filters. */
  .documents-page > .page-header:has([data-filter-overflow]) > .page-header-left {
    flex: 1 1 100%;
    width: 100%;
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  .documents-page > .page-header:has([data-filter-overflow]) > .page-header-left > .search-toolbar {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .documents-page > .page-header:has([data-filter-overflow]) > .page-header-left > [data-filter-overflow] {
    flex: 1 1 100%;
    width: 100%;
  }

  .documents-page > .page-header:has([data-filter-overflow]) > .page-header-actions {
    flex: 1 1 100%;
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
}

/* The filters keep their natural width and overflow into More filters, so the
   row itself never shrinks them and never wraps. */
.banking-filter-grid {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  gap: var(--space-2);
  align-items: center;
  min-width: 0;
}

/* "More filters" is a two-level menu: names here, the filter itself in a
   flyout beside whichever name is pointed at. */
.filter-overflow-menu > .filter-dropdown-panel,
.accounting-advanced-filters > .filter-dropdown-panel {
  width: auto;
  min-width: 240px;
  padding: var(--space-1);
  overflow: visible;
}

/* The bucket always ends its row, so its menu opens inward from the button's
   right edge instead of running off the viewport. */
.filter-overflow-menu > .filter-dropdown-panel {
  left: auto;
  right: 0;
}

/* `filter-overflow.js` counts the filters in use that the bucket holds. */
.filter-overflow-count {
  font-weight: 600;
}

.filter-menu {
  display: flex;
  flex-direction: column;
  max-height: 60vh;
  overflow-y: auto;
}

.filter-menu-item {
  position: relative;
}

.filter-menu-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: inherit;
  font-size: 13px;
  text-align: left;
  cursor: default;
}

.filter-menu-name {
  flex: 1;
  min-width: 0;
}

.filter-menu-item:hover > .filter-menu-trigger,
.filter-menu-item.is-open > .filter-menu-trigger {
  background: var(--bg-muted);
}

.filter-menu-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.filter-menu-arrow {
  flex: none;
  font-size: 14px;
  color: var(--fg-subtle);
}

/* Fixed, not absolute: the name list scrolls, and a scroll container clips an
   absolutely positioned child. A fixed one escapes it, so JS places it. */
.filter-menu-flyout {
  display: none;
  position: fixed;
  z-index: 1100;
  min-width: 260px;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-popover);
}

.filter-menu-item:hover > .filter-menu-flyout,
.filter-menu-item.is-open > .filter-menu-flyout {
  display: block;
}

/* Inside a flyout the options are the point, so the control shows them
   directly instead of asking for another click. */
.filter-menu-flyout .filter-dropdown > .filter-dropdown-trigger {
  display: none;
}

/* Outranks the rule that keeps a nested dropdown's panel shut: in a flyout the
   options are the content, not a second thing to open. */
.filter-menu-flyout .filter-dropdown:not(.open) > .filter-dropdown-panel,
.filter-menu-flyout .filter-dropdown.open > .filter-dropdown-panel {
  display: flex;
  position: static;
  min-width: 0;
  max-width: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.filter-menu-flyout .accounting-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.banking-page > .page-header .page-header-actions,
.accounting-toolbar > .page-header-actions {
  flex: none;
}

/* The filter grid is `flex: none`, so a row too narrow for it overflows rather
   than shrinking and would paint straight across the pagination beside it. The
   actions win the paint order so they stay whole and clickable. The row itself
   only stops being cut once `filter-overflow` moves what does not fit into
   More filters. */
.accounting-toolbar > .page-header-actions,
.banking-page > .page-header > .page-header-actions {
  position: relative;
  z-index: 2;
  padding-left: var(--space-3);
  background: var(--surface);
}

.accounting-filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.accounting-toolbar .accounting-filter-field > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.accounting-filter-field input,
.accounting-filter-field select {
  min-width: 112px;
  height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
}

.accounting-filter-field input[type="search"],
.accounting-filter-field input[type="text"] {
  min-width: 176px;
}

.accounting-range-filter {
  width: 240px;
  padding: var(--space-3);
}

.accounting-range-fields {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.accounting-toolbar .accounting-range-field > span {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.accounting-range-field input[type="text"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.filter-dropdown-trigger.has-error {
  color: var(--danger-strong);
  border-color: var(--danger-border);
  background: var(--danger-tint);
}

.accounting-range-field input[aria-invalid="true"],
.date-range-custom-inputs input[aria-invalid="true"],
.date-range-custom-inputs input[aria-invalid="true"] + [data-european-date-display] {
  border-color: var(--danger);
}

.accounting-range-field .accounting-filter-error,
.date-range-custom .accounting-filter-error {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--danger-strong);
  font: var(--text-xs);
  letter-spacing: normal;
  text-transform: none;
}

.accounting-filter-notice {
  margin: 10px 14px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  background: var(--danger-tint);
  color: var(--danger-strong);
  font: var(--text-sm);
}

.accounting-range-filter .filter-dropdown-apply {
  width: 100%;
  border-top: none;
  border-radius: var(--r-md);
}

.accounting-advanced-filters {
  position: relative;
  align-self: center;
}

/* Nothing has overflowed into it yet — an always-visible, always-empty
   "More filters" button would be dead weight in the row. */
.accounting-advanced-filters:has(.filter-menu:empty) {
  display: none;
}

.accounting-advanced-filters > .filter-dropdown-trigger {
  height: 34px;
}

.accounting-active-filter-summary {
  display: block;
  max-width: 280px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--fg-muted);
  font: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accounting-advanced-filters.open {
  flex-basis: auto;
}

.accounting-advanced-filters.open > .filter-dropdown-trigger {
  width: max-content;
  color: var(--brand-pressed);
  background: var(--brand-tint);
}

.accounting-advanced-filters > .filter-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: auto;
  z-index: 100;
  width: auto;
  min-width: 240px;
  padding: var(--space-1);
  /* A scroll container would clip the level-two flyout that escapes this box. */
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}

.accounting-advanced-filters > .filter-dropdown-panel > .accounting-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.accounting-toolbar .accounting-advanced-filters .accounting-filter-field > span {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.accounting-advanced-filters .accounting-filter-field input,
.accounting-advanced-filters .accounting-filter-field select {
  width: 100%;
  min-width: 0;
}

.accounting-filter-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.accounting-filter-actions {
  flex: none;
}

/* Accounting waits longer than the others because its filter row cannot
   collapse all the way: the row sits inside a form that sizes itself to its
   own contents, so the script reads a width that never tightens and stops
   once one filter and the bucket remain. Measured against that, the row holds
   to a 750px header — a 810px viewport beside the icon rail. */
@media (max-width: 810px) {
  .accounting-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .accounting-toolbar > .page-header-left {
    flex: 1 1 100%;
    min-width: 0;
  }

  .accounting-toolbar > .page-header-actions {
    margin-left: auto;
    padding-left: 0;
  }
}

.accounting-results {
  min-width: 0;
}

.accounting-table-overflow {
  min-width: 0;
  overflow: visible;
}

.accounting-table-container {
  max-height: none;
  background: var(--surface);
}

.accounting-results-table {
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.accounting-results-table > .accounting-exceptions {
  min-width: 1020px;
}

.accounting-results-table > .accounting-open-items {
  min-width: calc(1262px
    - var(--accounting-open-item-kind-hidden, 0px)
    - var(--accounting-open-item-doc-hidden, 0px)
    - var(--accounting-open-item-booked-hidden, 0px)
    - var(--accounting-open-item-days-hidden, 0px)
    - var(--accounting-open-item-candidates-hidden, 0px));
}

.accounting-results-table > .accounting-clearings {
  min-width: max(100%, calc(1160px
    - var(--accounting-clearing-actor-hidden, 0px)
    - var(--accounting-clearing-origin-hidden, 0px)
    - var(--accounting-clearing-exported-hidden, 0px)
    - var(--accounting-clearing-export-file-hidden, 0px)));
}

.accounting-table code {
  font: var(--text-mono);
  font-variant-numeric: tabular-nums;
}

/* Accounting overview lists (Exceptions/Open items/Clearings): match the AP/
   Document Management lists' lighter sans typography (see the #document-list
   rule above) instead of the mono machine-value rule, so amounts, dates, and
   account names read as normal text, not machine-value monospace. */
.accounting-table .amount-cell,
.accounting-table .accounting-date-cell,
.accounting-table .accounting-account-key {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
}

/* Stacked cell content stacks the CHILDREN, never the cell. A `td` whose
   display is not `table-cell` leaves the table's column model, so the cells
   after it move up one column and every value lands under the wrong header. */
.accounting-date-cell > *,
.accounting-account-cell > *,
.accounting-table td:has(.accounting-secondary) > * {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accounting-date-cell > * + *,
.accounting-account-cell > * + *,
.accounting-table td:has(.accounting-secondary) > * + * {
  margin-top: 1px;
}

/* Exceptions Context column: Counterparty and Remittance each get their own
   line (divs, block by default) instead of running inline after a label --
   the label already tells you which is which, so dropping it and stacking
   the two lines reads faster and saves horizontal space in a narrow column. */
.accounting-exception-evidence-parties > * + * {
  margin-top: 1px;
}

.accounting-exception-evidence-detail {
  margin-top: 2px;
}

.accounting-exception-evidence-parties > *,
.accounting-exception-evidence-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accounting-account-cell strong {
  font: var(--text-body-strong);
}

/* An Orcha-owned account's name wraps rather than shortens, so accounts that
   differ only at the end (Primary, Secondary) stay apart; its info marker
   follows the last word. */
.accounting-account-cell > .accounting-account-name {
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
}

.accounting-account-cell .accounting-account-name__text {
  color: inherit;
  font: inherit;
}

.accounting-account-cell .orcha-account-marker {
  display: inline-flex;
  margin-left: 4px;
  color: var(--fg-subtle);
  font-size: 13px;
  vertical-align: -2px;
  cursor: help;
}

/* The neutral tag beside an Orcha-owned account's name on sheet titles. */
.orcha-account-tag {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: var(--text-caption);
  vertical-align: middle;
  white-space: nowrap;
  cursor: help;
}

.accounting-account-cell span,
.accounting-secondary,
.accounting-age,
.accounting-table-note {
  color: var(--fg-subtle);
  font: var(--text-caption);
}

.accounting-summary-cell {
  white-space: nowrap;
}

.accounting-evidence {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accounting-context-link,
.accounting-back-link {
  color: var(--link);
  font-weight: 600;
}

.accounting-row-link {
  color: inherit;
  text-decoration: none;
}

.accounting-row-link:hover,
.accounting-row-link:focus-visible {
  color: var(--link);
  text-decoration: underline;
}

/* Tooltips the reader does not have to wait for. A native `title` is held back
   by a browser delay of roughly a second that no stylesheet can shorten, so
   anything explaining a control that is refusing to work, or a word the reader
   does not know, says it too late. Anything carrying `data-tip` gets one. */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 40;
  width: max-content;
  max-width: 280px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  transition: opacity 60ms linear 100ms;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after,
[data-tip]:focus-within::after {
  opacity: 1;
}

/* Default placement: below, left-aligned. Inside a scrolling table this hangs
   down into the rows rather than out of the container. */
[data-tip]::after {
  top: calc(100% + var(--space-1));
  left: 0;
}

/* A sticky table header's z-index (set to keep it above scrolling rows) also
   ranks it against ITS SIBLING header cells — a later column always paints
   over an earlier one at equal z-index, regardless of the tooltip's own
   z-index, because the tooltip never escapes its cell's stacking context.
   Bumping the hovered cell itself above its siblings is what actually frees
   the tooltip. Scoped to `thead th` generically so it covers every sticky
   table header in the app, not just one table's class. */
thead th:has([data-tip]:hover),
thead th:has([data-tip]:focus-visible),
thead th:has([data-tip]:focus-within) {
  z-index: 10;
}

/* With `tooltip.js` loaded, one floating `.app-tooltip` replaces the pseudo-
   element above: it sits in viewport coordinates, so a truncated cell's or a
   scroll panel's overflow cannot cut it off. The pseudo-element keeps its
   text, visually hidden, for a screen reader reading the page rather than
   moving focus. */
html.has-floating-tips [data-tip]::after {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  box-shadow: none;
}

.app-tooltip {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  white-space: pre-line;
  overflow-wrap: anywhere;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 80ms ease-out;
}

.app-tooltip[hidden] {
  display: none;
}

.app-tooltip.is-visible {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  [data-tip]::after,
  .app-tooltip {
    transition: none;
  }
}

/* A tooltip on an icon or tag that is not itself a control still takes focus,
   so a keyboard reader gets the explanation too (the Orcha account tag). */
.tip-anchor {
  display: inline-flex;
  align-items: center;
  cursor: help;
}

.tip-anchor:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* A disabled control receives no pointer or focus events, so the reason it is
   disabled sits on this focusable wrapper around it. */
.disabled-tip {
  display: inline-flex;
  cursor: not-allowed;
}

.disabled-tip > :disabled {
  pointer-events: none;
}

.disabled-tip:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-md);
}

/* A glossary term looks hoverable, or nobody discovers it. The dotted rule
   marks the word; the icon is what a reader actually recognises as "there is an
   explanation here", so it sits to the right of the term. */
.glossary-term {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  border-bottom: 1px dotted var(--fg-faint);
  cursor: help;
  white-space: nowrap;
}

.glossary-term-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glossary-term-icon {
  flex: none;
  margin-left: 3px;
  color: var(--fg-faint);
  font-size: 12px;
  vertical-align: -1px;
}

.glossary-term:hover .glossary-term-icon {
  color: var(--brand);
}

/* A header's tooltip must not inherit the header's uppercase micro-type. */
th .glossary-term::after,
.accounting-field-label .glossary-term::after {
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
}

/* A tooltip opens rightward from its term by default, which pushes a
   right-edge column's tooltip past the table and widens the container's
   scrollable area even though the tooltip itself stays hidden until hover. */
.banking-transactions thead th:nth-last-child(-n + 3) .glossary-term::after,
.banking-statements thead th:nth-last-child(-n + 3) .glossary-term::after,
.banking-clearings thead th:nth-last-child(-n + 3) .glossary-term::after,
.accounting-table thead th:nth-last-child(-n + 3) .glossary-term::after,
.accounting-clearings thead th:nth-child(n + 8) .glossary-term::after,
.accounting-open-items thead th:nth-child(n + 7) .glossary-term::after {
  right: 0;
  left: auto;
}

/* The dialog footer is the last thing on screen, so its tooltip goes upward. */
.accounting-preview-clearing[data-tip]::after {
  top: auto;
  bottom: calc(100% + var(--space-1));
  right: 0;
  left: auto;
}

.accounting-technical-details {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.accounting-technical-details > summary {
  width: max-content;
  cursor: pointer;
  color: var(--fg-muted);
  font: var(--text-sm);
  font-weight: 600;
}

.accounting-technical-details > summary:hover {
  color: var(--fg);
}

.accounting-technical-details code {
  overflow-wrap: anywhere;
  font: var(--text-mono);
}

.table-empty-state {
  margin: 0;
  padding: 48px;
  color: var(--fg-subtle);
  font-style: normal;
  text-align: center;
}

.accounting-detail {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.banking-detail-page {
  width: 100%;
  max-width: none;
  margin: 0;
}

.accounting-open-item-workbench-page {
  width: 100%;
  max-width: none;
  margin: 0;
}

.accounting-detail-card,
.banking-detail-card {
  padding: var(--space-4);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.banking-detail-card-warning {
  border: 1px solid var(--warning-border);
  background: var(--warning-tint);
}
.banking-detail-card-warning > a.btn-secondary {
  background: var(--surface);
}
.banking-detail-card-warning > h2 {
  border-bottom-color: var(--warning-border);
  color: var(--warning-strong);
}

.accounting-detail-card > h2,
.banking-detail-card > h2 {
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  font: var(--text-h3);
}

.banking-detail-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.banking-detail-card-header > h2 {
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
  font: var(--text-h3);
}

.banking-detail-card-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.accounting-detail-card h3,
.accounting-detail-card h4,
.banking-detail-card h3,
.banking-detail-card h4 {
  margin: var(--space-3) 0 var(--space-2);
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* The statement detail's data panel follows the document data panel: sections
   are full width without a frame, separated by a divider and opened by a
   header band, and the overview's values sit in text boxes. Warning cards stay
   boxed as callouts. The panel's scroll area pads 14px at the sides. */
.banking-statement-detail .banking-statement-scroll {
  gap: 10px;
}
.banking-statement-detail .banking-statement-scroll > .banking-detail-card:not(.banking-detail-card-warning) {
  margin: 0 -14px;
  padding: 0 14px 14px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}
.banking-statement-detail .banking-statement-scroll > .banking-detail-card:not(.banking-detail-card-warning) > :is(h2, .banking-detail-card-header) {
  margin: 0 -14px 14px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.banking-statement-detail .banking-statement-scroll > .banking-detail-card:not(.banking-detail-card-warning) :is(h2, .banking-detail-card-header > h2) {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
}
.banking-statement-detail .banking-overview-facts {
  gap: 8px 16px;
}
.banking-statement-detail .banking-overview-fact {
  padding: 0;
  border-bottom: none;
}
.banking-statement-detail .banking-overview-fact dt {
  margin-bottom: 3px;
}
.banking-statement-detail .banking-overview-fact dd {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.accounting-facts,
.banking-facts,
.accounting-provenance-list {
  margin: 0;
}

.accounting-facts > div,
.banking-facts > dt,
.banking-facts > dd,
.accounting-provenance-list > div {
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.banking-facts {
  display: grid;
  grid-template-columns: minmax(160px, 0.35fr) minmax(0, 1fr);
}

.accounting-facts > div,
.accounting-provenance-list > div {
  display: grid;
  grid-template-columns: minmax(140px, 0.35fr) minmax(0, 1fr);
  gap: var(--space-3);
}

.accounting-facts > div:last-child,
.accounting-provenance-list > div:last-child {
  border-bottom: 0;
}

.accounting-facts dt,
.banking-facts dt,
.accounting-provenance-list dt {
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.accounting-facts dd,
.banking-facts dd,
.accounting-provenance-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.banking-facts > dt:nth-last-of-type(1),
.banking-facts > dd:last-child {
  border-bottom: 0;
}

.banking-detail-card .form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.banking-detail-card .form-actions form {
  margin: 0;
}

.banking-statement-page > .page-header .page-header-left,
.banking-transaction-page > .page-header .page-header-left {
  flex: 1;
  flex-wrap: nowrap;
}

.banking-occurrences th,
.banking-occurrences td,
.banking-history th,
.banking-history td,
.banking-supports th,
.banking-supports td,
.banking-clearings th,
.banking-clearings td {
  vertical-align: top;
}

/* Clearings table (Allocation evidence and history): what actually caused
   the empty gap + forced horizontal scrollbar wasn't the table failing to
   fill its grid cell -- it was two header tooltips (.glossary-term::after,
   "Clearing"/"Clearing status"/"Differences") opening rightward/downward
   by default and overflowing past the table's own edges while invisible,
   inflating the container's scrollable content box (fixed in 6da86c4968 /
   a28ee6d0c9). With that fixed, the table's own `width: 100%` (base
   `.table` rule) fills the column exactly like every sibling section here
   (e.g. Revisions), so this container is intentionally left at its default
   width -- no fit-content/max-width override.

   min-height guards a residual case of the same vertical tooltip issue:
   [data-tip]::after is meant to "hang down into the rows rather than out
   of the container", which assumes the table has enough rows for its
   height to already cover the tooltip's reach. Clearings is commonly 1-2
   rows, short enough that the tooltip's ~107px reach below the header can
   still exceed the container's own content height. A floor tall enough
   for header + tooltip stops that without capping real overflow --
   max-height/overflow-y (from .table-container) still take over once
   enough real rows exceed 400px. */
.banking-clearings-container {
  min-height: 116px;
  overflow-x: auto;
}

.banking-occurrences td,
.banking-history td {
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.banking-occurrences .banking-occurrence-duplicate {
  width: 8.5rem;
  min-width: 7rem;
  font-size: 12px;
}

.bank-duplicate-decision > * {
  display: block;
}

.banking-detail-card > .table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.banking-detail-card > .empty-state {
  font-style: normal;
}

.banking-technical-details > summary {
  width: max-content;
  cursor: pointer;
  color: var(--fg-muted);
  font: var(--text-sm);
  font-weight: 600;
}

.banking-technical-details > summary:hover {
  color: var(--fg);
}

.banking-detail-page > .banking-technical-details {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.banking-technical-details code,
.banking-technical-details pre {
  display: block;
  max-width: 100%;
  margin: var(--space-2) 0 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: var(--text-mono);
}

.banking-review-item > .banking-technical-details {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-muted);
}

.banking-review-item > .banking-technical-details dl {
  display: grid;
  grid-template-columns: minmax(160px, 0.35fr) minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 0;
}

.banking-review-item > .banking-technical-details dt {
  color: var(--fg-muted);
  font: var(--text-label);
}

.banking-review-item > .banking-technical-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.banking-allocation-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.banking-allocation-form > input[type="hidden"] {
  display: none;
}

.banking-allocation-form label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Text fields and selects, not every input: a checkbox given a text field's
   height, padding and border renders as a tall bordered box with a tick
   floating in it. */
.banking-allocation-form input:not([type="checkbox"]):not([type="radio"]):not(.bank-invoice-workbench__candidate-row-amount-input),
.banking-allocation-form select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 5px 32px 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
}

.banking-allocation-form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.banking-allocation-form input:not([type="checkbox"]):not([type="radio"]):focus,
.banking-allocation-form select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.banking-allocation-form textarea {
  width: 100%;
  min-width: 0;
  min-height: 88px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
  resize: vertical;
}

.banking-allocation-form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.banking-allocation-form > ul,
.banking-allocation-form > button {
  grid-column: 1 / -1;
}

.banking-allocation-form > ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.banking-allocation-form > button {
  justify-self: start;
}

.banking-direct-allocation-form {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.banking-direct-allocation-form > h3,
.banking-direct-allocation-form > p {
  grid-column: 1 / -1;
}

.banking-direct-allocation-form > p {
  margin: 0;
  color: var(--fg-muted);
}

.banking-account-assignment-form,
.banking-account-create-form,
.banking-checkpoint-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.banking-account-assignment-form {
  grid-template-columns: minmax(240px, 420px) max-content;
}

.banking-account-assignment-form label,
.banking-account-create-form label,
.banking-checkpoint-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.banking-account-assignment-form select,
.banking-account-create-form input:not([type="checkbox"]),
.banking-account-create-form select,
.banking-checkpoint-form input,
.banking-checkpoint-form select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 5px 32px 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
}

.banking-account-assignment-form select,
.banking-account-create-form select,
.banking-checkpoint-form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.banking-account-assignment-form select:focus,
.banking-account-create-form input:focus,
.banking-account-create-form select:focus,
.banking-checkpoint-form input:focus,
.banking-checkpoint-form select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.banking-account-create-form label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  align-self: center;
  letter-spacing: normal;
  text-transform: none;
}

.banking-account-create-form input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.banking-account-create-form > h3,
.banking-account-create-form > p,
.banking-account-create-form > button {
  grid-column: 1 / -1;
}

.banking-account-create-form > button,
.banking-checkpoint-form > button {
  justify-self: start;
}

.accounting-provenance-values {
  margin: 0;
  padding-left: var(--space-4);
}

.accounting-applications {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-3);
}

.accounting-application {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}

.accounting-application header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.accounting-reversal-effect {
  color: var(--fg-muted);
}

.clearing-equation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: stretch;
}

.equation-equals {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font: 600 20px/1.3 var(--font-sans);
}

.accounting-error {
  max-width: 640px;
  margin: var(--space-7) auto;
  padding: var(--space-5);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.accounting-error > iconify-icon {
  color: var(--danger);
  font-size: 24px;
}

.accounting-error h1 {
  margin: var(--space-2) 0;
  font: var(--text-h2);
}

.accounting-clearing-workflow {
  display: flex;
  max-width: 1040px;
  margin: 0 auto;
  flex-direction: column;
  gap: var(--space-4);
}

.accounting-reason-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--space-1);
}

/* The input and its unit are one control on one line, aligned to each other
   rather than to the grid's baseline. */
.accounting-amount-field {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--space-2);
}

.accounting-amount-field input {
  min-width: 0;
  flex: 1 1 auto;
}

.accounting-amount-field .currency-suffix {
  flex: none;
  font: var(--text-sm);
}

.accounting-field-label {
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.accounting-reason-field textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-body);
}

.accounting-form-help {
  margin: var(--space-2) 0 0;
  color: var(--fg-subtle);
  font: var(--text-sm);
}

.accounting-clearing-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.accounting-proof-digest {
  overflow-wrap: anywhere;
  font: var(--text-mono);
}

.accounting-clearing-unavailable {
  border-color: var(--warning-border);
}

.accounting-clearing-incompatibilities {
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.accounting-clearing-incompatibilities li {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

/* Each refusal reason may name the items it is about; those read as a nested
   block under the sentence rather than as more flex children beside it. */
.accounting-clearing-incompatibilities li {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.accounting-clearing-incompatibilities .accounting-provenance-values {
  margin: 0;
  padding: 0;
  color: var(--fg-muted);
  font: var(--text-sm);
  list-style: none;
}

.accounting-clearing-incompatibilities .accounting-provenance-values li {
  padding: 2px 0;
  border: 0;
}

.accounting-tab:focus-visible,
.accounting-context-link:focus-visible,
.accounting-back-link:focus-visible,
.accounting-filters input:focus-visible,
.accounting-filters select:focus-visible,
.accounting-advanced-filters > summary:focus-visible,
.accounting-detail a:focus-visible,
.accounting-toolbar .pagination-controls a:focus-visible,
.accounting-clearing-workflow a:focus-visible,
.accounting-clearing-workflow button:focus-visible,
.accounting-clearing-workflow input:focus-visible,
.accounting-clearing-workflow select:focus-visible,
.accounting-clearing-workflow textarea:focus-visible,
.accounting-clearing-dialog a:focus-visible,
.accounting-clearing-dialog button:focus-visible,
.accounting-clearing-dialog input:focus-visible,
.accounting-clearing-dialog select:focus-visible,
.accounting-clearing-dialog textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}


/* Manual-clearing dialog
   -----------------------------------------------------------------------------
   Every manual-clearing step (compose, confirm, refuse) renders as one
   `.accounting-dialog-step` swapped into this dialog over the open-item list:
   a fixed header, a scrolling body, and a footer that keeps the decision
   buttons reachable however long the selection is. */

.accounting-clearing-dialog {
  box-sizing: border-box;
  width: min(1040px, calc(100vw - var(--space-6)));
  max-width: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.accounting-clearing-dialog::backdrop {
  background: rgba(28, 24, 19, 0.45);
}

/* Export-to-DATEV dialog
   -----------------------------------------------------------------------------
   A single, non-wizard step, so it reuses the `.accounting-dialog-*` chrome
   classes directly rather than going through `.accounting-clearing-dialog`'s
   step machinery. */
.accounting-export-dialog {
  box-sizing: border-box;
  width: min(520px, calc(100vw - var(--space-6)));
  max-width: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.accounting-export-dialog::backdrop {
  background: rgba(28, 24, 19, 0.45);
}

.accounting-export-dialog .accounting-dialog-body {
  max-height: min(600px, calc(100vh - var(--space-6)));
}

/* Without this, focused controls fall back to Chrome's raw default outline —
   a bare rectangular ring that reads as unstyled next to the app's own
   focus-ring token. Same override `.accounting-clearing-dialog` uses. */
.accounting-export-dialog a:focus-visible,
.accounting-export-dialog button:focus-visible,
.accounting-export-dialog input:focus-visible,
.accounting-export-dialog select:focus-visible,
.accounting-export-dialog textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* The height cap sits on the step rather than on the dialog: Chromium lays
   `::backdrop` out as a child of its originating element, so making the dialog
   itself a flex container turns the backdrop into a flex item inside it and the
   page behind stops being dimmed. The dialog therefore stays a plain block and
   the flex chain that feeds `.accounting-dialog-body`'s scroll starts here. */
.accounting-clearing-dialog-body,
.accounting-dialog-step {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(880px, calc(100vh - var(--space-6)));
}

.accounting-dialog-step {
  flex: 1 1 auto;
  margin: 0;
  gap: 0;
}

.accounting-dialog-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.accounting-dialog-heading {
  flex: 1;
  min-width: 0;
}

/* Sans, like every other heading in the workspace. `--text-h2` is serif and is
   only used by the standalone error page; a serif title here reads as a
   different product from the cards underneath it. */
.accounting-dialog-title {
  margin: 0;
  font: 600 18px/1.3 var(--font-sans);
  color: var(--fg);
}

.accounting-dialog-subtitle {
  margin: var(--space-1) 0 0;
  color: var(--fg-muted);
  font: var(--text-sm);
}

.accounting-dialog-close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  font-size: 16px;
  cursor: pointer;
}

.accounting-dialog-close:hover {
  background: var(--bg-muted);
  color: var(--fg);
}

.accounting-dialog-body {
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  background: var(--surface);
}

.accounting-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* The step supplies the dialog's own scroll and footer, so the cards inside it
   drop the standalone page's spacing and the in-card action row. */
.accounting-dialog-body > .accounting-detail-card {
  margin: 0;
}

.accounting-dialog-body > .accounting-detail-card:first-child > h2 {
  margin-top: 0;
}

.accounting-clearing-source {
  background: var(--brand-tint);
  border-color: var(--brand-border);
}

.accounting-clearing-source-amount {
  margin: var(--space-3) 0 0;
}

.accounting-clearing-dialog .accounting-clearing-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* A refusal is a sentence, not a worksheet: it reads as a compact dialog rather
   than a full-width one with its message stranded in a corner. */
.accounting-clearing-dialog:has(.accounting-clearing-unavailable) {
  width: min(560px, calc(100vw - var(--space-6)));
}

@media (max-width: 900px) {
  .accounting-clearing-dialog,
  .accounting-clearing-dialog:has(.accounting-clearing-unavailable) {
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .accounting-clearing-dialog-body,
  .accounting-dialog-step {
    max-height: 100vh;
    height: 100%;
  }

  .accounting-dialog-header,
  .accounting-dialog-body,
  .accounting-dialog-footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .accounting-dialog-footer {
    flex-wrap: wrap;
  }
}

@media (max-width: 900px) {
  .accounting-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .accounting-filter-actions {
    justify-content: flex-end;
  }

  .clearing-equation {
    grid-template-columns: 1fr;
  }

  .equation-equals {
    min-height: 32px;
  }
}

.bank-invoice-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto auto auto auto;
  column-gap: var(--space-4);
  row-gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--fg);
}

.bank-invoice-workbench__bank,
.bank-invoice-workbench__invoice {
  display: grid;
  min-width: 0;
  grid-row: 1 / 5;
  grid-template-rows: subgrid;
  row-gap: var(--space-3);
}

.bank-invoice-workbench__bank {
  grid-column: 1;
}

.bank-invoice-workbench__invoice {
  grid-column: 2;
}

.bank-invoice-workbench__anchor,
.bank-invoice-workbench__candidates {
  display: grid;
  grid-row: 2 / 5;
  grid-template-rows: subgrid;
  row-gap: var(--space-3);
}

.bank-invoice-workbench__candidates {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

/* Anchor facts size the work row; both documents share the row below it.
   Short screens scroll the page, keeping the complete anchor card visible. */
.bank-invoice-workbench--quadrant,
.bank-invoice-workbench--payment-modes {
  --workbench-page-chrome: 172px;
  --workbench-footer-height: 80px;
  --workbench-control-height: 34px;
  container-type: inline-size;
  /* The work row (anchor card, candidate list) gets half again its natural
     height so more candidates show without scrolling. */
  grid-template-rows: auto minmax(510px, max-content) clamp(520px, 68vh, 1040px) auto auto;
  min-height: max(520px, calc(100dvh - var(--workbench-page-chrome) - var(--elevated-chrome, 0px)));
  height: auto;
  flex-shrink: 0;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__supplemental {
  grid-row: 4;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__footer {
  grid-row: 5;
}

/* The action bar follows the workbench width but stays above the 26px app
   footer, including while the history below the workbench is scrolled.
   Its content sets the height; dropdowns use top-layer popovers. */
.bank-invoice-workbench--quadrant .bank-invoice-workbench__footer,
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__footer {
  position: fixed;
  bottom: calc(26px + var(--space-4));
  width: 100cqw;
  height: auto;
  min-height: var(--workbench-footer-height);
  /* One line of controls sits in the middle of the bar's minimum height. */
  align-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.accounting-open-item-workbench-page:has(.bank-invoice-workbench--payment-modes),
.banking-detail-page:has(.bank-invoice-workbench--quadrant) {
  padding-bottom: calc(var(--space-6) + var(--workbench-footer-space, 80px));
}

/* A control focused or scrolled to never lands behind the fixed action bar. */
main.content:has(.bank-invoice-workbench--quadrant),
.banking-detail-page:has(.bank-invoice-workbench--quadrant) {
  scroll-padding-bottom: calc(26px + var(--space-6) + var(--workbench-footer-space, 80px));
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__control-line,
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__control-line {
  flex-shrink: 0;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__work-cell,
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__work-cell {
  min-width: 0;
  contain: size;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__bank,
.bank-invoice-workbench--quadrant .bank-invoice-workbench__invoice {
  grid-row: 1 / 4;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__anchor,
.bank-invoice-workbench--quadrant .bank-invoice-workbench__candidates {
  display: grid;
  min-height: 0;
  grid-row: 2 / 4;
  grid-template-rows: subgrid;
  row-gap: var(--space-3);
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__anchor-summary,
.bank-invoice-workbench--quadrant .bank-invoice-workbench__work-cell {
  display: flex;
  min-height: 0;
  grid-row: 1;
  flex-direction: column;
  gap: var(--space-3);
  overflow: hidden;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__anchor-summary {
  min-height: max-content;
  overflow: visible;
}

/* A hidden panel stays hidden. The layout rules below give these elements a
   `display`, which outranks the `hidden` attribute; the extra attribute here
   is what puts the attribute back on top, whatever the source order. */
.bank-invoice-workbench [hidden][data-workbench-mode-panel],
.bank-invoice-workbench [hidden][data-workbench-panel],
.bank-invoice-workbench [hidden][data-workbench-suggestions] {
  display: none;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__panels {
  display: grid;
  min-height: 0;
  grid-row: 2;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__anchor > .bank-invoice-workbench__document {
  display: flex;
  min-height: 0;
  grid-row: 2;
  flex-direction: column;
  overflow: hidden;
}

/* Only the inspected candidate is visible, so the panels stack in one cell. */
.bank-invoice-workbench--quadrant .bank-invoice-workbench__panels > * {
  grid-area: 1 / 1;
  min-height: 0;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__candidate {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__candidate > .bank-invoice-workbench__document {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__document iframe,
.bank-invoice-workbench--quadrant .bank-invoice-workbench__document img,
.bank-invoice-workbench--quadrant .bank-invoice-workbench__missing {
  min-height: 0;
  height: auto;
  flex: 1;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__candidate-scroll {
  min-height: 0;
  max-height: none;
  flex: 1;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__work-cell
  > div:not([hidden]):not(.bank-invoice-workbench__control-line) {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
}

/* The rule above already stretches .no-invoice itself to fill .work-cell (it
   is a plain div child, and this compound selector outweighs the `display:
   contents` .no-invoice carries elsewhere — see below). But .no-invoice has
   only the one child below, and an ordinary flex child defaults to sizing
   itself by content rather than filling its now-stretched parent, which is
   why the card stopped short of the candidate list's height. */
.bank-invoice-workbench--quadrant .bank-invoice-workbench__no-invoice
  > .bank-invoice-workbench__candidate-summary {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bank-invoice-workbench--quadrant .bank-invoice-workbench__work-cell
  [data-workbench-suggestions]:not([hidden]),
.bank-invoice-workbench--quadrant .bank-invoice-workbench__work-cell
  [data-workbench-search-results]:not([hidden]) {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
}

/* The anchor's own document is the bank quadrant, so it no longer needs the
   spacer that used to line the anchor up with the invoice column's tabs. */
.bank-invoice-workbench--quadrant .bank-invoice-workbench__tabs-spacer {
  display: none;
}

.bank-invoice-workbench__candidate-row[hidden] {
  display: none;
}

.bank-invoice-workbench__tabs-spacer,
.bank-invoice-workbench__tabs {
  grid-row: 1;
}

.bank-invoice-workbench:not(.bank-invoice-workbench--quadrant):not(.bank-invoice-workbench--payment-modes):has([data-workbench-search-controls])
  .bank-invoice-workbench__anchor {
  display: flex;
  flex-direction: column;
  align-self: start;
  width: 100%;
  box-sizing: border-box;
  gap: var(--space-3);
}

/* The list is where the work happens, so it takes the height the documents no
   longer hold, and grows with the viewport rather than staying at six rows. */
.bank-invoice-workbench__candidate-scroll {
  max-height: clamp(300px, 40vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bank-invoice-workbench__candidate-tools {
  display: grid;
  grid-row: 1;
  gap: var(--space-3);
  min-width: 0;
}

/* The results list is a grid item of the tools above and takes their gap; the
   candidate list and its empty state sit in a sibling wrapper that has none of
   its own. Both need the same distance from the search bar, or whichever one
   the query happens to produce looks attached to it. */
.bank-invoice-workbench__candidate-tools ~ [data-workbench-suggestions] {
  margin-top: var(--space-3);
}

/* The candidate list is a ledger table: one line per candidate, amounts in a
   column, and the allocation field inside the row rather than beside it. */
/* Fixed layout so the reference column absorbs the remainder and truncates,
   rather than the table growing past its own quadrant on a narrow screen. */
.bank-invoice-workbench__candidate-list {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 0;
}

.bank-invoice-workbench__candidate-list th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px var(--space-2);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--fg-subtle);
  font: var(--text-caption);
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.bank-invoice-workbench__candidate-list td {
  padding: 6px var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.bank-invoice-workbench__candidate-list tbody tr:last-child td {
  border-bottom: 0;
}

.bank-invoice-workbench__candidate-list tbody tr:hover {
  background: var(--bg-subtle);
}

.bank-invoice-workbench__candidate-list tbody tr:has([data-workbench-row-select]:checked) {
  background: var(--brand-tint);
}

.bank-invoice-workbench__column-select { width: 30px; }
.bank-invoice-workbench__column-due { width: 92px; }
.bank-invoice-workbench__column-why { width: 96px; }
.bank-invoice-workbench__column-open { width: 104px; text-align: right; }
.bank-invoice-workbench__column-allocate { width: 132px; text-align: right; }

/* The ledger reads as one object: an outer rule around the whole table, with the
   sticky header and the last row meeting it cleanly. */
.bank-invoice-workbench__candidate-scroll {
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* Below this width the fixed columns leave the reference too little to show,
   so the date and reason move beneath it while the amount and allocation keep
   the right edge; narrower still, the allocation drops under the amount too.
   The header no longer sits above anything, so a bare date carries its own
   label. */
@container (max-width: 620px) {
  .bank-invoice-workbench__candidate-list,
  .bank-invoice-workbench__candidate-list tbody,
  .bank-invoice-workbench__candidate-list tr,
  .bank-invoice-workbench__candidate-list td {
    display: block;
  }

  .bank-invoice-workbench__candidate-list thead {
    display: none;
  }

  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__candidate-row-wrap:not([hidden]),
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__blocked-row {
    display: grid;
    grid-template-areas:
      "select reference reference open allocate"
      "select due       why       open allocate";
    grid-template-columns: 22px auto 1fr auto auto;
    align-items: center;
    gap: var(--space-1) var(--space-2);
    padding: var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
  }

  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__candidate-row-wrap:last-child,
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__blocked-row:last-child {
    border-bottom: 0;
  }

  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__blocked-row {
    background: var(--bg-subtle);
  }

  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__candidate-row-wrap td,
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__blocked-row td {
    width: auto;
    padding: 0;
    border-bottom: 0;
    background: none;
  }

  .bank-invoice-workbench__column-select { grid-area: select; align-self: start; margin-top: 2px; }
  .bank-invoice-workbench__column-reference { grid-area: reference; min-width: 0; }
  .bank-invoice-workbench__column-due { grid-area: due; }
  .bank-invoice-workbench__column-why { grid-area: why; }
  .bank-invoice-workbench__column-open { grid-area: open; align-self: start; }
  .bank-invoice-workbench__column-allocate { grid-area: allocate; align-self: start; }

  .bank-invoice-workbench__column-due[data-label]::before {
    content: attr(data-label) " ";
    color: var(--fg-faint);
  }
}

@container (max-width: 460px) {
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__candidate-row-wrap:not([hidden]),
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__blocked-row {
    grid-template-areas:
      "select reference reference reference open"
      "select due       why       .         allocate";
    grid-template-columns: 22px auto auto minmax(0, 1fr) auto;
  }

  .bank-invoice-workbench__column-allocate { align-self: center; }
}

@container (max-width: 340px) {
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__candidate-row-wrap:not([hidden]),
  .bank-invoice-workbench__candidate-list .bank-invoice-workbench__blocked-row {
    grid-template-areas:
      "select reference reference"
      "select due       why"
      "select open      allocate";
    grid-template-columns: 22px auto minmax(0, 1fr);
  }

  .bank-invoice-workbench__column-open { text-align: left; }
  .bank-invoice-workbench__column-allocate { justify-self: end; }
}

/* The reference cell is the row's own button: clicking it opens the candidate's
   document below, which is the only thing the panel still holds. */
.bank-invoice-workbench__candidate-row {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.bank-invoice-workbench__candidate-row:hover .bank-invoice-workbench__candidate-row-title strong,
.bank-invoice-workbench__candidate-row[aria-pressed="true"] .bank-invoice-workbench__candidate-row-title strong {
  color: var(--brand-pressed);
  text-decoration: underline;
}

/* Unmatch beside a transaction's View clearing reads as one more link. */
.bank-invoice-workbench__fact-action.btn-link {
  padding: 0;
  color: var(--brand);
  font: inherit;
  cursor: pointer;
}

.bank-invoice-workbench__fact-action.btn-link:hover {
  color: var(--brand-pressed);
}

/* A row whose number opens its invoice: the link and the preview button are
   siblings, laid over one grid so the number still leads the button's type
   chip and party line as it does inside a plain row's button. */
.bank-invoice-workbench__candidate-reference {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  column-gap: var(--space-2);
  align-items: baseline;
}

.bank-invoice-workbench__candidate-row-link {
  position: relative;
  z-index: 1;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__candidate-reference > .bank-invoice-workbench__candidate-row {
  display: grid;
  grid-column: 1 / -1;
  grid-row: 1 / span 3;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
  align-items: baseline;
}

.bank-invoice-workbench__candidate-reference > .bank-invoice-workbench__candidate-row > * {
  grid-column: 1 / -1;
}

.bank-invoice-workbench__candidate-reference > .bank-invoice-workbench__candidate-row > .bank-invoice-workbench__candidate-row-title {
  grid-column: 2;
  grid-row: 1;
}

.bank-invoice-workbench__candidate-row-link:hover,
.bank-invoice-workbench__candidate-row-link:focus-visible,
.bank-invoice-workbench__candidate-reference:has(> .bank-invoice-workbench__candidate-row:hover) .bank-invoice-workbench__candidate-row-link,
.bank-invoice-workbench__candidate-reference:has(> .bank-invoice-workbench__candidate-row[aria-pressed="true"]) .bank-invoice-workbench__candidate-row-link {
  color: var(--brand-pressed);
  text-decoration: underline;
}

.bank-invoice-workbench__candidate-row-wrap--removed .bank-invoice-workbench__candidate-row-link {
  color: var(--fg-muted);
}

.bank-invoice-workbench__candidate-row-party {
  display: block;
  overflow: hidden;
  color: var(--fg-subtle);
  font: var(--text-caption);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__payee-badge {
  margin-top: 4px;
  padding: 1px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.bank-invoice-workbench__candidate-evidence,
.bank-invoice-workbench__candidate-conflicts {
  margin-top: var(--space-1);
  font: var(--text-caption);
  white-space: normal;
  overflow-wrap: anywhere;
}

.bank-invoice-workbench__candidate-evidence summary {
  color: var(--fg-subtle);
  cursor: pointer;
}

.bank-invoice-workbench__candidate-conflicts {
  color: var(--warning-strong);
}

.bank-invoice-workbench__candidate-evidence ul,
.bank-invoice-workbench__candidate-conflicts ul {
  margin: var(--space-1) 0;
  padding-left: var(--space-4);
}

.bank-invoice-workbench__candidate-row-amount {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Why a candidate is here, in one word. The sentence is the chip's title. */
.bank-invoice-workbench__why {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  font: var(--text-caption);
  white-space: nowrap;
}

/* A blocked or waiting row is evidence, not an option: the chip stays quiet so
   it never competes with a reason a candidate is actually proposable. */
.bank-invoice-workbench__why--blocked,
.bank-invoice-workbench__why--waiting {
  background: var(--bg-muted);
  color: var(--fg-muted);
}

/* A search result's status runs to a few words, so its chip wraps inside the
   column rather than spilling over the amount beside it. */
.bank-invoice-workbench__column-why .bank-invoice-workbench__why {
  max-width: 100%;
  white-space: normal;
}

/* Why a result cannot be matched is the one sentence worth reading in full,
   so it wraps where the reference and party truncate. */
.bank-invoice-workbench__candidate-row-guidance {
  display: block;
  margin-top: 2px;
  color: var(--fg-subtle);
  font: var(--text-caption);
}

.bank-invoice-workbench__blocked-heading td {
  padding-top: var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--fg-subtle);
  font: var(--text-caption);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bank-invoice-workbench__blocked-heading iconify-icon {
  margin-right: var(--space-1);
  vertical-align: -2px;
}

/* Nothing here can be matched, so the whole row recedes: the reference is still
   a link, because opening it is the one thing worth doing. The row reads as
   greyed at a glance — never as a candidate somebody overlooked. */
.bank-invoice-workbench__blocked-row td {
  padding: 6px var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  vertical-align: middle;
}

.bank-invoice-workbench__blocked-row .bank-invoice-workbench__candidate-row-title strong,
.bank-invoice-workbench__blocked-row .bank-invoice-workbench__candidate-row-amount,
.bank-invoice-workbench__blocked-row .bank-invoice-workbench__candidate-row-party,
.bank-invoice-workbench__blocked-row .bank-invoice-workbench__candidate-row-date {
  color: var(--fg-faint);
  font-weight: 400;
}

.bank-invoice-workbench__blocked-row .bank-invoice-workbench__item-type {
  color: var(--fg-faint);
  opacity: 0.7;
}

.bank-invoice-workbench__blocked-row:hover .bank-invoice-workbench__candidate-row-title strong {
  color: var(--brand-pressed);
  text-decoration: underline;
}

.bank-invoice-workbench__blocked-row a.bank-invoice-workbench__candidate-row {
  display: block;
  text-decoration: none;
}

.bank-invoice-workbench__why--party { background: var(--success-tint); color: var(--success-strong); }
.bank-invoice-workbench__why--reference,
.bank-invoice-workbench__why--exact { background: var(--info-tint); color: var(--azure-600); }
.bank-invoice-workbench__why--date { background: var(--warning-tint); color: var(--warning-strong); }
.bank-invoice-workbench__why--history,
.bank-invoice-workbench__why--linked { background: var(--accent-violet-tint); color: var(--accent-violet); }
.bank-invoice-workbench__why--amount,
.bank-invoice-workbench__why--other { background: var(--bg-muted); color: var(--fg-muted); }
.bank-invoice-workbench__why--included { background: var(--brand); color: var(--fg-on-brand); }
.bank-invoice-workbench__why--included.bank-invoice-workbench__why--removing {
  background: var(--warning-tint);
  color: var(--warning-strong);
}
.bank-invoice-workbench__why--removed { background: var(--bg-muted); color: var(--fg-muted); }

/* A pairing a person removed stays listed, muted, with who removed it. */
.bank-invoice-workbench__candidate-row-wrap--removed .bank-invoice-workbench__candidate-row-title strong,
.bank-invoice-workbench__candidate-row-wrap--removed .bank-invoice-workbench__candidate-row-amount {
  color: var(--fg-muted);
}
.bank-invoice-workbench__rejection {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin-top: 2px;
  color: var(--fg-muted);
  font: var(--text-caption);
}
.bank-invoice-workbench__rejection iconify-icon { flex: none; margin-top: 2px; }
.bank-invoice-workbench__rejection > span { display: flex; flex-direction: column; gap: 1px; }
.bank-invoice-workbench__rejection-reason { font-style: italic; }
.bank-invoice-workbench__rejection-review {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.bank-invoice-workbench__rejection-review:hover { text-decoration: underline; }
.bank-invoice-workbench__row-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 2px 0 0;
  font: var(--text-caption);
}
.bank-invoice-workbench__unmatch-state { color: var(--danger-strong); }
/* Keep match and Remove match… share one band, centred on the footer row: the
   struck adjustment cells make that row taller than the buttons. */
.bank-invoice-workbench__unmatch-actions {
  display: flex;
  flex-shrink: 0;
  align-self: center;
  gap: var(--space-2);
  margin-left: auto;
}
.bank-invoice-workbench__unmatch-actions[hidden] { display: none; }
.bank-invoice-workbench__unmatch-actions > .btn {
  min-width: 132px;
  justify-content: center;
}
.bank-invoice-workbench__optional {
  color: var(--fg-muted);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.bank-invoice-workbench__candidate-row-selected {
  grid-column: 2 / -1;
  color: var(--success-strong);
}

/* The candidate row's own include checkbox and allocation field, so several
   items can be assembled into one match without opening each panel. */
.bank-invoice-workbench__candidate-row-wrap[hidden] {
  display: none;
}

.bank-invoice-workbench__candidate-row-select {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.bank-invoice-workbench__candidate-row-allocate {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

.bank-invoice-workbench__candidate-row-amount-input {
  width: 92px;
  height: 34px;
  padding: 5px var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-mono);
  text-align: right;
}

/* No stepper on a money field: nobody nudges an allocation penny by penny, and
   the reserved box held the digits off the right edge they are aligned to. */
.bank-invoice-workbench__candidate-row-amount-input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.bank-invoice-workbench__candidate-row-amount-input::-webkit-inner-spin-button,
.bank-invoice-workbench__candidate-row-amount-input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

/* A row that is not in the match reads as inert: no fill, a hairline border
   and faint digits, rather than a sand-filled field that still looks active. */
.bank-invoice-workbench__candidate-row-amount-input:disabled {
  border-color: var(--border-subtle);
  background: transparent;
  color: var(--fg-faint);
}

.bank-invoice-workbench__candidate-row-currency {
  color: var(--fg-muted);
  font: var(--text-caption);
}

.bank-invoice-workbench__candidate-row-date {
  font-variant-numeric: tabular-nums;
}

/* Search amounts include a currency; wrap it at the space while keeping the
   number intact and clear of the adjacent allocation input. */
[data-workbench-search-row] .bank-invoice-workbench__candidate-row-amount {
  display: block;
  max-width: 100%;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
}

/* The original amount behind a search result's open one — context, not the
   figure the column is about, so it recedes the same way a currency code
   does next to the amount it belongs to. */
.bank-invoice-workbench__search-result-total {
  display: block;
  color: var(--fg-muted);
  font: var(--text-caption);
}

.bank-invoice-workbench__candidate-row-inspect {
  color: var(--brand);
  font: var(--text-caption);
  white-space: nowrap;
}

.bank-invoice-workbench__candidate-row-title {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: var(--space-2);
}

.bank-invoice-workbench__candidate-row-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__candidate-row-title .bank-invoice-workbench__item-type {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: var(--text-caption);
  white-space: nowrap;
}

/* The running ledger in the footer: what is being settled, what is allocated,
   what is left. */
.bank-invoice-workbench__ledger {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-right: auto;
}

/* Each cell reserves its width so a changing figure never resizes the bar. */
.bank-invoice-workbench__ledger-cell {
  min-width: 112px;
  margin-right: var(--space-4);
  padding-right: var(--space-4);
  border-right: 1px solid var(--border-subtle);
}

.bank-invoice-workbench__ledger-cell:last-child {
  margin-right: 0;
  padding-right: 0;
  border-right: 0;
}

.bank-invoice-workbench__ledger-cell span {
  display: block;
  color: var(--fg-subtle);
  font: var(--text-caption);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bank-invoice-workbench__ledger-cell strong {
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.bank-invoice-workbench__ledger-cell--remaining strong {
  color: var(--warning-strong);
}

.bank-invoice-workbench__secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.bank-invoice-workbench__secondary-actions[hidden] {
  display: none;
}

/* The transaction's history stays collapsed: what is settled now sits on the
   workbench's transaction card. */
.banking-history > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  list-style: none;
}

.banking-history > summary::-webkit-details-marker {
  display: none;
}

.banking-history > summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--fg-muted);
  border-bottom: 2px solid var(--fg-muted);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}

.banking-history[open] > summary::before {
  transform: rotate(45deg);
}

.banking-history > summary h2 {
  margin: 0;
  font: var(--text-h3);
}

/* The match workbench is the transaction page itself, not a card on it. */
.banking-allocation-workspace {
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.banking-allocation-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-3);
}

.banking-history .banking-history-list {
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

/* An anchor card leads with its reference and two equal figures, Amount and
   Open; the status sits as a pill beside the heading, never beside a figure. */
.bank-invoice-workbench__anchor-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font: 600 20px/1.3 var(--font-sans);
  overflow-wrap: anywhere;
}

.bank-invoice-workbench__item-type .bank-invoice-workbench__heading-pill,
.bank-invoice-workbench__anchor-title .bank-invoice-workbench__heading-pill {
  margin-left: var(--space-2);
  font: var(--text-caption);
  letter-spacing: normal;
  text-transform: none;
  vertical-align: middle;
}

.bank-invoice-workbench__heading-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-left: var(--space-2);
  font-family: var(--font-sans);
  vertical-align: middle;
}

.bank-invoice-workbench__heading-pills .badge {
  font-family: var(--font-sans);
}

.bank-invoice-workbench__heading-pills .bank-invoice-workbench__heading-pill {
  margin-left: 0;
}

.bank-invoice-workbench__anchor-party {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.bank-invoice-workbench__anchor-party span {
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

.bank-invoice-workbench__anchor-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
}

.bank-invoice-workbench__anchor-figures dt {
  color: var(--fg-subtle);
  font: var(--text-caption);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bank-invoice-workbench__anchor-figures dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Skonto, write-offs and the other adjustments are ledger cells of their own
   between Allocated and Open; the wrapper only groups them for the script. */
.bank-invoice-workbench__adjustments {
  display: contents;
}

.bank-invoice-workbench__adjustments > .bank-invoice-workbench__ledger-cell:last-child {
  margin-right: var(--space-4);
  padding-right: var(--space-4);
  border-right: 1px solid var(--border-subtle);
}

.bank-invoice-workbench__adjustment-cell span:first-child {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__adjustment-value {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.bank-invoice-workbench__adjustment-value .bank-invoice-workbench__adjustment-remove { margin-left: var(--space-1); }

.bank-invoice-workbench__adjustment-edit {
  padding: 0 2px;
  border: 0;
  border-bottom: 1px dashed currentColor;
  background: none;
  color: var(--fg);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.bank-invoice-workbench__adjustment-cell--skonto .bank-invoice-workbench__adjustment-edit {
  color: var(--success-strong);
}

.bank-invoice-workbench__adjustment-cell--other .bank-invoice-workbench__adjustment-edit {
  color: var(--warning-strong);
}

.bank-invoice-workbench__adjustment-cell--reversed s {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.bank-invoice-workbench__adjustment-cell--reversed small {
  color: var(--danger-strong);
  font: var(--text-caption);
}

/* A plain X, like the app's other icon buttons, with a 28px hit area. */
.bank-invoice-workbench__adjustment-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 16px;
}

.bank-invoice-workbench__adjustment-remove:hover {
  background: var(--bg-muted);
  color: var(--fg);
}

.bank-invoice-workbench__adjustment-edit:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.bank-invoice-workbench__add-adjustment {
  display: flex;
  align-items: center;
}

.bank-invoice-workbench__add-adjustment-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px dashed var(--brand-border);
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--brand);
  cursor: pointer;
  font: var(--text-label);
  white-space: nowrap;
}

.bank-invoice-workbench__add-adjustment-button[hidden] {
  display: none;
}

.bank-invoice-workbench__add-adjustment-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.bank-invoice-workbench__adjustment-edit:focus-visible,
.bank-invoice-workbench__adjustment-remove:focus-visible,
.bank-invoice-workbench__add-adjustment-button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* In the top layer, so the footer's own clipping never cuts it off and it
   never widens the page. */
.bank-invoice-workbench__adjustment-popover[popover] {
  position: fixed;
  inset: auto;
  box-sizing: border-box;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--fg);
}

.bank-invoice-workbench__adjustment-popover:popover-open {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.bank-invoice-workbench__popover-title {
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bank-invoice-workbench__popover-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bank-invoice-workbench__popover-list button {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--fg);
  cursor: pointer;
  font: var(--text-body);
  text-align: left;
}

.bank-invoice-workbench__popover-list button:hover:not(:disabled) {
  background: var(--bg-hover);
}

.bank-invoice-workbench__popover-list button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.bank-invoice-workbench__popover-list small {
  color: var(--fg-muted);
  font: var(--text-caption);
  text-align: right;
}

.bank-invoice-workbench__popover-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__popover-field .form-input,
.bank-invoice-workbench__popover-field .form-select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.bank-invoice-workbench__popover-field [data-adjustment-field="amount"] {
  font-family: var(--font-mono);
  text-align: right;
}

/* The amount carries its currency, as the candidate rows' Allocate does. */
.bank-invoice-workbench__popover-amount {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bank-invoice-workbench__popover-amount .form-input {
  flex: 1;
}

/* The account search opens its list like a select, with the app's chevron
   in place of the browser's list marker (still clickable beneath it). */
.bank-invoice-workbench__popover-field input[data-adjustment-field="account"] {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.bank-invoice-workbench__popover-field input[data-adjustment-field="account"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  cursor: pointer;
}

.bank-invoice-workbench__popover-note,
.bank-invoice-workbench__popover-error,
.bank-invoice-workbench__popover-warning {
  margin: 0;
  font: var(--text-caption);
}

.bank-invoice-workbench__popover-note {
  color: var(--fg-muted);
}

.bank-invoice-workbench__popover-warning {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.bank-invoice-workbench__popover-error {
  color: var(--danger-strong);
}

.bank-invoice-workbench__popover-error[hidden] {
  display: none;
}

/* Qualified by the popover so it outranks `.banking-allocation-form label`,
   whose stacked, uppercase field label would put the box on its own row. */
.bank-invoice-workbench__adjustment-popover .bank-invoice-workbench__popover-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  color: var(--fg);
  font: var(--text-caption);
  letter-spacing: normal;
  text-transform: none;
}

.bank-invoice-workbench__popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.bank-invoice-workbench__ledger-cell--remaining.is-zero strong {
  color: var(--success);
}

/* The panel's own summary is gone: its facts are on the candidate row. What
   remains is the form's real select and amount inputs, which the row controls
   proxy, kept in the DOM and out of sight. */
.bank-invoice-workbench__candidate-controls {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Usually every status in here is hidden. Let the region collapse to nothing
   in that case rather than reserve room that pushes the footer onto a second
   line, where it grows tall enough to cover the rows behind it. */
.bank-invoice-workbench__comparison-status-region {
  min-width: 0;
  flex: 1 1 0;
}

@media (min-width: 801px) {
  .bank-invoice-workbench__comparison-status-region:has([data-workbench-party-warning]:not([hidden])) {
    flex-basis: 240px;
  }
}

.bank-invoice-workbench__footer .bank-invoice-workbench__difference {
  flex: 0 0 auto;
}

.bank-invoice-workbench__remainder {
  flex: 0 1 auto;
  width: 420px;
  max-width: 100%;
  min-width: 0;
}

.bank-invoice-workbench__remainder-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.bank-invoice-workbench__remainder-fields label {
  display: flex;
  flex: 1 1 160px;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__remainder-fields select {
  width: 100%;
  min-width: 0;
  min-height: var(--workbench-control-height, 40px);
  padding: 0 32px 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  color: var(--fg);
  font: var(--text-body);
  appearance: none;
  -webkit-appearance: none;
}

.bank-invoice-workbench__remainder-fields select:hover:not(:disabled) {
  border-color: var(--brand);
}

.bank-invoice-workbench__remainder-fields select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.bank-invoice-workbench__remainder p {
  margin: var(--space-1) 0 0;
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__remainder[hidden],
.bank-invoice-workbench__remainder-fields [hidden] {
  display: none;
}

.bank-invoice-workbench__footer .bank-invoice-workbench__difference-amount {
  width: 110px;
  min-width: 110px;
}

/* The selects hold a stable width at any given viewport, but may narrow rather
   than push the footer onto a second line: a wrapped sticky footer grows tall
   enough to cover the rows behind it. */
.bank-invoice-workbench__footer .bank-invoice-workbench__difference-fields {
  flex: 0 1 auto;
  grid-template-columns: repeat(2, minmax(148px, 200px));
}

.bank-invoice-workbench__footer > .btn {
  min-width: 132px;
  flex-shrink: 0;
  align-self: flex-end;
  justify-content: center;
}

/* With remainder or difference controls showing, every band lines up on one
   label row and one control row: the helper note below the remainder select
   no longer lifts that select, and Match sits on the control row. */
@media (min-width: 801px) {
  .bank-invoice-workbench__footer:has(> .bank-invoice-workbench__remainder:not([hidden]),
                                      > .bank-invoice-workbench__difference:not([hidden])) {
    align-items: flex-start;
  }

  .bank-invoice-workbench__footer:has(> .bank-invoice-workbench__remainder:not([hidden]),
                                      > .bank-invoice-workbench__difference:not([hidden])) > .btn {
    min-height: var(--workbench-control-height);
    align-self: flex-start;
    margin-top: calc(12px * 1.4 + var(--space-1));
  }

  .bank-invoice-workbench__footer .bank-invoice-workbench__difference {
    align-items: flex-start;
  }

  /* Reason and Account need the room: the remainder band narrows so Match
     stays on the control row, and a Match that still wraps keeps to the
     right edge rather than starting a new row on the left. */
  .bank-invoice-workbench__footer:has(> .bank-invoice-workbench__difference:not([hidden]))
    > .bank-invoice-workbench__remainder {
    width: 260px;
  }

  .bank-invoice-workbench__footer > .btn {
    margin-left: auto;
  }
}

/* A long account name truncates rather than wrapping, so choosing one does not
   change the bar's height either. */
.bank-invoice-workbench__footer [data-workbench-dropup-label] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .bank-invoice-workbench__ledger-cell {
    min-width: 96px;
    margin-right: var(--space-3);
    padding-right: var(--space-3);
  }
}

.bank-invoice-workbench__included-list,
.bank-invoice-workbench__suggestions-pagination,
.bank-invoice-workbench__search-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bank-invoice-workbench__included-list[hidden],
.bank-invoice-workbench__suggestions-pagination[hidden],
.bank-invoice-workbench__search-pagination[hidden] {
  display: none;
}

.bank-invoice-workbench__included-list {
  flex-wrap: wrap;
  padding: var(--space-1) 0;
}

.bank-invoice-workbench__included-list > .btn {
  min-width: 0;
  max-width: min(200px, 100%);
}

.bank-invoice-workbench__included-list > .btn > iconify-icon {
  flex-shrink: 0;
}

.bank-invoice-workbench__included-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__suggestions-pagination,
.bank-invoice-workbench__search-pagination {
  justify-content: space-between;
}

.bank-invoice-workbench__candidate-amount,
.bank-invoice-workbench__candidate-submit-fields {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The empty state is a row of the table, so it inherits its frame instead of
   drawing a second one under an empty header. */
.bank-invoice-workbench__candidate-empty-row td {
  padding: var(--space-5);
  border-bottom: 0;
  color: var(--fg-muted);
  text-align: center;
}

.bank-invoice-workbench__candidate-empty-row strong {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--fg);
}

.bank-invoice-workbench__candidate-empty-row p {
  margin: 0 auto var(--space-1);
  max-width: 46ch;
}

.bank-invoice-workbench__candidate-empty {
  display: grid;
  grid-row: 2 / 4;
  place-items: start center;
  min-height: 260px;
  padding: var(--space-5);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  text-align: center;
}

.bank-invoice-workbench__tabs-spacer {
  min-height: 38px;
}

.bank-invoice-workbench__anchor-summary {
  grid-row: 2;
}

.bank-invoice-workbench__anchor > .bank-invoice-workbench__document {
  grid-row: 3;
}

.bank-invoice-workbench__side-label,
.bank-invoice-workbench__document-header,
.bank-invoice-workbench__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.bank-invoice-workbench__side-label {
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Which side is the bank and which the invoice is the first thing a person
   reads, so the side's name is set larger than the pill beside it. */
.bank-invoice-workbench__side-label > span:first-child {
  color: var(--fg);
  font: 600 15px/1.3 var(--font-sans);
  letter-spacing: 0.05em;
}

.bank-invoice-workbench__side-label span:last-child {
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--brand-tint);
  color: var(--brand-pressed);
  font: var(--text-caption);
}

.bank-invoice-workbench__side-label--anchor span:last-child {
  background: var(--brand);
  color: var(--fg-on-brand);
}

.bank-invoice-workbench__search-candidate > .bank-invoice-workbench__search-help {
  grid-row: 4;
}

.bank-invoice-workbench__search-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.bank-invoice-workbench__search-input {
  flex: 1;
}

.bank-invoice-workbench__search-input input {
  width: 100%;
  height: 34px;
  box-sizing: border-box;
}

/* The search box sits on the same line as the settlement/mode tabs, so the
   brand-colored focus ring .banking-allocation-form gives every other field
   reads as competing with them for attention. Focusing it looks the same as
   not -- !important because that form-wide rule's two :not() clauses give it
   more specificity than a selector scoped this narrowly can match without
   repeating them. */
.bank-invoice-workbench__search-input input:focus {
  border-color: var(--border-strong) !important;
  outline: none !important;
  box-shadow: none !important;
}

.bank-invoice-workbench__search-bar > [data-workbench-filter-toggle] {
  height: 34px;
  box-sizing: border-box;
}

.bank-invoice-workbench__filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}

/* A popover, positioned by the delegated `beforetoggle` listener
   (bank-invoice-workbench.js) rather than by inset/margin: those default to
   centering it in the viewport, which is right for a dialog but not for a
   panel that belongs next to the button that opened it. */
.bank-invoice-workbench__filters[popover] {
  position: fixed;
  inset: auto;
  margin: 0;
  box-shadow: var(--shadow-popover);
}

/* [popover] elements are UA-hidden by default via `[popover]:not(:popover-
   open) { display: none !important }`, which should already beat the plain
   `display: grid` above -- but this panel stayed visible, `display: grid`,
   after closing in testing regardless, so it is said again here rather than
   trusted to that rule alone. */
.bank-invoice-workbench__filters[popover]:not(:popover-open) {
  display: none;
}

.bank-invoice-workbench__filters label[hidden] {
  display: none;
}

.bank-invoice-workbench__filters label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg);
  font: var(--text-label);
}

.bank-invoice-workbench__filters .bank-invoice-workbench__filter-checkbox {
  flex-direction: row;
  align-items: center;
  align-self: end;
  gap: var(--space-2);
}

.bank-invoice-workbench__filter-checkbox input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
}

.bank-invoice-workbench__filter-checkbox span {
  text-transform: none;
  letter-spacing: normal;
}

.bank-invoice-workbench__candidates:has([data-workbench-search-controls]) .bank-invoice-workbench__candidate-empty {
  min-height: 80px;
  align-items: center;
  padding: var(--space-3);
}

.bank-invoice-workbench__filters select,
.bank-invoice-workbench__filters input {
  width: 100%;
  height: 34px;
  box-sizing: border-box;
  min-width: 0;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
}

.bank-invoice-workbench__filters select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.bank-invoice-workbench__filters input[type="number"] {
  padding-right: 4px;
  -webkit-appearance: auto;
  appearance: auto;
}

.bank-invoice-workbench__filters input[type="number"]::-webkit-inner-spin-button,
.bank-invoice-workbench__filters input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  opacity: 1;
}

.bank-invoice-workbench__filter-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: var(--space-1);
}

.bank-invoice-workbench__search label,
.bank-invoice-workbench__search-selection,
.bank-invoice-workbench__search-help {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* A class-level `display` outranks the user agent's `[hidden]`, so the
   attribute needs saying again here to hide the help before a search. */
.bank-invoice-workbench__search-help[hidden] {
  display: none;
}

/* Fills [data-workbench-search-results] (the toggled container) the same way
   [data-workbench-suggestions] fills its own -- .candidate-scroll inside
   either one takes it from there with its own flex:1 and scroll. */
.bank-invoice-workbench__search-results {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
}

.bank-invoice-workbench__search-result--unavailable .bank-invoice-workbench__candidate-row {
  opacity: 0.65;
}

.bank-invoice-workbench__search-help {
  margin: 0;
}

.bank-invoice-workbench__search-help span {
  color: var(--fg-muted);
  font: var(--text-caption);
}

.bank-invoice-workbench__search-selection[hidden] {
  display: none;
}

.bank-invoice-workbench__search-selection {
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.bank-invoice-workbench__search-selection > .btn {
  align-self: flex-start;
}

.bank-invoice-workbench__anchor-summary,
.bank-invoice-workbench__candidate-summary {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--fg);
}

.bank-invoice-workbench__anchor-summary {
  grid-template-rows: max-content max-content 1fr;
}

.bank-invoice-workbench__candidate-summary:not(.bank-invoice-workbench__search) {
  grid-template-rows: max-content max-content max-content max-content 1fr;
}

.bank-invoice-workbench__search {
  display: flex;
  flex-direction: column;
}

input.bank-invoice-workbench__native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.bank-invoice-workbench__primary-amount {
  font: var(--text-h1);
}

/* The title keeps its own width and the reference takes what is left, so a long
   unbreakable reference truncates instead of running under the title. */
.bank-invoice-workbench__summary-heading {
  display: grid;
  min-width: 0;
  min-height: 36px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: var(--space-3);
}

.bank-invoice-workbench__summary-amount {
  display: flex;
  min-height: 38px;
  align-items: center;
}

.bank-invoice-workbench__item-type,
.bank-invoice-workbench__item-identifier {
  margin: 0;
}

.bank-invoice-workbench__item-type {
  color: var(--fg);
  font: 600 20px/1.3 var(--font-sans);
}

.bank-invoice-workbench__item-identifier {
  max-width: 100%;
  overflow: hidden;
  color: var(--fg-muted);
  font: var(--text-body);
  font-weight: 600;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__selection-label,
.bank-invoice-workbench__selection-value {
  margin: 0;
}

.bank-invoice-workbench__selection-label {
  color: var(--fg-muted);
  font: var(--text-body);
}

.bank-invoice-workbench__selection-value {
  max-width: 100%;
  overflow: hidden;
  color: var(--fg);
  font: var(--text-body);
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h3.bank-invoice-workbench__panel-heading {
  margin: 0;
  color: var(--fg);
  font: 600 20px/1.3 var(--font-sans);
  text-transform: none;
  letter-spacing: normal;
}

.bank-invoice-workbench__selection-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
}

.bank-invoice-workbench__selection-actions > .btn {
  align-self: flex-end;
}

.bank-invoice-workbench__amount-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Rewritten by the workbench script as the selection changes. */
.bank-invoice-workbench__live-remainder {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bank-invoice-workbench__allocation-status {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font: var(--text-caption);
  font-weight: 600;
}

.bank-invoice-workbench__facts {
  display: grid;
  margin: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.bank-invoice-workbench__facts div {
  min-width: 0;
}

.bank-invoice-workbench__facts dt {
  color: var(--fg-muted);
  font: var(--text-caption);
}

.bank-invoice-workbench__facts dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--fg);
}

.bank-invoice-workbench__tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  padding-bottom: 2px;
}

.bank-invoice-workbench__tab {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-1);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg);
  cursor: pointer;
}

.bank-invoice-workbench__tab[aria-selected="true"] {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-pressed);
}

/* Stacks something above the ordinary per-candidate tabs row within the
   same grid cell those tabs alone would otherwise occupy — either the
   first-order Match invoice/No invoice switch (same visual language as the
   AP open-item workbench's settlement-method switch,
   .external-payment-tabs / .settlement-mode, so the two genuinely
   different-mode switches in the app read as one pattern), or, once a
   transaction is already resolved without an invoice, the notice below. */
.bank-invoice-workbench__tabs--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  overflow-x: visible;
}

.bank-invoice-workbench__resolved-notice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--success-border);
  border-radius: var(--r-md);
  background: var(--success-tint);
  color: var(--success-strong);
  font: var(--text-sm);
}

/* The resolution mode and the search share one line. The strip the mode used
   to own cost a row of candidates, and the mode is a two-state choice, which a
   switch states as plainly as a tab strip did. */
.bank-invoice-workbench__control-line {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.bank-invoice-workbench__control-line > .bank-invoice-workbench__candidate-tools {
  flex: 1;
  min-width: 0;
}

/* Everything but the switch: searching for an invoice is meaningless while the
   answer is that there is none. */
.bank-invoice-workbench__control-line.is-inert
  > .bank-invoice-workbench__candidate-tools {
  opacity: 0.45;
  pointer-events: none;
}

.bank-invoice-workbench__mode-switch {
  display: inline-flex;
  flex: 0 0 auto;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}

.bank-invoice-workbench__mode-option {
  padding: 0 var(--space-3);
  border: 0;
  background: none;
  color: var(--fg-muted);
  font: var(--text-body);
  white-space: nowrap;
  cursor: pointer;
}

.bank-invoice-workbench__mode-option + .bank-invoice-workbench__mode-option {
  border-left: 1px solid var(--border);
}

.bank-invoice-workbench__mode-option:hover {
  color: var(--fg);
}

.bank-invoice-workbench__mode-option[aria-pressed="true"] {
  background: var(--surface);
  color: var(--brand-pressed);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.bank-invoice-workbench__mode-option:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.bank-invoice-workbench__tabs-row {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  padding-bottom: 2px;
}

.bank-invoice-workbench__tabs-row[hidden],
.bank-invoice-workbench__candidate-empty[hidden] {
  display: none;
}

.bank-invoice-workbench__candidate {
  display: contents;
}

.bank-invoice-workbench__candidate-summary {
  grid-row: 2;
}

.bank-invoice-workbench__candidate > .bank-invoice-workbench__document {
  grid-row: 3;
}

.bank-invoice-workbench__candidate[hidden] {
  display: none;
}

/* Same subgrid pass-through as .bank-invoice-workbench__candidate above —
   its child .bank-invoice-workbench__candidate-summary still lands at
   grid-row 2 via that class's own rule. Kept as its own (non-"candidate")
   class because it is no longer one of the per-candidate tabs; it is the
   No invoice mode's panel. */
.bank-invoice-workbench__no-invoice {
  display: contents;
}

.bank-invoice-workbench__no-invoice[hidden] {
  display: none;
}

/* The Refund mode swaps the match footer for its own; the footer's `display`
   would otherwise outrank the `hidden` attribute. */
.bank-invoice-workbench .bank-invoice-workbench__footer[hidden] {
  display: none;
}

.bank-invoice-workbench__refund-warning {
  margin: 0;
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__ledger-cell.is-over strong {
  color: var(--danger);
}

/* Refund mode takes the whole column, down past where the match mode's
   document preview sits, so the picked payments and the result pages stay in
   view without a second scroller. */
.bank-invoice-workbench--quadrant .bank-invoice-workbench__candidates:has(
    > .bank-invoice-workbench__work-cell > [data-workbench-mode-panel="refund"]:not([hidden]))
  > .bank-invoice-workbench__work-cell {
  grid-row: 1 / 3;
}

/* The invoice search and filters have nothing to do in Refund mode. */
.bank-invoice-workbench__control-line[data-workbench-mode="refund"]
  > :not(.bank-invoice-workbench__mode-switch) {
  display: none;
}

/* The refund card stacks its rows at their content height. When the column
   is too short for all of them, only the list of earlier payments gives way
   and scrolls under its own header, so its pages and the picked payments stay
   in view. */
.bank-invoice-workbench__refund > .bank-invoice-workbench__candidate-summary {
  display: flex;
  flex-direction: column;
}

.bank-invoice-workbench__refund > .bank-invoice-workbench__candidate-summary > * {
  flex: none;
}

.bank-invoice-workbench__refund > .bank-invoice-workbench__candidate-summary > [data-refund-results] {
  display: flex;
  flex: 0 1 auto;
  min-height: 160px;
  flex-direction: column;
}

.bank-invoice-workbench__refund-results {
  display: flex;
  min-height: 0;
  flex: 0 1 auto;
  flex-direction: column;
  gap: var(--space-2);
}

.bank-invoice-workbench__refund-results > .bank-invoice-workbench__refund-table-frame {
  min-height: 0;
  flex: 0 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bank-invoice-workbench__refund-results > nav {
  flex: none;
}

.bank-invoice-workbench__refund-originals thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Both refund tables are ledger rows on one grid each, so a column is only as
   wide as what it holds; narrow columns stack each row onto two lines. */
.bank-invoice-workbench__refund-table-frame {
  container-type: inline-size;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.bank-invoice-workbench__refund-table-frame[hidden] {
  display: none;
}

.bank-invoice-workbench__refund-selected-heading {
  margin: 0;
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font: 600 13px/1.4 var(--font-sans);
}

.bank-invoice-workbench__refund-table {
  display: block;
  width: 100%;
  border-collapse: collapse;
}

.bank-invoice-workbench__refund-table thead,
.bank-invoice-workbench__refund-table tbody {
  display: block;
}

.bank-invoice-workbench__refund-table tr {
  display: grid;
  align-items: center;
  column-gap: var(--space-3);
  padding: 6px var(--space-2);
}

.bank-invoice-workbench__refund-table thead tr {
  padding-block: 7px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.bank-invoice-workbench__refund-table th {
  padding: 0;
  overflow: hidden;
  color: var(--fg-subtle);
  font: var(--text-caption);
  letter-spacing: 0.05em;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.bank-invoice-workbench__refund-table td {
  min-width: 0;
  padding: 0;
}

.bank-invoice-workbench__refund-table tbody tr {
  min-height: 40px;
  border-bottom: 1px solid var(--border-subtle);
}

.bank-invoice-workbench__refund-table tbody tr:last-child {
  border-bottom: 0;
}

.bank-invoice-workbench__refund-table .bank-invoice-workbench__refund-empty {
  display: block;
  color: var(--fg-muted);
}

.bank-invoice-workbench__refund-cell-select { grid-area: select; }
.bank-invoice-workbench__refund-cell-date { grid-area: date; white-space: nowrap; }
.bank-invoice-workbench__refund-cell-party { grid-area: party; }
.bank-invoice-workbench__refund-cell-amount { grid-area: amount; text-align: right; }
.bank-invoice-workbench__refund-cell-booked { grid-area: booked; }
.bank-invoice-workbench__refund-cell-refund { grid-area: refund; }
.bank-invoice-workbench__refund-cell-remove { grid-area: remove; text-align: right; }
.bank-invoice-workbench__refund-cell-account { grid-area: account; }

.bank-invoice-workbench__refund-table th.bank-invoice-workbench__refund-cell-amount {
  text-align: right;
}

.bank-invoice-workbench__refund-cell-party strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__refund-cell-amount,
.bank-invoice-workbench__refund-table td.bank-invoice-workbench__refund-cell-amount {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bank-invoice-workbench__refund-originals tr {
  grid-template-columns: 18px 80px minmax(0, 1.4fr) 128px minmax(0, 1fr);
  grid-template-areas: "select date party amount booked";
}

.bank-invoice-workbench__refund-originals tbody tr:hover {
  background: var(--bg-subtle);
}

.bank-invoice-workbench__refund-originals tbody tr:has([data-refund-original-select]:checked) {
  background: var(--brand-tint);
}

/* A payment that cannot be reversed reads as inert: no checkbox, a grey row,
   faint figures and the reason in its place. */
.bank-invoice-workbench__refund-original--unavailable,
.bank-invoice-workbench__refund-originals tbody tr.bank-invoice-workbench__refund-original--unavailable:hover {
  background: var(--bg-subtle);
  color: var(--fg-faint);
}

.bank-invoice-workbench__refund-original--unavailable strong,
.bank-invoice-workbench__refund-original--unavailable .bank-invoice-workbench__candidate-row-amount,
.bank-invoice-workbench__refund-original--unavailable .bank-invoice-workbench__candidate-row-party {
  color: var(--fg-faint);
  font-weight: 500;
}

.bank-invoice-workbench__refund-unavailable-reason {
  display: block;
  color: var(--fg-muted);
  font: var(--text-caption);
  font-style: italic;
}

.bank-invoice-workbench__refund-selected tr {
  grid-template-columns: 76px minmax(0, 1fr) 112px 128px 28px;
  column-gap: var(--space-2);
  grid-template-areas:
    "date    party   amount  refund  remove"
    "account account account account account";
}

.bank-invoice-workbench__refund-booked-to {
  display: block;
  overflow: hidden;
  color: var(--fg-subtle);
  font: var(--text-caption);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__refund-booked-to:empty {
  display: none;
}

.bank-invoice-workbench__refund-cell-account:has(> label[hidden]) {
  display: none;
}

.bank-invoice-workbench__refund-selected .bank-invoice-workbench__refund-cell-account label {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-2);
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__refund-cell-account select {
  width: min(100%, 320px);
  height: 34px;
  padding: 0 32px 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--fg);
  font: var(--text-sm);
}

.bank-invoice-workbench__refund-remove {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--fg-muted);
  cursor: pointer;
}

.bank-invoice-workbench__refund-remove:hover,
.bank-invoice-workbench__refund-remove:focus-visible {
  background: var(--danger-tint);
  color: var(--danger-strong);
}

@container (max-width: 520px) {
  .bank-invoice-workbench__refund-table thead {
    display: none;
  }

  .bank-invoice-workbench__refund-originals tr {
    grid-template-columns: 18px minmax(0, 1fr) 128px;
    grid-template-areas:
      "select party  amount"
      "select date   booked";
    row-gap: 2px;
  }

  .bank-invoice-workbench__refund-originals .bank-invoice-workbench__refund-cell-date {
    color: var(--fg-subtle);
    font: var(--text-caption);
  }

  .bank-invoice-workbench__refund-originals .bank-invoice-workbench__refund-cell-booked {
    text-align: right;
  }

  .bank-invoice-workbench__refund-selected tr {
    grid-template-columns: 80px minmax(0, 1fr) 112px 28px;
    grid-template-areas:
      "party   party   party   remove"
      "date    amount  refund  refund"
      "account account account account";
    row-gap: var(--space-1);
  }

  .bank-invoice-workbench__refund-selected .bank-invoice-workbench__refund-cell-amount {
    text-align: left;
  }

  .bank-invoice-workbench__refund-selected td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--fg-subtle);
    font: var(--text-caption);
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .bank-invoice-workbench__refund-selected .bank-invoice-workbench__refund-cell-refund {
    text-align: right;
  }
}

/* The refund bar keeps its status on one line and the irreversibility note
   on a line of its own, so a narrow window wraps the bar rather than the
   words. */
.bank-invoice-workbench__refund-footer .bank-invoice-workbench__comparison-status-region {
  flex: 1 1 240px;
}

.bank-invoice-workbench__refund-footer .bank-invoice-workbench__comparison-status {
  width: fit-content;
  max-width: 100%;
}

.bank-invoice-workbench__refund-footer .bank-invoice-workbench__refund-warning {
  order: 10;
  flex-basis: 100%;
}

/* A line the workbench cannot change: its Bank evidence card alone, full
   width, above what was booked on it. */
.bank-invoice-workbench--evidence-only {
  display: block;
}

.bank-invoice-workbench--evidence-only .bank-invoice-workbench__bank {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bank-invoice-workbench--evidence-only .bank-invoice-workbench__tabs-spacer {
  display: none;
}

.banking-allocation-workspace:has(> .bank-invoice-workbench--evidence-only) {
  display: grid;
  gap: var(--space-3);
}

.banking-booked-refund,
.banking-refund-remainder {
  display: grid;
  gap: var(--space-3);
}

.banking-booked-refund > *,
.banking-refund-remainder > * {
  margin: 0;
}

.banking-booked-refund .banking-detail-card-header {
  margin: 0;
}

.banking-booked-refund .table-status-pill {
  width: auto;
  min-width: 0;
  padding-inline: var(--space-2);
  white-space: nowrap;
}

.banking-booked-refund__rows {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.banking-booked-refund__row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.banking-booked-refund__row:last-child {
  border-bottom: 0;
}

.banking-booked-refund__amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.banking-booked-refund__booked,
.banking-booked-refund__by,
.banking-refund-remainder__empty {
  color: var(--fg-muted);
}

.banking-booked-refund__accounting,
.banking-booked-refund__undo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.banking-booked-refund__label {
  color: var(--fg-muted);
  font: var(--text-label);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

@media (max-width: 700px) {
  .banking-booked-refund__row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .banking-booked-refund__effect {
    grid-column: 1;
    grid-row: 2;
    color: var(--fg-muted);
  }
}

/* Accounting → Monthly close */
.accounting-close-month {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
}

.accounting-close-month__label {
  min-width: 9rem;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}

.accounting-close {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-4);
  align-content: start;
}

.accounting-close-card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
}

.accounting-close-card > * {
  min-width: 0;
}

.accounting-close-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.accounting-close-card__head h2 {
  margin: 0;
  font: var(--text-h3);
}

.accounting-close-count {
  margin-left: var(--space-2);
  color: var(--fg-muted);
  font-weight: 400;
}

.accounting-close-card__hint {
  color: var(--fg-muted);
  font: var(--text-sm);
}

.accounting-close-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  color: var(--fg-muted);
}

.accounting-close-summary b {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.accounting-close-empty {
  margin: 0;
  padding: var(--space-4) 0;
  color: var(--fg-muted);
  font: var(--text-body, 400 14px/1.5 var(--font-sans));
}

/* The register reads like the other Accounting tables: the shared header,
   row rules and sticky head on a solid ground, wrapped cells, and fixed
   column widths that a tick or a note never shifts. */
.accounting-close-frame {
  max-height: none;
  overflow-y: visible;
}

/* Where the register is wider than its card, the card scrolls its own table
   sideways and the header sticks within the frame. The register needs 1130px
   beside the 220px sidebar and the page padding. */
@media (max-width: 1439px) {
  .accounting-results-table.accounting-close-frame {
    max-height: calc(100dvh - 220px);
    overflow: auto;
  }

  .accounting-close-frame .accounting-close-table thead th {
    top: 0;
  }
}

.accounting-close-frame .accounting-close-table {
  width: 100%;
  min-width: 1130px;
  table-layout: fixed;
}

/* The page's scroll area pads its top; the header cells stick at the very top
   of it, over that padding, so no scrolled row shows above them. The frame's
   own sticky thead would hold them a padding lower. */
.accounting-close-frame .accounting-close-table thead {
  position: static;
}

.accounting-close-table thead th {
  position: sticky;
  top: calc(-1 * var(--space-4));
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
  white-space: nowrap;
}

.accounting-close-table td {
  vertical-align: top;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

.accounting-close-table tbody tr:hover {
  background: none;
}

.accounting-close-table tr[data-close-refund] > td {
  border-top: 1px solid var(--border);
}

.accounting-close-table tbody tr:first-child > td {
  border-top: 0;
}

.accounting-close-table .accounting-close-child > td {
  border-top: 0;
}

.accounting-close-table .accounting-close-accounting .table-status-pill {
  height: auto;
  padding-block: var(--space-1);
  line-height: 1.35;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.accounting-close-table .table-status-pill {
  width: auto;
  min-width: 0;
  max-width: 100%;
  padding-inline: var(--space-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accounting-close-amount {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.accounting-close-table th.accounting-close-amount,
.accounting-close-table td.accounting-close-amount {
  text-align: right;
  white-space: nowrap;
}

.accounting-close-figure {
  white-space: nowrap;
}

.accounting-close-original {
  display: grid;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.accounting-close-original__document,
.accounting-close-ack__note {
  color: var(--fg-muted);
  font: var(--text-caption);
}

.accounting-close-tick {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.accounting-close-tick .btn {
  flex: none;
  white-space: nowrap;
}

.accounting-close-note {
  min-width: 72px;
  height: 32px;
  flex: 1 1 72px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}

.accounting-close-note:focus-visible {
  border-color: var(--brand);
  outline: 2px solid var(--brand-tint);
}

.accounting-close-ack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.accounting-close-ack__note {
  flex-basis: 100%;
}

.accounting-close-undo {
  display: inline-flex;
}

.page-header-actions .btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* Below the width the month picker and Download CSV share with the tabs,
   the toolbar wraps like AP's rather than laying one over the other. */
.accounting-toolbar:has(.accounting-close-month) {
  flex-wrap: wrap;
  row-gap: var(--space-2);
}

.accounting-toolbar:has(.accounting-close-month) .page-header-left {
  flex-wrap: wrap;
  min-width: 0;
}

/* The remainder's two answers side by side, each a form of its own with the
   app's labelled fields. */
.banking-refund-remainder__options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
}

.banking-refund-remainder__option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
}

.banking-detail-card .banking-refund-remainder__option h3 {
  margin: 0;
}

.banking-refund-remainder__field {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
}

.banking-refund-remainder__field select {
  width: 100%;
  min-height: 40px;
  padding: 0 32px 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--fg);
  font: var(--text-sm);
}

.banking-refund-remainder__field select:focus-visible {
  border-color: var(--brand);
  outline: 2px solid var(--brand-tint);
}

.banking-refund-remainder__option .btn {
  margin-top: auto;
}

.bank-invoice-workbench__amount {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--fg);
  font: var(--text-label);
}

/* .banking-allocation-form label sets uppercase/letter-spacing for the
   proposal-edit form's own fields; this label happens to share that
   ancestor and the tag but isn't one of those fields, so it needs an
   explicit, higher-specificity override back to normal case. */
.bank-invoice-workbench__search-selection label.bank-invoice-workbench__amount {
  text-transform: none;
  letter-spacing: normal;
}

.bank-invoice-workbench__amount[hidden] {
  display: none;
}

/* Same [hidden] override as .bank-invoice-workbench__amount above:
   .banking-allocation-form label sets display: flex on every label inside
   the workbench form, which otherwise beats a bare [hidden] selector. */
[data-no-invoice-note-row][hidden],
[data-no-invoice-account-row][hidden] {
  display: none;
}

.bank-invoice-workbench__amount-tooltip {
  width: fit-content;
}

.bank-invoice-workbench__amount-control {
  display: inline-grid;
  width: fit-content;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}

.bank-invoice-workbench__amount-currency {
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__select-button {
  width: fit-content;
  justify-self: start;
  justify-content: center;
  margin-top: auto;
  text-align: center;
}

.bank-invoice-workbench__select-button[aria-pressed="true"] {
  border-color: var(--border);
  background: transparent;
  color: var(--fg);
}

.bank-invoice-workbench__document-header {
  min-height: 42px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--bg-subtle);
  color: var(--fg);
}

/* A long filename cannot move one PDF below its peer. The full name remains
   available in the title while document actions keep their compact labels. */
:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__document-header {
  flex: 0 0 42px;
  height: 42px;
  min-width: 0;
}

:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__document-header > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__document-header > :not(:first-child) {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Both documents stay on screen, so neither may claim the page on its own.
   A 520px floor on each meant the two of them asked for more than a laptop
   viewport before the candidate list had been given anything. */
.bank-invoice-workbench__document iframe,
.bank-invoice-workbench__document img,
.bank-invoice-workbench__missing {
  width: 100%;
  height: clamp(260px, 34vh, 520px);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: var(--bg-muted);
}

/* Nothing to render needs no room to render it in: the placeholder states the
   absence and stops, instead of reserving a document-sized empty box. */
.bank-invoice-workbench__missing {
  height: auto;
  min-height: 0;
  background: var(--bg-subtle);
}

.bank-invoice-workbench__document img {
  /* The workbench compares two documents side by side in fixed-height boxes,
     so a photographed original is fitted whole into its box rather than
     scrolled like the taller single-document panels. */
  object-fit: contain;
  image-orientation: from-image;
}

.bank-invoice-workbench__missing:not([hidden]) {
  display: grid;
  box-sizing: border-box;
  place-items: center;
  padding: var(--space-5);
  color: var(--fg-muted);
  text-align: center;
}

.bank-invoice-workbench__supplemental {
  display: grid;
  grid-column: 1 / -1;
  grid-row: 5;
  gap: var(--space-3);
}

.bank-invoice-workbench__supplemental > * {
  min-width: 0;
}

/* The footer's bands keep their own width: only the status region flexes, so
   a longer message or a different account name never shifts the controls. */
.bank-invoice-workbench__footer {
  --workbench-control-height: 40px;
  position: sticky;
  bottom: 0;
  z-index: 3;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  grid-row: 6;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--brand-tint) 94%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.bank-invoice-workbench__comparison-status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--fg-muted);
  font-weight: 600;
}

.bank-invoice-workbench__comparison-status--match {
  color: var(--success-strong);
}

.bank-invoice-workbench__comparison-status--error {
  color: var(--danger-strong);
}

.bank-invoice-workbench__comparison-status--warning {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
}

.bank-invoice-workbench__comparison-status--warning iconify-icon {
  flex-shrink: 0;
}

.bank-invoice-workbench__comparison-status--removing {
  color: var(--fg);
  font-weight: 400;
}
.bank-invoice-workbench__comparison-status--removing iconify-icon {
  flex-shrink: 0;
  color: var(--danger-strong);
}

.bank-invoice-workbench__comparison-status[hidden],
.bank-invoice-workbench__difference[hidden] {
  display: none;
}

.bank-invoice-workbench__difference {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: flex-end;
  gap: var(--space-2);
}

.bank-invoice-workbench__difference-amount {
  display: flex;
  min-width: 110px;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__difference-amount strong {
  color: var(--fg);
  font: var(--text-body);
}

.bank-invoice-workbench__difference-fields {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: var(--space-2);
}

.bank-invoice-workbench__difference-fields label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--fg-muted);
  font: var(--text-label);
}

.bank-invoice-workbench__dropup {
  display: block;
  min-width: 0;
}

.bank-invoice-workbench__dropup-trigger {
  display: flex;
  width: 100%;
  min-height: var(--workbench-control-height, 40px);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--fg);
  font: var(--text-body);
  text-align: left;
}

.bank-invoice-workbench__dropup-trigger:hover:not(:disabled),
.bank-invoice-workbench__dropup-trigger[aria-expanded="true"] {
  border-color: var(--brand);
}

.bank-invoice-workbench__dropup-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.bank-invoice-workbench__dropup-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.bank-invoice-workbench__dropup-list[popover] {
  position: fixed;
  inset: auto;
  width: var(--workbench-dropup-width, 240px);
  max-height: min(280px, calc(100vh - 16px));
  margin: 0;
  padding: var(--space-1);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: var(--shadow-popover);
}

.bank-invoice-workbench__dropup-option {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font: var(--text-body);
  text-align: left;
}

.bank-invoice-workbench__dropup-option:hover,
.bank-invoice-workbench__dropup-option:focus-visible,
.bank-invoice-workbench__dropup-option[aria-selected="true"] {
  outline: 0;
  background: var(--brand-tint);
  color: var(--brand-pressed);
}

.banking-detail-more {
  padding: var(--space-3) var(--space-4);
}

.banking-detail-more > summary {
  color: var(--fg-muted);
  cursor: pointer;
  font-weight: 600;
}

.banking-detail-more > .banking-facts {
  margin-top: var(--space-3);
}

.banking-history-empty {
  text-align: left;
  padding: 0;
}

.banking-evidence-history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

h3.banking-evidence-history-heading {
  margin: var(--space-4) 0 var(--space-2);
  color: var(--fg);
  font: var(--text-body-strong);
  text-transform: none;
  letter-spacing: normal;
}

h3.banking-evidence-history-heading:first-child {
  margin-top: 0;
}

.banking-history-list {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.banking-history-card,
.banking-history-row {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}

.banking-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-muted);
}

.banking-revision-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.banking-history-row--outdated {
  background: var(--bg);
}

.banking-history-meta time,
.banking-history-row > time {
  color: var(--fg-muted);
  font: var(--text-caption);
}

.banking-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.banking-history-row p {
  grid-column: 1 / -1;
  margin: 0;
}

.approval-decision-controls {
  display: contents;
}

.approval-review-topbar {
  flex-shrink: 0;
}
.approval-review-notes {
  flex-shrink: 0;
  padding: var(--space-3) 16px 0;
}
.approval-review-notes .approval-callout:last-child {
  margin-bottom: 0;
}
.content:has(> .approval-review-topbar) {
  padding-bottom: 26px;
}
.content:has(> .approval-review-topbar) > .detail-container {
  flex: 1;
  height: auto;
  min-height: 0;
}

.approval-review-topbar-status,
.approval-review-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.approval-review-topbar-actions {
  min-width: 0;
  flex-wrap: wrap;
}

.approval-review-approver {
  display: grid;
  gap: 1px;
  margin-right: var(--space-2);
  text-align: right;
}

.approval-review-approver-label {
  color: var(--fg-muted);
  font: var(--text-caption);
}

.approval-line-items-wrap {
  overflow-x: auto;
}

.approval-decision-controls p,
.approval-decision-status p {
  margin: 0;
}

.approval-decision-buttons,
.approval-confirmation-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.approval-decision-status {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}

.approval-decision-status:has(.approval-decision-comment) {
  width: min(480px, 100%);
}
.approval-decision-comment {
  display: grid;
  gap: var(--space-1);
  margin-top: var(--space-2);
  font-size: 12px;
  font-weight: 400;
}
.approval-decision-comment p {
  max-height: 10rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.approval-decision-comment em { color: var(--fg-muted); }

@media (max-width: 520px) {
  .approval-confirmation-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .content:has(> .approval-review-topbar) {
    overflow-y: auto;
  }

  .content:has(> .approval-review-topbar) > .detail-container {
    flex: none;
    overflow: visible;
  }
}

@media (max-width: 700px) {
  body:has(.approval-review-topbar) .sidebar {
    display: none;
  }

  body:has(.approval-review-topbar) .content {
    margin-left: 0;
    min-width: 0;
  }

  .approval-review-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-3) 16px;
  }

  .approval-review-topbar-status,
  .approval-review-topbar-actions {
    min-width: 0;
    justify-content: space-between;
  }

  .approval-review-topbar-status {
    flex-wrap: wrap;
  }

  .approval-review-approver {
    min-width: 0;
    margin-right: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .approval-decision-buttons {
    flex-wrap: nowrap;
  }

  .approval-decision-buttons .btn {
    min-width: 0;
  }

  .content:has(.approval-review-topbar) .detail-container {
    min-height: 0;
  }

  .content:has(.approval-review-topbar) .pdf-panel > iframe {
    flex: 0 0 auto;
    height: clamp(260px, 40vh, 420px);
  }

  .content:has(.approval-review-topbar) .section-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .content:has(.approval-review-topbar) .tab-link {
    flex: 0 0 auto;
  }

  .content:has(.approval-review-topbar) .line-items-wrap::before {
    content: "Swipe to see all columns";
    display: block;
    padding: 0 0 var(--space-2);
    color: var(--fg-muted);
    font: var(--text-caption);
  }
}

@media (max-width: 360px) {
  .approval-review-topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .approval-review-approver {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
  }

  .approval-decision-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 800px) {
  .bank-invoice-workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .bank-invoice-workbench__bank,
  .bank-invoice-workbench__invoice,
  .bank-invoice-workbench__anchor,
  .bank-invoice-workbench__candidates {
    display: flex;
    grid-column: 1;
    grid-row: auto;
    flex-direction: column;
    gap: var(--space-3);
  }

  .bank-invoice-workbench__tabs-spacer {
    display: none;
  }

  .bank-invoice-workbench__footer {
    grid-column: 1;
    grid-row: auto;
  }

  .bank-invoice-workbench__difference-fields {
    grid-template-columns: 1fr;
  }

  .bank-invoice-workbench__footer,
  .bank-invoice-workbench__difference {
    align-items: stretch;
    flex-direction: column;
  }

  .bank-invoice-workbench__facts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .bank-invoice-workbench__amount {
    grid-template-columns: 1fr;
  }
}
/* Partner Approvals */
.partner-approval-review {
  display: block;
  background: var(--bg);
}

.partner-approval-review > .detail-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
}

/* .partner-approval-tabs now sits inline in .page-header-left beside the
   search bar (see documents-page/AP), so it carries no margin of its own. */

.partner-approval-review .panel-supplier {
  color: var(--fg);
  font-weight: 600;
  max-width: none;
}

.partner-approval-review .panel-header .badge {
  padding: 3px 11px;
}

.partner-approval-row-count {
  color: var(--fg-muted);
  font-size: 12px;
}

.partner-approval-table,
.partner-approval-evidence-table {
  width: 100%;
}

/* Header/cell font, size and padding come from the shared .table rule
   (style.css:2575) rather than being redeclared here, so this table reads
   identically to every other list table in the app (AP, AR, …). */
.partner-approval-table td,
.partner-approval-evidence-table td,
.partner-approval-evidence-table th {
  vertical-align: middle;
}

.partner-approval-row + .partner-approval-row,
.partner-approval-evidence-row + .partner-approval-evidence-row {
  border-top: 1px solid var(--border-subtle);
}

.partner-approval-target,
.partner-approval-count {
  color: var(--fg);
}

.partner-approval-table th {
  white-space: nowrap;
}

/* A plain header like AP's; (0,2,2) so the active sort column stays plain too. */
.table.partner-approval-table thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* AP's status pill width; "Needs remediation" needs 118px. */
.partner-approval-table {
  --table-status-pill-width: 124px;
}

.partner-approval-table .table-status-pill {
  padding: 1px 11px;
}

/* Long supplier and entity names wrap rather than truncate, so every tab
   fits without horizontal scroll at 1280px and no name is cut. */
.partner-approval-table td.partner-approval-supplier-cell {
  min-width: 170px;
  max-width: 260px;
}

.partner-approval-table td.partner-approval-target-cell {
  min-width: 120px;
  max-width: 220px;
}

/* First invoice numbers wrap inside a tight cap instead of widening the table. */
.partner-approval-table td.partner-approval-invoice-cell {
  min-width: 8rem;
  max-width: 160px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.partner-approval-supplier,
.partner-approval-target {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 1360px) {
  .partner-approval-table {
    --table-status-pill-width: auto;
  }

  .partner-approval-table td.partner-approval-supplier-cell {
    min-width: 180px;
    max-width: 240px;
  }

  .partner-approval-table td.partner-approval-target-cell {
    max-width: 130px;
  }
}

/* Under the supplier name: where it stands, apart from the case. */
.partner-approval-standing {
  display: block;
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: 12px;
}

.partner-approval-standing.tone-danger {
  color: var(--danger-strong);
}

.partner-approval-case-cell {
  white-space: nowrap;
}

/* The invoice view's supplier case card. */
.supplier-approval-alert {
  margin: 10px 0 0;
}

/* Invoice tabs share the bar evenly, as the documents source tabs do: no
   padding or border of their own beyond the shared symmetric padding, the
   divider is a shadow, so flex splits the bar exactly. Past the minimum width
   the tablist scrolls. The company gives way first, truncated, and is dropped
   on a tab too narrow to show more than a few letters of it; the tab's title
   names both in full. */
.partner-approval-invoice-tab {
  flex: 1 1 0;
  min-width: 140px;
  overflow: hidden;
  container: partner-invoice-tab / inline-size;
}

.partner-approval-invoice-tab + .partner-approval-invoice-tab {
  box-shadow: inset 1px 0 0 var(--border-subtle);
}

.partner-approval-invoice-tab-main {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* What Orcha wrote to each company's Dynamics vendor. */
.partner-approval-dynamics-history {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) 0 0;
  list-style: none;
  border-top: 1px dashed var(--border-subtle);
}

.partner-approval-dynamics-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
}

.partner-approval-dynamics-history-label {
  color: var(--fg);
}

.partner-approval-dynamics-history-time {
  color: var(--fg-muted);
  font-size: 12px;
  white-space: nowrap;
}

.partner-approval-dynamics-history-error {
  margin: var(--space-1) 0 0;
  color: var(--danger-strong);
  font-size: 12px;
}

/* The open tab's Accounts Payable link, among the data panel header actions. */
.partner-approval-open-invoice {
  gap: 6px;
  white-space: nowrap;
}

.partner-approval-open-invoice:hover {
  color: var(--fg);
}

.partner-approval-open-invoice iconify-icon {
  color: var(--brand);
  font-size: 15px;
}

.partner-approval-open-invoice[hidden] {
  display: none;
}

.partner-approval-list .badge-danger,
.partner-approval-list-page .badge-danger,
.partner-approval-review .badge-danger {
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  color: var(--danger-strong);
}

.partner-approval-empty {
  padding: var(--space-7) var(--space-5);
}

.partner-approval-invoice,
.partner-approval-data,
.partner-approval-evidence,
.partner-approval-activations {
  min-width: 0;
}

.partner-approval-invoice-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.partner-approval-invoice-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}

.partner-approval-invoice-heading,
.partner-approval-activation-heading,
.partner-approval-data-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.partner-approval-invoice-kind {
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.partner-approval-invoice-number {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font: var(--text-mono);
}

.partner-approval-invoice-fields {
  display: grid;
  gap: var(--space-4);
}

.partner-approval-invoice-list {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.partner-approval-data-heading h2 {
  margin: 0;
}

.partner-approval-data-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

/* The Updated tab's details wrap, so the reviewer column stays on screen. */
.partner-approval-update-table td.partner-approval-update-details {
  white-space: normal;
  min-width: 220px;
  overflow-wrap: anywhere;
}

.partner-approval-update-table td.partner-approval-update-when {
  white-space: nowrap;
}

/* A heading that starts a group of fields spans the grid. */
.partner-approval-data-group {
  grid-column: 1 / -1;
  margin: var(--space-2) 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
}

/* The invoice's other accounts, approved with the one above: shown, not edited. */
.partner-approval-further-hint {
  grid-column: 1 / -1;
  margin: 0;
}
.partner-approval-further-accounts {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.partner-approval-further-accounts > li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 12px;
}
.partner-approval-further-accounts > li + li {
  border-top: 1px solid var(--border-subtle);
}
.partner-approval-further-iban {
  font-family: var(--font-mono, monospace);
  font-size: 13px;
}
.partner-approval-further-details {
  color: var(--fg-muted);
  font-size: 13px;
}

/* The lazily loaded Dynamics choices take their own cells in the grid above. */
.partner-approval-dynamics-choices {
  display: contents;
}

.partner-approval-field select[aria-busy="true"] {
  background-color: var(--bg-canvas);
  color: var(--fg-muted);
  cursor: progress;
}

/* Shared by every Partner Approvals text field: the Supplier Data section and
   the decision forms both use this, in the AP data panel's boxed field look. */
.partner-approval-field {
  display: grid;
  gap: var(--space-1);
}

.partner-approval-field :is(input, select, textarea) {
  width: 100%;
  min-height: 36px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-canvas);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}

.partner-approval-field textarea {
  min-height: 76px;
  resize: vertical;
}

.partner-approval-field :is(input[readonly], textarea[readonly], select:disabled) {
  background: var(--surface);
  color: var(--fg);
  cursor: default;
}

.partner-approval-field :is(input[readonly], textarea[readonly]):focus {
  outline: none;
}

.partner-approval-field select:disabled {
  -webkit-text-fill-color: var(--fg);
  opacity: 1;
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
}

/* Mono like AP's Payment IBAN and BIC. */
.partner-approval-data :is(#iban, #swift-code) {
  font-family: var(--font-mono);
  font-size: 13px;
}

.partner-approval-action-explanation {
  display: grid;
  gap: var(--space-3);
}

.partner-approval-evidence-table {
  table-layout: fixed;
}

.partner-approval-evidence-table td {
  overflow-wrap: anywhere;
  white-space: normal;
}

.partner-approval-evidence-empty td {
  padding: var(--space-5);
  color: var(--fg-muted);
  text-align: center;
}

.partner-approval-activation {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}

.partner-approval-activation + .partner-approval-activation {
  border-top: 1px solid var(--border-subtle);
}

.partner-approval-activation-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.partner-approval-activation-details > div {
  display: grid;
  gap: var(--space-1);
}

.partner-approval-supplier-id {
  display: none;
}

@media (max-width: 900px) {
  .partner-approval-table {
    min-width: 720px;
  }

  .partner-approval-activation-details {
    grid-template-columns: 1fr;
  }
}

.partner-approval-review-columns > * {
  min-width: 0;
}

.partner-approval-validation .validation-issues-banner {
  margin: var(--space-3) 0;
}

/* The invoice viewer fills the left panel below the tab bar, as on AP. */
.partner-approval-invoice,
.partner-approval-invoice-viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.partner-approval-invoice-tablist {
  display: flex;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

/* Tabs that still overflow scroll, with a right-edge fade while more tabs
   follow. The fade is driven by the tablist's own scroll position, so it is
   absent when nothing overflows and gone once scrolled to the end; the
   scrollbar is hidden only where the fade can show. */
@property --partner-invoice-tablist-fade {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes partner-invoice-tablist-fade {
  from { --partner-invoice-tablist-fade: 32px; }
  to   { --partner-invoice-tablist-fade: 0px; }
}

@supports (animation-timeline: scroll()) {
  .partner-approval-invoice-tablist {
    scrollbar-width: none;
    animation: partner-invoice-tablist-fade linear both;
    animation-timeline: scroll(self inline);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--partner-invoice-tablist-fade)), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - var(--partner-invoice-tablist-fade)), transparent);
  }

  .partner-approval-invoice-tablist::-webkit-scrollbar {
    display: none;
  }
}

/* Shrinks long before the invoice number does. */
.partner-approval-invoice-tab-meta {
  flex: 0 1000 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--fg-subtle);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@container partner-invoice-tab (max-width: 190px) {
  .partner-approval-invoice-tab-meta {
    display: none;
  }
}

.partner-approval-invoice-panel[hidden],
.approval-footer [hidden] {
  display: none;
}

.partner-approval-invoice-pdf {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.partner-approval-invoice-pdf .partner-approval-invoice-document-viewer,
.partner-approval-invoice-pdf > iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
}

/* Below the status card: which invoice the checks come from. */
.partner-approval-validation-source {
  overflow-wrap: anywhere;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--fg-subtle);
}

.partner-approval-validation .validation-check-card,
.partner-approval-validation .fraud-flag-card {
  width: 100%;
  color: var(--fg);
  text-align: left;
}

.partner-approval-validation-callout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 13px;
}

.partner-approval-validation-callout span {
  color: var(--fg-muted);
  font-size: 12px;
}

.partner-approval-validation-rows {
  display: grid;
  gap: var(--space-2);
}

.partner-approval-validation .supplier-verification-box,
.partner-approval-validation .partner-approval-tax-format,
.partner-approval-validation .fraud-detection-section {
  margin-top: 0;
}

/* The AP data panel flattens diagnostic boxes inside a status drawer. Keep
   the same hierarchy here: the drawer is the surface, and checks are rows. */
.partner-approval-validation .status-drawer .supplier-verification-box,
.partner-approval-validation .status-drawer .partner-approval-tax-format,
.partner-approval-validation .status-drawer .fraud-detection-section,
.partner-approval-validation .status-drawer .validation-box {
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.partner-approval-validation .status-drawer .sv-header,
.partner-approval-validation .status-drawer .validation-box-title,
.partner-approval-validation .status-drawer .section-header {
  padding: 0 0 6px;
  border-bottom-color: var(--bg-muted);
}

.partner-approval-validation .status-drawer .sv-checks,
.partner-approval-validation .status-drawer .validation-box-content,
.partner-approval-validation .status-drawer .section-body {
  padding-right: 0;
  padding-left: 0;
}

.approval-footer-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: 10px 0;
}

.approval-footer-summary {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: var(--space-3);
}

.approval-footer-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.approval-footer-eyebrow {
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.approval-footer-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-footer-meta {
  overflow: hidden;
  color: var(--fg-subtle);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-footer-actions {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
}

.approval-footer-actions > form {
  display: contents;
}

.approval-footer-list {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.approval-footer-list-heading {
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.approval-footer-history-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  color: var(--fg-muted);
  font-size: 12px;
}

.approval-footer-history-row strong {
  color: var(--fg);
}

.partner-approval-history {
  display: grid;
  gap: var(--space-2);
}

@media (max-width: 900px) {
  .approval-footer-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .approval-footer-actions {
    width: 100%;
  }

  .approval-footer-actions > form > .btn {
    flex: 1;
  }
}

.signature-confirm { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.signature-confirm-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.signature-confirm-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.signature-confirm-log li {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 8px; border-left: 2px solid var(--border); background: var(--bg-subtle);
}
.signature-confirm-log-confirmed { border-left-color: var(--success-strong); }
.signature-confirm-log-revoked { border-left-color: var(--warning-strong); }
.signature-confirm-log-action { font-weight: 600; color: var(--text-primary); }
.signature-confirm-log-actor { flex: 1; }
.signature-confirm-log-at { font-variant-numeric: tabular-nums; white-space: nowrap; }
.signature-confirm-button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text-primary);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.signature-confirm-button:hover { background: var(--bg-hover); }
.signature-confirm-hint { font-size: 12px; color: var(--text-secondary); }

/* Duplicate review detail -------------------------------------------------
   The resolver uses the same full-bleed chrome as invoice detail pages, but
   keeps its evidence, decision, and source-document sections readable as a
   single vertical workbench. */
.invoice-section.payable-review-alert {
  overflow: hidden;
  padding: 10px 14px 13px;
}
.supplier-comms-ad + .payable-review-alert {
  margin-top: 0;
}
.payable-review-alert-summary {
  align-items: center;
  cursor: pointer;
  justify-content: space-between;
  list-style: none;
  padding-bottom: 8px;
}
.payable-review-alert-summary::-webkit-details-marker {
  display: none;
}
.payable-review-alert-summary-copy {
  align-items: center;
  display: flex;
  gap: 8px;
  line-height: 1;
  min-width: 0;
}
.payable-review-alert-icon {
  color: var(--fg);
  flex: 0 0 auto;
  font-size: 16px;
}
.payable-review-alert-chevron {
  color: var(--fg-subtle);
  flex: 0 0 auto;
  font-size: 16px;
  transition: transform var(--dur-base) var(--ease);
}
.payable-review-alert[open] .payable-review-alert-chevron {
  transform: rotate(180deg);
}
.payable-review-alert-details {
  padding: 0;
}
.payable-review-alert-details p {
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  max-width: 720px;
}
.payable-review-alert-action {
  margin-top: 12px;
}

.payable-review-detail-page {
  display: block;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 32px;
  background: var(--bg);
}
.payable-review-detail-page .detail-topbar {
  justify-content: flex-start;
  gap: var(--space-3);
  flex-wrap: nowrap;
}
.payable-review-detail-page .detail-topbar > .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.payable-review-detail-page .detail-topbar > .search-toolbar {
  flex: 0 1 360px;
  min-width: 240px;
  margin-left: 0;
  margin-right: 0;
}
.payable-review-detail-page .detail-topbar .search-input {
  width: 100%;
}
.payable-review-detail-intro,
.payable-review-detail-page .payable-review-top-row,
.payable-review-detail-page .payable-review-members {
  width: calc(100% - 56px);
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}
.payable-review-detail-intro {
  padding-top: 28px;
  padding-bottom: 8px;
}
.payable-review-eyebrow {
  margin: 0 0 5px;
  color: var(--fg-subtle);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}
.payable-review-detail-title {
  margin: 0;
  color: var(--fg);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
}
.payable-review-detail-copy {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.5;
}
.payable-review-detail-page .payable-review-top-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  margin-bottom: 0;
}
.payable-review-detail-page .payable-review-top-row > .data-panel {
  min-height: 0;
  padding: 20px;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.payable-review-detail-page .payable-review-evidence-header {
  align-items: flex-start;
  gap: 16px;
}
.payable-review-detail-page .payable-review-evidence-header h2,
.payable-review-detail-page .payable-review-resolution-panel > h2 {
  color: var(--fg);
  font-size: 18px;
  line-height: 1.25;
}
.payable-review-detail-page .payable-review-members {
  margin-top: 28px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.payable-review-members-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.payable-review-members-header .payable-review-eyebrow {
  margin-bottom: 4px;
}
.payable-review-members-header h2 {
  margin: 0;
  color: var(--fg);
  font-size: 18px;
  line-height: 1.25;
}

@media (max-width: 900px) {
  .payable-review-detail-page .payable-review-top-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .payable-review-detail-page .detail-topbar {
    align-items: stretch;
    flex-wrap: wrap;
  }
  .payable-review-detail-page .detail-topbar > .search-toolbar {
    flex-basis: 100%;
    min-width: 0;
  }
  .payable-review-detail-intro,
  .payable-review-detail-page .payable-review-top-row,
  .payable-review-detail-page .payable-review-members {
    width: calc(100% - 28px);
  }
  .payable-review-detail-intro {
    padding-top: 20px;
  }
  .payable-review-detail-page .payable-review-top-row,
  .payable-review-detail-page .payable-review-members {
    margin-top: 12px;
  }
  .payable-review-members-header {
    flex-direction: column;
  }
}
/* Cockpit -------------------------------------------------------------------
   A board of cards, one per owning surface. Every row is a link into the list
   that owns it; the page renders no rows of its own. */

/* White ground rather than the sand canvas the list pages sit on. The cards
   keep their hairline border, which is what separates them from it. */
.content-cockpit {
  background: var(--surface);
}

.cockpit-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}

.cockpit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.cockpit-card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.cockpit-card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
.cockpit-card-icon {
  display: flex;
  align-items: center;
  flex: none;
  line-height: 1;
  font-size: 16px;
  color: var(--fg-muted);
}
.cockpit-card-title:hover { color: var(--brand-pressed); }

.cockpit-card-scope {
  font-size: 11px;
  color: var(--fg-subtle);
  white-space: nowrap;
}

.cockpit-card-total {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted);
}

.cockpit-buckets {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cockpit-bucket + .cockpit-bucket { border-top: 1px solid var(--border-subtle); }

.cockpit-bucket-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--fg);
  text-decoration: none;
}
.cockpit-bucket-link:hover {
  background: var(--brand-tint-hover);
  text-decoration: none;
}

.cockpit-bucket-label { font-size: 13px; }

/* The row-level form of `.cockpit-card-unranged`: one row of a dated card whose
   own list cannot filter by date. */
.cockpit-bucket-unranged {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--warning-strong);
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
  white-space: nowrap;
}

.cockpit-bucket-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
}

/* A card with no buckets has to be exactly as tall as a card with one, or a
   board of mixed states reads as ragged. A bucket row is a 21px line box plus
   10px above and below, so these states match that box rather than setting
   their own padding. */
/* Said by a card whose list cannot filter by date, so its number covers all
   time while its neighbours are narrowed. Quiet, but never absent. */
.cockpit-card-unranged {
  display: flex;
  align-items: center;
  margin: 0;
  min-height: 28px;
  padding: 0 16px;
  font-size: 11.5px;
  color: var(--warning-strong);
  background: var(--warning-tint);
  border-bottom: 1px solid var(--warning-border);
}

.cockpit-card-clear,
.cockpit-card-loading,
.cockpit-card-failed {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  min-height: 41px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--fg-subtle);
}

.cockpit-card-clear-icon {
  font-size: 14px;
  color: var(--success);
}

.cockpit-empty {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 40px 24px;
  text-align: center;
}
.cockpit-empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.cockpit-empty-note {
  margin: 0;
  font-size: 13px;
  color: var(--fg-subtle);
}


/* Single-invoice external payment recording. */
/* The settlement mode is this column's two-state switch, and it shares the
   search's line rather than owning a strip above it. */
.external-payment-tabs {
  display: inline-flex;
  flex: 0 0 auto;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.external-payment-tabs .settlement-mode {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 var(--space-3);
  border: 0;
  background: none;
  color: var(--fg-muted);
  font: var(--text-body);
  white-space: nowrap;
  cursor: pointer;
}
.external-payment-tabs .settlement-mode + .settlement-mode,
.external-payment-tabs .settlement-mode + .settlement-mode-unavailable {
  border-left: 1px solid var(--border);
}
.external-payment-tabs .settlement-mode-unavailable:focus-visible {
  outline-offset: -2px;
}
.external-payment-tabs .settlement-mode:hover {
  color: var(--fg);
}
.external-payment-tabs .settlement-mode[aria-pressed="true"] {
  background: var(--surface);
  color: var(--brand-pressed);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.external-payment-tabs .settlement-mode:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
/* The icons cost width the search needs more than the labels need decoration. */
.external-payment-tabs .settlement-mode iconify-icon {
  display: none;
}
.external-payment-form .form-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-4) 0;
}
.external-payment-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-weight: 500;
}
.external-payment-form [hidden] {
  display: none;
}
.external-payment-source-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.external-payment-other-source {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.external-payment-other-source small {
  display: block;
}
/* The calendar button sits inside the date field, on its right edge. */
.external-payment-form .external-payment-date {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
}
.external-payment-date [data-european-date-display],
.external-payment-date .european-date-picker {
  grid-row: 2;
  grid-column: 1;
}
.external-payment-date [data-european-date-display] {
  padding-right: 40px;
}
.external-payment-date .european-date-picker {
  z-index: 1;
  justify-self: end;
  width: 32px;
  height: 30px;
  margin-right: 4px;
  border-color: transparent;
  background: transparent;
}
.external-payment-date small {
  grid-row: 3;
}

/* A recorded payment's Suspense leg: where it was paid from, below its status. */
.accounting-paid-from-form {
  display: grid;
  grid-template-columns: minmax(0, 420px) auto;
  align-items: end;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
}
.accounting-paid-from-form .btn {
  justify-self: start;
}
.accounting-paid-from-form .alert,
.accounting-paid-from-form small {
  grid-column: 1 / -1;
}
.accounting-paid-from-form small {
  grid-row: 3;
  color: var(--fg-muted);
}
.accounting-paid-from-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-weight: 500;
}
.accounting-paid-from-form select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
@media (max-width: 640px) {
  .accounting-paid-from-form {
    grid-template-columns: minmax(0, 1fr);
  }
}
.external-payment-form input,
.external-payment-form select,
.external-payment-form textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.external-payment-form small {
  color: var(--fg-muted);
  font-weight: 400;
}
.external-payment-details {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.external-payment-details .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.external-payment-record-note {
  color: var(--fg-muted);
  font: var(--text-sm);
  line-height: 1.5;
}
.external-payment-draft-run-warning {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
  color: var(--warning-strong);
  font: var(--text-sm);
}
/* An invoice's settlement page: the document panel's record bar in place of a
   headline. */
.accounting-record-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-3);
  min-height: 36px;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.accounting-record-header .panel-invoice-number {
  margin-left: 0;
  max-width: none;
}
.accounting-record-header .panel-supplier {
  flex: 0 1 auto;
  max-width: none;
}
.accounting-processing-status-settled {
  border-color: var(--success-border);
  background: var(--success-tint);
}
.accounting-processing-status-settled > iconify-icon {
  color: var(--success);
}
.accounting-processing-status > .btn-secondary {
  background: var(--surface);
}
.accounting-processing-status > .btn-secondary:hover {
  background: var(--bg-muted);
}
.accounting-open-item-workbench-page > #section-external-payment {
  width: 100%;
  box-sizing: border-box;
  align-self: stretch;
}
.accounting-open-item-workbench-page > .accounting-detail {
  max-width: none;
  margin: 0;
}
.accounting-open-item-page .data-panel > .panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
/* The open item's split view (beside its source document) follows the
   document data panel: sections are full width without a frame, separated by
   a divider and opened by a header band, and facts sit in text boxes. The
   panel body pads 12px at the sides. The bank-matching workbench keeps its
   own layout. */
.accounting-open-item-page .detail-container .data-panel .accounting-detail {
  gap: 10px;
  padding: 0 0 24px;
}
.accounting-open-item-page .detail-container .data-panel .accounting-detail > :is(.review-section, .accounting-detail-card) {
  margin: 0 -12px;
  padding: 0 12px 14px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}
.accounting-open-item-page .detail-container .data-panel .accounting-detail > .review-section > .review-section-header,
.accounting-open-item-page .detail-container .data-panel .accounting-detail > .accounting-detail-card > h2 {
  margin: 0 -12px 14px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.accounting-open-item-page .detail-container .data-panel .accounting-detail :is(.review-section-header h2, .accounting-detail-card > h2) {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
}
.accounting-open-item-page .detail-container .data-panel .accounting-facts > div {
  align-items: center;
  padding: 3px 0;
  border-bottom: none;
}
/* Beside the source document the panel is narrower than the viewport, so the
   facts' two columns follow the section's own width, not the viewport's. */
.accounting-open-item-page .detail-container .data-panel .accounting-open-item-overview {
  container-type: inline-size;
}
@container (max-width: 640px) {
  .accounting-open-item-page .detail-container .data-panel .accounting-open-item-overview .accounting-facts {
    grid-template-columns: minmax(0, 1fr);
  }
}
.accounting-open-item-page .detail-container .data-panel .accounting-facts dd {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.external-payment-date-warning {
  color: var(--fg-muted);
  border-left: 3px solid var(--brand);
  padding-left: var(--space-3);
}
#section-external-payment[hidden],
#section-match[hidden] {
  display: none;
}
@media (max-width: 720px) {
  .external-payment-form .form-grid,
  .external-payment-details .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  #section-external-payment {
    overflow-x: auto;
  }
}
/* The invoice-anchored workbench is the same four quadrants as the
   transaction-anchored one — work over its own document, one column per side —
   with a row of its own for the settlement-mode tabs.

   The left column stays flattened by `display: contents` rather than becoming
   a real column, because the matching form and the record-payment form are
   siblings here. Nesting them would be invalid, so the rows are placed on
   their children instead. */
.bank-invoice-workbench--payment-modes {
  /* Invoice settlement has an additional title above the workbench card. */
  --workbench-page-chrome: 208px;
  align-items: stretch;
}
.bank-invoice-workbench--payment-modes > .bank-invoice-workbench__bank,
.bank-invoice-workbench--payment-modes .transaction-matching-panel {
  display: contents;
}
.bank-invoice-workbench--payment-modes > .bank-invoice-workbench__invoice {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-row: 1 / 4;
  grid-template-rows: subgrid;
  row-gap: var(--space-3);
}
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__anchor {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-row: 2 / 4;
  grid-template-rows: subgrid;
  row-gap: var(--space-3);
}
/* Facts on the work row, document on the document row — the same line as the
   inspected transaction's. */
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__anchor-summary {
  display: flex;
  min-height: max-content;
  grid-row: 1;
  flex-direction: column;
  gap: var(--space-3);
  overflow: visible;
}
.bank-invoice-workbench--payment-modes
  .bank-invoice-workbench__anchor > .bank-invoice-workbench__document {
  display: flex;
  min-height: 0;
  grid-row: 2;
  flex-direction: column;
  overflow: hidden;
}
.bank-invoice-workbench--payment-modes > .bank-invoice-workbench__bank > .bank-invoice-workbench__side-label {
  grid-column: 1;
  grid-row: 1;
}
.bank-invoice-workbench--payment-modes .transaction-matching-panel > .bank-invoice-workbench__candidates {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-column: 1;
  grid-row: 2 / 4;
  grid-template-rows: subgrid;
  row-gap: var(--space-3);
}
.bank-invoice-workbench--payment-modes .transaction-matching-panel > .bank-invoice-workbench__supplemental {
  grid-column: 1;
  grid-row: 4;
}
.bank-invoice-workbench--payment-modes .transaction-matching-panel > .bank-invoice-workbench__footer {
  grid-column: 1 / -1;
  grid-row: 5;
}
/* Record payment fills the left work/document area below the mode switch.
   Its own scroll keeps the switch visible and the invoice grid unchanged. */
.bank-invoice-workbench--payment-modes #section-external-payment {
  grid-column: 1;
  grid-row: 2 / 4;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
  .bank-invoice-workbench__candidates {
  display: flex;
  align-self: start;
  flex-direction: column;
}

.bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
  .bank-invoice-workbench__work-cell {
  flex: 0 0 auto;
  contain: none;
}

.bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
  #section-external-payment {
  margin-top: calc(var(--workbench-control-height) + var(--space-3));
}

/* Retain the match action rows in the shared grid. Invisible controls cannot
   receive focus, while the invoice PDF stays in place. */
.bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
  .bank-invoice-workbench__footer[hidden] {
  display: flex;
  visibility: hidden;
}

.bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
  .bank-invoice-workbench__supplemental[hidden] {
  display: grid;
  visibility: hidden;
}

.bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
  :is(.bank-invoice-workbench__footer, .bank-invoice-workbench__supplemental)[hidden] * {
  visibility: hidden !important;
}

/* Inside the candidate column, the same split as the quadrant workbench: the
   list on the work row, the inspected transaction's document beneath it. */
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__work-cell {
  display: flex;
  min-height: 0;
  grid-row: 1;
  flex-direction: column;
  gap: var(--space-3);
  overflow: hidden;
}

.bank-invoice-workbench--payment-modes .bank-invoice-workbench__panels {
  display: grid;
  min-height: 0;
  grid-row: 2;
}

.bank-invoice-workbench--payment-modes .bank-invoice-workbench__panels > * {
  grid-area: 1 / 1;
  min-height: 0;
}

.bank-invoice-workbench--payment-modes .bank-invoice-workbench__candidate,
.bank-invoice-workbench--payment-modes
  .bank-invoice-workbench__candidate > .bank-invoice-workbench__document {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.bank-invoice-workbench--payment-modes .bank-invoice-workbench__document iframe,
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__document img,
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__missing {
  min-height: 0;
  height: auto;
  flex: 1;
}

.bank-invoice-workbench--payment-modes .bank-invoice-workbench__candidate-scroll {
  min-height: 0;
  max-height: none;
  flex: 1;
}

.bank-invoice-workbench--payment-modes .bank-invoice-workbench__work-cell
  > div:not([hidden]):not(.bank-invoice-workbench__control-line),
.bank-invoice-workbench--payment-modes
  .bank-invoice-workbench__work-cell [data-workbench-suggestions]:not([hidden]),
.bank-invoice-workbench--payment-modes
  .bank-invoice-workbench__work-cell [data-workbench-search-results]:not([hidden]) {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
}

/* The anchor's own document is the invoice quadrant, so the spacer that lined
   it up with the tabs is no longer needed. */
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__tabs-spacer {
  display: none;
}

/* Candidate rows contain the visible selection and allocation controls.
   Keep the corresponding form inputs without adding a strip above the PDF. */
.bank-invoice-workbench--quadrant .bank-invoice-workbench__search-candidate
  > .bank-invoice-workbench__candidate-summary,
.bank-invoice-workbench--payment-modes .bank-invoice-workbench__search-candidate
  > .bank-invoice-workbench__candidate-summary {
  display: none;
}

/* The list, pagination, and help scroll together below the fixed search line.
   Captions and included items cannot squeeze the table below its own rows. */
:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__work-cell
  > div.bank-invoice-workbench__matching-content:not([hidden]) {
  overflow-y: auto;
  overscroll-behavior: contain;
}

:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__work-cell .bank-invoice-workbench__matching-content
  :is([data-workbench-suggestions], [data-workbench-search-results],
      .bank-invoice-workbench__search-results, .bank-invoice-workbench__candidate-scroll):not([hidden]) {
  flex: 0 0 auto;
  overflow: visible;
}

:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__matching-content > * {
  flex-shrink: 0;
}

/* Selections outside the current result page retain a compact amount editor.
   Several selections scroll here without displacing the candidate table. */
:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__work-cell
  > div.bank-invoice-workbench__search-selection-fallbacks:not([hidden]) {
  flex: 0 1 auto;
  max-height: 96px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bank-invoice-workbench__search-selection-fallback {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 16px minmax(0, 1fr) 100px auto;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
}

.bank-invoice-workbench__search-fallback-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-invoice-workbench__search-selection-fallback input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 15px;
  margin: 0;
  accent-color: var(--brand);
}

.bank-invoice-workbench .bank-invoice-workbench__search-selection-fallback input[type="number"] {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: var(--space-1) var(--space-2);
  font: var(--text-mono);
  text-align: right;
}

/* The empty preview has no iframe border to outline its document quadrant. */
:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__empty-document > .bank-invoice-workbench__document {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}

:is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
  .bank-invoice-workbench__empty-document .bank-invoice-workbench__document-header {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 1px solid var(--border);
}

.bank-invoice-workbench--payment-modes [hidden] {
  display: none;
}
.bank-invoice-workbench--payment-modes .external-payment-tabs {
  flex-wrap: wrap;
  margin: 0;
}
.bank-invoice-workbench--payment-modes #section-external-payment {
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  overflow-x: auto;
}
.bank-invoice-workbench--payment-modes .external-payment-form > .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.bank-invoice-workbench--payment-modes .external-payment-source-column {
  grid-column: 1 / -1;
}
.bank-invoice-workbench--payment-modes .external-payment-details .form-grid {
  grid-template-columns: minmax(0, 1fr);
}
@media (max-width: 480px) {
  .bank-invoice-workbench--payment-modes .external-payment-form > .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1200px) {
  :is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
    .bank-invoice-workbench__matching-content {
    min-width: 0;
    overflow-x: auto;
  }

  :is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
    .bank-invoice-workbench__control-line {
    flex-wrap: wrap;
  }

  :is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
    .bank-invoice-workbench__control-line > .bank-invoice-workbench__candidate-tools {
    flex: 1 1 260px;
  }
}

@media (min-width: 801px) and (max-width: 1200px) {
  .bank-invoice-workbench--quadrant,
  .bank-invoice-workbench--payment-modes {
    --workbench-control-height: 76px;
  }
}

@media (max-width: 800px) {
  .bank-invoice-workbench--quadrant,
  .bank-invoice-workbench--payment-modes {
    display: flex;
    height: auto;
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-4);
  }

  :is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
    :is(.bank-invoice-workbench__bank, .bank-invoice-workbench__invoice,
        .bank-invoice-workbench__anchor, .bank-invoice-workbench__candidates) {
    display: flex;
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-3);
  }

  :is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
    .bank-invoice-workbench__work-cell {
    height: 360px;
    flex: 0 0 auto;
  }

  :is(.bank-invoice-workbench--quadrant, .bank-invoice-workbench--payment-modes)
    :is(.bank-invoice-workbench__anchor, .bank-invoice-workbench__candidate)
    > .bank-invoice-workbench__document {
    height: clamp(520px, 90vh, 1040px);
    flex: 0 0 auto;
  }

  .bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
    .bank-invoice-workbench__work-cell {
    height: auto;
  }

  .bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
    #section-external-payment {
    margin-top: 0;
  }

  .bank-invoice-workbench--payment-modes[data-settlement-mode="external"]
    :is(.bank-invoice-workbench__footer, .bank-invoice-workbench__supplemental)[hidden] {
    display: none;
  }
}


/* Shared, visible decision area for banking reviews and payment corrections. */
.review-section {
  grid-column: 1 / -1;
  min-width: 0;
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  scroll-margin-top: 5rem;
}
.review-section-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}
.review-section-header > div { display: contents; }
.review-section-header h2 { grid-column: 1; grid-row: 1; margin: 0; font: var(--text-h3); }
.review-section-description { grid-column: 1 / -1; grid-row: 2; margin: 0; max-width: none; }
.review-section-header > .review-section-status { grid-column: 2; grid-row: 1; }
.review-section-status {
  flex-shrink: 0;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: .75rem;
  font-weight: 600;
}
.review-section-body { min-width: 0; }
.review-section-body form { max-width: 100%; }
.review-section-body textarea { min-height: 6rem; }
.review-section-body .form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.review-section-body details { margin-top: var(--space-3); }
.review-section-body summary { cursor: pointer; font-weight: 600; }
.review-section-body pre { overflow-x: auto; max-width: 100%; }
.review-section-body .table-container { overflow-x: auto; }
.review-section-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); }
@media (max-width: 720px) {
  .review-section-grid { grid-template-columns: minmax(0, 1fr); }
  .review-section { padding: var(--space-3); }
}

.review-section-status-complete { background: var(--success-tint); color: var(--success-strong); }

.review-section-body > form + form,
.review-section-body > div + form { margin-top: var(--space-3); }
.payment-run-correction-history { max-width: 24rem; }
.payment-run-correction-history-detail { margin-top: var(--space-1); font: var(--text-sm); color: var(--fg-muted); overflow-wrap: anywhere; white-space: normal; }
.payment-instruction-correction-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2) var(--space-4); }
.payment-instruction-correction-facts dt { color: var(--fg-muted); }
.payment-instruction-correction-facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .review-section .payment-instruction-correction-facts { grid-template-columns: minmax(0, 1fr); }
  .review-section .payment-instruction-correction-facts dd { margin-bottom: var(--space-2); }
}

.banking-account-choice { display: flex; flex-wrap: wrap; gap: var(--space-3); border: 0; padding: 0; margin: 0 0 var(--space-4); }
.banking-account-choice legend { margin-bottom: var(--space-2); font-weight: 600; }
.banking-account-choice label { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.banking-account-choice input { width: auto; margin: 0; }
.banking-account-review-option[hidden] { display: none; }
.banking-review-item + .banking-review-item { border-top: 1px solid var(--border-subtle); padding-top: var(--space-3); margin-top: var(--space-3); }
.review-section .banking-review-item > form { display: grid; gap: var(--space-3); }
.review-section .banking-review-item > form > label { display: grid; gap: var(--space-1); }
.review-section .banking-review-item > form > button { justify-self: start; }

.banking-account-fields { border: 0; padding: 0; margin: 0; min-width: 0; }

.review-section select,
.review-section textarea,
.review-section input[type="text"] {
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background-color: var(--surface);
  color: var(--fg);
  padding: 8px 10px;
  font: inherit;
  max-width: 100%;
}
.review-section select {
  min-height: 34px;
  padding: 5px 32px 5px 10px;
  border-radius: var(--r-md);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.review-section select:focus,
.review-section textarea:focus,
.review-section input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.review-section .form-actions { justify-content: flex-start; align-items: flex-end; }
.review-section .form-actions form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); }
.review-section .form-actions label { display: grid; gap: var(--space-1); }
.banking-route-correction-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.banking-route-correction-manual-form { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
.banking-route-correction-manual-form label { display: grid; flex: 1; min-width: 180px; gap: var(--space-1); }
.banking-account-assignment-form > .banking-account-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.banking-account-assignment-form > .banking-account-fields > label { flex: 1; min-width: 180px; }
/* A refusal's sentence and its confirmation span the dialog; the account
   picker keeps its own width. */
.banking-account-assignment-form:has(> .form-error) { grid-template-columns: minmax(0, 1fr); }
.banking-account-assignment-form > .form-warning,
.banking-account-assignment-form > .form-error { grid-column: 1 / -1; }
.banking-account-assignment-form:has(> .form-error) > .banking-account-fields > label:not(.banking-account-iban-confirm) {
  flex: 0 1 420px;
}
.banking-account-assignment-form > .banking-account-fields > label.banking-account-iban-confirm,
.banking-account-create-form > label.banking-account-iban-confirm {
  flex: 1 1 100%;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg);
  font: var(--text-sm);
  letter-spacing: normal;
  text-transform: none;
}
@media (max-width: 900px) {
  .payment-instruction-not-executed > .page-header { height: auto; min-height: 50px; }
  .payment-instruction-not-executed .page-header-left { flex-wrap: wrap; min-width: 0; }
  .payment-instruction-not-executed .payment-run-back { white-space: nowrap; flex-shrink: 0; }
}

[data-workbench-select-button][hidden] { display: none; }

/* Bank source comparison and explicit multi-payment review. */
.content:has(.bank-duplicate-review-page) {
  background: var(--surface);
  overflow-y: auto;
}
.content:has(.bank-duplicate-review-page) > .global-command-header {
  margin-top: 0;
}
.bank-duplicate-review-page {
  flex: 0 0 auto;
  min-height: 100%;
  overflow: visible;
  padding: 0 24px 48px;
  background: var(--surface);
}
.bank-duplicate-review-page > .page-header {
  height: 51px;
  min-height: 51px;
  padding: 5px 14px;
  margin: 0 -24px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: visible;
}
.bank-review-summary,.bank-review-result,.bank-review-confirmation { padding:20px; border:1px solid var(--border-color, #dedbd5); border-radius:8px; background:var(--surface); margin-bottom:32px; }
.bank-review-summary { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; }
.bank-review-summary-status { flex:0 0 auto; order:2; }
.bank-review-summary-copy { min-width:0; }
.bank-review-summary p { margin:8px 0 0; }
.bank-review-workbench { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:28px; align-items:stretch; }
.bank-review-queue,.bank-review-decision { padding:20px; border:1px solid var(--border-color, #dedbd5); border-radius:8px; background:var(--bg-surface, #fff); min-width:0; height:100%; box-sizing:border-box; align-self:stretch; }
.bank-review-workbench h2 { font-size:17px; margin:0 0 16px; }
.bank-review-workbench h3 { font-size:15px; margin:0 0 12px; }
.bank-review-workbench h4 { font-size:13px; margin:0 0 16px; }
.bank-review-select-all { display:flex; align-items:center; gap:8px; }
.bank-review-muted { font-size:12px; color:var(--text-secondary, #62615d); }
.bank-review-table-scroll { max-height:840px; overflow:auto; }
.bank-review-table-scroll table { width:100%; font-size:12px; }
.bank-review-table-scroll th { position:sticky; top:0; background:var(--bg-surface, #fff); }
.bank-review-table-scroll td { padding:10px 8px; vertical-align:middle; }
.bank-review-table-scroll td:nth-child(2) { white-space:normal; overflow-wrap:anywhere; }
.bank-review-table-scroll tbody tr[data-review-row] { cursor:pointer; }
.bank-review-table-scroll tbody tr.is-review-focus > td { background:#eff6ff; }
.bank-review-table-scroll tbody tr.is-review-focus > td:first-child { box-shadow:inset 3px 0 0 var(--primary, #2563eb); }
.bank-review-comparison select { display:block; width:100%; min-width:0; margin-top:8px; }
.bank-review-row-link { border:0; background:none; color:inherit; text-align:left; cursor:pointer; padding:0; font:inherit; }
.bank-review-row-link span { display:block; margin-top:3px; color:var(--text-secondary, #62615d); }
.bank-review-row-link[aria-pressed=true] { color:var(--primary, #2563eb); }
.bank-review-pagination { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:16px; font-size:12px; }
.bank-review-columns { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin:16px 0 24px; }
.bank-duplicate-pair-page .bank-review-facts > div { display:grid; grid-template-columns:110px minmax(0,1fr); gap:12px; margin:8px 0; }
.bank-duplicate-pair-page .bank-review-facts dt { margin:0; }
.bank-duplicate-pair-page .bank-review-source iframe,.bank-duplicate-pair-page .bank-review-source .document-viewer { height:520px; }
.bank-review-match-note { margin:0 0 12px; font-size:12px; color:var(--fg-muted); }
.bank-review-source-line { margin:-6px 0 12px; font-size:12px; color:var(--fg-muted); overflow-wrap:anywhere; }
.bank-review-columns > div { background:var(--bg-subtle, #f8f7f4); padding:14px; border-radius:6px; min-width:0; }
.bank-review-facts { margin:0; font-size:13px; }
.bank-review-facts > div { margin:0 0 12px; }
.bank-review-facts dt,.bank-review-source-meta dt { font-size:11px; color:var(--text-secondary, #62615d); margin-bottom:4px; }
.bank-review-facts dd,.bank-review-source-meta dd { margin:0; overflow-wrap:anywhere; }
.bank-review-choice-cards { display:grid; gap:8px; }
.bank-review-choice { display:flex; align-items:flex-start; gap:10px; padding:14px; border:1px solid var(--border-color, #dedbd5); border-radius:6px; cursor:pointer; }
.bank-review-choice-cards.is-disabled .bank-review-choice { color:var(--text-secondary, #8b8983); background:var(--bg-subtle, #f8f7f4); border-color:#e5e2dc; cursor:not-allowed; }
.bank-review-choice-cards.is-disabled .bank-review-choice input { cursor:not-allowed; }
.bank-review-choice-cards.is-disabled .bank-review-choice:has(input:checked) { color:inherit; background:#eff6ff; border-color:var(--primary, #2563eb); }
.bank-review-choice:has(input:checked) { border-color:var(--primary, #2563eb); background:#eff6ff; }
.bank-review-choice input { margin-top:3px; }
.bank-review-choice-disabled { color:var(--fg-muted); background:var(--bg-subtle); cursor:not-allowed; }
.bank-review-choice-disabled input { cursor:not-allowed; }

.bank-review-choice strong,.bank-review-choice span span { display:block; }
.bank-review-choice span span { color:var(--text-secondary, #62615d); font-size:12px; margin-top:5px; line-height:1.5; }
.bank-review-impact { height:80px; box-sizing:border-box; padding:12px 0; font-size:12px; line-height:1.5; overflow:auto; }
.bank-review-note { display:block; font-size:12px; margin:0 0 12px; }
.bank-review-note textarea { display:block; width:100%; box-sizing:border-box; margin-top:6px; padding:10px; border:1px solid var(--border-color, #dedbd5); border-radius:6px; font:inherit; }
.bank-review-pdfs { display:grid; grid-template-columns:1fr 1fr; gap:28px; margin-top:40px; }
.bank-review-source { border:1px solid var(--border-color, #dedbd5); border-radius:8px; overflow:hidden; background:var(--bg-surface, #fff); }
.bank-review-source-heading { display:flex; justify-content:space-between; align-items:center; padding:16px; gap:8px; }
.bank-review-source-heading h3 { margin:0 0 4px; font-size:16px; }
.bank-review-source-heading p { margin:0; font-size:12px; color:var(--text-secondary, #62615d); }
.bank-review-source-meta { padding:0 16px 16px; display:grid; grid-template-columns:1fr 1fr; gap:12px; font-size:12px; margin:0; }
.bank-review-source iframe { display:block; width:100%; height:1280px; border:0; border-top:1px solid var(--border-color, #dedbd5); }
.bank-review-source .document-viewer { height:1280px; border-top:1px solid var(--border-color, #dedbd5); }
.bank-review-error { background:#fff1f0; color:#952626; border:1px solid #eac7c4; border-radius:6px; padding:14px; margin:12px 0; }
.bank-review-notice { padding:12px; background:#eff8f1; border-radius:6px; }
.bank-review-columns .bank-review-notice { margin:12px 0; font-size:12px; line-height:1.5; }
.bank-review-warning { background:var(--warning-tint); color:var(--warning-strong); border:1px solid var(--warning-border); border-radius:6px; padding:12px; margin:12px 0; font-size:12px; line-height:1.5; }
.bank-review-warning[hidden] { display:none; }
.bank-review-conflicts { background:var(--danger-tint); color:var(--danger-strong); border:1px solid var(--danger-border); border-radius:6px; padding:12px; margin:12px 0; font-size:12px; line-height:1.5; }
.bank-review-finish { display:flex; justify-content:space-between; align-items:center; padding:20px; border:1px solid var(--border-color, #dedbd5); border-radius:8px; margin-top:24px; }
.bank-review-result .btn + .btn { margin-left:8px; }
.bank-review-action-bar { position:sticky; bottom:34px; z-index:5; margin:24px -20px 0; background:var(--surface); box-shadow:0 -6px 18px rgba(31, 35, 40, .12); }
.bank-review-action-bar p { margin:4px 0 0; font-size:12px; color:var(--text-secondary, #62615d); }
.bank-review-action-bar button:disabled { opacity:.55; cursor:not-allowed; }
.bank-review-confirmation form { display:inline-block; margin:16px 0 0 12px; }
@media (max-width:600px) {
  .banking-transaction-page > .page-header { height:auto; min-height:51px; flex-wrap:wrap; gap:8px; }
  .banking-transaction-page > .page-header .page-header-left { flex-basis:100%; min-width:0; }
  .banking-transaction-page > .page-header .page-header-left > .btn { flex:none; white-space:nowrap; }
  .banking-transaction-page > .page-header .search-container { flex:1; min-width:0; }
  .banking-transaction-page > .page-header .search-input { width:100%; min-width:0; }
  .banking-transaction-page > .page-header .page-header-actions { margin-left:auto; }
  .banking-transaction-page .banking-evidence-history-grid { grid-template-columns:minmax(0, 1fr); }
}
.bank-duplicate-pair-page .bank-review-confirmation form { display:block; margin:16px 0; }
.bank-duplicate-pair-page > .page-header .page-header-left { flex:1; min-width:0; flex-wrap:nowrap; }
.bank-duplicate-pair-page > .page-header .page-header-left > .btn { flex:none; }
.bank-duplicate-pair-page > .page-header .search-container { min-width:0; }
@media (max-width:600px) {
  .bank-duplicate-pair-page > .page-header .search-container { flex:1; }
  .bank-duplicate-pair-page > .page-header .search-input { min-width:0; width:100%; }
}


/* Bank statement import summary. */
.bank-duplicate-review-page { background: #fff; }
#bank-import-summary-dialog {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  background: #fff;
}
#bank-import-summary-dialog::backdrop { background: rgba(0, 0, 0, .4); }
#bank-import-summary-dialog > div { background: #fff; }
#bank-import-summary-dialog .modal-header { position: sticky; top: 0; z-index: 2; background: #fff; }
.bank-import-modal-body { padding: 20px; }
#bank-import-summary-dialog .bank-import-table thead th,
#bank-import-summary-dialog .bank-import-table tbody td:last-child { background: #f7f7f7; }
.bank-review-confirmation.bank-import-confirmation {
  width: 100%;
  max-width: 1176px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  margin: 0;
}
.bank-import-confirmation > .bank-review-error {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 20px;
  margin: 0 0 20px;
}
.bank-import-confirmation > .bank-review-error.bank-import-stale {
  color: var(--warning-strong);
  background: var(--warning-tint);
  border-color: var(--warning-border);
}
.bank-import-confirmation > .bank-review-error > p,
.bank-import-confirmation > .bank-review-error form > p {
  grid-column: 1;
  margin: 0;
}
.bank-import-confirmation > .bank-review-error form > p { font-size: 12px; }
.bank-import-confirmation > .bank-review-error form { display: contents; }
.bank-import-confirmation > .bank-review-error form > button {
  grid-column: 2;
  grid-row: 1 / span 2;
}
.bank-import-summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 275px;
  align-items: start;
  gap: 22px;
  min-width: 0;
}
.bank-import-impact,
.bank-import-approval {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.bank-import-impact { overflow: hidden; }
.bank-import-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.bank-import-context > div { min-width: 0; }
.bank-import-context h2 {
  margin: 0;
  color: var(--fg);
  font: 600 18px/1.3 var(--font-serif);
}
.bank-import-context p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.bank-import-context > .badge { flex: none; }
.bank-import-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}
.bank-import-count {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 19px 22px;
  min-width: 0;
}
.bank-import-count + .bank-import-count { border-left: 1px solid var(--border); }
.bank-import-count > div { min-width: 0; }
.bank-import-count > strong {
  flex: none;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--fg);
  font: 600 30px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.bank-import-count-label,
.bank-import-count-help { display: block; }
.bank-import-count-label {
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}
.bank-import-count-help {
  margin-top: 3px;
  color: var(--fg-muted);
  font-size: 12px;
}
.bank-import-impact-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 19px 22px;
  border-bottom: 1px solid var(--border);
}
.bank-import-impact-heading h2 {
  margin: 0;
  color: var(--fg);
  font: 600 18px/1.3 var(--font-serif);
}
.bank-import-currency { color: var(--fg-muted); font-size: 12px; }
.bank-import-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
.bank-import-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 13px;
}
.bank-import-table thead th {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg-muted);
  background: var(--bg-subtle);
  font: 500 11px/1.4 var(--font-sans);
  text-align: right;
  white-space: nowrap;
}
.bank-import-table th:first-child { text-align: left; }
.bank-import-table tbody th,
.bank-import-table tbody td {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.bank-import-table tbody tr:last-child th,
.bank-import-table tbody tr:last-child td { border-bottom: 0; }
.bank-import-table tbody th { color: var(--fg); font-weight: 500; }
.bank-import-table tbody td {
  color: var(--fg);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bank-import-table tbody td:last-child {
  background: var(--bg-subtle);
  font-weight: 600;
}
.bank-import-table .bank-review-amount { font-family: var(--font-mono); font-size: 13px; }
.bank-import-table .bank-import-change { color: var(--success-strong); }
.bank-import-totals-note {
  margin: 0;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.45;
}
.bank-import-approval { padding: 22px; }
.bank-import-approval h2 {
  margin: 0 0 13px;
  color: var(--fg);
  font: 600 20px/1.3 var(--font-serif);
}
.bank-import-approval > p {
  margin: 0 0 18px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.45;
}
.bank-import-approval .bank-import-readiness {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--success-strong);
}
.bank-import-readiness:not(.bank-import-not-ready)::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 19px;
  height: 19px;
  border: 1px solid var(--success-border);
  border-radius: 50%;
  background: var(--success-tint);
  font-size: 12px;
}
.bank-import-approval .bank-import-readiness.bank-import-not-ready { color: var(--fg-muted); }
.bank-review-confirmation.bank-import-confirmation .bank-import-approval form {
  display: block;
  width: 100%;
  margin: 8px 0 0;
}
.bank-import-approval form button,
.bank-import-approval > .btn {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
}
.bank-import-approval .btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  gap: 8px;
}
.bank-import-approval > .btn { margin-top: 8px; }
.bank-import-quiet-note {
  margin: 22px 0 0 !important;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  font-size: 12px !important;
}
@media (max-width: 1200px) {
  .bank-import-table thead th,
  .bank-import-table tbody th,
  .bank-import-table tbody td { padding-left: 13px; padding-right: 13px; }
}
@media (max-width: 850px) {
  .bank-import-summary-layout { grid-template-columns: minmax(0, 1fr); }
  .bank-import-approval { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 240px); column-gap: 20px; align-items: center; }
  .bank-import-approval h2,
  .bank-import-readiness,
  .bank-import-approval > p,
  .bank-import-quiet-note { grid-column: 1; }
  .bank-import-approval h2 { margin: 0 0 8px; }
  .bank-import-approval .bank-import-readiness { margin-bottom: 6px; }
  .bank-import-approval > p { margin-bottom: 0; }
  .bank-review-confirmation.bank-import-confirmation .bank-import-approval form,
  .bank-import-approval > .btn { grid-column: 2; }
  .bank-review-confirmation.bank-import-confirmation .bank-import-approval form { grid-row: 1 / span 2; align-self: end; }
  .bank-import-approval > .btn { grid-row: 3; }
  .bank-import-quiet-note { margin-top: 10px !important; }
}
@media (max-width: 600px) {
  #bank-import-summary-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .bank-import-modal-body { padding: 12px; }
  .bank-duplicate-review-page:has(#bank-import-summary-dialog) > .page-header .page-header-left { flex: 1; min-width: 0; flex-wrap: nowrap; }
  .bank-duplicate-review-page:has(#bank-import-summary-dialog) > .page-header .page-header-left > .btn { flex: none; }
  .bank-duplicate-review-page:has(#bank-import-summary-dialog) > .page-header .search-container { flex: 1; min-width: 0; }
  .bank-duplicate-review-page:has(#bank-import-summary-dialog) > .page-header .search-input { width: 100%; min-width: 0; }
  .bank-import-confirmation > .bank-review-error { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .bank-import-confirmation > .bank-review-error form > button { grid-column: 1; grid-row: auto; justify-self: start; }
  .bank-import-context { align-items: flex-start; flex-direction: column; gap: 10px; padding: 16px; }
  .bank-import-count { align-items: flex-start; gap: 10px; padding: 17px 14px; }
  .bank-import-count > strong { font-size: 26px; }
  .bank-import-count-label { font-size: 12px; }
  .bank-import-count-help { font-size: 11px; }
  .bank-import-impact-heading { padding: 16px; }
  .bank-import-totals-note { padding: 12px 14px; }
  .bank-import-table thead th,
  .bank-import-table tbody th,
  .bank-import-table tbody td { padding: 14px 11px; }
  .bank-import-table .bank-review-amount { font-size: 11px; }
  .bank-import-approval { display: block; padding: 18px; }
  .bank-import-approval h2 { margin-bottom: 12px; }
  .bank-import-approval > p { margin-bottom: 14px; }
  .bank-review-confirmation.bank-import-confirmation .bank-import-approval form { margin: 0; }
  .bank-import-approval > .btn { margin-top: 8px; }
}
@media (max-width: 600px) {
  .bank-import-table { min-width: 0; }
  .bank-import-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bank-import-table,
  .bank-import-table tbody { display: block; }
  .bank-import-table tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--border-subtle); }
  .bank-import-table tbody tr:last-child { border-bottom: 0; }
  .bank-import-table tbody th,
  .bank-import-table tbody td,
  .bank-import-table tbody tr:last-child th,
  .bank-import-table tbody tr:last-child td { border-bottom: 0; }
  .bank-import-table tbody th { grid-column: 1 / -1; padding: 14px 12px 4px; }
  .bank-import-table tbody td { min-width: 0; padding: 4px 12px 14px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .bank-import-table tbody td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--fg-muted); font: 500 11px/1.4 var(--font-sans); }
}
.bank-duplicate-review-page [hidden] { display:none !important; }
@media (max-width:1100px) { .bank-review-workbench { grid-template-columns:1fr; } }
@media (max-width:700px) {
  .bank-duplicate-review-page { padding:0 14px 32px; }
  .bank-duplicate-review-page > .page-header { margin-left:-14px; margin-right:-14px; padding-left:14px; padding-right:14px; }
  .bank-review-summary { flex-direction:column; gap:12px; }
  .bank-review-summary-status { order:0; }
  .bank-review-pdfs { grid-template-columns:1fr; }
  .bank-review-finish { align-items:flex-start; flex-direction:column; }
  .bank-review-action-bar { margin-left:-12px; margin-right:-12px; }
  .bank-review-result .btn + .btn { margin-left:0; margin-top:8px; }
  .bank-review-columns { grid-template-columns:1fr; }
  .bank-review-queue,.bank-review-decision { padding:12px; }
  .bank-review-source iframe,.bank-review-source .document-viewer { height:880px; }
  .content:has(.bank-review-action-bar) { scroll-padding-bottom:110px; }
  .bank-review-table-scroll th,.bank-review-table-scroll td { padding:8px 6px; }
  .bank-review-table-scroll th { white-space:nowrap; overflow-wrap:normal; word-break:normal; font-size:10px; letter-spacing:.2px; }
  .bank-review-table-scroll td { white-space:normal; overflow-wrap:break-word; }
  .bank-review-table-scroll th:first-child,.bank-review-table-scroll td:first-child { width:28px; }
  .bank-review-action-bar { flex-direction:row; align-items:center; gap:12px; padding:12px 14px; }
  .bank-review-action-bar > div { min-width:0; }
  .bank-review-action-bar p { display:none; }
  .bank-review-action-bar .btn { flex:none; }
}

/* Manual pairing uses the statement review shell and workbench search controls. */
.bank-duplicate-mark-page > h1 { font-size:24px; margin:0 0 8px; }
.bank-mark-notice { background:#fff8e5; border:1px solid #f0d89c; border-radius:8px; padding:16px 20px; margin:20px 0 28px; }
.bank-mark-notice p { margin:6px 0 0; }
.bank-mark-anchor { background:var(--bg-subtle, #f8f7f4); padding:20px; border-radius:6px; margin:20px 0; }
.bank-mark-anchor .bank-review-facts { display:grid; grid-template-columns:1fr 1fr; gap:12px 20px; }
.bank-mark-candidates { display:grid; gap:10px; max-height:650px; overflow:auto; padding:2px; }
.bank-mark-candidate { margin:0; }
.bank-mark-candidate > span { min-width:0; width:100%; overflow-wrap:anywhere; }
.bank-mark-candidate .bank-mark-amount { color:var(--fg); font-weight:600; }
.bank-mark-browse { display:inline-block; margin-top:16px; }
.bank-duplicate-mark-page [data-mark-form] { margin-top:28px; }
.bank-mark-actions { display:flex; gap:8px; }
.bank-duplicate-mark-page .bank-invoice-workbench__search-bar { width:100%; }
.bank-duplicate-mark-page .bank-invoice-workbench__search-input { flex:1; min-width:0; }
.bank-duplicate-mark-page .bank-invoice-workbench__search-input input { width:100%; }
@media (max-width:760px) { .bank-mark-anchor .bank-review-facts { grid-template-columns:1fr; } }
.bank-duplicate-mark-page [data-mark-form] { display:contents; }
.bank-duplicate-mark-page [data-mark-form] > .bank-review-note { margin-top:28px; }
.bank-duplicate-pair-page [data-review-confirm] > .bank-review-note { margin-top:16px; }
.bank-duplicate-mark-page .bank-invoice-workbench__search-input input { height:39px; padding:8px 10px; border:1px solid var(--border, #dedbd5); border-radius:5px; background:var(--surface); color:var(--fg); font:inherit; }

/* Shared page-specific actions remain separate from workflow submit buttons. */
.page-actions { position:relative; flex-shrink:0; }
.page-actions__trigger { display:flex; align-items:center; justify-content:center; gap:8px; min-height:38px; padding:8px 13px; border:1px solid var(--border, #dedbd5); border-radius:5px; background:#fff; color:var(--fg, #29251f); font:inherit; font-weight:600; list-style:none; cursor:pointer; white-space:nowrap; }
.page-actions__trigger::-webkit-details-marker { display:none; }
.page-actions__trigger:hover { background:var(--bg-subtle, #f8f7f4); }
.page-actions__trigger:focus-visible,.page-actions__item:focus-visible { outline:2px solid var(--accent, #096cbb); outline-offset:2px; }
.page-actions__chevron { flex-shrink:0; }
.page-actions[open] .page-actions__chevron { transform:rotate(180deg); }
.page-actions__menu { position:absolute; top:calc(100% + 8px); right:0; z-index:1100; box-sizing:border-box; width:320px; max-width:calc(100vw - 16px); overflow:auto; padding:7px; border:1px solid var(--border, #dedbd5); border-radius:8px; background:#fff; box-shadow:0 12px 38px #2222; text-align:left; }
.page-actions__group + .page-actions__group { margin-top:5px; padding-top:5px; border-top:1px solid var(--border, #dedbd5); }
.page-actions__heading { padding:7px 10px 4px; font-size:10px; font-weight:600; letter-spacing:.8px; text-transform:uppercase; color:var(--fg-muted, #827b73); }
.page-actions__item { display:block; padding:10px; border-radius:4px; color:var(--fg, #29251f); text-decoration:none; white-space:normal; }
.page-actions__item:hover,.page-actions__item:focus { background:#edf5fc; color:var(--fg, #29251f); text-decoration:none; }
.page-actions__label { display:block; font-size:14px; font-weight:600; line-height:1.4; }
.page-actions__description { display:block; margin-top:3px; color:var(--fg-muted, #827b73); font-size:12px; font-weight:400; line-height:1.4; }
/* Invoice groups preserve the existing account-pill editing language. */
#line-item-grouping [hidden] { display: none !important; }
.grouping-toolbar { display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px; }
.grouping-modes { display:flex;gap:3px;background:var(--bg-muted,#f3f5f7);padding:3px;border-radius:6px; }
.grouping-modes button,.grouping-selection button { border:1px solid transparent;background:transparent;padding:7px 12px;border-radius:4px;font:inherit;cursor:pointer; }
.grouping-modes button[aria-pressed="true"] { background:white;border-color:#c9d8e2;color:#245b80; }
.grouping-modes[aria-disabled="true"] { opacity:.55; }
.grouping-modes button:disabled { cursor:not-allowed; }
.grouping-modes button[aria-pressed="true"]:disabled { color:inherit;border-color:#dce2e7; }
.grouping-settings { display:flex;align-items:center;justify-content:center;width:34px;height:34px;border:1px solid #dce2e7;border-radius:5px;color:inherit; }
.grouping-selection { display:flex;align-items:center;gap:12px;padding:10px 12px;margin-bottom:10px;background:#eaf3fa;border-radius:5px; }
.grouping-selection button { border-color:#c6dbea;background:white; }
.grouping-selection .grouping-delete-selected { margin-left:auto;border-color:#e3b5af;color:#b42318; }
.grouping-selection .grouping-delete-selected:hover { background:#fff1ef; }
.grouping-delete-dialog { width:500px;max-height:85vh;overflow:auto; }
.grouping-delete-dialog h2 { margin:0 0 16px;font-size:20px; }
.grouping-delete-lines { list-style:none;margin:0 0 16px;padding:0;max-height:32vh;overflow:auto;border:1px solid var(--border);border-radius:var(--r);background:var(--surface); }
.grouping-delete-lines li { display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 16px;padding:12px;border-bottom:1px solid var(--border); }
.grouping-delete-lines li:last-child { border-bottom:0; }
.grouping-delete-lines span { overflow-wrap:anywhere; }
.grouping-delete-lines strong { white-space:nowrap; }
.grouping-delete-lines small { grid-column:1/-1;color:var(--muted); }
.grouping-delete-dialog p { font-size:13px;line-height:1.5; }
.grouping-delete-impact { width:100%;border-collapse:collapse;margin:16px 0;font-size:12px; }
.grouping-delete-impact th,.grouping-delete-impact td { padding:8px 0;text-align:right;border-bottom:1px solid var(--border);font-weight:400; }
.grouping-delete-impact th:first-child { text-align:left; }
.grouping-delete-note { color:var(--muted); }
.grouping-table { width:100%;min-width:var(--grouping-min-width,700px);table-layout:fixed; }
.grouping-col-check { width:30px; }
.grouping-col-reference { width:44px; }
.grouping-col-account { width:96px; }
.grouping-col-dimension { width:96px; }
.grouping-col-vat { width:64px; }
.grouping-col-vat-coded { width:116px; }
.grouping-col-amount { width:104px; }
.grouping-table .editable-value,.grouping-table input { min-width:0;max-width:100%;box-sizing:border-box; }
.grouping-table tbody > tr.li-row > td .editable-value.is-editing { width:100%!important; }
.grouping-table .li-tax .editable-value { flex:1;min-width:0; }
.line-items.grouping-table td .editable-value[data-field-path="/currency"] { display:inline-block!important;width:auto!important;vertical-align:middle;padding:5px 4px; }
.grouping-table .li-row,.grouping-table .grouping-parent { cursor:default; }
.grouping-table [data-grouping-reference] { cursor:pointer; }
.grouping-table td.pos,.grouping-table td.desc { position:static; }
.line-items.grouping-table thead th { vertical-align:middle; }
.grouping-table thead th:nth-child(2) { left:auto;text-align:center; }
.line-items.grouping-table td.pos,.grouping-table td[data-grouping-reference] { text-align:center;vertical-align:middle;padding:4px; }
.grouping-table .pos-number,.grouping-table .pos-chevron { vertical-align:middle; }
.grouping-table td.desc { max-width:220px; }
.line-items.grouping-table .grouping-check { width:30px;text-align:center;vertical-align:middle; }
.grouping-table .grouping-check input[type="checkbox"] { display:block;margin:0 auto; }
.grouping-table .grouping-parent td { background:#eef4f8;border-top:1px solid #c6dbea;border-bottom:1px solid #c6dbea;padding-top:13px;padding-bottom:13px; }
.grouping-table .grouping-parent td:first-child { border-left:4px solid #4b82a8; }
.grouping-ref { display:inline-block;background:#467b9f;color:white;border-radius:4px;padding:3px 6px;font-weight:600; }
.grouping-name,.grouping-name-input { font:inherit;text-align:left;cursor:text;color:inherit; }
.grouping-kind { display:block;width:fit-content;font-size:11px;color:#4a6d85;margin-top:4px; }
/* A line booked on its own shows its booking text above, its description below
   as plain text. */
.line-text-description { display:block;margin:4px 0 0 8px;font-size:12px;font-style:italic;color:var(--fg-muted);overflow-wrap:anywhere; }
/* A group's amount is the sum of its lines; its tooltip points to the lines.
   The line-items scroller clips above and below the table, so the tooltip opens
   to the left, inside the group row. */
.grouping-amount { position:relative;display:inline-block;max-width:100%;cursor:help; }
.grouping-table .grouping-parent td.amount { overflow:visible; }
.grouping-amount[data-tooltip]::after { content:attr(data-tooltip);position:absolute;top:50%;right:calc(100% + 8px);transform:translateY(-50%);z-index:20;width:max-content;max-width:240px;padding:7px 10px;border:1px solid var(--border-strong);border-radius:var(--r-md);background:var(--surface);box-shadow:var(--shadow-md);color:var(--fg);font:var(--text-sm);text-align:left;white-space:normal;pointer-events:none;opacity:0;visibility:hidden;transition:opacity 80ms ease; }
.grouping-amount:hover::after { opacity:1;visibility:visible; }
.grouping-table tr[data-parent-group] .pos { border-left:2px solid #c6dbea; }
.grouping-table .grouping-selected td { background:#deedf8; }
.grouping-message { margin-bottom:12px;padding:12px;background:#fff5df;color:#795216; }
.grouping-footer { padding:12px 0;color:#6b7280;font-size:12px; }
.line-item-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.line-item-actions > .add-line-item { margin: 0; }
.line-item-actions > .amount-basis-dropdown { margin-left: auto; }
@media(max-width:600px) { .grouping-modes button { padding:7px;font-size:12px; } .grouping-selection { flex-wrap:wrap; } }
.grouping-picker-scope { padding:8px 10px;background:#eaf3fa;color:#245b80;font-size:12px;border-radius:4px;margin-bottom:6px; }

.li-detail-line-fields { margin-top: 20px; }

.accounting-grouping-fields { display:flex;flex-direction:column;gap:16px;max-width:660px;margin-bottom:16px; }
.accounting-grouping-fields .form-group { min-width:0;margin-bottom:0; }
.accounting-grouping-fields fieldset { border:0;margin:0;padding:0;min-width:0; }
.accounting-grouping-fields legend { padding:0;margin-bottom:8px;font-weight:500; }
.accounting-grouping-option { display:flex;align-items:center;gap:8px;margin-bottom:8px;font-weight:400;cursor:pointer; }
.accounting-grouping-option input { flex:none;width:auto;margin:0; }
.accounting-grouping-threshold input { max-width:160px; }

/* AP list Skonto schedule: one compact percentage/date line per tier. */
.skonto-schedule-cell {
  min-width: 124px;
  vertical-align: middle;
  white-space: nowrap;
}
.skonto-schedule {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.skonto-schedule-line {
  display: flex;
  align-items: baseline;
  gap: 2px;
  line-height: 1.35;
}
.skonto-schedule-percentage {
  min-width: 29px;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
}
.skonto-schedule-date,
.skonto-schedule-empty {
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 13px;
}

/* AP list Cash Discount badge: percentage and days left. Dashed with a dot
   when the saving covers only part of the invoice; amber with "!" when the
   cash discount review warns. The shared [data-tip] tooltip states the saving,
   the payable amount and the invoice's own instruction; it opens to the left
   because the badge sits against the Amount column. */
.skonto-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  padding: 1px 6px;
  border: 1px solid #d8d8d8;
  background: transparent;
  color: #999;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: default;
}
.skonto-badge.is-partial {
  border-style: dashed;
  border-color: var(--border-strong);
}
.skonto-badge.is-unclear {
  border-color: var(--warning-border);
  color: var(--warning);
}
.skonto-badge .skonto-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.skonto-badge .skonto-bang {
  font-weight: 700;
}
/* The header's Skonto badge: an inline badge that opens the Cash Discount
   manager, amber when its saving ends within 2 days. */
.skonto-badge.skonto-indicator {
  align-self: center;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.skonto-badge.skonto-indicator:hover,
.skonto-badge.skonto-indicator:focus-visible {
  border-color: var(--border-strong);
  color: var(--fg-muted);
}
.skonto-badge.skonto-indicator.is-soon {
  border-color: var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning);
}
.skonto-badge[data-skonto-card] {
  cursor: help;
}
.skonto-badge.skonto-indicator[data-skonto-card] {
  cursor: pointer;
}

/* The card a Skonto badge shows on hover or focus (skonto-card.js). */
.skonto-hovercard {
  position: fixed;
  z-index: 900;
  width: 280px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 24px rgba(28, 24, 19, 0.12);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.45;
}
.skonto-hovercard[hidden] {
  display: none;
}
.skonto-card-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.skonto-card-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.skonto-card-row:last-of-type {
  border-bottom: 0;
}
.skonto-card-row.is-soon > span:first-child {
  color: var(--warning);
  font-weight: 600;
}
.skonto-card-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.skonto-card-count {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-subtle);
}
.skonto-card-note {
  margin-top: 6px;
  color: var(--fg-muted);
}
.skonto-card-quote {
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.skonto-card-warning {
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--warning-tint);
  border: 1px solid var(--warning-border);
  border-radius: var(--r-md);
}
.skonto-card-link {
  display: block;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}
.skonto-card-link:hover {
  text-decoration: underline;
}


.party-card-field-value-row-boxed.supplier-account-invalid {
  border-color: var(--danger-border);
  background: var(--danger-tint);
  color: var(--danger-strong);
}


.supplier-account-control {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
}

/* The longest party-field label wraps inside the shared 70px label column,
   so its box lines up with VAT-ID and Phone. */
.party-card-field.supplier-account .party-card-field-label {
  flex: 0 0 70px;
  max-width: 70px;
}

/* The open picker is a top-layer popover, so the box keeps its own height
   rather than collapsing to its padding while the value is swapped out. */
.supplier-account-control > .party-card-field-value-row-boxed {
  min-height: 32px;
}

.supplier-account-number {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.supplier-account-placeholder {
  color: var(--fg-subtle);
}
.supplier-account-feedback {
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  color: var(--danger-strong);
  font-size: 0.8125rem;
  line-height: 1.45;
  max-width: 34rem;
}
.supplier-account-feedback iconify-icon { flex-shrink: 0; margin-top: 0.15rem; }

/* Accounting supplier card: the seller's account and the policy's consolidated
   account as two radio tiles side by side (stacked once the panel is narrow).
   The confirmation opens only when the unbooked tile is picked, and shows the
   preview and button of the picked tile. */
/* Pulled up under Invoice Details so it sits 6px below the Delivery container,
   the gap between that section's own containers. */
.accounting-choice {
  margin: -8px 0 12px;
  padding: 12px 16px;
}
.accounting-choice.is-review { border-color: var(--warning-border); }
.accounting-choice-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}
.accounting-choice-summary::-webkit-details-marker { display: none; }
.accounting-choice-summary .payment-container-title { margin-bottom: 0; white-space: nowrap; }
.accounting-choice[open] > .accounting-choice-summary { margin-bottom: 10px; }
.accounting-choice[open] .accounting-choice-booked { display: none; }
.accounting-choice-booked {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
}
.accounting-choice-booked-name { overflow: hidden; text-overflow: ellipsis; }
.accounting-choice-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--fg-muted);
  transition: transform 0.15s;
}
.accounting-choice[open] .accounting-choice-chevron { transform: rotate(180deg); }
.accounting-choice-chip {
  flex-shrink: 0;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--info-tint);
  color: var(--brand-hover);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}
.accounting-choice-chip.is-warning { background: var(--warning-tint); color: var(--warning-strong); }
.accounting-choice-message {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 10px;
  color: var(--warning-strong);
  font-size: 13px;
  line-height: 1.45;
}
.accounting-choice-message iconify-icon { flex-shrink: 0; margin-top: 0.15rem; }
.accounting-choice-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.accounting-choice-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
}
.accounting-choice-option:hover { border-color: var(--brand-border); background: var(--brand-tint-hover); }
.accounting-choice-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.accounting-choice-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.accounting-choice-options:disabled .accounting-choice-option { cursor: default; }
.accounting-choice-options:disabled .accounting-choice-option:not(:has(input:checked)) {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--fg-muted);
}
.accounting-choice-option input { flex-shrink: 0; margin: 3px 0 0; accent-color: var(--brand); }
.accounting-choice-option-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.accounting-choice-option-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.accounting-choice-option-name { font-size: 14px; font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.accounting-choice-account { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }
.accounting-choice-account.is-missing { font-family: inherit; font-style: italic; }
.accounting-choice-option-description { font-size: 12px; line-height: 1.4; color: var(--fg-muted); }
.accounting-choice-confirm {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}
.accounting-choice-form:has(.accounting-choice-option input:checked:not([data-current])) .accounting-choice-confirm { display: flex; }
.accounting-choice-preview { display: none; margin: 0; font-size: 13px; line-height: 1.45; color: var(--fg); }
.accounting-choice-actions { display: flex; justify-content: flex-end; }
.accounting-choice-actions .btn { display: none; }
.accounting-choice-form:has(input[data-choice="source-seller"]:checked) .accounting-choice-preview[data-choice="source-seller"],
.accounting-choice-form:has(input[data-choice="consolidated"]:checked) .accounting-choice-preview[data-choice="consolidated"] { display: block; }
.accounting-choice-form:has(input[data-choice="source-seller"]:checked) .accounting-choice-actions .btn[data-choice="source-seller"],
.accounting-choice-form:has(input[data-choice="consolidated"]:checked) .accounting-choice-actions .btn[data-choice="consolidated"] { display: inline-flex; }
.accounting-choice-reason-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.accounting-choice-hint { font-weight: 400; letter-spacing: 0; text-transform: none; }
.accounting-choice-reason {
  box-sizing: border-box;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.accounting-choice-reason:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
#accounting-supplier-result:not(:empty) { margin-top: 8px; font-size: 13px; }
.accounting-choice-note { margin: 8px 0 0; font-size: 12px; color: var(--fg-muted); }
.supplier-account-note {
  display: block;
  color: var(--fg-subtle);
  font-size: 0.8125rem;
  line-height: 1.45;
  max-width: 34rem;
}
.approval-callout { margin-bottom: 12px; }
.approval-callout iconify-icon { display: inline-flex; flex-shrink: 0; align-items: center; height: 21px; font-size: 16px; color: var(--warning); }
.approval-callout a { color: inherit; text-decoration: underline; text-underline-offset: 0.15em; }
.approval-catalogue-refresh { margin-left: 8px; }
#supplier-account-field { scroll-margin-top: 6rem; }

/* AP export controls share the Received toolbar and payment selection. */
.ap-export-split {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.documents-page:has(#ap-export-split) > .page-header > .page-header-actions {
  position: relative;
  z-index: 3;
}
.ap-export-main,
.ap-export-split > .filter-dropdown-trigger {
  box-sizing: border-box;
  height: 32px;
  padding-block: 0;
  line-height: normal;
}
.ap-export-main { border-radius: var(--r-md) 0 0 var(--r-md); gap: 6px; }
/* While the wizard loads, the icon gives way to the shared spinner
   (.htmx-indicator) and a second click is ignored. The label stays, so the
   toolbar keeps its width and its filters do not reflow. */
.ap-export-main.htmx-request { pointer-events: none; }
.ap-export-main.htmx-request .ap-export-main-icon { display: none; }
.ap-export-submit[aria-busy="true"] .ap-batch-spinner { display: inline-block; }
dialog.ap-export-wizard[aria-busy="true"] .history-modal-close { visibility: hidden; }
.ap-export-split > .filter-dropdown-trigger {
  border-radius: 0 var(--r-md) var(--r-md) 0;
  border-left: 0;
  padding-inline: 8px;
}
dialog.ap-export-wizard {
  width: min(640px, 94vw);
  max-height: 85vh;
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}
dialog.ap-export-wizard[open] { display: flex; }
dialog.ap-export-wizard::backdrop { background: rgba(18, 16, 11, 0.45); backdrop-filter: blur(6px); }
.ap-export-wizard-content { display: flex; flex-direction: column; min-height: 0; width: 100%; background: var(--surface); }
.ap-export-wizard-body { padding: 24px; overflow-y: auto; }
.ap-export-wizard-body h3 { margin: 0 0 12px; font: var(--text-h3); }
.ap-export-choice { display: flex; align-items: center; gap: 12px; padding: 14px; margin-block: 8px; border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
.ap-export-choice:has(input:checked) { border-color: var(--brand-border); background: var(--brand-tint); }
.ap-export-count { margin-left: auto; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.ap-export-summary { padding: 14px; border-radius: var(--r-md); background: var(--brand-tint); }
.ap-export-warning { padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--fg-muted); }
.ap-export-result .btn { margin: 8px 8px 0 0; }
.ap-export-blockers { margin: 8px 0; padding-left: 20px; max-height: 240px; overflow-y: auto; }
.ap-export-blockers li { margin: 4px 0; }
.ap-export-wizard [hidden] { display: none; }
@media (max-width: 600px) {
  .ap-export-wizard-body { padding: 16px; }
}

/* The AP list's batch dialog: how many selected invoices the action takes,
   what would let it take more, and why it leaves the others out. */
dialog.ap-batch-dialog {
  width: min(520px, 94vw);
  max-height: 85vh;
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}
dialog.ap-batch-dialog[open] { display: flex; }
dialog.ap-batch-dialog::backdrop { background: rgba(18, 16, 11, 0.45); backdrop-filter: blur(6px); }
.ap-batch-dialog-content { display: flex; flex-direction: column; min-height: 0; width: 100%; background: var(--surface); }
.ap-batch-title { margin: 0; font: var(--text-h3); }
.ap-batch-dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 4px 24px 24px; overflow-y: auto; }
.ap-batch-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--fg);
}
.ap-batch-summary-count { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--brand-pressed); }
.ap-batch-summary-of { color: var(--fg-muted); }

dialog.ap-batch-dialog:has(.ap-run-check) { width: min(720px, 94vw); }
.ap-batch-dialog-body:has(> .ap-run-check) { padding-top: 16px; overflow: hidden; }
.ap-run-check { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; }
.ap-run-check-groups { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }
.ap-run-check-group { flex: none; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.ap-run-check-group.is-risk { border-color: #d9a441; }
.ap-run-check-group.is-risk .ap-run-check-head { background: #fdf6e7; }
.ap-run-check-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; }
.ap-run-check-head iconify-icon { flex: none; margin-top: 2px; color: var(--fg-muted); }
.ap-run-check-head .ap-run-check-ok { color: #2f8a57; }
.ap-run-check-head .ap-run-check-warning { color: #b7791f; }
.ap-run-check-title { font-weight: 600; }
.is-muted .ap-run-check-title { font-weight: 500; }
.ap-run-check-sub { margin-top: 2px; color: var(--fg-muted); font-size: 13px; line-height: 1.45; }
.ap-run-check-sub b, .ap-run-check-intro b { font-weight: 600; color: var(--fg); }
details.ap-run-check-group > summary { list-style: none; cursor: pointer; }
details.ap-run-check-group > summary::-webkit-details-marker { display: none; }
.ap-run-check-head iconify-icon.ap-run-check-chevron { margin-left: auto; transition: transform 0.15s ease; }
details[open] .ap-run-check-chevron { transform: rotate(180deg); }
.ap-run-check-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.ap-run-check-row {
  display: grid;
  grid-template-columns: 118px 1fr 210px 92px;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 7px 14px;
  font-size: 13px;
}
.ap-run-check-row.has-pick { grid-template-columns: 22px 118px 1fr 130px 92px; }
.ap-run-check-row + .ap-run-check-row { border-top: 1px solid var(--border); }
.ap-run-check-row input { justify-self: start; margin: 0; accent-color: var(--brand); }
.ap-run-check-number { font-family: 'JetBrains Mono', monospace; font-size: 12px; overflow-wrap: anywhere; }
.ap-run-check-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ap-run-check-note { color: var(--fg-muted); }
.ap-run-check-row.is-off { color: var(--fg-muted); }
.ap-run-check-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-top: 1px solid var(--border);
}
.ap-run-check-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.ap-run-check-option:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.ap-run-check-option input { flex: none; margin: 2px 0 0; accent-color: var(--brand); }
.ap-run-check-option b { display: block; font-weight: 600; }
.ap-run-check-option small { display: block; color: var(--fg-muted); font-size: 12px; }
.ap-run-check-intro { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.45; }
.ap-run-check-all {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 7px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: 12px;
  cursor: pointer;
}
.ap-run-check-all input { margin: 0; accent-color: var(--brand); }
.ap-run-check-gate {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 6px;
  background: #fdf6e7;
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
}
.ap-run-check-gate[hidden] { display: none; }
.payment-method-override .form-group label.payment-method-gate {
  display: none;
  margin-top: 8px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  letter-spacing: normal;
  text-transform: none;
}
.payment-method-override:has(option[value="transfer-orcha-run"]:checked) .form-group label.payment-method-gate {
  display: flex;
}
.ap-run-check-gate input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: #b7791f; }
.ap-run-check-gate b { display: block; font-weight: 600; }
.ap-run-check-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ap-run-check-foot-note { color: var(--fg-muted); font-size: 13px; }
.ap-run-check-foot .ap-batch-actions { flex: none; margin: 0; }
.ap-batch-groups { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ap-batch-groups:empty { display: none; }
.ap-batch-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
}
.ap-batch-group > iconify-icon { flex: none; font-size: 15px; color: var(--fg-muted); }
.ap-batch-group-text { flex: 1; min-width: 0; }
.ap-batch-group.is-blocked { color: var(--fg-muted); }
.ap-batch-group .btn { flex: none; }
.ap-batch-also-release { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; }
.ap-batch-show-others { align-self: flex-start; font-size: 13px; }
.ap-batch-actions { display: flex; justify-content: flex-end; gap: 12px; }
.ap-batch-run-checks { display: inline-flex; align-items: center; gap: 6px; }
.ap-batch-spinner {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ap-batch-spin 0.8s linear infinite;
}
.ap-batch-commit { display: inline-flex; align-items: center; gap: 8px; }
.ap-batch-spinner.is-active,
.ap-batch-run-checks.htmx-request .ap-batch-spinner,
.ap-batch-commit.htmx-request .ap-batch-spinner { display: inline-block; }
dialog.ap-batch-dialog[aria-busy="true"] .history-modal-close { visibility: hidden; }
dialog.ap-batch-dialog[aria-busy="true"] a { pointer-events: none; opacity: 0.5; }
@keyframes ap-batch-spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  .ap-batch-dialog-body { padding: 4px 16px 16px; }
}

/* The unmatch confirmations open straight on their rows, with no subtitle
   between: the first block keeps the dialog's spacing below its header. */
#bank-unmatch-dialog .ap-batch-dialog-body,
#workbench-unmatch-dialog .ap-batch-dialog-body { padding-top: 20px; }
@media (max-width: 640px) {
  #bank-unmatch-dialog .ap-batch-dialog-body,
  #workbench-unmatch-dialog .ap-batch-dialog-body { padding-top: 16px; }
}

/* Hovering a batch action marks the rows it takes and fades the rest. */
#document-list table.ap-batch-preview tbody tr { transition: opacity 0.12s, background 0.12s; }
#document-list table.ap-batch-preview tbody tr:not(.is-batch-target) { opacity: 0.4; }
#document-list table.ap-batch-preview tbody tr.is-batch-target { background: var(--brand-tint); }

.ap-export-step-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}
.ap-export-history-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}
.ap-export-history-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
}
.table td.ap-export-history-outcome {
  min-width: 240px;
  white-space: normal;
}
/* Below this width the six columns only fit if their text may wrap. */
@media (max-width: 900px) {
  #ap-export-history-modal .table td { white-space: normal; }
  #ap-export-history-modal .table td.ap-export-history-outcome { min-width: 150px; }
}
.ap-export-history-status {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
  font-size: 13px;
  vertical-align: middle;
}
.ap-export-history-status iconify-icon {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 14px;
}
.ap-export-history-status.is-pending { color: var(--fg-muted); }
.ap-export-history-status.is-failed { color: var(--danger-strong); }
.ap-export-history-date {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ap-export-history-filter .european-date-picker { height: 34px; }
.ap-export-history-filter select,
.ap-export-history-filter input[type="date"],
.ap-export-history-filter [data-european-date-display] {
  box-sizing: border-box;
  min-width: 128px;
  height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: var(--text-sm);
}
.ap-export-history-filter select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

/* Received's export actions need a second row before the shared phone layout. */
@media (min-width: 741px) and (max-width: 900px) {
  .documents-page:has(#ap-export-split) > .page-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .documents-page:has(#ap-export-split) > .page-header > .page-header-left {
    flex: 1 1 100%;
  }
  .documents-page:has(#ap-export-split) > .page-header > .page-header-actions {
    margin-left: auto;
    padding-left: 0;
  }
}
@media (max-width:720px) {
  #banking-page-body.banking-page-body:has(> .banking-transactions) { overflow-x:auto; }
  .banking-transactions { min-width:1100px; }
  .bank-duplicate-pair-page .bank-review-facts > div { grid-template-columns:90px minmax(0,1fr); gap:8px; }
}
.banking-superseded-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:16px; }

.zero-amount-export-skipped > td {
  color: var(--fg-subtle);
  background: var(--bg-subtle);
}
.zero-amount-export-skipped .amount,
.zero-amount-export-skipped .editable-value,
.zero-amount-export-skipped .li-account-number {
  color: var(--fg-subtle);
}
.zero-amount-export-info {
  display: inline-flex; align-items: center; height: 29px;
  margin-left: 6px; vertical-align: middle;
}
.line-items td.amount:has(> .zero-amount-export-info) > .editable-value[data-field-type="currency"] {
  display: inline-block !important;
  width: calc(100% - 26px);
  max-width: calc(100% - 26px);
  vertical-align: middle;
}
.line-items.grouping-table tbody > tr.li-row > td.amount:has(> .zero-amount-export-info) > .editable-value[data-field-type="currency"].is-editing {
  right: 28px;
  width: 170px !important;
  max-width: none !important;
}
.zero-amount-export-info-button {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; padding: 3px; background: transparent; color: var(--fg-subtle);
  cursor: help; border-radius: 3px;
}
.zero-amount-export-info-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.zero-amount-export-info-button iconify-icon { font-size: 14px; }
.zero-amount-export-tooltip {
  display: none; position: fixed; inset: auto; margin: 0;
  width: min(280px, calc(100vw - 24px)); padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-card);
  text-align: left; white-space: normal; font: 13px/1.5 var(--font-sans);
  z-index: 1000; pointer-events: none;
}
.zero-amount-export-tooltip[data-open="true"] { display: block; }
.zero-amount-export-tooltip strong,
.zero-amount-export-tooltip span { display: block; }
.zero-amount-export-tooltip span { margin-top: 5px; }
.zero-amount-export-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; }
.zero-amount-export-note iconify-icon { font-size: 14px; }
.zero-amount-export-toggle {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  font-size: 13px; color: var(--fg-muted); cursor: pointer;
}
.zero-amount-export-toggle:has(input:disabled) { cursor: not-allowed; opacity: .7; }
.grouping-toolbar:has(.zero-amount-export-toggle) { flex-wrap: wrap; }

.accounting-zero-amount-export { border: 0; padding: 0; margin: 0 0 16px; max-width: 660px; }
.accounting-zero-amount-export legend { padding: 0; margin-bottom: 8px; font-weight: 500; }
.accounting-zero-amount-export p { margin: 0; color: var(--fg-muted); font-size: 13px; }
.accounting-due-date { border: 0; padding: 0; margin: 0 0 16px; max-width: 660px; }
.accounting-due-date legend { padding: 0; margin-bottom: 8px; font-weight: 500; }
.accounting-due-date .form-group { margin-bottom: 0; }
.accounting-due-date .form-group input { max-width: 160px; }
.accounting-due-date p { margin: 8px 0 0; color: var(--fg-muted); font-size: 13px; }
.accounting-transfers-paid-via { border: 0; padding: 0; margin: 0 0 24px; max-width: 660px; }
.accounting-transfers-paid-via legend { padding: 0; margin-bottom: 8px; font-weight: 500; }
.accounting-transfers-paid-via p { margin: 8px 0 0; color: var(--fg-muted); font-size: 13px; }

/* Visible review sections share the full footer width equally. */
.invoice-workflow-footer {
  position: sticky;
  bottom: 10px;
  z-index: 6;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin: 16px 0 -14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: 0 10px 28px rgba(28, 24, 19, .18), 0 2px 6px rgba(28, 24, 19, .08);
  container-type: inline-size;
  container-name: invoice-footer;
}
.invoice-workflow-footer .workflow-column {
  position: relative;
  min-width: 0;
  padding: 10px;
}
.invoice-workflow-footer:not([data-stage-focus]) .workflow-column:not(.workflow-column-empty):not(:has(> .workflow-column-empty)):not(:empty) ~ .workflow-column {
  border-left: 1px solid var(--border);
}
.invoice-workflow-footer .workflow-column-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 100%;
}
.invoice-workflow-footer .approval-footer {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 0;
}
/* The footer keeps its bar a row at every width; the narrow approval panel's
   stacked bar does not apply here (the container query below wraps it). */
.invoice-workflow-footer .approval-footer-bar { padding: 0; height: 100%; gap: 6px; flex-direction: row; align-items: center; }
.invoice-workflow-footer .approval-footer-text,
.invoice-workflow-footer .workflow-popover { flex: 1; min-width: 0; }
/* The status keeps a readable start beside its actions instead of "A…". */
.invoice-workflow-footer .workflow-release-summary,
.invoice-workflow-footer .workflow-export-summary { min-width: 4.5em; }
.invoice-workflow-footer .approval-footer-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invoice-workflow-footer .approval-footer-actions,
.invoice-workflow-footer .workflow-matching-actions { display: flex; gap: 4px; flex: none; align-items: center; width: auto; }
.invoice-workflow-footer .btn { padding: 5px 7px; font-size: 12px; white-space: nowrap; }
.invoice-workflow-footer .approval-footer-avatars .approver-avatar { width: 24px; height: 24px; font-size: 10px; }
.invoice-workflow-footer .workflow-popover > summary { cursor: pointer; list-style: none; }
.invoice-workflow-footer .workflow-popover > summary::-webkit-details-marker { display: none; }
.invoice-workflow-footer .workflow-popover-body,
.invoice-workflow-footer .approval-footer-list,
.invoice-workflow-footer .approval-footer .approval-callout {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: min(440px, 70vw);
  max-height: 45vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 12px;
  margin: 0;
}
.invoice-workflow-footer .workflow-export-column .workflow-popover-body { left: auto; right: 0; }
.invoice-workflow-footer .workflow-footer-poll { display: none; }
@container invoice-footer (max-width: 950px) {
  .invoice-workflow-footer .approval-footer-meta,
  .invoice-workflow-footer .approval-footer-avatars { display: none; }
  .invoice-workflow-footer .workflow-matching-actions { gap: 3px; }
  /* The approval's actions stay beside its title, like the Release and Export
     actions, and take a line of their own only when the title would shrink
     below a readable width. */
  .invoice-workflow-footer .approval-footer-bar { flex-wrap: wrap; row-gap: 4px; }
  .invoice-workflow-footer .approval-footer-bar > .approval-footer-text,
  .invoice-workflow-footer .approval-footer-bar > .approval-footer-summary { flex: 1 1 9em; min-width: 0; }
}
/* Stacked panels scroll the page, whose bottom the fixed .app-footer (28px)
   covers. */
@media (max-width: 900px) {
  .invoice-workflow-footer { bottom: calc(28px + 10px); }
}
@media (max-width: 600px) {
  .invoice-workflow-footer { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
  .invoice-workflow-footer:not([data-stage-focus]) .workflow-column:not(.workflow-column-empty):not(:has(> .workflow-column-empty)):not(:empty) ~ .workflow-column { border-left: 0; border-top: 1px solid var(--border); }
  .invoice-workflow-footer .workflow-matching-actions { flex-direction: row; }
}

.invoice-workflow-footer .workflow-approval-column { display: flex; align-items: center; gap: 5px; }
.approval-capability-footer .workflow-approval-column { flex-wrap: nowrap; }
@media (max-width: 600px) {
  .approval-capability-footer .workflow-approval-column { flex-wrap: wrap; }
  .approval-capability-footer .approval-review-all-approvals { flex: 1 0 100%; }
}
/* While the organization is paused the footer shows status only: the pause
   script marks every action it disables. */
.invoice-workflow-footer [data-pause-disabled][aria-disabled="true"] { display: none; }
/* An approval column with actions gets a larger share, so its title and its
   buttons fit on one line like the Release and Export columns. */
@media (min-width: 601px) {
  .invoice-workflow-footer:not([data-stage-focus]):not(:has(> .workflow-release-column)):has(> .workflow-approval-column:nth-child(1 of .workflow-column) .approval-footer-actions) {
    grid-template-columns: minmax(0, 1.45fr);
  }
  .invoice-workflow-footer:not([data-stage-focus]):not(:has(> .workflow-release-column)):has(> .workflow-approval-column:nth-child(2 of .workflow-column) .approval-footer-actions) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
  }
  /* Approval, Release, Export keep the same shares in every state, so
     approving or releasing never resizes the columns: Approval fits Approve
     and Reject, Release fits its button, and its "by" note truncates. */
  .invoice-workflow-footer:not([data-stage-focus]):has(> .workflow-release-column) {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.15fr);
  }
}
.invoice-workflow-footer .workflow-column-empty,
.invoice-workflow-footer .workflow-column:has(> .workflow-column-empty),
.invoice-workflow-footer .workflow-column:empty { display: none; }
.invoice-workflow-footer .workflow-approval-column > .approval-footer { flex: 1; min-width: 0; }
.invoice-workflow-footer .workflow-release-action { flex: none; }
.invoice-workflow-footer .approval-footer-eyebrow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}
.invoice-workflow-footer .workflow-check-error {
  color: var(--danger-strong);
  font-size: 12px;
}
.invoice-workflow-footer .approval-footer-list .approvers-list li {
  flex-wrap: nowrap;
  gap: 8px;
}
.invoice-workflow-footer .approval-footer-list .approver-trailing {
  flex: none;
  min-width: 0;
  justify-content: flex-end;
}
.invoice-workflow-footer .approval-footer-list .approver-trailing .text-input {
  min-width: 0;
  flex: none;
  width: clamp(90px, 20cqw, 160px);
}
.invoice-workflow-footer .approval-footer-list .approver-trailing .approval-reject-dialog .text-input {
  width: 100%;
}
/* Deciding on behalf takes a reason: the reason field and the decisions
   take a line of their own under the approver's name, so the name stays
   readable and the panel never scrolls sideways. */
.invoice-workflow-footer .approval-footer-list .approvers-list li:has(> .approver-trailing > .text-input) {
  flex-wrap: wrap;
  row-gap: 8px;
}
.invoice-workflow-footer .approval-footer-list .approvers-list li:has(> .approver-trailing > .text-input) > .approver-id {
  flex: 1 1 0;
  min-width: 0;
}
.invoice-workflow-footer .approval-footer-list .approver-trailing:has(> .text-input) {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin-left: 0;
  align-items: center;
  gap: 6px;
  padding-left: calc(24px + 10px);
  box-sizing: border-box;
}
.invoice-workflow-footer .approval-footer-list .approver-trailing:has(> .text-input) > .text-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 30px;
  font-size: 13px;
}
.approval-footer-list .approver-trailing .btn-icon { width: 24px; height: 24px; }
/* Adding an approver by hand, under the roster. */
.approval-footer-list .approvers-add {
  display: flex;
  padding: 8px 0 10px;
  border-top: 1px solid var(--border-subtle);
}
.approval-footer-list .approvers-list:empty + .approvers-add { border-top: 0; }
/* The approver picker: a type-ahead whose options open in flow under the
   input, so the overlay holding them never clips them. */
.add-approver-form.approver-picker { flex-wrap: wrap; }
.approver-picker-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
}
.approver-picker-options {
  order: 3;
  flex-basis: 100%;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.approver-picker-options[hidden],
.approver-picker-options li[hidden] { display: none; }
.approver-picker-status {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--fg-muted);
}
.approver-picker-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.approver-picker-option:hover,
.approver-picker-option:focus-visible { background: var(--bg-hover); outline: none; }
.approver-picker-email { font-size: 12px; color: var(--fg-muted); }
.approver-picker-retry {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.approval-footer-overlays { display: contents; }
.invoice-workflow-footer .workflow-approval-column,
.invoice-workflow-footer .approval-footer { position: static; }
.invoice-workflow-footer .approval-footer-overlays {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.invoice-workflow-footer .approval-footer-list,
.invoice-workflow-footer .approval-footer .approval-callout {
  position: static;
  transform: none;
  flex: none;
  box-sizing: border-box;
  pointer-events: auto;
}
.invoice-workflow-footer .approval-footer-list { width: 100%; }
.invoice-workflow-footer .approval-footer .approval-callout { width: min(440px, 100%); }
.invoice-workflow-footer .workflow-export-column { position: static; }
.invoice-workflow-footer .workflow-export-column .workflow-popover-body {
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
}
.invoice-workflow-footer:has(.workflow-popover[open]) .approval-footer-overlays { display: none; }
.invoice-workflow-footer .workflow-footer-overlays {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.invoice-workflow-footer .workflow-footer-overlays > * { pointer-events: auto; }

/* Footer panels (edits, approvers, release checklist, export): one card
   that opens above the stage it belongs to (the footer script sets
   `--panel-left` to that stage's left edge), with a heading, the items that
   hold the stage up, its rows and its actions. */
.invoice-workflow-footer .workflow-footer-overlays { bottom: calc(100% + 8px); align-items: flex-start; }
.invoice-workflow-footer .workflow-footer-overlays > .approval-footer-list,
.invoice-workflow-footer .workflow-footer-overlays > .workflow-export-panel {
  display: block;
  width: min(440px, 100%);
  box-sizing: border-box;
  max-height: 52vh;
  overflow: auto;
  margin: 0 0 0 var(--panel-left, 0px);
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-popover);
  font-size: 13px;
}
.invoice-workflow-footer .workflow-footer-overlays > .workflow-export-panel:not(.workflow-release-panel) { padding: 14px 16px; }
.invoice-workflow-footer > .workflow-column:has([aria-expanded="true"]) { background: var(--brand-tint); }
.invoice-workflow-footer > .workflow-column :is(.approval-footer-summary, .approval-footer-bar, .approval-footer) { background: transparent; }
.invoice-workflow-footer .footer-panel-head { margin-bottom: 4px; }
.invoice-workflow-footer .footer-panel-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 2px;
  font: 600 14px/1.35 var(--font-sans);
  color: var(--fg);
}
.invoice-workflow-footer .footer-panel-head h3 iconify-icon { flex: none; font-size: 15px; color: var(--fg-muted); }
.invoice-workflow-footer .footer-panel-head p { margin: 0; color: var(--fg-muted); font-size: 13px; line-height: 1.45; }
.invoice-workflow-footer .footer-panel-group,
.invoice-workflow-footer .footer-panel-issues {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.invoice-workflow-footer .footer-panel-group-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font: 600 11px/1.3 var(--font-sans);
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.invoice-workflow-footer .footer-panel-issues .footer-panel-group-heading { color: var(--warning-strong); }
.invoice-workflow-footer .footer-panel-issues ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.invoice-workflow-footer .footer-panel-issues li {
  display: grid;
  gap: 1px;
  padding: 5px 0 5px 10px;
  border-left: 3px solid var(--amber-500);
}
.invoice-workflow-footer .footer-panel-issues li.is-note { border-left-color: var(--border-strong); }
.invoice-workflow-footer .footer-panel-issues li > a,
.invoice-workflow-footer .footer-panel-issues li > span:first-child { font-weight: 600; color: var(--warning-strong); text-decoration: none; }
.invoice-workflow-footer .footer-panel-issues li.is-note > a,
.invoice-workflow-footer .footer-panel-issues li.is-note > span:first-child { color: var(--fg); }
.invoice-workflow-footer .footer-panel-issues li > a:hover { text-decoration: underline; }
.invoice-workflow-footer .footer-panel-issue-detail { font-size: 12px; color: var(--fg-muted); }
.invoice-workflow-footer .footer-panel-issues li > .btn { justify-self: start; margin-top: 4px; }
.invoice-workflow-footer .footer-panel-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--warning-tint);
  color: var(--warning-strong);
  font-size: 12px;
}
.invoice-workflow-footer .footer-panel-note.is-info { background: var(--brand-tint); color: var(--brand-hover); }
.invoice-workflow-footer .footer-panel-note iconify-icon { flex: none; margin-top: 2px; }
.invoice-workflow-footer .footer-panel-more { margin: 6px 0 0; font-size: 12px; color: var(--fg-subtle); }
.invoice-workflow-footer .workflow-footer-overlays .approval-revoke-note,
.invoice-workflow-footer .workflow-footer-overlays .approval-rate-note { margin: 10px 0 0; font-size: 12px; color: var(--fg-muted); }
.invoice-workflow-footer .workflow-footer-overlays .footer-panel-head + .approvers-list,
.invoice-workflow-footer .workflow-footer-overlays .footer-panel-head + .workflow-export-details,
.invoice-workflow-footer .workflow-footer-overlays .footer-panel-issues + .approvers-list,
.invoice-workflow-footer .workflow-footer-overlays .footer-panel-issues + .workflow-export-details,
.invoice-workflow-footer .workflow-footer-overlays .approval-rate-note + .approvers-list,
.invoice-workflow-footer .workflow-footer-overlays .approval-revoke-note + .approvers-list {
  margin-top: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}
.invoice-workflow-footer .workflow-footer-overlays .approvers-list:empty { display: none; }
.approver-state.is-reset {
  background: var(--warning-tint);
  color: var(--warning-strong);
  border: 1px solid var(--warning-border);
}
.invoice-workflow-footer .workflow-release-summary:hover .approval-footer-title,
.invoice-workflow-footer .workflow-export-summary:hover .approval-footer-title,
.invoice-workflow-footer .workflow-edits-summary:hover .approval-footer-title { color: var(--brand); }
/* Explicit checks: a spinner while the request is in flight, then a
   running pill until the check finishes. */
@keyframes workflow-spin { to { transform: rotate(360deg); } }
.invoice-workflow-footer .workflow-spinner {
  display: none;
  flex: none;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: workflow-spin .7s linear infinite;
}
.invoice-workflow-footer .workflow-check-button.htmx-request .workflow-spinner,
.invoice-workflow-footer .workflow-export-button.htmx-request .workflow-spinner,
.invoice-workflow-footer .workflow-export-button[aria-busy="true"] .workflow-spinner,
.invoice-workflow-footer .workflow-check-running .workflow-spinner { display: inline-block; }
.invoice-workflow-footer .workflow-check-button.htmx-request,
.invoice-workflow-footer .workflow-export-button.htmx-request { cursor: progress; opacity: .85; }
.invoice-workflow-footer .workflow-check-running {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.invoice-workflow-footer .workflow-disclosure {
  margin-left: 3px;
  font-size: 11px;
  vertical-align: -1px;
  color: var(--fg-faint);
  transition: transform var(--dur-fast, .12s) var(--ease, ease);
}
.invoice-workflow-footer [aria-expanded="true"] .workflow-disclosure { transform: rotate(180deg); color: var(--brand); }
.invoice-workflow-footer .approval-footer-summary:hover .workflow-disclosure,
.invoice-workflow-footer .workflow-release-summary:hover .workflow-disclosure,
.invoice-workflow-footer .workflow-export-summary:hover .workflow-disclosure,
.invoice-workflow-footer .workflow-edits-summary:hover .workflow-disclosure { color: var(--brand); }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details { border-top: 0; }
.invoice-workflow-footer .workflow-footer-overlays .approvers-list { margin: 0; padding: 0; }
.invoice-workflow-footer .workflow-footer-overlays .approvers-list > li {
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.invoice-workflow-footer .workflow-footer-overlays .approvers-list > li:last-child { border-bottom: 0; }
.invoice-workflow-footer .workflow-footer-overlays .approver-avatar { flex: none; width: 24px; height: 24px; font-size: 10px; }
.invoice-workflow-footer .workflow-footer-overlays .approver-id { flex: 1; min-width: 0; }
.invoice-workflow-footer .workflow-footer-overlays .approver-trailing { flex: none; margin-left: auto; }
/* The export row's explanation reads as the row's second line, like the
   approvers' and the release checklist's: one grid row whose icon and state
   pill centre on the name and the explanation together. */
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details:has(> .workflow-detail-content) {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: center;
  padding: 8px 0;
}
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details:has(> .workflow-detail-content) .workflow-detail-list,
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details:has(> .workflow-detail-content) .workflow-detail-list > li { display: contents; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details:has(> .workflow-detail-content) .approver-avatar { grid-column: 1; grid-row: 1 / span 2; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details:has(> .workflow-detail-content) .approver-id { grid-column: 2; grid-row: 1; align-self: end; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details:has(> .workflow-detail-content) .approver-trailing { grid-column: 3; grid-row: 1 / span 2; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-detail-content {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  margin: 0;
  padding: 0;
  font-size: 11px;
  line-height: 16.5px;
  color: var(--fg-faint);
}
.invoice-workflow-footer .workflow-footer-overlays .workflow-detail-content p { margin-bottom: 2px; }
/* Error details use their own row so the upload icon centres on the callout,
   independently of the destination heading and retry action. */
.invoice-workflow-footer .workflow-footer-overlays > .workflow-export-panel:not(.workflow-release-panel) { padding: 8px 16px; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details.has-delivery-error {
  grid-template-columns: 24px minmax(0, 1fr);
  row-gap: 8px;
}
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details .panel-callout { align-items: center; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details .panel-callout > iconify-icon { flex: none; font-size: 14px; line-height: 1; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details .panel-callout .callout-text p { margin: 0; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details .panel-callout .callout-text p + p { margin-top: 4px; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details.has-delivery-error .approver-avatar { grid-row: 2; }
.invoice-workflow-footer .workflow-footer-overlays > .workflow-export-panel[data-delivery-phase="exporting"] .workflow-export-details:has(.panel-callout) .approver-avatar { grid-row: 2; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details.has-delivery-error .workflow-detail-content { display: contents; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details.has-delivery-error .workflow-detail-content > * { grid-column: 2; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details.has-delivery-error .workflow-detail-content > :first-child { grid-row: 2; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-detail-content > .workflow-export-button { margin-top: 8px; justify-self: start; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-details.has-delivery-error .workflow-detail-content > .workflow-export-button { margin-top: 0; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-actions { font-size: 12px; }
.invoice-workflow-footer .workflow-footer-overlays .workflow-export-actions { margin-top: 4px; gap: 4px 16px; }
/* Footer stages. Every shown column opens with its numbered marker (a CSS
   counter, so hidden columns are not counted), coloured by the column's
   `data-stage-tone`. The footer script (`document-status-strip.js`) expands
   the stage that needs the viewer (`.is-stage-focus`) and collapses the
   others to their marker and a short label. The footer is a size container,
   whose style containment hides its own counter-reset from its children, so
   the first child resets the counter for its siblings. */
.invoice-workflow-footer > :first-child { counter-reset: workflow-stage; }
.invoice-workflow-footer > .workflow-column[data-stage-key]:not(:has(> .workflow-column-empty)) {
  display: flex;
  align-items: center;
  gap: 8px;
}
.invoice-workflow-footer > .workflow-column > .workflow-column-row { flex: 1; min-width: 0; }
.invoice-workflow-footer .stage-num {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 3px;
  border-radius: 50%;
  background: var(--stone-100);
  color: var(--stone-600);
  box-shadow: inset 0 0 0 1.5px var(--stone-300);
  font: 700 15px/1 var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
}
.invoice-workflow-footer .stage-num::before {
  counter-increment: workflow-stage;
  content: counter(workflow-stage);
}
.invoice-workflow-footer .stage-num::after {
  content: "";
  display: none;
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--stone-500) no-repeat center / 9px 9px;
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="draft"], :has([data-stage-tone="draft"])) > .stage-num {
  background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0)), var(--amber-500);
  color: var(--white);
  box-shadow: 0 0 0 3px var(--warning-tint), 0 1px 2px rgba(125, 78, 0, .35);
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="active"], :has([data-stage-tone="active"])) > .stage-num {
  background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0)), var(--brand);
  color: var(--white);
  box-shadow: 0 0 0 3px var(--brand-border), 0 1px 2px rgba(7, 90, 158, .35);
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="attention"], :has([data-stage-tone="attention"])) > .stage-num {
  background: var(--warning-tint);
  color: var(--warning-strong);
  box-shadow: inset 0 0 0 1.5px var(--warning-border);
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="info"], :has([data-stage-tone="info"])) > .stage-num {
  background: var(--brand-tint);
  color: var(--brand);
  box-shadow: inset 0 0 0 1.5px var(--info-border);
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="done"], :has([data-stage-tone="done"])) > .stage-num {
  background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0)), var(--success);
  color: var(--white);
  box-shadow: 0 0 0 3px var(--success-tint);
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="blocked"], :has([data-stage-tone="blocked"])) > .stage-num {
  color: var(--fg-faint);
  box-shadow: inset 0 0 0 1.5px var(--border);
}
.invoice-workflow-footer .workflow-column:is([data-stage-tone="blocked"], :has([data-stage-tone="blocked"])) > .stage-num::after {
  display: block;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='11' x='3' y='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
}
/* A stage held up by requirements or notes carries their count on its marker. */
.invoice-workflow-footer .workflow-column[data-stage-key] > .stage-num.stage-num[data-issues]::after {
  content: attr(data-issues);
  display: grid;
  place-items: center;
  right: -6px;
  top: -6px;
  bottom: auto;
  width: auto;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  box-sizing: border-box;
  background: var(--amber-500);
  background-image: none;
  color: var(--white);
  font: 700 9.5px/1 var(--font-sans);
  border-radius: var(--r-pill);
}
.invoice-workflow-footer .workflow-edits-column .approval-footer-avatars .approver-avatar { margin-left: -6px; border: 2px solid var(--surface); }
.invoice-workflow-footer .workflow-edits-column .approval-footer-avatars .approver-avatar:first-child { margin-left: 0; }
.invoice-workflow-footer .workflow-edits-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
/* The panel scrolls when its content outgrows it; Save and Discard stay on its
   bottom edge, over the panel's own background and bottom padding. */
.invoice-workflow-footer .workflow-edits-panel .workflow-edits-actions {
  position: sticky;
  bottom: -14px;
  margin: 14px -16px -14px;
  padding: 10px 16px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
}
.invoice-workflow-footer .workflow-edits-discard { border-color: transparent; background: transparent; color: var(--danger-strong); }
.invoice-workflow-footer .workflow-edits-discard:hover { background: var(--danger-tint); }
.invoice-workflow-footer .approval-footer-meta.is-warning { color: var(--warning-strong); }
/* The draft's changes: one row per field, saved value struck through. */
.invoice-workflow-footer .workflow-edits-changes {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
  font-size: 12px;
}
.invoice-workflow-footer .workflow-edits-changes dt { color: var(--fg-muted); font-weight: 600; }
.invoice-workflow-footer .workflow-edits-changes dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  min-width: 0;
  margin: 0;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}
.invoice-workflow-footer .workflow-edits-changes dd iconify-icon { flex: none; color: var(--fg-faint); font-size: 11px; }
.invoice-workflow-footer .workflow-edits-before { color: var(--fg-subtle); text-decoration: line-through; }
.invoice-workflow-footer .workflow-edits-after { color: var(--fg); }
/* What the person tells Orcha it got wrong, below their changes. */
.invoice-workflow-footer .feedback-note-group .footer-panel-group-heading { cursor: default; }
.feedback-beta {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--accent-violet-tint);
  color: var(--accent-violet);
  font: 700 9.5px/1.4 var(--font-sans);
  letter-spacing: .4px;
  text-transform: uppercase;
  vertical-align: middle;
}
.invoice-workflow-footer .feedback-note-input {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 52px;
  box-sizing: border-box;
  resize: vertical;
  font: 13px/1.45 var(--font-sans);
}
.invoice-workflow-footer .feedback-note-help { margin: 6px 0 0; color: var(--fg-muted); font-size: 12px; line-height: 1.45; }

/* Focus layout: the expanded stage takes the free width between the
   collapsed ones, and a short track joins every stage to the next. A stage
   keeps its marker's outer size and its outer padding whether it is expanded
   or not, so changing the expanded stage moves nothing else; the footer
   script marks the first and last shown stages (`.is-stage-first`,
   `.is-stage-last`), which hidden columns would otherwise hide from
   :first-of-type. Only the narrow layout wraps, giving the expanded stage's
   content a line of its own. */
.invoice-workflow-footer[data-stage-focus] { display: flex; flex-wrap: nowrap; justify-content: center; align-items: stretch; }
.invoice-workflow-footer[data-stage-layout="narrow"] { flex-wrap: wrap; }
.invoice-workflow-footer[data-stage-focus] > .workflow-column {
  flex: none;
  gap: 6px;
  padding: 10px 8px;
  cursor: pointer;
}
.invoice-workflow-footer[data-stage-focus] > .workflow-column.is-stage-first { padding-left: 14px; border-top-left-radius: var(--r-xl); border-bottom-left-radius: var(--r-xl); }
.invoice-workflow-footer[data-stage-focus] > .workflow-column.is-stage-last { padding-right: 14px; border-top-right-radius: var(--r-xl); border-bottom-right-radius: var(--r-xl); }
.invoice-workflow-footer[data-stage-focus] > .workflow-column:not(.is-stage-focus):hover { background: var(--stone-50); }
.invoice-workflow-footer[data-stage-focus] > .workflow-column:has(~ .is-stage-focus)::after,
.invoice-workflow-footer[data-stage-focus] > .is-stage-focus ~ .workflow-column::before {
  content: "";
  flex: none;
  align-self: center;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: var(--border);
}
.invoice-workflow-footer[data-stage-focus] > .workflow-column.is-stage-focus {
  flex: 1 1 0;
  gap: 10px;
  min-width: 0;
  padding-right: 14px;
  padding-left: 14px;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 0;
  cursor: auto;
}
.invoice-workflow-footer[data-stage-focus] > .workflow-column.is-stage-focus.is-stage-first { border-left: 0; }
.invoice-workflow-footer[data-stage-focus] > .workflow-column.is-stage-focus.is-stage-last { border-right: 0; }
.invoice-workflow-footer[data-stage-focus] > .is-stage-focus > .stage-num { width: 34px; height: 34px; margin: 1px; font-size: 17px; }
.invoice-workflow-footer[data-stage-focus] > .workflow-column:not(.is-stage-focus) :is(.approval-footer-actions, .workflow-matching-actions, .workflow-release-action, .approval-footer-meta, .approval-footer-avatars, .workflow-disclosure, .btn, .info-tooltip) { display: none; }
.invoice-workflow-footer[data-stage-focus] > .workflow-column:not(.is-stage-focus) :is(.approval-footer-summary, .workflow-release-summary, .workflow-export-summary, .workflow-edits-summary) { pointer-events: none; }
.invoice-workflow-footer[data-stage-focus] > .workflow-column:not(.is-stage-focus) .approval-footer-title {
  max-width: 9em;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
/* The expanded stage's actions never wrap under its title: when they leave
   it too little room, the footer script stacks the stages two by two
   (`data-stage-layout="grid"`), and below that shows only the markers over
   the expanded stage (`"narrow"`). */
.invoice-workflow-footer[data-stage-layout="row"] > .workflow-column .approval-footer-bar,
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column .approval-footer-bar { flex-wrap: nowrap; }
.invoice-workflow-footer[data-stage-layout="grid"] {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column.workflow-column {
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
}
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column:not(.is-stage-focus) .approval-footer-title { max-width: none; }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column::before,
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column::after { display: none; }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="right"] { border-left: 1px solid var(--border); }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="lower"] { border-top: 1px solid var(--border); }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="span"] { grid-column: 1 / -1; }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="top-left"] { border-top-left-radius: var(--r-xl); }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="top-right"] { border-top-right-radius: var(--r-xl); }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="bottom-left"] { border-bottom-left-radius: var(--r-xl); }
.invoice-workflow-footer[data-stage-layout="grid"] > .workflow-column[data-stage-cell~="bottom-right"] { border-bottom-right-radius: var(--r-xl); }
/* Narrow: the markers form one row, in order, over the expanded stage. */
.invoice-workflow-footer[data-stage-layout="narrow"] > .workflow-column:not(.is-stage-focus) { padding: 8px 4px; border-radius: 0; }
.invoice-workflow-footer[data-stage-layout="narrow"] > .workflow-column:not(.is-stage-focus) > :not(.stage-num) { display: none; }
.invoice-workflow-footer[data-stage-layout="narrow"] > .workflow-column.is-stage-focus { display: contents; }
.invoice-workflow-footer[data-stage-layout="narrow"] > .is-stage-focus > .stage-num { align-self: center; width: 30px; height: 30px; margin: 11px 7px; font-size: 15px; }
.invoice-workflow-footer[data-stage-layout="narrow"] > .is-stage-focus > :not(.stage-num) {
  order: 1;
  flex: 1 0 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.invoice-workflow-footer .workflow-export-actions { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; }
.invoice-workflow-footer .workflow-export-summary,
.invoice-workflow-footer .workflow-release-summary,
.invoice-workflow-footer .workflow-edits-summary {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.invoice-workflow-footer .workflow-export-panel {
  width: 100%;
  box-sizing: border-box;
  max-height: 45vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 12px;
}
.invoice-workflow-footer .workflow-footer-overlays > [hidden] { display: none; }
.invoice-workflow-footer .workflow-release-column .workflow-status-line,
.invoice-workflow-footer .workflow-export-column .workflow-status-line { white-space: normal; }
.invoice-workflow-footer .workflow-release-column .workflow-status-line .approval-footer-title,
.invoice-workflow-footer .workflow-export-column .workflow-status-line .approval-footer-title {
  flex: 0 1 auto;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  text-overflow: clip;
  line-height: 17px;
}
.invoice-workflow-footer .workflow-release-column .workflow-status-line .approval-footer-meta,
.invoice-workflow-footer .workflow-export-column .workflow-status-line .approval-footer-meta {
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@container invoice-footer (max-width: 600px) {
  .invoice-workflow-footer .workflow-release-column .workflow-column-row,
  .invoice-workflow-footer .workflow-export-column .workflow-column-row { flex-wrap: wrap; align-items: flex-start; row-gap: 6px; }
  .invoice-workflow-footer .workflow-release-column .workflow-release-summary,
  .invoice-workflow-footer .workflow-export-column .workflow-export-summary { flex: 1 0 100%; }
}

.invoice-workflow-footer .workflow-status-line { width: 100%; max-width: 100%; display: flex; align-items: baseline; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; }
.invoice-workflow-footer .workflow-status-line .approval-footer-title { flex: none; }
.invoice-workflow-footer .workflow-status-line .approval-footer-meta { display: inline; min-width: 0; }
.invoice-workflow-footer .workflow-status-line .approval-footer-meta::before { content: "· "; }
.invoice-workflow-footer .workflow-check-error:empty { display: none; }
.invoice-workflow-footer .workflow-check-error:not(:empty) { padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-card); font-size: 13px; }

.invoice-workflow-footer .workflow-matching-actions { flex-direction: row; flex-wrap: wrap; max-width: 100%; gap: 4px; }

/* Native buttons and text summaries share the same two-line typography. */
.invoice-workflow-footer .approval-footer-text { gap: 0; font-family: inherit; line-height: 1.5; }
.invoice-workflow-footer .approval-footer-eyebrow { font-size: 10px; line-height: 15px; }
.invoice-workflow-footer .approval-footer-title { font-size: 13px; line-height: 19.5px; font-weight: 400; }
.invoice-workflow-footer .approval-footer-meta { font-size: 12px; line-height: 18px; }
.invoice-workflow-footer .workflow-export-summary,
.invoice-workflow-footer .workflow-release-summary { font-family: inherit; line-height: 1.5; }

.invoice-workflow-footer .workflow-check-tooltip .info-tooltip-content,
.invoice-workflow-footer .workflow-approval-tooltip .info-tooltip-content { width: 280px; font-weight: 400; white-space: normal; }
@container invoice-footer (max-width: 950px) {
  .invoice-workflow-footer .workflow-matching-column:has(.workflow-check-tooltip + .workflow-check-tooltip) .workflow-column-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .invoice-workflow-footer .workflow-matching-column:has(.workflow-check-tooltip + .workflow-check-tooltip) .approval-footer-text { flex-direction: row; align-items: baseline; gap: 6px; width: 100%; }
  .invoice-workflow-footer .workflow-matching-column:has(.workflow-check-tooltip + .workflow-check-tooltip) .workflow-status-line { flex: 1; }
}

.invoice-workflow-footer .btn { box-sizing: border-box; height: 30px; min-height: 30px; line-height: 18px; display: inline-flex; align-items: center; justify-content: center; }

.invoice-workflow-footer .workflow-export-panel { overflow-wrap: anywhere; }

/* Read-only invoice values sit on white, like every read-only box; on a
   locked invoice that includes boxes that still carry an editable value. */
#invoice-fields[data-editable="false"] :is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed),
#invoice-fields .invoice-field-readonly,
#invoice-fields .field-group:not(:has(.editable-value)) > .field-value,
#invoice-fields .value-row:not(:has(.editable-value)) .value-amount {
  background: var(--surface);
  cursor: default;
}
#invoice-fields[data-editable="false"] :is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed):not(.supplier-account-invalid) {
  border-color: var(--border);
}
#invoice-fields[data-editable="false"] :is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed) {
  box-shadow: none;
}
#invoice-fields[data-editable="false"] :is(.field-value-row-boxed, .party-card-name-row-boxed, .party-card-address-row-boxed, .party-card-field-value-row-boxed)::after {
  content: none;
}
/* A value Orcha filled in keeps its frame on a read-only invoice too. */
#invoice-fields[data-editable="false"] .field-group.is-derived .field-value-row-boxed {
  border-color: var(--warning-border);
  background: color-mix(in srgb, var(--warning-tint) 40%, var(--white));
}
#invoice-fields .line-items td > .invoice-field-readonly {
  display: block;
  box-sizing: border-box;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
}


/* Manual invoice corrections remain within the existing Payment rows. */
.financial-summary .amount-basis { gap: 12px; flex-wrap: wrap; }
.financial-calculation-incomplete,
.calculated-totals-unsaved { padding: 10px 12px; background: var(--warning-bg, #fff6db); border-radius: var(--r-md); color: var(--fg); }
.calculated-totals-unsaved { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.printed-total-difference { display: flex; justify-content: flex-end; align-items: flex-start; gap: 6px; margin: 2px 0 0; font-size: 12px; line-height: 1.4; color: var(--warning-strong); text-align: right; }
.printed-total-difference iconify-icon { flex: none; margin-top: 2px; }
.financial-summary .prepayment > .value-row { gap: 12px; }
.financial-summary .prepayment .value-label { min-width: 0; }
.prepayment-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.prepayment-actions .inline-add-control { margin: 0; }
.prepayment-description { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.prepayment-description > span { display: block; width: 100%; }
.editable-value.prepayment-description { width: 240px !important; max-width: 100%; font-size: 12px; line-height: 1.5; color: var(--fg); }
.editable-value.prepayment-description:hover { border-color: var(--brand); background: var(--bg-canvas); }
.editable-value.prepayment-description.is-human-edited { box-shadow: none; }
.editable-value.prepayment-description.is-saving { animation: none; }
.prepayment-remove { flex: none; }
.prepayment-remove:hover { border-color: var(--red-500); color: var(--red-500); }
.inline-add-control:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.prepayment-add { margin: 10px 0; }
@media (max-width: 600px) {
  .financial-summary .prepayment > .value-row { flex-wrap: wrap; gap: 6px; }
  .financial-summary .prepayment .value-label { flex-basis: 100%; }
  .financial-summary .prepayment .value-amount { margin-left: auto; }
  .editable-value.prepayment-description { width: calc(100% - 38px) !important; }
}
.financial-summary > .btn { margin: 8px 0; }
@media (max-width: 900px) {
  .content-documents .detail-topbar { flex-wrap: wrap; flex-shrink: 0; gap: 8px; padding: 8px 12px; }
  .content-documents .detail-topbar > .command-bar { flex: 1 1 180px; margin-left: 0; min-width: 0; }
  .content-documents .detail-container { overflow: visible; }
  .content-documents .data-panel-content { flex: none; }
  .content-documents .data-panel-scroll { height: auto; overflow: visible; }
  .content-documents .data-panel > .panel-header { flex-wrap: wrap; padding: 10px 12px; }
  .content-documents .data-panel > .panel-header .panel-header-meta { flex: 1 1 100%; flex-wrap: wrap; }
  .content-documents .data-panel > .panel-header .panel-actions { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .content-documents { scroll-padding-bottom: calc(35vh + 40px); }
  .content-documents .invoice-status-layout:has(> .approval-workflow-footer) { padding-bottom: calc(35vh + 48px); }
  .content-documents .invoice-status-layout > .approval-workflow-footer {
    position: fixed;
    z-index: 105;
    left: calc(var(--sidebar-width) + 12px);
    right: 12px;
    bottom: 36px;
    max-height: 35vh;
    margin: 0;
    overflow-y: auto;
  }
  .content-documents .financial-summary .value-row { gap: 8px; }
}

.amount-basis-dropdown > summary { list-style: none; }
.amount-basis-dropdown > summary::-webkit-details-marker { display: none; }
.amount-basis-dropdown > summary:focus-visible,
.amount-basis-dropdown .filter-dropdown-option:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.amount-basis-dropdown[open] > .filter-dropdown-panel { display: flex; }
.amount-basis-dropdown > .filter-dropdown-panel { left: auto; right: 0; min-width: 220px; padding: 4px; }
.amount-basis-dropdown .filter-dropdown-option { justify-content: space-between; padding: 10px; border-radius: var(--r-md); text-align: left; }
.amount-basis-dropdown .filter-dropdown-option.is-active { background: var(--brand-tint); }
.amount-basis-option-copy { display: flex; flex-direction: column; gap: 2px; }
.amount-basis-option-copy > strong { font-size: 13px; font-weight: 600; }
.amount-basis-option-copy > span { font-size: 12px; font-weight: 400; color: var(--fg-muted); }

.adjustment-extracted-label { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adjustment-extracted-label .inline-add-control { margin: 0; }
.add-line-item + .inline-add-control { margin-left: 8px; }
.invoice-adjustment-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(480px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0; border: 0; border-left: 1px solid var(--border); background: #fff; color: var(--fg); box-shadow: -12px 0 36px #0002; }
.invoice-adjustment-drawer::backdrop { background: #17223555; }
.invoice-adjustment-form { height: 100%; display: flex; flex-direction: column; font-family: inherit; font-size: 13px; }
.invoice-adjustment-form header, .invoice-adjustment-form footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; flex: none; border-bottom: 1px solid var(--border); }
.invoice-adjustment-form footer { justify-content: flex-end; border-bottom: 0; border-top: 1px solid var(--border); }
.invoice-adjustment-form h2 { margin: 0; font-size: 18px; font-weight: 600; }
.invoice-adjustment-body { padding: 20px 24px; overflow: auto; flex: 1; }
.invoice-adjustment-body > p:first-child, .adjustment-help { margin: 0 0 18px; color: var(--fg-muted); line-height: 1.5; }
.invoice-adjustment-form label { display: block; font-weight: 500; margin-bottom: 16px; min-width: 0; }
.invoice-adjustment-form input:not([type=checkbox]), .invoice-adjustment-form select { display: block; margin-top: 6px; box-sizing: border-box; width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 4px; background: #fff; color: var(--fg); font: inherit; }
.invoice-adjustment-form input:focus, .invoice-adjustment-form select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.invoice-adjustment-form fieldset { border: 0; padding: 0; margin: 4px 0 16px; min-width: 0; }
.invoice-adjustment-form legend { font-weight: 600; margin-bottom: 14px; }
.invoice-adjustment-form .adjustment-split-toggle { display: flex; gap: 6px; align-items: center; font-weight: 400; }
.invoice-adjustment-form [hidden] { display: none !important; }
.adjustment-allocation { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 8px; align-items: center; }
.adjustment-allocation .inline-add-control { margin: 0; }
.adjustment-error { color: var(--red-500, #b42318); line-height: 1.5; }
.adjustment-fee-actions { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--border); padding-top: 20px; margin: 20px 0; }
.adjustment-fee-actions .btn { display: inline-flex; white-space: nowrap; margin: 0; }
.adjustment-fee-actions [data-delete-fee] { color: var(--danger); }
.invoice-adjustment-form .adjustment-confirm-delete { background: var(--danger); background-image: none; border-color: var(--danger); color: #fff; }
.invoice-adjustment-form .adjustment-confirm-delete:hover { background: var(--danger-strong); border-color: var(--danger-strong); }
.adjustment-financial-preview { margin-top: 20px; }
.adjustment-financial-preview h3 { margin: 0 0 12px; font-size: 14px; }
.adjustment-comparison { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 12px; }
.adjustment-comparison caption { text-align: left; color: var(--fg-muted); margin-bottom: 8px; }
.adjustment-comparison th, .adjustment-comparison td { padding: 9px 0; border-bottom: 1px solid var(--border); text-align: right; font-weight: 400; }
.adjustment-comparison th:first-child { text-align: left; padding-right: 12px; }
.adjustment-comparison td { font-variant-numeric: tabular-nums; }
.adjustment-comparison tbody tr:last-child { font-weight: 600; }
.adjustment-preview-warnings { padding: 12px 12px 12px 28px; border: 1px solid var(--warning-border); border-radius: var(--r-md); background: var(--warning-tint); color: var(--fg); line-height: 1.5; }
.calculated-totals-unsaved { margin: 12px 0; padding: 12px; border: 1px solid var(--warning-border); border-radius: var(--r-md); background: var(--warning-tint); font-size: 13px; line-height: 1.5; }
.calculated-totals-unsaved p { margin: 0 0 10px; }
.calculated-totals-unsaved ul { padding-left: 18px; margin: 0 0 12px; }
.fee-adjustment-details { display: flex; flex-direction: column; gap: 3px; }
.fee-amount-actions { display: inline-flex; gap: 12px; align-items: center; }
.fee-amount-actions .inline-add-control { margin: 0; }
@media (max-width: 400px) {
  .adjustment-fee-actions { gap: 8px; }
  .adjustment-fee-actions .btn.btn-secondary { padding: 7px 8px; font-size: 12px; }
}

.amount-due-adjustments { margin-top: 10px; }
/* Amount Due's border-top is the one line below the invoice total. Adjustments
   between the two get a line above them too, so they sit between two rules. */
#invoice-calculated-total.value-row { border-bottom: none; }
.amount-due-adjustments:has(.amount-due-adjustment) { margin-top: 0; padding-top: 10px; border-top: 1px solid var(--border); }
.amount-due-adjustment .prepayment-actions { gap: 6px; }
.amount-due-adjustment .value-row { padding: 5px 0; align-items: center; }
.amount-due-adjustment-reference { color: var(--fg-muted); font-size: 11px; }
.amount-due-line-note { display: block; margin-top: 3px; color: var(--fg-muted); font-size: 10px; line-height: 1.3; }
/* Where Orcha took a line's VAT rate from, under its description; gone once a person sets it. */
.line-items td.desc .li-rate-source {
  display: block;
  width: max-content;
  max-width: 100%;
  margin-top: 4px;
  padding: 0 6px;
  border: 1px solid var(--info-border);
  border-radius: 999px;
  background: var(--info-tint);
  color: var(--brand-hover);
  font: var(--text-caption);
  text-align: left;
}
/* A line input the invoice calculation needs but does not have. */
.line-items td .editable-value.calculation-input-missing:not(.is-editing),
.line-items-table .editable-value.calculation-input-missing:not(.is-editing),
.line-items .li-eur.calculation-input-missing,
.invoice-field-readonly.calculation-input-missing {
  border-color: var(--danger);
  background: var(--danger-tint);
  color: var(--danger-strong);
}
.calculation-missing-note { display: block; margin-top: 3px; color: var(--danger); font-size: 10px; line-height: 1.3; }
@media (max-width: 600px) {
  .financial-summary .amount-due-adjustment > .value-row { flex-wrap: wrap; gap: 6px; }
  .financial-summary .amount-due-adjustment .value-label { flex-basis: 100%; }
  .financial-summary .amount-due-adjustment .value-amount { margin-left: auto; }
}

.adjustment-tax-controls { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: center; gap: 10px; margin-bottom: 16px; }
.invoice-adjustment-form .adjustment-tax-controls select,
.invoice-adjustment-form .adjustment-tax-controls input { margin-top: 0; }
.adjustment-vat-input { position: relative; display: block; min-width: 0; }
.invoice-adjustment-form .adjustment-vat-input input { padding-right: 32px; }
.adjustment-vat-input > span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--fg-muted); pointer-events: none; }
.adjustment-allocation > .adjustment-vat-input { align-self: end; margin-bottom: 16px; }
.adjustment-tax-selection { min-width: 0; }
.adjustment-allocation > .adjustment-tax-selection { align-self: end; margin-bottom: 16px; }
.adjustment-tax-controls:has([data-tax-code]:not([hidden])) > .adjustment-tax-selection,
.adjustment-allocation:has([data-tax-code]:not([hidden])) > .adjustment-tax-selection { grid-column: 1 / -1; }
.adjustment-allocation:has([data-tax-code]:not([hidden])) { grid-template-columns: minmax(0, 1fr) auto; }
.adjustment-allocation:has([data-tax-code]:not([hidden])) > [data-remove-allocation] { grid-row: 1; grid-column: 2; }
.adjustment-tax-rate { display: block; margin-top: 8px; font-variant-numeric: tabular-nums; }
.adjustment-tax-help { margin: 6px 0 0; color: var(--fg-muted); line-height: 1.5; overflow-wrap: anywhere; }


.adjustment-save-control { position: relative; display: inline-flex; }
.adjustment-save-control:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: var(--r-md); }
.adjustment-save-help { position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 2; width: max-content; max-width: min(280px, calc(100vw - 48px)); padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface, white); color: var(--fg); box-shadow: 0 4px 14px #0002; font-size: 12px; line-height: 1.5; white-space: normal; visibility: hidden; opacity: 0; pointer-events: none; }
.adjustment-save-control:hover .adjustment-save-help,
.adjustment-save-control:focus-within .adjustment-save-help { visibility: visible; opacity: 1; }

.invoice-correction-action.btn.btn-secondary {
  min-height: 34px;
  box-sizing: border-box;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  gap: 6px;
}
.invoice-correction-action.btn.btn-secondary:hover { background: var(--bg-muted); color: var(--fg); border-color: var(--border); }
.financial-summary .amount-due-adjustment-type.btn { font-family: var(--font-sans); font-size: 13px; font-weight: 400; color: var(--fg-muted); }
.financial-summary .value-row.total .value-label,
.financial-summary .value-row.total .value-amount { font-family: var(--font-sans); }

.financial-summary .document-amount-references { margin-top: 16px; font-family: var(--font-sans); }
.financial-summary .document-amount-references > summary { cursor: pointer; color: var(--fg-muted); font-size: 13px; }
.financial-summary .document-amount-references[open] > summary { margin-bottom: 8px; }
/* Partner Approvals case page: the Approval section holds the case's
   read-only facts and "Your decision" (inputs and one primary action); the
   secondary sections follow. */
.partner-approval-pill,
.partner-approval-case-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--fg-muted);
  font: 600 12px/1 var(--font-sans);
  white-space: nowrap;
}
.partner-approval-case-pill {
  height: 26px;
  padding: 0 11px;
  border-radius: var(--r-lg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}
.partner-approval-case .partner-approval-pill {
  height: 20px;
  margin-left: 2px;
}
:is(.partner-approval-pill, .partner-approval-case-pill).tone-success {
  border-color: var(--success-border);
  background: var(--success-tint);
  color: var(--success-strong);
}
:is(.partner-approval-pill, .partner-approval-case-pill).tone-warning {
  border-color: var(--warning-border);
  background: var(--warning-tint);
  color: var(--warning-strong);
}
:is(.partner-approval-pill, .partner-approval-case-pill).tone-danger {
  border-color: var(--danger-border);
  background: var(--danger-tint);
  color: var(--danger-strong);
}
:is(.partner-approval-pill, .partner-approval-case-pill).tone-info {
  border-color: var(--info-border);
  background: var(--info-tint);
  color: var(--azure-700);
}

/* The right pane adapts to its own width, which the resizable invoice
   pane beside it sets, not to the viewport's. The containers are the header
   and the body, not the whole panel, so nothing fixed-position is newly
   confined to the panel. */
.partner-approval-review-data > .panel-header {
  container: partner-approval-header / inline-size;
}
.partner-approval-review-data .panel-body {
  container: partner-approval-data / inline-size;
  padding-top: 0;
}
/* The first section sits flush under the panel header, whose border is its
   top edge. */
:is(#document-content, .partner-approval-review) .partner-approval-review-data .panel-body > .invoice-section:first-child {
  border-top: 0;
}

/* Header: case pill, supplier, standing. The row wraps rather than cut the
   supplier name; a narrow pane shows the Accounts Payable link as its icon. */
.partner-approval-review .data-panel > .panel-header {
  white-space: normal;
}
.partner-approval-review .data-panel > .panel-header .panel-header-meta {
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 4px 0;
}
.partner-approval-review .panel-header-meta .panel-supplier {
  flex: 0 1 auto;
  overflow: visible;
  font-size: 15px;
  white-space: normal;
  overflow-wrap: anywhere;
}
@container partner-approval-header (max-width: 720px) {
  .partner-approval-open-invoice {
    padding-right: 10px;
    padding-left: 10px;
  }
  .partner-approval-open-invoice-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.partner-approval-case-block {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 0 0 6px;
}
.partner-approval-case-block + .partner-approval-case-block {
  margin-top: 14px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.partner-approval-caption {
  margin: 0;
  padding: 0;
  color: var(--fg-subtle);
  font: 600 11px/1.4 var(--font-sans);
  letter-spacing: 0.7px;
  text-transform: uppercase;
}
.partner-approval-case-frame {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
}
.partner-approval-case-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
/* The columns are set here, not by the first row, which may span them. */
.partner-approval-case-table > colgroup > .partner-approval-case-label { width: 120px; }
.partner-approval-case-table > colgroup > .partner-approval-case-status { width: 44px; }
.partner-approval-case-table th,
.partner-approval-case-table td {
  padding: 12px 16px 12px 0;
  vertical-align: top;
  text-align: left;
}
.partner-approval-case-table tr + tr > * {
  border-top: 1px solid var(--border-subtle);
}
.partner-approval-case-table th {
  width: 120px;
  padding-left: 16px;
  color: var(--fg-subtle);
  font: 500 11px/1.6 var(--font-sans);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.partner-approval-case-table td {
  min-width: 0;
  color: var(--fg);
  font: 400 14px/1.45 var(--font-sans);
  overflow-wrap: anywhere;
}
.partner-approval-case-table td.partner-approval-case-status {
  width: 44px;
  text-align: right;
}
.partner-approval-case-lead > * {
  background: var(--bg-subtle);
}
.partner-approval-case-table td.partner-approval-case-wide {
  padding: 12px 16px;
}
.partner-approval-case-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  font-size: 16px;
}
.partner-approval-case-icon.tone-success,
.supplier-case-card iconify-icon.tone-success { color: var(--success); }
.partner-approval-case-icon.tone-warning,
.supplier-case-card iconify-icon.tone-warning { color: var(--warning); }
.partner-approval-case-icon.tone-danger { color: var(--danger-strong); }
.partner-approval-hint {
  display: block;
  margin-top: 2px;
  color: var(--fg-subtle);
  font: 400 12px/1.4 var(--font-sans);
}
.partner-approval-tab-badge {
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--danger-tint);
  color: var(--danger-strong);
  font: 600 11px/18px var(--font-sans);
}
.partner-approval-table .partner-approval-dynamics-cell {
  padding-right: 24px;
}
.partner-approval-dynamics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.partner-approval-retry-form { display: inline-flex; margin: 0; }
.partner-approval-retry-form + .partner-approval-retry-form { margin-left: 6px; }
.partner-approval-retry-form .btn { display: inline-flex; align-items: center; gap: 6px; }
.partner-approval-activation-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.partner-approval-activation-card + .partner-approval-activation-card { margin-top: 12px; }
.partner-approval-activation-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 0;
}
.partner-approval-activation-entity { font-weight: 600; }
.partner-approval-activation-head .table-status-pill { margin-left: auto; }
.partner-approval-activation-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 16px 14px;
}
.partner-approval-activation-body p { margin: 0; }
.partner-approval-activation-hint { color: var(--fg-muted); font-size: 13px; }
.partner-approval-activation-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.partner-approval-activation-note {
  flex: 1 1 260px;
  margin: 0;
  color: var(--fg-muted);
  font-size: 13px;
}
.partner-approval-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: 400 13px/1.45 var(--font-sans);
}
.partner-approval-banner.tone-info { border-color: var(--info-border); }
.partner-approval-banner.tone-success { border-color: var(--success-border); }
.partner-approval-banner.tone-danger { border-color: var(--danger-border); }
.partner-approval-banner > iconify-icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  font-size: 16px;
}
.partner-approval-banner.tone-success > iconify-icon { color: var(--success); }
.partner-approval-banner.tone-danger > iconify-icon { color: var(--danger-strong); }
.partner-approval-banner.tone-neutral > iconify-icon { color: var(--fg-muted); }
.partner-approval-banner > .spinner-small { flex: none; margin-top: 2px; }
.partner-approval-banner-text { flex: 1; min-width: 0; }
.partner-approval-banner-text p { margin: 0; }
.partner-approval-banner-title { font-weight: 500; }
.partner-approval-banner-text .partner-approval-banner-detail { margin-top: 2px; color: var(--fg-muted); }
.partner-approval-banner-link { flex: none; white-space: nowrap; font-weight: 500; }
.partner-approval-list-banner { padding: 8px 16px; background: var(--bg); }
.partner-approval-list-banner .partner-approval-banner { margin: 0; }
.partner-approval-hint.is-taken {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  color: var(--warning);
}
.partner-approval-hint.is-taken iconify-icon {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  font-size: 14px;
}
.partner-approval-meta {
  color: var(--fg-subtle);
  font: 400 12px/1.4 var(--font-mono);
}
.partner-approval-line {
  display: block;
}
.partner-approval-line.monospace,
.partner-approval-case-table .monospace {
  font: 400 13px/1.45 var(--font-mono);
}
.partner-approval-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.partner-approval-comparison-side {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.partner-approval-comparison-new > .partner-approval-meta {
  color: var(--warning-strong);
}
.partner-approval-comparison-value {
  display: block;
  overflow-wrap: anywhere;
}
.partner-approval-comparison.is-mono .partner-approval-comparison-value {
  font: 400 13px/1.45 var(--font-mono);
}
.partner-approval-comparison mark {
  padding: 0 1px;
  border-radius: var(--r-sm);
  background: var(--warning-border);
  color: inherit;
}

/* Your decision */
/* Its rows stay packed at the top: two companies' choices share one grid row
   of the form, and the shorter one must not spread its rows to the taller's
   height when a search lists vendors in only one of them. */
.partner-approval-decision {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.partner-approval-decision > legend.partner-approval-caption {
  float: left;
  width: 100%;
}
.partner-approval-decision > legend + * {
  clear: both;
}
.supplier-change-form {
  display: grid;
  margin: 0;
}
.supplier-change-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.supplier-change-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  cursor: pointer;
}
/* A VAT ID, IBAN or name change also offers "Different supplier". */
.supplier-change-options:has(> :nth-child(3)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.supplier-change-option:hover { border-color: var(--brand); }
/* An answer that no longer applies, e.g. moving an exported invoice. */
.supplier-change-option:has(input:disabled) {
  border-color: var(--border);
  background: var(--bg-subtle);
  cursor: not-allowed;
}
.supplier-change-option:has(input:disabled) .supplier-change-option-title { color: var(--fg-muted); }
.supplier-change-option:has(input:checked) {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.supplier-change-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.supplier-change-option input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}
.supplier-change-option-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.supplier-change-option-title {
  color: var(--fg);
  font: 600 14px/1.3 var(--font-sans);
}
.supplier-change-option-hint {
  color: var(--fg-muted);
  font: 400 13px/1.4 var(--font-sans);
  overflow-wrap: anywhere;
}
.supplier-change-edit {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.supplier-change-edit > .form-field { margin-bottom: 0; }
.supplier-change-edit > .form-field:only-child { grid-column: 1 / -1; }
.supplier-change-case:has(input[name="decision"][value="change"]:checked) .supplier-change-edit { display: grid; }
.partner-approval-decision-checks {
  display: none;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-subtle);
}
.supplier-change-case:has(input[name="decision"][value="change"]:checked) .partner-approval-decision-checks,
.partner-approval-choice-panel .partner-approval-decision-checks { display: grid; }
.partner-approval-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--fg);
  font: 400 14px/1.4 var(--font-sans);
  cursor: pointer;
}
.partner-approval-check input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}
.partner-approval-decision-data {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
}
.partner-approval-decision-data-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0 0 12px;
  color: var(--fg);
  font: 600 14px/1.4 var(--font-sans);
}
.partner-approval-decision-data-title .partner-approval-hint { display: inline; margin: 0; }
.partner-approval-reject-consequence {
  margin: 0 0 4px;
  color: var(--fg);
  font: 500 13px/1.5 var(--font-sans);
}
/* Several cases: each block names its case and its invoice, which shows
   its tab. */
.partner-approval-block-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 10px;
}
.partner-approval-block-company {
  color: var(--fg-muted);
  font-weight: 400;
}
.partner-approval-block-invoice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: 600 13px/1.4 var(--font-sans);
  cursor: pointer;
}
.partner-approval-block-invoice:hover > span:first-of-type { text-decoration: underline; }
.partner-approval-block-invoice:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.partner-approval-decision-form {
  display: grid;
  gap: 12px;
  margin: 0;
}
.partner-approval-decision-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.partner-approval-decision-outcome {
  flex: 1 1 220px;
  margin: 0;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}
.partner-approval-decision-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.partner-approval-decision-footer .btn {
  justify-content: center;
  white-space: nowrap;
}
.partner-approval-decision-form [hidden] {
  display: none;
}
.partner-approval-decision-form > .partner-approval-action-explanation:not([hidden]) {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-subtle);
}
/* "Different supplier" swaps the change's checks and button for the
   separate form that creates the invoice supplier. */
.supplier-change-different { display: none; }
.supplier-change-case:has(input[name="decision"][value="different"]:checked) .supplier-change-different { display: block; }
.supplier-change-case:has(input[name="decision"][value="different"]:checked) .supplier-change-form .partner-approval-decision-footer { display: none; }
.supplier-change-case [data-change-outcome] { display: none; }
.supplier-change-case [data-change-outcome="none"] { display: inline; }
.supplier-change-case:has(input[name="decision"]:checked) [data-change-outcome="none"] { display: none; }
.supplier-change-case:has(input[name="decision"][value="keep"]:checked) [data-change-outcome="keep"],
.supplier-change-case:has(input[name="decision"][value="change"]:checked) [data-change-outcome="change"] { display: inline; }
/* A decision's button is never grey: until a decision is chosen (or, adding
   a supplier, its required Dynamics codes are) it has the white secondary
   look and does not submit; then it is the blue primary action. The
   choose-supplier footer's placeholder is the same white button. */
.supplier-change-case:not(:has(input[name="decision"]:checked)) .partner-approval-decision-footer .btn-primary,
.partner-approval-decision-form:has([data-approval-required]:invalid) .btn-primary[data-approval-approve],
.partner-approval-pending-submit {
  border-color: var(--border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: none;
}
.supplier-change-case:not(:has(input[name="decision"]:checked)) .partner-approval-decision-footer .btn-primary,
.partner-approval-pending-submit {
  cursor: default;
  pointer-events: none;
}
/* Not the shared greyed-out disabled look of `.btn[aria-disabled]`. */
.btn.partner-approval-pending-submit[aria-disabled="true"] {
  opacity: 1;
  filter: none;
}

/* Choose supplier: the invoice beside each candidate, then one tile per
   candidate and "Different supplier", wrapping on a narrow pane; choosing one
   reveals its panel below the tiles (partner-approvals.js). Until then the
   footer says no decision is taken. */
.partner-approval-candidates-scroll {
  overflow-x: auto;
}
.partner-approval-case-table .partner-approval-candidates {
  width: 100%;
  min-width: calc(104px + var(--candidate-columns, 3) * 150px);
  border-collapse: collapse;
  table-layout: fixed;
}
.partner-approval-case-table .partner-approval-candidates :is(th, td) {
  width: auto;
  padding: 7px 12px 7px 0;
  border-top: 0;
  background: none;
  vertical-align: top;
  text-align: left;
}
.partner-approval-case-table .partner-approval-candidates tbody tr > * {
  border-top: 1px solid var(--border);
}
/* The label column ends where the case table's does, so the values line up. */
.partner-approval-candidates > colgroup > .partner-approval-candidates-label {
  width: 104px;
}
.partner-approval-case-table .partner-approval-candidates thead th {
  padding-top: 0;
  color: var(--fg);
  font: 400 12px/1.4 var(--font-sans);
  letter-spacing: normal;
  text-transform: none;
}
.partner-approval-candidates-name {
  display: block;
  font: 600 13px/1.35 var(--font-sans);
}
.partner-approval-case-table .partner-approval-candidates tbody th {
  padding-left: 0;
}
.partner-approval-case-table .partner-approval-candidates td {
  font-size: 13px;
}
.partner-approval-case-table .partner-approval-candidates td.monospace .partner-approval-comparison-value {
  font: 400 13px/1.45 var(--font-mono);
}
.partner-approval-candidates-cell {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.partner-approval-candidates-value {
  min-width: 0;
}
.partner-approval-candidates-cell > .partner-approval-case-icon {
  flex: 0 0 auto;
  margin-top: 1px;
}
.partner-approval-candidates mark {
  padding: 0 1px;
  border-radius: var(--r-sm);
  background: var(--warning-border);
  color: inherit;
}
.partner-approval-account { white-space: nowrap; }
.partner-approval-case-table .partner-approval-account { white-space: normal; overflow-wrap: anywhere; }
.supplier-change-options.supplier-choice-options {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
/* Finding another Dynamics vendor: the results stay out of the layout until there are any. */
.partner-approval-vendor-query { max-width: 420px; }
.supplier-change-options:empty { display: none; }
.supplier-change-option:has(input:disabled) { cursor: default; opacity: 0.6; }
.supplier-change-option:has(input:disabled):hover { border-color: var(--border-strong); }

/* A vendor another supplier already holds, offered as that supplier: not a
   choice of the radio group, so it is neither faded nor selectable; its
   button moves the pending supplier's invoices there. */
.supplier-change-option.partner-approval-held-vendor {
  cursor: default;
  background: var(--surface);
}
.supplier-change-option.partner-approval-held-vendor:hover { border-color: var(--border-strong); }
.partner-approval-held-vendor-icon {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--fg-muted);
  font-size: 16px;
}
.partner-approval-held-vendor .partner-approval-merge {
  align-self: flex-start;
  margin-top: 8px;
}
.partner-approval-choice-panel {
  display: grid;
  gap: 12px;
  margin: 0;
}
.partner-approval-choice-panel[hidden] { display: none; }
.supplier-choice:has(input[data-choice-panel]:checked) > .supplier-choice-pending { display: none; }
/* "Also update Dynamics": open, one row per field the invoice shows
   differently; the confirmation appears once a field is ticked. */
.supplier-update-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0;
}
.supplier-update-summary .partner-approval-hint { display: inline; margin: 0; }
.supplier-update-title {
  color: var(--fg);
  font: 600 14px/1.4 var(--font-sans);
}
.supplier-update-fields {
  display: grid;
  gap: 0;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}
.supplier-update-field {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.supplier-update-field > .partner-approval-hint.is-taken {
  grid-column: 1 / -1;
  margin-top: -4px;
}
.supplier-update-before,
.supplier-update-after {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.supplier-update-value {
  color: var(--fg-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.supplier-update-after > input {
  width: 100%;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: 400 13px/1.4 var(--font-sans);
}
.supplier-update-details > .partner-approval-hint { margin-top: 8px; }
.supplier-update-confirmation { display: none; }
.partner-approval-choice-panel:has(input[name^="update-"]:checked) .supplier-update-confirmation { display: flex; }
.supplier-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.supplier-editor-grid > .form-field { margin-bottom: 0; }
.supplier-create-form { display: grid; gap: 12px; margin: 0; }
/* A field with a hint below it keeps its neighbour's label and input on top. */
.supplier-create-form .partner-approval-field { align-content: start; }

/* Secondary sections: the summary sits right of the title, before the chevron. */
.partner-approval-section-heading {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-right: 8px;
}
.partner-approval-section-heading > iconify-icon {
  flex: none;
  font-size: 16px;
}
/* The pill is taller than the title row; it overhangs the header's padding
   so the header keeps the height of the others. */
.partner-approval-section-pill {
  display: inline-flex;
  flex: none;
  margin: -3px 0 -3px auto;
}
.partner-approval-section-meta {
  overflow: hidden;
  margin-left: auto;
  color: var(--fg-subtle);
  font: 400 13px/1.2 var(--font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AP invoice page: the read-only case card; the decision is taken in
   Partner Approvals. */
.supplier-case-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--stone-100);
}
.supplier-case-card.is-held {
  border-color: var(--warning-border);
  background: color-mix(in srgb, var(--warning-tint) 55%, var(--surface));
}
.supplier-case-card-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.supplier-case-card-question {
  margin: 0;
  color: var(--fg);
  font: 600 16px/1.35 var(--font-sans);
}
.supplier-case-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 10px 12px;
}
.supplier-case-card-field {
  display: grid;
  align-content: start;
  min-width: 0;
}
.supplier-case-card-value {
  display: grid;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font: 400 14px/22px var(--font-sans);
  overflow-wrap: anywhere;
}
.supplier-case-card-row.is-mono .supplier-case-card-value {
  font: 400 13px/22px var(--font-mono);
}
.supplier-case-card-value mark {
  padding: 0 1px;
  border-radius: var(--r-sm);
  background: var(--warning-border);
  color: inherit;
}
.supplier-case-card-same {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.supplier-case-card-same-item {
  gap: 4px;
  border-color: var(--success-border);
  background: var(--success-tint);
  color: var(--success-strong);
  font-weight: 500;
}
.supplier-case-card-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--warning-strong);
  font: 500 13px/1.4 var(--font-sans);
}
.supplier-case-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.supplier-case-card-note {
  flex: 1 1 200px;
  color: var(--fg-muted);
  font-size: 13px;
}
.supplier-case-card-footer .supplier-approval-alert-action {
  margin: 0 0 0 auto;
  white-space: nowrap;
}

@container partner-approval-data (max-width: 600px) {
  .supplier-change-options, .supplier-change-edit, .partner-approval-comparison { grid-template-columns: minmax(0, 1fr); }
  .supplier-change-options.supplier-choice-options { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .partner-approval-case-table th,
  .partner-approval-case-table > colgroup > .partner-approval-case-label { width: 96px; }
  .supplier-update-field { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .supplier-update-field > .partner-approval-check { grid-column: 1 / -1; }
}
@container partner-approval-data (max-width: 480px) {
  .supplier-editor-grid, .partner-approval-data-fields { grid-template-columns: 1fr; }
}
.partner-approval-invoice-pdf > iframe { height: 100%; min-height: 0; }
@media (max-width: 700px) {
  .partner-approval-review > .detail-topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .partner-approval-review > .detail-topbar > .btn { white-space: nowrap; }
  .partner-approval-review > .detail-topbar .command-bar { order: 3; width: 100%; min-width: 0; flex-basis: 100%; }
}

/* Dynamics setup stays inside the shared integration card. */
.dynamics-setup { margin-top: 12px; }
.dynamics-setup summary { cursor: pointer; font-weight: 500; }
.dynamics-settings-form { display: grid; gap: 8px; max-width: 560px; margin-top: 12px; }
.dynamics-settings-form label { font-size: 13px; font-weight: 500; }
.dynamics-settings-form .form-input {
  width: 100%; min-width: 0; height: 36px; box-sizing: border-box;
  padding: 6px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--fg); font-family: inherit; font-size: 13px;
}
.dynamics-settings-form .form-input:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
[id^="connection-dynamics-"] .connection-row { align-items: flex-start; }
[id^="connection-dynamics-"] .connection-row-description { overflow-wrap: anywhere; }
.dynamics-company-controls { display: flex; align-items: center; gap: 10px; }
.dynamics-company-controls .form-input { max-width: 160px; }
.dynamics-company-controls button { min-height: 36px; white-space: nowrap; }
.dynamics-settings-form .form-hint { margin: 0; overflow-wrap: anywhere; }
.dynamics-feedback { margin: 10px 0; font-size: 13px; }
.dynamics-feedback.error { color: var(--color-danger, #b42318); }
@media (max-width: 600px) {
  .dynamics-company-controls { flex-wrap: wrap; }
  [id^="connection-dynamics-"] .connection-row { flex-wrap: wrap; }
  [id^="connection-dynamics-"] .connection-row-actions { margin-left: 44px; }
}

/* Account sheet */
/* One account's items as DEBIT (left) / CREDIT (right), the header strip above
   it and its small dialogs (app/ui/account_sheet.clj). Light lines only: a
   1px --border column divider, heading underline and total line, and a
   --border-subtle hairline between rows, never under the last one. */
.account-sheet-page { display: flex; flex-direction: column; gap: var(--space-4); }
.account-sheet-origin-note { display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--fg-muted); font: var(--text-sm); }
.account-sheet-origin-note iconify-icon { flex: none; font-size: 15px; color: var(--fg-subtle); }
.account-sheet-origin-note strong { color: var(--fg); font-weight: 600; }
.account-sheet-origin-note a { margin-left: auto; color: var(--link); text-decoration: none; white-space: nowrap; }

.account-sheet__number { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.account-sheet__currency { color: var(--fg-faint); font-weight: 400; }
.account-sheet__label { margin: 0; color: var(--fg-muted); font: var(--text-caption); letter-spacing: .5px; text-transform: uppercase; }
.account-sheet__help { margin: 0; color: var(--fg-subtle); font: var(--text-sm); }
.account-sheet__code { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); }
/* A reference (invoice, credit-note or bank reference) inside a title. */
.account-sheet__ref { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Header strip */
.account-sheet-header { display: flex; flex-direction: column; gap: var(--space-3); }
.account-sheet-header__top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.account-sheet-header__pill-icon { font-size: 12px; }
.account-sheet-header__title { font: var(--text-h2); color: var(--fg); }
.account-sheet-header__title .account-sheet__ref { font: inherit; font-family: var(--font-mono); letter-spacing: -.01em; }
.account-sheet-header__party { font: var(--text-body-strong); color: var(--fg); }
.account-sheet-header__account { font: var(--text-mono); color: var(--fg-muted); }
.account-sheet-header__account small { font: var(--text-sm); color: var(--fg-subtle); }
.account-sheet-header__document { display: inline-flex; align-items: center; gap: var(--space-2); margin-left: auto; padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--fg-muted); font: var(--text-sm); white-space: nowrap; }
.account-sheet-header__document iconify-icon { font-size: 16px; color: var(--fg-subtle); }
.account-sheet-header__document a { color: var(--link); text-decoration: none; }
.account-sheet-header__links { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.account-sheet-header__document + .account-sheet-header__links { margin-left: 0; }
.account-sheet-header__link { display: inline-flex; align-items: center; gap: var(--space-2); padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--r-md); color: var(--link); font: var(--text-sm); text-decoration: none; white-space: nowrap; }
.account-sheet-header__link iconify-icon { font-size: 16px; color: var(--fg-subtle); }
.account-sheet-header__facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-7); margin: 0; padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.account-sheet-header__facts > div { display: flex; flex-direction: column; gap: 2px; }
.account-sheet-header__facts dt { color: var(--fg-muted); font: var(--text-caption); letter-spacing: .5px; text-transform: uppercase; }
.account-sheet-header__facts dd { margin: 0; color: var(--fg); font: var(--text-body); }
.account-sheet-header__facts dd .account-sheet__date { font-family: var(--font-mono); font-size: 13px; }
.account-sheet-header__facts dd .account-sheet__sub { margin-left: 6px; color: var(--fg-subtle); font: var(--text-sm); }
.account-sheet-header__facts dd a { margin-left: 6px; color: var(--link); font: var(--text-sm); text-decoration: none; }
.account-sheet-header__value--success { color: var(--success-strong); }
.account-sheet-header__facts dd.account-sheet-header__value--warning { display: flex; align-items: center; gap: 6px; color: var(--warning-strong); font-weight: 600; }
.account-sheet-header__value--warning .account-sheet__sub { color: var(--warning-strong); font-weight: 400; }
.account-sheet-header__facts dd.account-sheet-header__value--strong { color: var(--fg); font-weight: 600; }
.account-sheet-header__value--strong .account-sheet__sub { font-weight: 400; }

/* Sheet */
.account-sheet__title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-4); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); }
.account-sheet__title h2 { margin: 0; font: var(--text-h3); color: var(--fg); }
.account-sheet__account-number { margin-left: 2px; font: var(--text-mono); color: var(--fg-muted); }
.account-sheet__columns { display: grid; grid-template-columns: 1fr 1fr; }
/* A note under the columns stands clear of the totals line above it. */
.account-sheet__columns ~ .account-sheet-origin-note { margin-top: var(--space-3); }
.account-sheet__side { display: flex; flex-direction: column; min-width: 0; }
.account-sheet__side--debit { padding-right: var(--space-5); border-right: 1px solid var(--border); }
.account-sheet__side--credit { padding-left: var(--space-5); }
.account-sheet__side-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); padding: 0 0 var(--space-2); border-bottom: 1px solid var(--border); }
.account-sheet__side--credit .account-sheet__side-head { flex-direction: row-reverse; }
.account-sheet__side-head .account-sheet__label { color: var(--fg); font-size: 12px; font-weight: 600; letter-spacing: 1px; }
.account-sheet__side-head .account-sheet__help { font: var(--text-caption); font-weight: 400; color: var(--fg-subtle); }
.account-sheet__rows { display: flex; flex: 1; flex-direction: column; padding-bottom: var(--space-4); }
.account-sheet__row { position: relative; display: grid; grid-template-columns: 82px minmax(0, 1fr) 128px; gap: var(--space-3); align-items: baseline; padding: 10px 0; border-bottom: 0; font: var(--text-sm); }
.account-sheet__side--with-actions .account-sheet__row { grid-template-columns: 82px minmax(0, 1fr) 128px 28px; }
.account-sheet__row + .account-sheet__row { border-top: 1px solid var(--border-subtle); }
.account-sheet__row .account-sheet__date { font: var(--text-mono); color: var(--fg-muted); }
.account-sheet__text { min-width: 0; color: var(--fg); }
.account-sheet__row-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.account-sheet__sub { display: block; margin-top: 1px; color: var(--fg-subtle); font: var(--text-caption); font-weight: 400; }
.account-sheet__amount { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font: var(--text-mono); color: var(--fg); text-align: right; white-space: nowrap; }
.account-sheet__link { color: var(--link); font: var(--text-caption); font-family: var(--font-sans); font-weight: 400; text-decoration: none; }
.account-sheet__row--reversed .account-sheet__amount { color: var(--fg-subtle); }
.account-sheet__row--reversed .account-sheet__money { text-decoration: line-through; }
.account-sheet__row--highlighted { margin-right: -8px; margin-left: -12px; padding-right: 8px; padding-left: 12px; background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
.account-sheet__tag { display: inline-flex; align-items: center; gap: 4px; height: 17px; padding: 0 5px; border-radius: var(--r-sm); font: var(--text-caption); font-family: var(--font-sans); font-size: 11px; letter-spacing: .02em; white-space: nowrap; }
.account-sheet__tag iconify-icon { font-size: 12px; }
.account-sheet__tag--reversed { background: var(--surface); border: 1px solid var(--border); color: var(--fg-subtle); }
.account-sheet__marker { display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; padding: 1px 7px 1px 5px; border-radius: var(--r-sm); font: var(--text-caption); font-weight: 400; }
.account-sheet__marker iconify-icon { font-size: 13px; }
.account-sheet__marker--warning { background: var(--warning-tint); border: 1px solid var(--warning-border); color: var(--warning-strong); }
.account-sheet__marker--warning strong { font-weight: 600; }
.account-sheet__empty { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--r-md); color: var(--fg-subtle); font: var(--text-sm); }
.account-sheet__empty iconify-icon { flex: none; font-size: 16px; color: var(--fg-faint); }
.account-sheet__empty strong { color: var(--fg-muted); font-weight: 600; }
.account-sheet__empty a { color: var(--link); text-decoration: none; }
.account-sheet__row-action { align-self: start; justify-self: end; }
.account-sheet__remove { display: inline-flex; padding: 0; border: 0; background: none; color: var(--fg-faint); font-size: 15px; cursor: pointer; }
.account-sheet__remove:hover { color: var(--fg); }

/* Row menu */
.account-sheet__menu { position: relative; }
.account-sheet__menu-button { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; margin-top: -3px; border: 1px solid transparent; border-radius: var(--r-md); color: var(--fg-muted); font-size: 16px; list-style: none; cursor: pointer; }
.account-sheet__menu-button::-webkit-details-marker { display: none; }
.account-sheet__menu-button:hover, .account-sheet__menu[open] > .account-sheet__menu-button { background: var(--bg-subtle); border-color: var(--border); color: var(--fg); }
.account-sheet__menu-items { position: absolute; top: calc(100% + 4px); right: 0; z-index: 20; width: 300px; padding: 6px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-popover); text-align: left; }
.account-sheet__menu-item { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-md); background: none; color: var(--fg); font: var(--text-sm); font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
.account-sheet__menu-item:hover, .account-sheet__menu-item:focus-visible { background: var(--bg-subtle); }
.account-sheet__menu-label { display: flex; align-items: center; gap: 8px; }
.account-sheet__menu-label iconify-icon { font-size: 15px; color: var(--fg-muted); }
.account-sheet__menu-item--danger .account-sheet__menu-label, .account-sheet__menu-item--danger .account-sheet__menu-label iconify-icon { color: var(--danger); }
.account-sheet__menu-item small { padding-left: 23px; color: var(--fg-subtle); font: var(--text-caption); font-weight: 400; }

/* Totals */
.account-sheet__total { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: var(--space-3); align-items: baseline; margin-top: auto; padding: 10px 0 0; border-top: 1px solid var(--border); }
.account-sheet__side--with-actions .account-sheet__total { grid-template-columns: minmax(0, 1fr) 128px 28px; }
.account-sheet__total > span:first-child { color: var(--fg-muted); font: var(--text-label); letter-spacing: .5px; text-transform: uppercase; }
.account-sheet__total strong { justify-self: end; color: var(--fg); white-space: nowrap; }
.account-sheet__total strong .account-sheet__number { font: 600 14px/1.5 var(--font-mono); }
.account-sheet__total strong .account-sheet__currency { font: 400 13px/1.5 var(--font-mono); }

/* Balance line */
.account-sheet__balance { display: flex; align-items: center; gap: var(--space-5); margin-top: var(--space-5); padding: var(--space-3) var(--space-4); border-radius: var(--r-md); }
.account-sheet__balance-figure { display: flex; align-items: baseline; gap: var(--space-3); white-space: nowrap; }
.account-sheet__balance-figure .account-sheet__label { color: var(--fg-muted); }
.account-sheet__balance-figure strong { font: 600 20px/1.2 var(--font-mono); }
.account-sheet__balance-figure strong .account-sheet__currency { color: inherit; font-size: 14px; opacity: .65; }
.account-sheet__balance-figure em { font: var(--text-body-strong); font-style: normal; }
.account-sheet__balance-icon { align-self: center; font-size: 18px; }
.account-sheet__balance > .account-sheet__help { flex: 1; min-width: 0; color: var(--fg-muted); }
.account-sheet__balance-actions { display: flex; flex: none; align-items: center; gap: var(--space-3); }
.account-sheet__balance-actions .btn { gap: 6px; white-space: nowrap; }
.account-sheet__balance-actions .btn-secondary iconify-icon { font-size: 15px; color: var(--fg-muted); }
.account-sheet__balance--settled { background: var(--success-tint); border: 1px solid var(--success-border); }
.account-sheet__balance--settled .account-sheet__balance-figure strong,
.account-sheet__balance--settled .account-sheet__balance-figure em,
.account-sheet__balance--settled .account-sheet__balance-icon { color: var(--success-strong); }
.account-sheet__balance--open { background: var(--bg-subtle); border: 1px solid var(--border); }
.account-sheet__balance--open .account-sheet__balance-figure strong,
.account-sheet__balance--open .account-sheet__balance-figure em { color: var(--fg); }
.account-sheet__balance--open .account-sheet__balance-icon { color: var(--fg-subtle); }
.account-sheet__balance--closed, .account-sheet__balance--reserved, .account-sheet__balance--in-payment { background: var(--bg-subtle); border: 1px solid var(--border); }
.account-sheet__balance--closed .account-sheet__balance-figure strong, .account-sheet__balance--closed .account-sheet__balance-figure em,
.account-sheet__balance--reserved .account-sheet__balance-figure strong, .account-sheet__balance--reserved .account-sheet__balance-figure em,
.account-sheet__balance--in-payment .account-sheet__balance-figure strong, .account-sheet__balance--in-payment .account-sheet__balance-figure em { color: var(--fg); }
.account-sheet__balance--closed .account-sheet__balance-icon, .account-sheet__balance--reserved .account-sheet__balance-icon, .account-sheet__balance--in-payment .account-sheet__balance-icon { color: var(--fg-muted); }
.account-sheet__balance--overdue { background: var(--warning-tint); border: 1px solid var(--warning-border); }
.account-sheet__balance--overdue .account-sheet__balance-figure strong,
.account-sheet__balance--overdue .account-sheet__balance-figure em,
.account-sheet__balance--overdue .account-sheet__balance-icon { color: var(--warning-strong); }

/* Dialogs */
.account-sheet-dialog__subtitle { margin: 0; color: var(--fg-muted); font: var(--text-sm); }
.account-sheet-confirm { display: flex; flex-direction: column; gap: 16px; }
.account-sheet-confirm__rows { display: flex; flex-direction: column; gap: 10px; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-subtle); }
.account-sheet-confirm__row { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; align-items: baseline; gap: var(--space-3); }
.account-sheet-confirm__row--unlabelled { grid-template-columns: minmax(0, 1fr) auto; }
.account-sheet-confirm__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--fg); font: var(--text-sm); }
.account-sheet-confirm__text small { color: var(--fg-muted); font: var(--text-caption); }
.account-sheet-confirm__amount { text-align: right; white-space: nowrap; }
.account-sheet-confirm__separator { width: 100%; margin: 2px 0; border: 0; border-top: 1px solid var(--border); }
.account-sheet-confirm__balance { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3); border-radius: var(--r-md); font: var(--text-sm); }
.account-sheet-confirm__balance iconify-icon { flex: none; margin-top: 2px; font-size: 16px; }
.account-sheet-confirm__balance--settled { background: var(--success-tint); border: 1px solid var(--success-border); color: var(--success-strong); }
.account-sheet-confirm__balance--open { background: var(--bg-subtle); border: 1px solid var(--border); color: var(--fg); }

/* Edit mode: the manual-clearing composer */
.account-sheet-page--composer { flex: 1; min-height: 0; padding: var(--space-5) var(--space-6) var(--space-6); overflow-y: auto; background: var(--surface); }
.account-sheet-page__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-4); }
.account-sheet-page__title h1 { margin: 0; font: var(--text-h2); color: var(--fg); }
.account-sheet-page__title p { margin: 0; color: var(--fg-muted); font: var(--text-sm); }
.account-sheet-notice { display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--r-md); font: var(--text-sm); }
.account-sheet-notice iconify-icon { flex: none; font-size: 16px; }
.account-sheet-notice--warning { background: var(--warning-tint); border: 1px solid var(--warning-border); color: var(--warning-strong); }
.account-sheet-notice--danger { background: var(--danger-tint); border: 1px solid var(--danger-border); color: var(--danger-strong); }
.account-sheet--edit .account-sheet__side .account-sheet__row { grid-template-columns: 82px minmax(0, 1fr) 118px 18px; align-items: center; padding: 8px 0; }
.account-sheet--edit .account-sheet__row .account-sheet__date { align-self: baseline; padding-top: 2px; }
.account-sheet--edit .account-sheet__row-title { font-weight: 600; }
.account-sheet--edit .account-sheet__row-action { align-self: center; }
.account-sheet--edit .account-sheet__side .account-sheet__total { grid-template-columns: minmax(0, 1fr) 118px 18px; }
.account-sheet--edit .account-sheet__differences .account-sheet__row { border-top: 1px solid var(--border-subtle); }
.account-sheet__amount-field { display: flex; align-items: center; justify-content: flex-end; }
.account-sheet__amount-field input { width: 108px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--fg); font: var(--text-mono); font-size: 13px; text-align: right; }
.account-sheet__difference-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.account-sheet__difference-fields select { height: 28px; max-width: 100%; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--fg); font: var(--text-caption); }
.account-sheet__difference-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }
.account-sheet__difference-buttons[hidden], .account-sheet__difference-buttons [hidden] { display: none; }
.account-sheet__note { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; gap: var(--space-3); margin-top: var(--space-5); }
.account-sheet__note-field { display: flex; flex-direction: column; gap: 3px; }
.account-sheet__note-field input { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--fg); font: var(--text-sm); }
.account-sheet__note-field .account-sheet__help { font: var(--text-caption); }
.account-sheet__cancel { color: var(--fg-muted); font: var(--text-sm); text-decoration: none; }
.account-sheet__cancel:hover { color: var(--fg); }

/* Candidates below the edit-mode sheet */
.account-sheet-candidates__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-2); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); }
.account-sheet-candidates__head h2 { margin: 0; font: var(--text-h3); color: var(--fg); }
.account-sheet-candidates__table { width: 100%; border-collapse: collapse; font: var(--text-sm); }
.account-sheet-candidates__table th { padding: 6px var(--space-3) 6px 0; border-bottom: 1px solid var(--border-subtle); color: var(--fg-muted); font: var(--text-caption); letter-spacing: .5px; text-align: left; text-transform: uppercase; }
.account-sheet-candidates__table td { padding: 9px var(--space-3) 9px 0; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.account-sheet-candidates__table tr:last-child td { border-bottom: 0; }
.account-sheet-candidates__table td:first-child, .account-sheet-candidates__table th:first-child { padding-left: 10px; }
.account-sheet-candidates__date { width: 104px; color: var(--fg-muted); font: var(--text-mono); white-space: nowrap; }
.account-sheet-candidates__item strong { color: var(--fg); font-weight: 600; }
.account-sheet-candidates__item small { display: block; color: var(--fg-subtle); font: var(--text-caption); font-weight: 400; }
.account-sheet-candidates__table .account-sheet-candidates__open { width: 140px; padding-right: var(--space-6); font: var(--text-mono); text-align: right; white-space: nowrap; }
.account-sheet-candidates__action { width: 130px; padding-right: 0; text-align: right; }
.account-sheet-candidates__action .btn { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.account-sheet-candidates__action .btn[disabled] { opacity: .45; }
.account-sheet-candidates__row--blocked td { background: var(--bg-subtle); color: var(--fg-subtle); }
.account-sheet-candidates__row--blocked .account-sheet-candidates__item strong { color: var(--fg-muted); }
.account-sheet-candidates__reason { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--fg-muted); font: var(--text-sm); }
.account-sheet-candidates__reason iconify-icon { font-size: 14px; color: var(--fg-subtle); }
.account-sheet-candidates__reason a { margin-left: 4px; color: var(--link); text-decoration: none; }
.account-sheet__empty--dashed { align-items: flex-start; color: var(--fg-muted); }
.account-sheet__empty--dashed iconify-icon { margin-top: 2px; }

@media (max-width: 760px) {
  .account-sheet__title { flex-direction: column; gap: var(--space-1); }
  .account-sheet__columns { grid-template-columns: minmax(0, 1fr); }
  .account-sheet__side--debit { padding-right: 0; border-right: 0; }
  .account-sheet__side--credit { margin-top: var(--space-5); padding-left: 0; }
  .account-sheet__side--credit .account-sheet__side-head { flex-direction: row; }
  .account-sheet__row { grid-template-columns: 82px minmax(0, 1fr) auto; }
  .account-sheet__side--with-actions .account-sheet__row { grid-template-columns: 82px minmax(0, 1fr) auto 28px; }
  .account-sheet__balance { flex-wrap: wrap; gap: var(--space-3); }
  .account-sheet__balance > .account-sheet__help { flex-basis: 100%; }
  .account-sheet-header__document,
  .account-sheet-header__links { margin-left: 0; }
  .account-sheet-page--composer { padding: var(--space-4) var(--space-4) var(--space-6); }
  .account-sheet--edit .account-sheet__side .account-sheet__row { grid-template-columns: 72px minmax(0, 1fr) 108px 18px; }
  .account-sheet__note { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .account-sheet-candidates__head { flex-direction: column; gap: var(--space-1); }
  .account-sheet-candidates { overflow-x: auto; }
}
/* End account sheet */

/* A live proposal in the invoice workbench's candidate list: its Approve and
   Reject buttons, or the link to the payment that settles several invoices. */
.bank-invoice-workbench__proposal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  font: var(--text-caption);
  white-space: normal;
}

/* Partner Approvals: "Who sent these invoices?" — one decision for the ticked
   invoices, one search over every invoice company's suppliers. */
.supplier-choice-question { font-size: 17px; font-weight: 600; color: var(--fg); margin: 2px 0 10px; }
.supplier-choice-intro { display: block; margin: -4px 0 12px; }
.supplier-choice-invoices,
.supplier-choice-consequences { border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); padding: 12px 16px; }
.supplier-choice-invoices { margin-bottom: 14px; }
.supplier-choice-invoices .supplier-update-summary,
.supplier-choice-consequences .supplier-update-summary { margin: 0 0 4px; }
.supplier-choice-invoice { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; margin: 0 -10px; border-radius: var(--r-lg); cursor: pointer; }
.supplier-choice-invoice:not(:has(.supplier-choice-invoice-check)) { grid-template-columns: minmax(0, 1fr) auto; }
.supplier-choice-invoice + .supplier-choice-invoice { margin-top: 2px; }
.supplier-choice-invoice:hover { background: var(--brand-tint-hover); }
.supplier-choice-invoice.is-shown { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
.supplier-choice-invoice.is-excluded .supplier-choice-invoice-main { opacity: .55; }
.supplier-choice-invoice.is-excluded .supplier-choice-invoice-title { text-decoration: line-through; text-decoration-color: var(--fg-muted); }
.supplier-choice-invoice-check { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.supplier-choice-invoice-main { display: grid; gap: 1px; min-width: 0; }
.supplier-choice-invoice-title { color: var(--fg); }
.supplier-choice-invoice-end { display: flex; align-items: center; gap: 10px; }
.supplier-choice-invoice-amount { font-variant-numeric: tabular-nums; color: var(--fg); white-space: nowrap; }
.supplier-choice-invoice.is-excluded .supplier-choice-invoice-amount { display: none; }
.supplier-choice-search { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--fg-muted); }
.supplier-choice-search input { flex: 1; height: 100%; border: 0; outline: 0; background: transparent; box-shadow: none;
  padding: 0; font: inherit; font-size: 15px; color: var(--fg); }
.supplier-choice-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.supplier-choice-note { display: block; margin: 6px 0 8px; }
.supplier-choice-list { border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); overflow: hidden; }
.supplier-choice-list .supplier-choice-note { margin: 0; padding: 10px 16px; border-top: 1px solid var(--border); }
.supplier-choice-list-head { display: grid; grid-template-columns: 28px minmax(0, 1.4fr) minmax(0, 1.3fr) minmax(0, .6fr); gap: 12px;
  padding: 8px 16px; background: var(--bg-subtle); color: var(--fg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.supplier-choice-list-head span:first-child { grid-column: 2; }
.supplier-choice-list .supplier-choice { border-top: 1px solid var(--border); }
#partner-approval-header-case, #partner-approval-header-standing { display: contents; }
.supplier-choice-head { display: grid; grid-template-columns: 28px minmax(0, 1.4fr) minmax(0, 1.3fr) minmax(0, .6fr); gap: 12px;
  align-items: center; padding: 12px 16px; cursor: pointer; }
.supplier-choice-head:hover { background: var(--brand-tint-hover); }
.supplier-choice.is-selected > .supplier-choice-head { background: var(--brand-tint); }
.supplier-choice-main { display: grid; gap: 2px; min-width: 0; }
.supplier-choice-title { font-weight: 600; color: var(--fg); display: flex; align-items: center; gap: 6px; }
.supplier-choice-vendors { display: flex; flex-wrap: wrap; gap: 4px; }
.supplier-choice-matches { color: var(--fg-muted); }
/* A picked answer opens under its row; one at a time. */
.supplier-choice-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.supplier-choice.is-open > .supplier-choice-detail { grid-template-rows: 1fr; }
.supplier-choice-detail-clip { overflow: hidden; min-height: 0; }
.supplier-choice-detail-body { display: grid; gap: 14px; padding: 6px 16px 16px; }
.supplier-choice-detail .partner-approval-decision-footer { margin-top: 0; }
.supplier-choice.is-open { box-shadow: inset 3px 0 0 var(--brand); }
@media (prefers-reduced-motion: reduce) { .supplier-choice-detail { transition: none; } }
.supplier-choice-found { margin: 0; padding: 9px 16px; border-top: 1px solid var(--border); background: var(--brand-tint); color: var(--fg); }
.supplier-choice-search-block { border-top: 1px solid var(--border); padding-top: 10px; }
.supplier-choice-search-label { margin: 0 16px 6px; font-weight: 600; color: var(--fg); }
.supplier-choice-search-block .supplier-choice-search { margin: 0 16px 10px; }
.supplier-choice-list:has(.supplier-choice-candidates .supplier-choice) .supplier-choice-search-plain,
.supplier-choice-list:not(:has(.supplier-choice-candidates .supplier-choice)) .supplier-choice-search-not-listed { display: none; }
.supplier-choice-search-results .supplier-choice-note { border-top: 0; padding-top: 0; padding-left: 16px; }
.supplier-choice-adds { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; background: var(--bg-subtle); }
.supplier-choice-adds p { margin: 0 0 4px; }
.supplier-choice-adds-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; color: var(--fg); }
.supplier-choice-adds-company[hidden], .supplier-choice-adds[hidden] { display: none; }
.supplier-choice-adds .supplier-choice-company-fields { margin-top: 10px; }
.supplier-choice-compare { width: 100%; border-collapse: collapse; }
.supplier-choice-compare th, .supplier-choice-compare td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.supplier-choice-compare thead th { font-weight: 600; color: var(--fg); }
.supplier-choice-compare thead .partner-approval-meta { margin-left: 6px; }
.supplier-choice-compare tbody th { width: 90px; color: var(--fg-muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.supplier-choice-update { width: 110px; text-align: right !important; }
.supplier-choice-company-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.supplier-choice-pending { margin-top: 14px; }
.supplier-choice-form:has(.supplier-choice.is-selected) .supplier-choice-pending .partner-approval-decision-outcome { visibility: hidden; }
.supplier-choice-decision-footer-hint { display: block; }
.supplier-choice-left { display: block; }
.partner-approval-decision-outcome [data-when-all-ticked],
.partner-approval-decision-outcome [data-when-some-unticked] { display: block; }
.partner-approval-decision-outcome [hidden] { display: none !important; }
.supplier-choice-consequence { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.supplier-choice-consequences .supplier-update-summary + .supplier-choice-consequence { border-top: 0; }
.supplier-choice-consequence p { margin: 0 0 4px; }
.supplier-choice-consequence.is-warning { background: var(--warning-tint); margin: 0 -16px; padding: 10px 16px; }
.supplier-choice-consequence-icon { font-size: 17px; padding-top: 1px; }
.supplier-choice-consequence-icon.tone-success { color: var(--success); }
.supplier-choice-consequence-icon.tone-warning { color: var(--warning); }
.supplier-choice-consequence-icon.tone-neutral { color: var(--fg-muted); }
/* An invoice taken out of the decision stays visible, faded, while shown. */
.partner-approval-invoice-panel.is-excluded { opacity: .45; }

/* AP invoice page: an exported invoice whose supplier was corrected afterwards. */
.invoice-vendor-correction { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 12px; padding: 12px 14px;
  border: 1px solid var(--warning-border); border-radius: var(--r-lg); background: var(--warning-tint); color: var(--fg); }
.invoice-vendor-correction > iconify-icon { color: var(--warning); font-size: 18px; margin-top: 1px; }
.invoice-vendor-correction-text { flex: 1; min-width: 0; }
.invoice-vendor-correction-text p { margin: 0; }
.invoice-vendor-correction-title { font-weight: 600; }
.invoice-vendor-correction form { margin: 0; }
@media (max-width: 720px) {
  .supplier-choice-head { grid-template-columns: 28px minmax(0, 1fr); }
  .supplier-choice-list-head { display: none; }
  .supplier-choice-vendors, .supplier-choice-matches { grid-column: 2; }
  .supplier-choice-company-fields { grid-template-columns: 1fr; }
}
