/* Solon Clients page styles · v1.4.2 — Phase 8: .stat-dual-incl secondary
   KPI figure for "Incl. intercompany" total. Scoped via :not([hidden])
   per Locked Decision #14.
   v1.4.1 — Flag tooltip + 7-day SLA timer.
   Adds .flag-tooltip (hover card over the stage pill: stage, set-by, set-on,
   days-remaining or elapsed warning) and the name-capture view inside the
   existing .flag-dropdown chrome (.flag-name-label / -input / -confirm-btn).
   No new colour literals — surfaces resolved through theme tokens; the
   elapsed-timer line uses the same red palette as the FD pill (#EF4444)
   so the warning rhymes visually with the existing escalation tints.
   v1.4.0 — Phase 6: Account Manager Config.
   Adds .acct-mgr-pill (KAM/KAO neutral pills), filter dropdown chip + panel,
   Manage account managers toolbar button, import modal shell + six states,
   fuzzy-review rows. All togglable elements scoped via :not([hidden])
   per Locked Decision #14. No new colour literals — all surfaces resolved
   through existing theme tokens (D-01).
   v1.3.2 — Filter-chip redesign of the
   "Hide zero outstanding" / "Hide zero overdue" toggles. Outlined pill
   when off, brand-filled with checkmark when on. CSS-only change via
   :has(input:checked); existing change-event JS wiring untouched.
   v1.3.1 — Flag column hardening (v1.4.1):
   focus-visible ring on Stage cells and dropdown items for keyboard users;
   transient toast (.flag-toast) for save failures.
   v1.3.0 — v1.4.0 flag column: Stage pill badges,
   row tints (data-flag-stage attribute), and flag dropdown. Colours defined per
   agreed palette (AM=#F59E0B … Legal=#7F1D1D). Light/dark safe via low-opacity
   tints; :not(.row-detail) guard keeps drill-down rows neutral.
   v1.2.2 — POL-01 theme-parity sweep:
   replace the hardcoded info-banner blue (hex + rgba) with var(--primary) /
   rgba(var(--primary-rgb), *) so the banner picks up the active brand
   accent. No new tokens introduced.
   v1.2.1 — Phase 5 receipt visibility: .unalloc-flag, .receipt-row,
   .receipt-section-header. Theme-token colours only; preserves
   [hidden]:not() discipline (Locked Decision #14). */

/* 1) Sort indicator + sortable header */
#clients-table thead th[data-sort-direction="asc"]::after  { content: ' \25B2'; color: var(--primary); }
#clients-table thead th[data-sort-direction="desc"]::after { content: ' \25BC'; color: var(--primary); }
#clients-table thead th[data-sort-key]        { cursor: pointer; user-select: none; }
#clients-table thead th[data-sort-key]:hover  { color: var(--primary); }

/* 2) Table layout, sticky header, cells */
#clients-table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
    max-height: calc(100vh - 240px);
}
#clients-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
}
#clients-table thead th {
    position: sticky; top: 0; z-index: 10;
    background: var(--card-bg);
    padding: 8px 16px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
}
#clients-table thead th.numeric { text-align: right; }
#clients-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
#clients-table tbody td.numeric {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}
#clients-table tbody tr {
    cursor: pointer;
    transition: background-color 120ms;
}
#clients-table tbody tr:hover { background: rgba(255,255,255,0.03); }
[data-theme="light"] #clients-table tbody tr:hover { background: rgba(0,0,0,0.03); }

/* 3) Drill-down accordion */
.drill-chevron {
    display: inline-block;
    font-size: 0.7em;
    color: var(--text-dim);
    margin-right: 0.4rem;
    transition: transform 120ms;
}
tr[aria-expanded="true"] .drill-chevron { color: var(--primary); }
#clients-table tr.row-detail > td {
    padding: 0;
    background: rgba(var(--primary-rgb), 0.04);
    border-left: 3px solid var(--primary);
}
#clients-table tr.row-detail .drill-table { width: 100%; border-collapse: collapse; }
#clients-table tr.row-detail .drill-table th,
#clients-table tr.row-detail .drill-table td {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}
#clients-table tr.row-detail .drill-table th {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
}
#clients-table tr.row-detail .drill-table td.numeric {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}
.overdue-positive { color: var(--danger); font-weight: 700; }
.overdue-zero     { color: var(--text-muted); }
.drill-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 16px !important;
}

/* 4) Spinner */
#clients-loading:not([hidden]) {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 2rem;
    text-align: center;
}
.spinner-ring {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: clients-spin 0.75s linear infinite;
}
@keyframes clients-spin { to { transform: rotate(360deg); } }
.spinner-progress { color: var(--text-muted); font-size: 0.875rem; }
.spinner-sub      { color: var(--text-dim);   font-size: 0.875rem; }

/* 5) Empty state */
#clients-empty:not([hidden]) {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    max-width: 480px;
    margin: 2rem auto;
}
#clients-empty h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
#clients-empty p     { color: var(--text-secondary); margin: 0; font-size: 0.875rem; }
#clients-empty p.sub { color: var(--text-muted); }

/* 6) Fetch-failed banner */
.info-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.info-banner-icon { color: var(--primary); flex-shrink: 0; }

/* 7) Coverage indicator + popover */
.coverage-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.coverage-info-btn {
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text-dim);
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}
.coverage-info-btn:hover { color: var(--text-muted); }
.coverage-popover-wrap   { position: relative; display: inline-block; }
.coverage-popover {
    position: absolute;
    top: 100%; left: 0;
    z-index: 100;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    max-width: 320px;
    min-width: 240px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.coverage-popover h4 {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0.5rem 0 0.25rem;
}
.coverage-popover ul {
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: 'JetBrains Mono', monospace;
}
.coverage-popover li { padding: 2px 0; }

/* 8) Footnote */
.footnote {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.75rem 0 0;
}

/* 9) Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .spinner-ring                 { animation: none; border-top-color: var(--primary); }
    #clients-table tbody tr       { transition: none; }
    .drill-chevron                { transition: none; }
    .flag-stage-pill              { transition: none; }
}

/* 14) v1.4.0 — Client flags: escalation stage column, pills, row tints, dropdown */

/* Stage column header */
.flag-stage-col {
    width: 72px;
    min-width: 72px;
}

/* Stage cell */
.flag-stage-cell {
    width: 72px;
    min-width: 72px;
    white-space: nowrap;
}
.flag-stage-cell:focus { outline: none; }
.flag-stage-cell:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-radius: 6px;
}

/* Stage pill badge */
.flag-stage-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    transition: opacity 120ms;
}
.flag-stage-pill:hover              { opacity: 0.82; }
.flag-stage-pill--none              { color: var(--text-dim); background: transparent; letter-spacing: 0; font-weight: 400; }
.flag-stage-pill--am                { background: #F59E0B; color: #fff; }
.flag-stage-pill--md                { background: #F97316; color: #fff; }
.flag-stage-pill--fd                { background: #EF4444; color: #fff; }
.flag-stage-pill--ceo               { background: #DC2626; color: #fff; }
.flag-stage-pill--legal             { background: #7F1D1D; color: #fff; }

/* Row tints — base and hover. :not(.row-detail) keeps the drill-down row neutral. */
#clients-table tbody tr[data-flag-stage="AM"]:not(.row-detail)    { background-color: rgba(245,158,11,0.10); }
#clients-table tbody tr[data-flag-stage="MD"]:not(.row-detail)    { background-color: rgba(249,115,22,0.10); }
#clients-table tbody tr[data-flag-stage="FD"]:not(.row-detail)    { background-color: rgba(239,68,68,0.10); }
#clients-table tbody tr[data-flag-stage="CEO"]:not(.row-detail)   { background-color: rgba(220,38,38,0.12); }
#clients-table tbody tr[data-flag-stage="Legal"]:not(.row-detail) { background-color: rgba(127,29,29,0.12); }

#clients-table tbody tr[data-flag-stage="AM"]:hover               { background-color: rgba(245,158,11,0.18); }
#clients-table tbody tr[data-flag-stage="MD"]:hover               { background-color: rgba(249,115,22,0.18); }
#clients-table tbody tr[data-flag-stage="FD"]:hover               { background-color: rgba(239,68,68,0.18); }
#clients-table tbody tr[data-flag-stage="CEO"]:hover              { background-color: rgba(220,38,38,0.20); }
#clients-table tbody tr[data-flag-stage="Legal"]:hover            { background-color: rgba(127,29,29,0.20); }

/* Flag dropdown — appended to document.body, position:fixed set by JS */
.flag-dropdown {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    min-width: 136px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    font-family: 'DM Sans', sans-serif;
}
.flag-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
}
.flag-dropdown-item:hover             { background: rgba(var(--primary-rgb), 0.10); }
.flag-dropdown-item.flag-dropdown-active { font-weight: 700; }
.flag-dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.flag-dropdown-clear { color: var(--text-muted); }

/* Colour dots inside dropdown items */
.flag-dropdown-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.flag-dropdown-dot--am    { background: #F59E0B; }
.flag-dropdown-dot--md    { background: #F97316; }
.flag-dropdown-dot--fd    { background: #EF4444; }
.flag-dropdown-dot--ceo   { background: #DC2626; }
.flag-dropdown-dot--legal { background: #7F1D1D; }

/* Dropdown item keyboard focus ring */
.flag-dropdown-item:focus { outline: none; }
.flag-dropdown-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* v1.4.1 — Transient toast for flag save failures */
.flag-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid #DC2626;
    border-left: 4px solid #DC2626;
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-width: 360px;
    transition: opacity 300ms ease;
}
.flag-toast--fade { opacity: 0; }

/* v1.4.1 — Flag hover tooltip (stage pill only).
   Built fresh per mouseenter, appended to body, position:fixed by JS so it
   escapes the table wrapper's overflow:auto. z-index sits above the flag
   dropdown (200) so a tooltip can survive over an anchor cell. */
.flag-tooltip {
    position: fixed;
    z-index: 250;
    min-width: 200px;
    max-width: 280px;
    padding: 10px 12px;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.28);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8125rem;
    line-height: 1.35;
    pointer-events: none;  /* never steals hover from the pill */
}
.flag-tooltip-stage {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    margin-bottom: 6px;
}
.flag-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
}
.flag-tooltip-row > span:last-child {
    color: var(--text);
    font-weight: 500;
}
.flag-tooltip-timer {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
}
.flag-tooltip-timer--elapsed {
    color: #EF4444;  /* mirrors .flag-stage-pill--fd; intentional warning red */
}

/* v1.4.1 — Name-capture view inside the .flag-dropdown.
   When a stage option is clicked, the dropdown rewrites itself into a small
   "Confirm — Your name" form so each escalation step records who progressed
   it. Reuses .flag-dropdown chrome (background, border, shadow). */
.flag-name-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 4px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text);
}
.flag-name-input {
    display: block;
    width: calc(100% - 24px);
    margin: 4px 12px;
    padding: 6px 8px;
    background: var(--input-bg, var(--card-bg));
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
}
.flag-name-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25);
}
.flag-name-confirm-btn {
    display: block;
    width: calc(100% - 24px);
    margin: 6px 12px 8px;
    padding: 6px 10px;
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: opacity 120ms;
}
.flag-name-confirm-btn:hover:not(:disabled) { opacity: 0.9; }
.flag-name-confirm-btn:disabled              { opacity: 0.45; cursor: not-allowed; }
.flag-name-confirm-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* 10) Phase 2 — Toolbar (search left, hide-zero toggle right) */
#clients-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1rem;
}
.clients-toolbar-search {
    position: relative;
    flex: 1 1 240px;
    max-width: 360px;
    display: flex;
    align-items: center;
}
.clients-toolbar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}
#clients-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    line-height: 1.25;
}
#clients-search::placeholder { color: var(--text-dim); }
#clients-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
.clients-toolbar-toggles {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
/* Filter chips — outlined when off, brand-filled with checkmark when on.
   Uses :has(input:checked) so the existing change-event wiring is preserved. */
.clients-toolbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 6px 14px;
    /* v1.4.0 (Phase 6 redesign): brighter outline so the chip reads as
       interactive against the page background instead of disappearing. */
    border: 1px solid var(--text-muted);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.clients-toolbar-toggle:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--text);
}
/* Visually hide the native input but keep it focusable / form-submittable */
.clients-toolbar-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}
/* Active state — brand-filled */
.clients-toolbar-toggle:has(input:checked) {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.clients-toolbar-toggle:has(input:checked):hover {
    filter: brightness(1.08);
}
/* Checkmark only appears in the active state */
.clients-toolbar-toggle:has(input:checked)::before {
    content: '✓';
    display: inline-block;
    font-weight: 700;
    line-height: 1;
    font-size: 0.875rem;
}
/* Keyboard focus ring — anchored on the parent chip via :focus-within */
.clients-toolbar-toggle:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .clients-toolbar-toggle { transition: none; }
}

/* Phase 8 — secondary "Incl. intercompany" figure in KPI cards.
   Locked Decision #14: :not([hidden]) scoping required because the span
   is hidden via the [hidden] attribute when the intercompany toggle is OFF. */
.stat-dual-incl:not([hidden]) {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: -0.01em;
}

/* 11) Phase 2 — KPI summary strip (reuses .stat-card / .stat-label / .stat-value from dashboard.css) */
#clients-kpi-strip { margin: 0 0 1.5rem; }
.clients-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* 12) Phase 2 — Empty-search row inside the table */
.clients-empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 16px !important;
    font-style: italic;
}

/* 13) Phase 5 — Receipt visibility (v1.2.1).
   Outstanding cell ⓘ flag rendered when unallocatedAmount > 0.01.
   Allocated receipts indent under their parent invoice in the drill-down;
   unallocated receipts collect under a labelled section header. */
.unalloc-flag {
    display: inline-block;
    margin-left: 0.35rem;
    color: var(--text-muted);
    cursor: help;
    font-size: 0.875em;
    line-height: 1;
}
.unalloc-flag:hover { color: var(--text); }

#clients-table tr.row-detail .drill-table tr.receipt-row:not([hidden]) {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8125rem;
}
#clients-table tr.row-detail .drill-table tr.receipt-row td {
    border-bottom: 1px dashed var(--border);
}
#clients-table tr.row-detail .drill-table tr.receipt-row td.receipt-ref {
    padding-left: 32px;
}
#clients-table tr.row-detail .drill-table tr.receipt-unallocated td.receipt-ref {
    padding-left: 16px;
    font-style: normal;
}
#clients-table tr.row-detail .drill-table tr.receipt-unallocated {
    color: var(--text-secondary);
    font-style: normal;
}

#clients-table tr.row-detail .drill-table tr.receipt-section-header:not([hidden]) {
    background: rgba(var(--primary-rgb), 0.06);
}
#clients-table tr.row-detail .drill-table tr.receipt-section-header td {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding-top: 12px;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   Phase 6 — Account Manager Config (AMC-01, AMC-05, AMC-10..12)
   All togglable elements scoped via :not([hidden]) per Locked
   Decision #14. No new colour literals — only existing theme
   tokens + a single rgba(0,0,0,...) modal backdrop.
   ============================================================ */

/* Retroactive Locked Decision #14 fixes for pre-existing rules that
   set display: flex without a :not([hidden]) guard. Without these,
   the elements render as zero-content flex containers (banner shows
   as an empty 18px pill, toolbar takes flex height even when hidden). */
.info-banner[hidden],
.coverage-indicator[hidden],
#clients-toolbar[hidden] { display: none !important; }

/* Clients page now has 12 columns (Phase 6 added Account Manager + Account
   Owner). The shared .container max-width of 1440px is too narrow — the
   rightmost columns get clipped behind a horizontal scrollbar. Widen the
   container ONLY on pages that mount the clients table so other pages
   (Dashboard, Report Generator) keep their narrower layout. */
body:has(#clients-table-wrap) .container {
    max-width: 1760px;
}

/* ---------- KAM/KAO neutral pills (D-01: existing tokens only) ---------- */
.acct-mgr-pill {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    margin: 0 0.18rem 0.18rem 0;
    border-radius: 999px;
    background: var(--border);
    color: var(--text);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}
.acct-mgr-pill-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ---------- "Manage account managers" toolbar button — primary CTA ---------- */
.acct-mgr-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 6px 14px;
    border: 1px solid var(--primary);
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, filter 150ms ease;
}
.acct-mgr-toolbar-btn:hover {
    background: var(--primary-dark, var(--primary));
    border-color: var(--primary-dark, var(--primary));
    filter: brightness(1.05);
}
.acct-mgr-toolbar-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- KAM/KAO filter dropdown trigger + panel ---------- */
.acct-mgr-filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;     /* centre label + count inside the chip */
    gap: 0.4rem;
    padding: 6px 14px;
    border: 1px solid var(--text-muted);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.acct-mgr-filter-chip-label { display: inline-block; }
.acct-mgr-filter-chip:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
}
.acct-mgr-filter-chip:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.acct-mgr-filter-chip--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.acct-mgr-filter-chip--active:hover {
    filter: brightness(1.08);
    background: var(--primary);
}
.acct-mgr-filter-chip-count {
    display: inline-flex;
    min-width: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    justify-content: center;
}
/* When the count badge has no text (no filter selections), collapse it so
   the label is truly centred in the chip rather than offset by the badge's
   reserved min-width + gap. */
.acct-mgr-filter-chip-count:empty { display: none; }
/* When the chip is in its outlined (inactive) state, the count badge needs
   its own visible fill instead of inheriting the chip's transparent bg. */
.acct-mgr-filter-chip:not(.acct-mgr-filter-chip--active) .acct-mgr-filter-chip-count:not(:empty) {
    background: rgba(var(--primary-rgb), 0.18);
    color: var(--text);
}

.acct-mgr-filter-panel[hidden] { display: none; }
.acct-mgr-filter-panel:not([hidden]) {
    display: block;
    position: fixed;
    z-index: 1000;
    min-width: 180px;
    max-width: 280px;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.4rem 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.acct-mgr-filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
}
.acct-mgr-filter-option:hover { background: var(--border); }

/* ---------- Modal shell ([hidden]:not() per Locked Decision #14) ---------- */
.clients-modal[hidden] { display: none; }
.clients-modal:not([hidden]) {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.clients-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}
.clients-modal-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 32px);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    box-shadow: 0 24px 48px rgba(0,0,0,0.45);
    overflow: hidden;     /* let the scrollable body handle overflow */
}
.clients-modal-header {
    flex: none;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem 1.75rem 0.75rem 1.75rem;
}
.clients-modal-header-text {
    flex: 1 1 auto;
    min-width: 0;
}
.clients-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}
.clients-modal-subtitle {
    margin: 0.25rem 0 0 0;
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.45;
}
.clients-modal-close {
    flex: none;
    width: 32px;
    height: 32px;
    margin: -4px -4px 0 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}
.clients-modal-close:hover { background: var(--border); color: var(--text); }

.clients-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 1.75rem 1rem 1.75rem;
}

.clients-modal-footer {
    flex: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.75rem 1.25rem 1.75rem;
    border-top: 1px solid var(--border);
}
.clients-modal-footer-meta {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}
.clients-modal-footer-actions {
    flex: none;
    display: flex;
    gap: 0.5rem;
}

/* ---------- Modal state subtrees (data-state on root + [hidden] on each) ---------- */
.clients-modal-state[hidden] { display: none; }
.clients-modal-state:not([hidden]) { display: block; }

/* ---------- Dropzone (idle state) ---------- */
.acct-mgr-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin: 0.25rem 0 0 0;
    min-height: 160px;
    padding: 1.5rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: transparent;
    text-align: center;
    color: var(--text);
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.acct-mgr-dropzone:hover,
.acct-mgr-dropzone:focus-within {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.06);
}
.acct-mgr-dropzone.is-dragover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.12);
}
.acct-mgr-dropzone-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}
.acct-mgr-dropzone-primary {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.acct-mgr-dropzone-secondary {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ---------- Diff counts + fuzzy review (diff-preview state) ---------- */
.acct-mgr-diff-counts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin: 0 0 1.25rem 0;
}
.acct-mgr-diff-count {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.75rem;
    background: rgba(var(--primary-rgb), 0.08);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.acct-mgr-diff-count-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.acct-mgr-diff-count-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}
.acct-mgr-section-heading {
    margin: 0.5rem 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}
.acct-mgr-section-help {
    margin: 0 0 0.5rem 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
}
.acct-mgr-fuzzy-list {
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}
.acct-mgr-fuzzy-empty {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}
.acct-mgr-fuzzy-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    color: var(--text);
}
.acct-mgr-fuzzy-row + .acct-mgr-fuzzy-row { border-top: 1px solid var(--border); }
.acct-mgr-fuzzy-row-csv { font-weight: 600; }
.acct-mgr-fuzzy-row-arrow { color: var(--text-muted); }
.acct-mgr-fuzzy-row-candidate { color: var(--text-secondary); }
.acct-mgr-fuzzy-row-score {
    margin-left: auto;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

/* ---------- Done / Error state body styling ---------- */
.acct-mgr-state-message {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0;
    font-size: 0.9375rem;
    color: var(--text);
}
.acct-mgr-state-message--error {
    color: var(--text);
}
.acct-mgr-state-message--error .acct-mgr-state-icon { color: var(--danger, #EF4444); }
.acct-mgr-state-icon { flex: none; width: 20px; height: 20px; }

/* ---------- Modal buttons (Confirm/Cancel/Retry/Close) ---------- */
.clients-modal-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}
.clients-modal-btn:hover { background: var(--border); }
.clients-modal-btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.clients-modal-btn--primary:hover {
    background: var(--primary-dark, var(--primary));
    border-color: var(--primary-dark, var(--primary));
}
.clients-modal-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Parsing / Confirming spinners ---------- */
.acct-mgr-spinner {
    display: inline-block;
    width: 1rem; height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: acct-mgr-spin 0.8s linear infinite;
    vertical-align: middle;
}
@keyframes acct-mgr-spin { to { transform: rotate(360deg); } }
