/* Vectisint_2 — Phase 1 placeholder styles.
   Deliberately minimal. Replaced in Phase 3 with the real design system. */

:root {
  --fg: #1a1a1a;
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --accent: #1f6feb;
  --muted: #6b6b6b;
  --border: #e2e2e0;
  --error-bg: #ffecec;
  --error-fg: #9b1c1c;
  --info-bg: #e8f1ff;
  --info-fg: #1e4a99;
  --success-bg: #e8f6ec;
  --success-fg: #1e6b32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  height: 48px;
  width: auto;
  display: block;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.context-chip, .user-chip {
  font-size: 0.875rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background: #eef1f6;
  color: var(--muted);
}

.btn-link {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.site-main {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.flashes { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.flash {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.flash-error { background: var(--error-bg); color: var(--error-fg); }
.flash-info { background: var(--info-bg); color: var(--info-fg); }
.flash-success { background: var(--success-bg); color: var(--success-fg); }

.login-card {
  max-width: 400px;
  margin: 3rem auto;
  padding: 2rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.login-card h1 { margin-top: 0; }

.form-field { margin-bottom: 1.2rem; display: flex; flex-direction: column; }
.form-field label { font-weight: 600; margin-bottom: 0.35rem; }

.input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field-error {
  color: var(--error-fg);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.form-actions { display: flex; justify-content: flex-end; }

.btn {
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }

/* Destructive / irreversible action — red outline so the bookkeeper
   reads twice before clicking. Used on un-submit, cancel-deal,
   write-off, and similar emergency / dangerous transitions. */
.btn-danger {
  background: #fff;
  color: #9b1c1c;
  border: 1px solid #9b1c1c;
}
.btn-danger:hover { background: #fde2e2; }

/* Disabled / completed-state pill used in place of a button. Looks
   like a button but isn't clickable. */
.btn-disabled {
  background: #ecedef;
  color: #6b7280;
  cursor: not-allowed;
  opacity: 0.85;
}

.inline { display: inline; }
.muted { color: var(--muted); }
code { background: #eef1f6; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.9em; }

.context-summary { margin-top: 2rem; }
.context-summary dt { font-weight: 600; margin-top: 1rem; }
.context-summary dd { margin-left: 0; margin-bottom: 0.5rem; }

.site-footer {
  margin-top: 4rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* -------------------------------------------------------------------------
   Top-bar switcher (company + branch dropdowns)
   ------------------------------------------------------------------------- */

.switcher-form {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.switcher-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.switcher-select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  max-width: 14rem;
}

.switcher-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* -------------------------------------------------------------------------
   Dashboard empty state + tiles
   ------------------------------------------------------------------------- */

.empty-state {
  padding: 2rem;
  margin: 2rem 0;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
}

.empty-state p { margin: 0.4rem 0; }

/* -------------------------------------------------------------------------
   Site shell — header on top, sidebar + main below. Mirrors PHP
   Finance Manager's layout so employees recognise the structure.
   ------------------------------------------------------------------------- */
.site-shell {
  display: flex;
  min-height: calc(100vh - 88px); /* viewport minus header + footer */
}
.site-sidebar {
  flex: 0 0 220px;
  background: #2c2f36;
  color: #d8dbe0;
  padding: 0;
  border-right: 1px solid #1d1f24;
  transition: flex-basis 0.2s ease;
  display: flex;
  flex-direction: column;
}
.site-sidebar .sidebar-nav {
  flex: 1 1 auto;
  padding: 0.75rem 0;
}

/* Collapse buttons at the top + bottom of the sidebar — clicking
   either toggles the same state. PHP-style sidebars don't have these
   but they're more discoverable than a hamburger floating in the
   header, especially on a narrow screen. */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #1d1f24;
  color: #8b8e94;
  cursor: pointer;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-collapse-btn:hover {
  background: #34373e;
  color: #fff;
}
.sidebar-collapse-btn--bottom {
  border-bottom: none;
  border-top: 1px solid #1d1f24;
  margin-top: auto;
}
.sidebar-collapse-icon {
  display: inline-block;
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.2s ease;
}
body.sidebar-collapsed .sidebar-collapse-icon {
  transform: rotate(180deg);
}
body.sidebar-collapsed .sidebar-collapse-label {
  display: none;
}

/* Collapsed sidebar — icon-only column. Click hamburger to toggle. */
body.sidebar-collapsed .site-sidebar {
  flex: 0 0 60px;
}
body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .sidebar-caret,
body.sidebar-collapsed .sidebar-section {
  display: none;
}
body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 0.6rem 0;
}
body.sidebar-collapsed .sidebar-ico {
  font-size: 1.15rem;
}
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-section {
  padding: 1.25rem 1.25rem 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b8e94;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: #d8dbe0;
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.sidebar-link:hover {
  background: #34373e;
  color: #fff;
}
.sidebar-link.active {
  background: #20a8d8;
  color: #fff;
  border-left-color: #fff;
}
.sidebar-ico {
  display: inline-block;
  width: 1.1rem;
  text-align: center;
  font-size: 1rem;
  opacity: 0.85;
  flex: 0 0 auto;
}
.sidebar-text {
  flex: 1 1 auto;
}
.sidebar-caret {
  flex: 0 0 auto;
  font-size: 1rem;
  opacity: 0.5;
  margin-left: auto;
  transition: transform 0.15s ease;
}
.sidebar-link.active .sidebar-caret { opacity: 0.9; }

/* -------------------------------------------------------------------------
   Grouped sidebar items (<details>/<summary>) — top-level module openers
   that reveal their dropdown when clicked. The summary itself does NOT
   navigate; users pick a sub-link inside the dropdown. Each group
   auto-opens (server-rendered ``open`` attr) when the current endpoint
   belongs to the group, so deep-linking into a sub-page leaves the
   group expanded for context.
   ------------------------------------------------------------------------- */
.sidebar-group > details {
  /* Remove default summary marker — we use our own chevron. */
}
.sidebar-group > details > summary {
  list-style: none;
  cursor: pointer;
}
.sidebar-group > details > summary::-webkit-details-marker { display: none; }
.sidebar-group > details > summary::marker { display: none; }
.sidebar-group > details[open] > summary > .sidebar-caret {
  transform: rotate(90deg);
}
.sidebar-sub {
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem;
  background: rgba(0, 0, 0, 0.18);
}
.sidebar-sublink {
  padding-left: 3.1rem;
  font-size: 0.88rem;
  color: #bfc3c9;
}
.sidebar-sublink.active {
  /* Same brand-blue as top-level, slightly less heavy for hierarchy. */
  background: #1f7fa6;
  color: #fff;
  border-left-color: #fff;
}
/* In collapsed mode the dropdowns can't fit — hide them and treat
   each group's summary as a tooltip-only icon. */
body.sidebar-collapsed .sidebar-sub { display: none; }
body.sidebar-collapsed .sidebar-group > details > summary > .sidebar-caret {
  display: none;
}

body.with-sidebar .site-main {
  flex: 1;
  padding: 1.5rem 2rem;
  background: var(--bg);
}

/* When unauthenticated, no sidebar — main is full-width. */
body:not(.with-sidebar) .site-main {
  padding: 1.5rem 2rem;
}

@media (max-width: 800px) {
  .site-shell { flex-direction: column; }
  .site-sidebar {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid #1d1f24;
  }
  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
  }
  .sidebar-section { display: none; }
  .sidebar-link { padding: 0.4rem 0.75rem; border-left: none; border-radius: 4px; }
}

/* -------------------------------------------------------------------------
   PHP-style KPI strip — preserves the muscle memory of the PHP dashboard
   (4 colored cards across the top: Due / Paid / Late / Unpaid).
   Locked to 4 across on desktop, 2 across on tablet, 1 stacked on phone.
   ------------------------------------------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
@media (max-width: 1100px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .kpi-strip { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------------
   Forecast card — single big card holding the 24-month line chart and
   the 5 progress bars below it. Mirrors PHP's "Payment Forecast" panel.
   ------------------------------------------------------------------------- */
.forecast-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 2rem;
  overflow: hidden;
}
.forecast-card__head {
  padding: 1rem 1.25rem 0.5rem;
}
.forecast-card__head h2 {
  margin: 0;
  font-size: 1.05rem;
  border: none;
  padding: 0;
}
.forecast-card__head .muted {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
}
.forecast-card__chart {
  padding: 0.5rem 1rem 1rem;
  height: 280px;
  position: relative;
}
.forecast-card__bars {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
@media (max-width: 1100px) {
  .forecast-card__bars { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .forecast-card__bars { grid-template-columns: 1fr; }
}
.bar-label {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bar-strong {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0.25rem 0 0.45rem;
}
.bar-strong .muted {
  font-weight: 400;
  font-size: 0.85rem;
}
.progress {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill { height: 100%; transition: width 0.4s ease; }
.bar-success  { background: #2eb85c; }
.bar-info     { background: #39f;    }
.bar-warning  { background: #ffc107; }
.bar-danger   { background: #f86c6b; }
.bar-primary  { background: #20a8d8; }
.kpi {
  display: block;
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: 8px;
  text-decoration: none;
  color: #fff;
  background: #4a90e2;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  color: #fff;
}
.kpi-due    { background: #20a8d8; }  /* primary — invoiced */
.kpi-paid   { background: #63c2de; }  /* info     — paid */
.kpi-late   { background: #ffc107; color: #2e2a14; }  /* warning */
.kpi-late:hover { color: #2e2a14; }
.kpi-unpaid { background: #f86c6b; }  /* danger   — unpaid */
.kpi-amount {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.kpi-label {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  opacity: 0.95;
}
.kpi-period {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dashboard-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.tile {
  display: block;
  padding: 1.25rem 1.4rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.tile[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.tile[aria-disabled="true"]:hover {
  border-color: var(--border);
  transform: none;
}

.tile h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.tile p { margin: 0; font-size: 0.9rem; }

/* -------------------------------------------------------------------------
   Collapsible diagnostics panel
   ------------------------------------------------------------------------- */

.diagnostics {
  margin-top: 3rem;
  padding: 0.8rem 1rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.diagnostics > summary {
  cursor: pointer;
  font-size: 0.85rem;
  outline: none;
}

.diagnostics[open] > summary {
  margin-bottom: 0.75rem;
}

/* -------------------------------------------------------------------------
   List pages: header bar, filter bar, data table
   ------------------------------------------------------------------------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-header h1 { margin: 0; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}

.filter-bar .input { flex: 1; max-width: 28rem; }

/* -------------------------------------------------------------------------
   Data tables — used by every list page (assets, deals, clients,
   suppliers, AR globals, admin lists). Designed to handle long-text
   columns gracefully without horizontally clipping the rest of the
   table off the screen.
   ------------------------------------------------------------------------- */

/* The table itself — clean, zebra-striped, with a sticky header so
   column names stay visible when scrolling long lists. */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  /* `display: block` would let us overflow horizontally but breaks
     column widths; instead we wrap the table in `.table-wrap` (added
     via the CSS below using a wrapping ::before/::after pattern is
     not possible — so list templates that need horizontal scroll
     wrap their table in a div.table-wrap manually). */
}

.data-table th,
.data-table td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.4;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f4f5f8;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid #d8dde2;
}

/* Zebra stripes — very subtle, just enough to help the eye track
   across wide rows. */
.data-table tbody tr:nth-child(odd)  { background: #fff; }
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:hover           { background: #eef6fb; }

/* Sortable column headers — anchor styled to read as a header label,
   with a small ▲/▼ indicator when active and a low-contrast ↕ on
   idle columns so users can see they're clickable. */
.data-table.sortable thead th a.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.data-table.sortable thead th a.sort-link:hover {
  color: #1f6feb;
}
.data-table.sortable .sort-indicator {
  font-size: 0.7rem;
  line-height: 1;
}
.data-table.sortable .sort-indicator--idle {
  opacity: 0.25;
}
.data-table.sortable thead th a.sort-link:hover .sort-indicator--idle {
  opacity: 0.6;
}

/* Long-text cells — clamp to a max width and ellipsis-truncate. The
   full text shows on hover via the browser's title attribute (which
   the templates set for these fields). */
.data-table td.cell-truncate {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table td.cell-multiline {
  max-width: 380px;
  word-break: break-word;
}

/* Wrap container — gives any table that's wider than its parent a
   clean horizontal scrollbar instead of clipping the right edge. The
   `data-table` automatically rounds its corners, so the wrapper
   matches. */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.table-wrap .data-table {
  /* Inside a wrap, the table can be wider than the visible area. */
  border-radius: 0;
  border: none;
}

.actions-col { white-space: nowrap; width: 1%; text-align: right; }
.actions-col a { margin-right: 0.6rem; }
.actions-col a:last-child { margin-right: 0; }

.btn-link.danger { color: var(--error-fg); }
.btn-link.danger:hover { text-decoration: underline; }

/* -------------------------------------------------------------------------
   Two-column form grid (used by client new/edit forms)
   ------------------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
}

.form-grid .form-field { margin-bottom: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------------
   Danger zone (destructive actions on edit pages)
   ------------------------------------------------------------------------- */

.danger-zone {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--error-fg);
}

/* -------------------------------------------------------------------------
   Numeric / monospace cells (book values, costs, etc.)
   ------------------------------------------------------------------------- */

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* -------------------------------------------------------------------------
   Badges (status indicators in tables / detail pages)
   ------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}

.badge-active   { background: #e0efe4; color: #1e6b32; }
.badge-paused   { background: #fff4d6; color: #855700; }
.badge-closed   { background: #ecedef; color: #555858; }
.badge-muted    { background: #eef1f6; color: #6b6b6b; font-style: italic; }

/* Statement-row match-status badges (Phase B — reconciliation) */
.badge-unprocessed   { background: #eef1f6; color: #6b7280; }
.badge-auto_matched  { background: #dbeafe; color: #1e40af; }
.badge-ambiguous     { background: #fef3c7; color: #92400e; }
.badge-unmatched     { background: #fde2e2; color: #9b1c1c; }
.badge-ignored       { background: #ecedef; color: #6b7280; font-style: italic; }
.badge-confirmed     { background: #e0efe4; color: #1e6b32; }

/* Compact input variant — used inside tight per-row classification forms */
.input-sm { font-size: 0.85em; padding: 0.2rem 0.4rem; }

/* AR aging summary cards (Phase D) */
.aging-cards {
  display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.aging-card {
  display: block;
  text-decoration: none; color: inherit;
  flex: 1; min-width: 8.5rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid #e5e7eb; border-radius: 0.5rem;
  background: #fff;
  transition: border-color 0.1s ease;
}
.aging-card:hover { border-color: #94a3b8; }
.aging-card.is-active { border-color: #1f6feb; background: #f0f7ff; }
.aging-card-label { font-size: 0.85em; color: var(--muted); }
.aging-card-amount { font-weight: 700; margin: 0.15rem 0; }
.aging-card-count { font-size: 0.8em; color: var(--muted); }

/* Sidebar "needs attention" count badge */
.sidebar-count {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 9999px;
  background: #fde2e2;
  color: #9b1c1c;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}
.sidebar-count:hover { background: #fbd0d0; }

/* Client banking-quality panel on the edit page */
.banking-issues {
  background: #fff4d6;
  border: 1px solid #f0c674;
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0 1.25rem;
}
.banking-issues h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.banking-issues ul { padding-left: 1.25rem; }

/* Client banking-quality badges (data-quality surface) */
.badge-banking-ready    { background: #e0efe4; color: #1e6b32; }
.badge-banking-warnings { background: #fff4d6; color: #855700; }
.badge-banking-missing  { background: #fde2e2; color: #9b1c1c; }
.badge-banking-na       { background: #ecedef; color: #6b7280; font-style: italic; }

/* Mandate lifecycle badges (Phase E) */
.badge-mandate-active     { background: #e0efe4; color: #1e6b32; }
.badge-mandate-suspended  { background: #fff4d6; color: #855700; }
.badge-mandate-cancelled  { background: #ecedef; color: #555858; }

/* Aging badges — gradient red-er the further out */
.badge-aging-Current      { background: #e0efe4; color: #1e6b32; }
.badge-aging-1_30         { background: #fff4d6; color: #855700; }
.badge-aging-31_60        { background: #ffe2c2; color: #8a3b00; }
.badge-aging-61_90        { background: #ffd1d1; color: #8b1f1f; }
.badge-aging-90plus       { background: #fde2e2; color: #9b1c1c; font-weight: 700; }
.badge-aging-Uncategorised{ background: #ecedef; color: #555858; }

/* Compact card used for forms and per-row attribution UI */
.form-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1rem;
}
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

/* Collection-batch lifecycle badges (Phase A — payment automation) */
.badge-draft      { background: #eef1f6; color: #4b5563; }
.badge-submitted  { background: #dbeafe; color: #1e40af; }
.badge-reconciled { background: #e0efe4; color: #1e6b32; }
.badge-pending    { background: #fff4d6; color: #855700; }
.badge-success    { background: #e0efe4; color: #1e6b32; }
.badge-failed     { background: #fde2e2; color: #9b1c1c; }
.badge-disputed   { background: #fde2e2; color: #9b1c1c; }
.badge-withdrawn  { background: #ecedef; color: #6b7280; font-style: italic; }

/* Used on withdrawn-item rows — visually de-emphasise */
.row-muted { opacity: 0.55; }

/* Inline group of buttons in page headers / action bars */
.btn-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* Key/value definition list (used on batch detail header block) */
.kv-list {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0;
}
.kv-list dt { color: var(--muted); font-weight: 500; }
.kv-list dd { margin: 0; }

/* -------------------------------------------------------------------------
   Detail grid (read-only "view" pages — assets, deals, etc.)
   ------------------------------------------------------------------------- */

.detail-grid {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.5rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--card-bg);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.detail-grid dt {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: start;
  padding-top: 0.15rem;
}

.detail-grid dd {
  margin: 0;
}

.detail-grid pre.notes {
  background: #f4f5f8;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.92rem;
  margin: 0;
}

@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; gap: 0.2rem 0; }
  .detail-grid dt { margin-top: 0.7rem; }
}

/* -------------------------------------------------------------------------
   Status pills (deal status filter row)
   ------------------------------------------------------------------------- */

.status-pills {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.pill {
  padding: 0.3rem 0.85rem;
  border-radius: 9999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pill:hover { border-color: var(--accent); color: var(--accent); }

.pill-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pill-on:hover { color: #fff; filter: brightness(0.95); }

/* -------------------------------------------------------------------------
   Schedule preview table
   ------------------------------------------------------------------------- */

.schedule-preview { margin-top: 2.5rem; }

.schedule-preview h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.schedule-table {
  font-size: 0.88rem;
}

.schedule-table tbody tr.row-kind-actual { background: #f3f9f4; }
.schedule-table tbody tr.row-kind-actual:hover { background: #ebf5ed; }

.schedule-table tbody tr.row-kind-tranche { background: #fff8e1; }
.schedule-table tbody tr.row-kind-planned { background: #fdf6e3; }

/* -------------------------------------------------------------------------
   Lifecycle action button row + first-time pause explainer
   ------------------------------------------------------------------------- */

.lifecycle-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.lifecycle-actions form.inline { margin: 0; }

.explainer-card {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.25rem;
  background: #fffbe6;
  border: 1px solid #f5d97e;
  border-left: 4px solid #d8a407;
  border-radius: 6px;
}

.explainer-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #855700;
}

.explainer-card p { margin: 0.25rem 0; }
