/* =============================================================================
   WFM — Deepmalay Wealth Management
   Production design system. Written 2026-05 (Phase 9 polish pass).

   Design intent:
     Trust register for an Indian wealth-management firm — refined light surface,
     deep navy primary, restrained heritage-gold accent. Density informed by
     Stripe / Carta / Linear; status semantics from Material 3; type from Inter.

   Scope:
     Preserves every wfm-* class used by .razor markup so no template changes
     are required. Variables drive every component — re-skinning is a token edit.
============================================================================= */

/* =============================================================================
   1.  Design tokens
============================================================================= */
:root {
    /* — Surfaces ---------------------------------------------------------- */
    --wfm-surface-page:        #F7F8FA;   /* page background — barely-tinted */
    --wfm-surface-card:        #FFFFFF;   /* primary card / table surface    */
    --wfm-surface-sunken:      #F1F3F6;   /* inputs, table headers, code     */
    --wfm-surface-overlay:     rgba(11, 17, 32, 0.55);

    /* — Ink / text. Calibrated for WCAG AA on the page surface (#F7F8FA).
         #5B6478 → 6.6 : 1   AA pass for normal text
         #64748B → 5.2 : 1   AA pass — used for tertiary so dashes / placeholders
                              still meet the 4.5 : 1 minimum on older monitors. */
    --wfm-ink:                 #0B1120;   /* primary text — deep ink         */
    --wfm-ink-soft:            #1F2937;   /* body, table cells               */
    --wfm-ink-muted:           #5B6478;   /* secondary, captions             */
    --wfm-ink-faint:           #64748B;   /* tertiary, placeholders, dashes  */
    --wfm-ink-on-brand:        #FFFFFF;
    --wfm-ink-on-accent:       #2A1E04;

    /* — Hairlines / dividers --------------------------------------------- */
    --wfm-line:                #E4E7EC;   /* default border                  */
    --wfm-line-strong:         #CBD2DC;   /* emphasised border, dividers     */
    --wfm-line-soft:           #EEF1F4;

    /* — Brand: deep navy. Primary actions, headers, links. --------------- */
    --wfm-brand-50:            #EEF2F7;
    --wfm-brand-100:           #D7E0EC;
    --wfm-brand-200:           #A7B6CD;
    --wfm-brand-500:           #284772;
    --wfm-brand-600:           #1F385C;   /* default brand                   */
    --wfm-brand-700:           #15294A;
    --wfm-brand-800:           #0F1F38;

    /* — Accent: heritage gold (restrained). Use sparingly; never as bg fill
         for body text. Reserved for brand mark + deliberate emphasis only. */
    --wfm-accent-50:           #FBF6E9;
    --wfm-accent-200:           #E8D49A;
    --wfm-accent-500:           #B58A28;
    --wfm-accent-600:           #957012;   /* default accent                  */

    /* — Status — calibrated for AA contrast on tint bg ------------------- */
    --wfm-success-50:          #ECFDF5;
    --wfm-success-200:         #A7F3D0;
    --wfm-success-600:         #047857;
    --wfm-success-700:         #065F46;

    --wfm-warning-50:          #FFFBEB;
    --wfm-warning-200:         #FCD34D;
    --wfm-warning-600:         #B45309;
    --wfm-warning-700:         #92400E;

    --wfm-danger-50:           #FEF2F2;
    --wfm-danger-200:          #FCA5A5;
    --wfm-danger-600:          #B91C1C;
    --wfm-danger-700:          #991B1B;

    --wfm-info-50:             #EFF6FF;
    --wfm-info-200:            #BFDBFE;
    --wfm-info-600:            #1D4ED8;
    --wfm-info-700:            #1E40AF;

    /* — Spacing scale (8-px base) ---------------------------------------- */
    --wfm-space-1:             4px;
    --wfm-space-2:             8px;
    --wfm-space-3:             12px;
    --wfm-space-4:             16px;
    --wfm-space-5:             24px;
    --wfm-space-6:             32px;
    --wfm-space-7:             48px;
    --wfm-space-8:             64px;

    /* — Radius ------------------------------------------------------------ */
    --wfm-radius-xs:           4px;
    --wfm-radius-sm:           6px;
    --wfm-radius-md:           8px;
    --wfm-radius-lg:           12px;
    --wfm-radius-pill:         999px;

    /* — Shadow (close-to-surface, never glow) ---------------------------- */
    --wfm-shadow-xs:           0 1px 1px rgba(15,23,42,0.04),
                               0 1px 2px rgba(15,23,42,0.04);
    --wfm-shadow-sm:           0 1px 2px rgba(15,23,42,0.04),
                               0 2px 6px rgba(15,23,42,0.05);
    --wfm-shadow-md:           0 4px 8px rgba(15,23,42,0.05),
                               0 8px 24px rgba(15,23,42,0.06);
    --wfm-shadow-focus:        0 0 0 3px rgba(31, 56, 92, 0.18);

    /* — Type -------------------------------------------------------------- */
    --wfm-font-sans:           "Inter", -apple-system, BlinkMacSystemFont,
                               "Segoe UI", system-ui, "Helvetica Neue",
                               Arial, sans-serif;
    --wfm-font-mono:           "JetBrains Mono", "SF Mono", Menlo, Consolas,
                               "Liberation Mono", monospace;

    /* — Motion ------------------------------------------------------------ */
    --wfm-motion-fast:         140ms cubic-bezier(0.2, 0.0, 0.0, 1.0);
    --wfm-motion-medium:       220ms cubic-bezier(0.2, 0.0, 0.0, 1.0);

    /* — Z-index scale ----------------------------------------------------- */
    --wfm-z-topbar:            50;
    --wfm-z-modal:             1000;
    --wfm-z-toast:             1100;
}

/* =============================================================================
   2.  Reset & base
============================================================================= */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--wfm-font-sans);
    font-size: 0.9375rem;          /* 15 px — denser than 16, comfortable    */
    line-height: 1.5;
    color: var(--wfm-ink-soft);
    background: var(--wfm-surface-page);
    /* Block rogue horizontal scroll on the document. Tables that legitimately overflow the
       viewport scroll inside their own .wfm-table-scroll wrapper, which keeps sticky thead
       behaviour intact. Anything else hitting the document scrollbar is a layout bug. */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11" 1, "ss01" 1;   /* Inter stylistic refinements */
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--wfm-space-3);
    color: var(--wfm-ink);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
/* Page-rhythm contract:
     • h1 → its description-paragraph: tight pair (4 px) so the title block reads as one unit.
     • description → next section: 24 px so toolbar/grid feels like a separate region.
     • h2 (section heading): 24 px above, 12 px below — gives breathing room from the
       preceding card without floating away from its own card. */
h1 { font-size: 1.5rem;   letter-spacing: -0.02em; margin: var(--wfm-space-2) 0 var(--wfm-space-1); }
h2 { font-size: 1.125rem; margin: var(--wfm-space-5) 0 var(--wfm-space-3); }
h3 { font-size: 1rem; }
p  { margin: 0 0 var(--wfm-space-3); }
/* The description paragraph immediately following h1 owns the title-block spacing. */
h1 + p, h1 + p.wfm-muted { margin: 0 0 var(--wfm-space-5); }

/* Blazor's enhanced-nav focuses the page heading on every route change for screen-reader
   continuity. We don't want the resulting outline to render visually — it's not a keyboard
   focus, just a programmatic landmark shift. Suppress for headings only; interactive
   elements still get their proper :focus-visible ring elsewhere. */
h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus { outline: none; }

a {
    color: var(--wfm-brand-600);
    text-decoration: none;
    transition: color var(--wfm-motion-fast);
}
a:hover    { color: var(--wfm-brand-700); text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible {
    outline: none;
    box-shadow: var(--wfm-shadow-focus);
    border-radius: var(--wfm-radius-xs);
}

code {
    font-family: var(--wfm-font-mono);
    font-size: 0.875em;
    background: var(--wfm-surface-sunken);
    color: var(--wfm-ink);
    padding: 0.05rem 0.35rem;
    border-radius: var(--wfm-radius-xs);
}

hr {
    border: 0;
    border-top: 1px solid var(--wfm-line);
    margin: var(--wfm-space-5) 0;
}

::selection { background: rgba(31, 56, 92, 0.18); color: var(--wfm-ink); }

/* =============================================================================
   3.  Layout shell
============================================================================= */
.wfm-shell, .wfm-public {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;            /* mobile-safe — accounts for url bar     */
}

.wfm-topbar, .wfm-public-topbar {
    position: sticky;
    top: 0;
    z-index: var(--wfm-z-topbar);
    display: flex;
    align-items: center;
    gap: var(--wfm-space-5);
    padding: 0 var(--wfm-space-5);
    height: 60px;
    background: var(--wfm-surface-card);
    border-bottom: 1px solid var(--wfm-line);
    backdrop-filter: saturate(150%) blur(8px);
    -webkit-backdrop-filter: saturate(150%) blur(8px);
    transition: box-shadow var(--wfm-motion-fast);
}
/* Subtle 1-px shadow only when the page has scrolled — readable depth signal that the
   topbar is floating above content. Toggled by a tiny inline scroll listener in App.razor. */
.wfm-topbar.is-scrolled,
.wfm-public-topbar.is-scrolled {
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06),
                0 4px 8px rgba(15, 23, 42, 0.04);
    border-bottom-color: transparent;
}

.wfm-main, .wfm-public-main {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--wfm-space-5);
}

.wfm-public-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--wfm-space-7) var(--wfm-space-5);
}

.wfm-footer {
    padding: var(--wfm-space-4) var(--wfm-space-5);
    text-align: center;
    color: var(--wfm-ink-faint);
    font-size: 0.75rem;
    border-top: 1px solid var(--wfm-line-soft);
    background: var(--wfm-surface-card);
}

/* =============================================================================
   4.  Brand identity — wordmark + mark
============================================================================= */
.wfm-brand {
    display: flex;
    align-items: center;
    margin-right: auto;            /* nav floats right                       */
}
.wfm-brand a, .wfm-brand-link {
    display: inline-flex;
    align-items: center;
    gap: var(--wfm-space-3);
    color: var(--wfm-ink);
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: -0.015em;
    line-height: 1;
    text-decoration: none;
}
.wfm-brand a:hover, .wfm-brand-link:hover { text-decoration: none; }

/* Brand mark — the icon-only crop of the Deepmalay Wealth logo (deepmalay-mark.png).
   Cropped to a tight rectangle at its natural aspect ratio (~1.45:1, arc + figures +
   bars + hand), no white padding. Height-locked at 36 px in the topbar; width flows
   from the aspect ratio so the mark reads as bold as the wordmark next to it. */
.wfm-brand-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.wfm-brand-name {
    /* Two-line wordmark would be too tall for the 60 px topbar, so we keep both words
       on one line. Letter-tracking nudged in slightly for the bolder weight. */
    color: var(--wfm-ink);
    letter-spacing: -0.018em;
    white-space: nowrap;
}

.wfm-brand-sub {
    color: var(--wfm-ink-muted);
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: 0;
    border-left: 1px solid var(--wfm-line);
    padding-left: var(--wfm-space-3);
    margin-left: var(--wfm-space-1);
}

/* =============================================================================
   5.  Top navigation — tab style with active underline
============================================================================= */
.wfm-nav {
    display: flex;
    align-items: center;
    gap: var(--wfm-space-1);
    font-size: 0.875rem;
    height: 100%;
}
.wfm-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
    padding: 0 var(--wfm-space-3);
    color: var(--wfm-ink-muted);
    font-weight: 500;
    text-decoration: none;
    transition: color var(--wfm-motion-fast);
}
.wfm-nav a:hover {
    color: var(--wfm-ink);
    text-decoration: none;
}
.wfm-nav a.wfm-nav-active::after,
.wfm-nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: var(--wfm-space-3);
    right: var(--wfm-space-3);
    bottom: 0;
    height: 2px;
    background: var(--wfm-brand-600);
    border-radius: 2px 2px 0 0;
}
.wfm-nav a.wfm-nav-active,
.wfm-nav a[aria-current="page"] {
    color: var(--wfm-ink);
}

.wfm-nav-divider {
    width: 1px;
    height: 20px;
    background: var(--wfm-line);
    margin: 0 var(--wfm-space-2);
}

.wfm-user {
    display: inline-flex;
    align-items: center;
    gap: var(--wfm-space-2);
    color: var(--wfm-ink-soft);
    font-weight: 500;
    font-size: 0.8125rem;
}

.wfm-logout {
    color: var(--wfm-ink-muted);
    font-size: 0.8125rem;
    padding: var(--wfm-space-1) var(--wfm-space-2);
    border-radius: var(--wfm-radius-sm);
    transition: background var(--wfm-motion-fast), color var(--wfm-motion-fast);
}
.wfm-logout:hover {
    color: var(--wfm-ink);
    background: var(--wfm-surface-sunken);
    text-decoration: none;
}

/* =============================================================================
   6.  Cards & containers
============================================================================= */
.wfm-card {
    background: var(--wfm-surface-card);
    border: 1px solid var(--wfm-line);
    border-radius: var(--wfm-radius-lg);
    padding: var(--wfm-space-5);
    margin-top: var(--wfm-space-4);
    box-shadow: var(--wfm-shadow-xs);
}

/* Auth card — public flow */
.wfm-auth-card {
    background: var(--wfm-surface-card);
    border: 1px solid var(--wfm-line);
    border-radius: var(--wfm-radius-lg);
    padding: var(--wfm-space-7) var(--wfm-space-6);
    max-width: 26rem;
    width: 100%;
    text-align: center;
    box-shadow: var(--wfm-shadow-md);
}
.wfm-auth-card h1 {
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    margin-top: 0;
    margin-bottom: var(--wfm-space-1);
    color: var(--wfm-ink);
}
.wfm-auth-card > .wfm-muted {
    margin-bottom: var(--wfm-space-6);
}

/* =============================================================================
   7.  Buttons
============================================================================= */
.wfm-btn,
.wfm-btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--wfm-space-2);
    height: 36px;
    padding: 0 var(--wfm-space-4);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    color: var(--wfm-ink);
    background: var(--wfm-surface-card);
    border: 1px solid var(--wfm-line-strong);
    border-radius: var(--wfm-radius-md);
    cursor: pointer;
    user-select: none;
    transition: background var(--wfm-motion-fast),
                border-color var(--wfm-motion-fast),
                color var(--wfm-motion-fast),
                box-shadow var(--wfm-motion-fast);
}
.wfm-btn:hover {
    background: var(--wfm-surface-sunken);
    border-color: var(--wfm-line-strong);
}
.wfm-btn:active        { transform: translateY(0.5px); }
.wfm-btn:focus-visible { outline: none; box-shadow: var(--wfm-shadow-focus); }
.wfm-btn:disabled,
.wfm-btn[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
    background: var(--wfm-surface-card);
}

/* Primary — navy fill, white ink */
.wfm-btn-primary {
    color: var(--wfm-ink-on-brand);
    background: var(--wfm-brand-600);
    border-color: var(--wfm-brand-600);
}
.wfm-btn-primary:hover {
    background: var(--wfm-brand-700);
    border-color: var(--wfm-brand-700);
}
.wfm-btn-primary:disabled,
.wfm-btn-primary[disabled] {
    background: var(--wfm-brand-200);
    border-color: var(--wfm-brand-200);
    color: var(--wfm-ink-on-brand);
}

/* Danger — red border, soft fill */
.wfm-btn-danger {
    color: var(--wfm-danger-700);
    background: var(--wfm-danger-50);
    border-color: var(--wfm-danger-200);
}
.wfm-btn-danger:hover {
    background: #FCE5E5;
    border-color: var(--wfm-danger-200);
    color: var(--wfm-danger-700);
}

/* Small — for table row-action buttons. Same geometry contract, smaller scale. */
.wfm-btn-sm {
    height: 28px;
    padding: 0 var(--wfm-space-3);
    font-size: 0.8125rem;
    border-radius: var(--wfm-radius-sm);
}

/* Google — clean white CTA, thin shadow on hover */
.wfm-btn-google {
    width: 100%;
    height: 44px;
    background: var(--wfm-surface-card);
    color: #3C4043;
    border: 1px solid var(--wfm-line-strong);
    font-weight: 500;
}
.wfm-btn-google:hover {
    background: var(--wfm-surface-sunken);
    box-shadow: var(--wfm-shadow-sm);
}

/* =============================================================================
   8.  Inputs
============================================================================= */
.wfm-input,
input[type="text"].wfm-input,
input[type="email"].wfm-input,
input[type="number"].wfm-input,
input[type="date"].wfm-input,
select.wfm-input,
textarea.wfm-input {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 var(--wfm-space-3);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--wfm-ink);
    background: var(--wfm-surface-card);
    border: 1px solid var(--wfm-line-strong);
    border-radius: var(--wfm-radius-md);
    transition: border-color var(--wfm-motion-fast),
                box-shadow var(--wfm-motion-fast);
}
.wfm-input::placeholder { color: var(--wfm-ink-faint); }
.wfm-input:hover        { border-color: var(--wfm-ink-faint); }
.wfm-input:focus,
.wfm-input:focus-visible {
    outline: none;
    border-color: var(--wfm-brand-600);
    box-shadow: var(--wfm-shadow-focus);
}
.wfm-input:disabled {
    background: var(--wfm-surface-sunken);
    color: var(--wfm-ink-muted);
    cursor: not-allowed;
}

textarea.wfm-input {
    height: auto;
    padding: var(--wfm-space-2) var(--wfm-space-3);
    line-height: 1.5;
    font-family: inherit;
    resize: vertical;
}

select.wfm-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: var(--wfm-space-6);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right var(--wfm-space-3) center;
    background-size: 12px 12px;
    cursor: pointer;
}

input[type="file"].wfm-input,
input[type="file"] {
    height: auto;
    padding: var(--wfm-space-2);
}

/* =============================================================================
   9.  Toolbar — search + filters row
============================================================================= */
.wfm-toolbar {
    display: flex;
    align-items: center;
    gap: var(--wfm-space-2);
    margin: var(--wfm-space-4) 0;          /* symmetric 16 / 16 */
    flex-wrap: wrap;
}
.wfm-toolbar .wfm-input { min-width: 14rem; }
/* The match-count sits next to the filter cluster, not orphaned at the right edge.
   Pages may opt into right-alignment by adding .wfm-toolbar-spacer between filters
   and the count instead of relying on inline margin-left:auto on the count. */
.wfm-toolbar-spacer { flex: 1 1 auto; }
.wfm-toolbar-count {
    margin-left: var(--wfm-space-2);
    color: var(--wfm-ink-muted);
    font-size: 0.8125rem;
}

/* =============================================================================
   10.  Tables — data-dense, refined

   Sticky thead contract:
   - Each <table class="wfm-users-table"> lives inside <div class="wfm-table-scroll">
     which lives inside <div class="wfm-card"> (with no overflow:hidden on the card).
   - At desktop the wrapper has NO overflow — the table flows naturally and the thead's
     position:sticky resolves against the document scroll. CSS spec quirk: if a wrapper
     has overflow-x:auto, browsers force overflow-y to auto too, which traps sticky in
     a wrapper that has no scrollable height. We avoid that entirely at desktop.
   - At narrow viewports the wrapper switches to overflow-x:auto so dense tables are
     pannable on phones. Sticky-thead is sacrificed in that regime — acceptable, since
     mobile users typically see one card at a time anyway.
   - thead z-index 5 + box-shadow hairline (instead of border-bottom) so the bottom
     line paints above body rows on every webkit build.
============================================================================= */
.wfm-table-scroll {
    /* Desktop: transparent wrapper. Sticky thead works against the document. */
    -webkit-overflow-scrolling: touch;
}

.wfm-users-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    /* Tabular figures so amount columns align cleanly */
    font-variant-numeric: tabular-nums;
}
.wfm-users-table thead th {
    position: sticky;
    top: 60px;                        /* below the topbar                    */
    z-index: 5;
    background: var(--wfm-surface-sunken);
    color: var(--wfm-ink-muted);
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    padding: var(--wfm-space-3) var(--wfm-space-3);
    /* Use box-shadow as the bottom hairline so it paints above tbody rows that scroll
       under the thead — a real border can render below an adjacent row's background in
       some webkit builds. */
    box-shadow: inset 0 -1px 0 var(--wfm-line);
    white-space: nowrap;
}
.wfm-users-table tbody td {
    padding: var(--wfm-space-3) var(--wfm-space-3);
    border-bottom: 1px solid var(--wfm-line-soft);
    color: var(--wfm-ink-soft);
    vertical-align: middle;
}
.wfm-users-table tbody tr:last-child td { border-bottom: none; }
.wfm-users-table tbody tr {
    transition: background var(--wfm-motion-fast);
}
.wfm-users-table tbody tr:hover { background: var(--wfm-surface-sunken); }

/* Sortable header cursor + glyph spacing */
.wfm-table-sortable thead th {
    cursor: pointer;
    user-select: none;
}
.wfm-table-sortable thead th:hover { color: var(--wfm-ink); }

/* Row-level emphasis — RED ZONE rows get a faint red tint that survives the row
   hover state. Subtle enough to not shout, strong enough to scan. */
.wfm-row-red {
    background: rgba(220, 38, 38, 0.06);
    box-shadow: inset 3px 0 0 var(--wfm-danger-600);
}
.wfm-row-red:hover { background: rgba(220, 38, 38, 0.10) !important; }

/* Today grid (11 columns) — fixed layout pins each column to a known width so the
   Update-button cell always lands directly under its (visually empty) header on a
   ~1232 px content area at 100 % zoom. Scoped to .wfm-today-grid so other pages
   sharing .wfm-users-table (Reports, Clients, Users, Recently closed) are not affected.
   Sums to 1222 px which fits inside .wfm-card on the standard desktop shell. */
.wfm-today-grid {
    table-layout: fixed;
}
.wfm-today-grid thead th,
.wfm-today-grid tbody td {
    padding: 8px 10px;
    word-break: break-word;
}
.wfm-today-grid th:nth-child(1),  .wfm-today-grid td:nth-child(1)  { width: 104px; } /* URGENCY        */
.wfm-today-grid th:nth-child(2),  .wfm-today-grid td:nth-child(2)  { width: 140px; } /* CLIENT         */
.wfm-today-grid th:nth-child(3),  .wfm-today-grid td:nth-child(3)  { width: 70px;  } /* VENDOR         */
.wfm-today-grid th:nth-child(4),  .wfm-today-grid td:nth-child(4)  { width: 104px; } /* POLICY         */
.wfm-today-grid th:nth-child(5),  .wfm-today-grid td:nth-child(5)  { width: 96px;  } /* FUP            */
.wfm-today-grid th:nth-child(6),  .wfm-today-grid td:nth-child(6)  { width: 88px;  } /* AMOUNT         */
.wfm-today-grid th:nth-child(7),  .wfm-today-grid td:nth-child(7)  { width: 144px; } /* STATUS         */
.wfm-today-grid th:nth-child(8),  .wfm-today-grid td:nth-child(8)  { width: 120px; } /* NEXT CHECKPOINT*/
.wfm-today-grid th:nth-child(9),  .wfm-today-grid td:nth-child(9)  { width: 150px; } /* LAST INTERACT  */
.wfm-today-grid th:nth-child(10), .wfm-today-grid td:nth-child(10) { width: 96px;  } /* ASSIGNEE       */
.wfm-today-grid th:last-child,    .wfm-today-grid td:last-child {
    width: 110px;
    text-align: right;
    white-space: nowrap;
}

/* Narrow viewports — pull padding and font down before falling back to mobile scroll. */
@media (max-width: 1180px) {
    .wfm-today-grid                              { font-size: 0.8125rem; }
    .wfm-today-grid thead th, .wfm-today-grid tbody td { padding: 6px 8px; }
}

/* =============================================================================
   11.  Badges
============================================================================= */
.wfm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--wfm-radius-pill);
    border: 1px solid transparent;
    white-space: nowrap;
    text-transform: none;
}
.wfm-badge-active   { background: var(--wfm-success-50); color: var(--wfm-success-700); border-color: var(--wfm-success-200); }
.wfm-badge-pending  { background: var(--wfm-warning-50); color: var(--wfm-warning-700); border-color: var(--wfm-warning-200); }
.wfm-badge-inactive { background: var(--wfm-surface-sunken); color: var(--wfm-ink-muted); border-color: var(--wfm-line-strong); }
/* Soft-gray pill for "no semantic colour yet" states (NEW, ASSIGNED). Distinct from
   .wfm-badge-inactive which signals terminal-bad — same colour ramp, dimmer ink, lighter
   border to read as "neutral/quiet" rather than "closed-with-loss". */
.wfm-badge-neutral  { background: #F3F4F6; color: var(--wfm-ink-muted); border-color: var(--wfm-line); }
.wfm-badge-red      { background: var(--wfm-danger-50);  color: var(--wfm-danger-700);  border-color: var(--wfm-danger-200);  }
.wfm-badge-overdue  { background: #FFF3E6;               color: #9A3412;                border-color: #FED7AA;                }
.wfm-badge-inwindow { background: var(--wfm-info-50);    color: var(--wfm-info-700);    border-color: var(--wfm-info-200);    }

/* Subtle red dot for RED ZONE rows in compact contexts */
.wfm-badge-red::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--wfm-danger-600);
}

/* =============================================================================
   12.  Banners — info / warning / error
============================================================================= */
.wfm-banner {
    padding: var(--wfm-space-3) var(--wfm-space-4);
    border-radius: var(--wfm-radius-md);
    border: 1px solid transparent;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: var(--wfm-space-3) 0;
}
.wfm-banner.info    { background: var(--wfm-info-50);    color: var(--wfm-info-700);    border-color: var(--wfm-info-200);    }
.wfm-banner.warning { background: var(--wfm-warning-50); color: var(--wfm-warning-700); border-color: var(--wfm-warning-200); }
.wfm-banner.error   { background: var(--wfm-danger-50);  color: var(--wfm-danger-700);  border-color: var(--wfm-danger-200);  }

/* =============================================================================
   13.  Tabs — settings/users page
============================================================================= */
.wfm-tabs {
    display: flex;
    gap: var(--wfm-space-1);
    align-items: center;
    margin: var(--wfm-space-4) 0;            /* symmetric 16 / 16 — page rhythm */
    border-bottom: 1px solid var(--wfm-line);
}
.wfm-tab {
    background: transparent;
    border: 0;
    color: var(--wfm-ink-muted);
    padding: var(--wfm-space-2) var(--wfm-space-3);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    margin-bottom: -1px;
    transition: color var(--wfm-motion-fast);
}
.wfm-tab:hover { color: var(--wfm-ink); }
.wfm-tab.active {
    color: var(--wfm-ink);
}
.wfm-tab.active::after {
    content: "";
    position: absolute;
    inset: auto var(--wfm-space-3) -1px;
    height: 2px;
    background: var(--wfm-brand-600);
    border-radius: 2px 2px 0 0;
}

/* =============================================================================
   14.  Forms — grid + label
============================================================================= */
.wfm-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--wfm-space-4);
}
.wfm-form-grid label {
    display: flex;
    flex-direction: column;
    gap: var(--wfm-space-1);
}
.wfm-form-label {
    font-size: 0.8125rem;
    color: var(--wfm-ink-muted);
    font-weight: 500;
}

/* =============================================================================
   15.  Summary tiles — top of page metrics
============================================================================= */
.wfm-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--wfm-space-3);
    margin: var(--wfm-space-5) 0;
}
.wfm-summary-cell {
    background: var(--wfm-surface-card);
    border: 1px solid var(--wfm-line);
    border-radius: var(--wfm-radius-md);
    padding: var(--wfm-space-4);
    box-shadow: var(--wfm-shadow-xs);
}
.wfm-summary-num {
    font-size: 1.625rem;
    font-weight: 600;
    color: var(--wfm-ink);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.wfm-summary-label {
    font-size: 0.6875rem;
    color: var(--wfm-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: var(--wfm-space-2);
    font-weight: 600;
}

/* =============================================================================
   16.  Timeline
============================================================================= */
.wfm-timeline {
    list-style: none;
    padding: 0;
    margin: var(--wfm-space-3) 0 0;
    border-left: 2px solid var(--wfm-line);
    margin-left: var(--wfm-space-2);
}
.wfm-timeline-item {
    padding: var(--wfm-space-2) 0 var(--wfm-space-3) var(--wfm-space-4);
    margin-left: var(--wfm-space-1);
    position: relative;
}
.wfm-timeline-item::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 14px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--wfm-brand-600);
    border: 2px solid var(--wfm-surface-card);
    box-shadow: 0 0 0 1px var(--wfm-line);
}
.wfm-timeline-when {
    font-size: 0.75rem;
    color: var(--wfm-ink-muted);
}
.wfm-timeline-body {
    margin-top: 4px;
    color: var(--wfm-ink-soft);
}

/* =============================================================================
   17.  Modal (settings dialogs etc.)
============================================================================= */
.wfm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--wfm-surface-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--wfm-z-modal);
    padding: var(--wfm-space-4);
    animation: wfm-fade-in var(--wfm-motion-medium);
}
.wfm-modal {
    background: var(--wfm-surface-card);
    border: 1px solid var(--wfm-line);
    border-radius: var(--wfm-radius-lg);
    padding: var(--wfm-space-5);
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: var(--wfm-shadow-md);
    animation: wfm-pop-in var(--wfm-motion-medium);
}

/* =============================================================================
   18.  Avatars + user rows
============================================================================= */
.wfm-user-row {
    display: flex;
    gap: var(--wfm-space-3);
    align-items: center;
    margin: var(--wfm-space-3) 0;
    padding: var(--wfm-space-3);
    background: var(--wfm-surface-sunken);
    border: 1px solid var(--wfm-line-soft);
    border-radius: var(--wfm-radius-md);
}

.wfm-avatar    { width: 40px; height: 40px; border-radius: 50%; }
.wfm-avatar-sm { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }

.wfm-avatar-fallback {
    background: var(--wfm-brand-600);
    color: var(--wfm-ink-on-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* =============================================================================
   19.  Loading + spinner + 404
============================================================================= */
.wfm-loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: var(--wfm-space-4);
    background: var(--wfm-surface-page);
    color: var(--wfm-ink-muted);
}
.wfm-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--wfm-line);
    border-top-color: var(--wfm-brand-600);
    border-radius: 50%;
    animation: wfm-spin 0.8s linear infinite;
}
.wfm-not-found {
    text-align: center;
    padding: var(--wfm-space-8) var(--wfm-space-4);
}
.wfm-not-found h1 {
    font-size: 4rem;
    margin: 0;
    color: var(--wfm-ink-faint);
    letter-spacing: -0.04em;
}

/* =============================================================================
   20.  Numeric / muted utilities
============================================================================= */
.wfm-muted   { color: var(--wfm-ink-muted); }
.wfm-small   { font-size: 0.8125rem; }
.wfm-error   { color: var(--wfm-danger-700); margin-top: var(--wfm-space-3); }
.wfm-tnum    { font-variant-numeric: tabular-nums; }

/* Visually-hide content but keep it for assistive tech (e.g. labelling otherwise-empty
   header cells like the Today grid's actions column). */
.wfm-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;
}

/* Right-aligned currency / numeric column. Apply to <th> AND matching <td>s so
   the column hairline stays straight. Mirrors Bloomberg / Carta convention:
   currency right-aligns so 5-figure vs 6-figure values stack cleanly. */
.wfm-num-cell { text-align: right; font-variant-numeric: tabular-nums; }

.wfm-num-red  { color: var(--wfm-danger-700);  font-weight: 600; font-variant-numeric: tabular-nums; }
.wfm-num-warn { color: var(--wfm-warning-700); font-weight: 600; font-variant-numeric: tabular-nums; }

/* =============================================================================
   21.  Animations
============================================================================= */
@keyframes wfm-spin     { to { transform: rotate(360deg); } }
@keyframes wfm-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes wfm-pop-in   { from { opacity: 0; transform: translateY(4px) scale(0.98); }
                          to   { opacity: 1; transform: translateY(0)    scale(1);   } }

/* =============================================================================
   22.  Responsive
============================================================================= */
/* Tablet — keep brand-sub, compress nav padding. */
@media (max-width: 960px) {
    .wfm-topbar, .wfm-public-topbar { padding: 0 var(--wfm-space-4); }
    .wfm-nav                        { gap: 0; font-size: 0.8125rem; }
    .wfm-nav a                      { padding: 0 var(--wfm-space-2); }
}

/* Small — drop the brand subtitle (nav needs the room) and compress further.
   Tables get horizontal scroll here too — sticky thead is sacrificed in this regime. */
@media (max-width: 640px) {
    .wfm-topbar, .wfm-public-topbar { padding: 0 var(--wfm-space-3); gap: var(--wfm-space-3); }
    .wfm-main, .wfm-public-main     { padding: var(--wfm-space-3); }
    .wfm-brand-sub                  { display: none; }
    .wfm-nav-divider                { display: none; }
    .wfm-user > span:last-child     { display: none; }   /* avatar only       */
    .wfm-summary-grid               { grid-template-columns: repeat(2, 1fr); }
    .wfm-table-scroll               { overflow-x: auto; }
}

/* =============================================================================
   23.  Print
============================================================================= */
@media print {
    .wfm-topbar, .wfm-footer, .wfm-toolbar { display: none; }
    .wfm-card                              { box-shadow: none; border-color: var(--wfm-line); }
    body                                   { background: white; }
}

/* =============================================================================
   24.  Reduced motion — respect user preference
============================================================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
