/* ── Practicore brand tokens (ADR 0009) ───────────────────────────────── */
:root {
    --brand: #2E8B57;          /* Practicore green (light) */
    --brand-dark: #257346;     /* darker green (was a stray 8-digit alpha typo) */
    --text: #1d2b24;
    --muted: #5a6b62;          /* ≥4.5:1 on white for small text (WCAG AA) */
    --surface: #ffffff;
    --background: #f3f6f4;
    --danger: #b3372f;
    --border: #dde5e0;
    --shadow: 0 10px 30px rgba(29, 43, 36, 0.10);
    /* Primary-button gradient — the desktop's Practicore.Brush.BrandGradient
       (Theme/Tokens.axaml): navy → green, horizontal, with a hover variant. */
    --brand-gradient: linear-gradient(90deg, #0C2340 0%, #0B7A5A 100%);
    --brand-gradient-hover: linear-gradient(90deg, #143458 0%, #0E8E68 100%);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

h1:focus { outline: none; }

.app-root { min-height: 100vh; }

/* ── Wordmark ──────────────────────────────────────────────────────────── */
.wordmark { font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.wordmark-accent { color: var(--brand); }
.wordmark-lg { font-size: 2.4rem; }

/* ── Buttons & fields ──────────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 0.7rem 1rem;
    margin-top: 0.4rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--brand-gradient);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: filter 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
    box-shadow: 0 2px 6px rgba(12, 35, 64, 0.18);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-gradient-hover); box-shadow: 0 4px 12px rgba(12, 35, 64, 0.24); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-ghost {
    padding: 0.45rem 0.8rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--brand);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.btn-ghost:hover { border-color: var(--brand); }

.field { margin-bottom: 0.85rem; text-align: left; }
.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.3rem;
}
.control {
    width: 100%;
    padding: 0.6rem 0.7rem;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
}
.control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.15); }

/* Show/hide password toggle: a borderless text button overlaid at the right
   edge of the field; the input reserves room for it via padding-right. */
.password-wrap { position: relative; }
.password-wrap .control { padding-right: 3.6rem; }
.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
}
.password-toggle:hover { color: var(--brand); }
.password-toggle:focus-visible { outline: 2px solid var(--brand); border-radius: 5px; }

/* ── Auth screen ───────────────────────────────────────────────────────── */
.auth-screen, .tour-screen, .boot-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(46, 139, 87, 0.10), transparent),
        var(--background);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 2rem 1.8rem;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow);
    text-align: center;
}
.auth-brand { margin-bottom: 1.4rem; }
.auth-tagline {
    margin: 0.5rem 0 0;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: var(--muted);
}
.auth-tabs {
    display: flex;
    gap: 0.4rem;
    background: var(--background);
    border-radius: 10px;
    padding: 0.25rem;
    margin-bottom: 1.2rem;
}
.auth-tab {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.auth-tab.active { color: var(--brand); background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.auth-error {
    margin: 0.9rem 0 0;
    padding: 0.6rem 0.7rem;
    font-size: 0.86rem;
    color: var(--danger);
    background: rgba(179, 55, 47, 0.08);
    border-radius: 8px;
}
.auth-info {
    margin: 0.9rem 0 0;
    padding: 0.6rem 0.7rem;
    font-size: 0.86rem;
    color: var(--brand);
    background: rgba(46, 139, 87, 0.08);
    border-radius: 8px;
}
.auth-heading { margin: 0.2rem 0 1rem; font-size: 1.05rem; font-weight: 700; text-align: center; }
/* Onboarding "Set up your access" role list — stack the practitioner-role
   checkboxes with breathing room instead of cramming them on one line. */
.onboarding-roles {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 0.4rem auto 0.2rem;
    max-width: 16rem;
    text-align: left;
}
.onboarding-roles .role-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; }
/* A quiet, link-styled button (forgot-password, back-to-sign-in). A real <button>
   for keyboard/AT, painted as a link. */
.auth-link {
    display: block;
    width: 100%;
    margin: 0.8rem 0 0;
    padding: 0.3rem;
    font-size: 0.82rem;
    color: var(--brand);
    background: none;
    border: none;
    cursor: pointer;
    text-align: center;
}
.auth-link:hover { text-decoration: underline; }
.auth-foot { margin: 1.3rem 0 0; font-size: 0.68rem; color: var(--muted); }

/* ── Onboarding tour ───────────────────────────────────────────────────── */
.tour-card {
    width: 100%;
    max-width: 440px;
    padding: 2.2rem 2rem;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow);
    text-align: center;
}
.tour-dots { display: flex; justify-content: center; gap: 0.4rem; margin-bottom: 1.6rem; }
.tour-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: all 0.15s; }
.tour-dot.active { background: var(--brand); width: 22px; border-radius: 4px; }
.tour-body { min-height: 190px; }
.tour-icon { font-size: 3rem; }
.tour-body h2 { margin: 0.6rem 0 0.5rem; font-size: 1.4rem; }
.tour-body p { margin: 0 auto; max-width: 340px; color: var(--muted); line-height: 1.5; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 1.6rem; }
.tour-actions .btn-primary { width: auto; padding: 0.6rem 1.6rem; margin: 0; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.shell-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.4rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.shell-bar-left { display: flex; align-items: center; gap: 0.7rem; }
.shell-bar-right { display: flex; align-items: center; gap: 0.8rem; }
.shell-firm { font-size: 0.9rem; font-weight: 600; color: var(--muted); }

/* Account menu — the avatar is the button; the dropdown holds the view-as-role
   lens + sign out. */
.account-menu { position: relative; display: flex; align-items: center; }
.shell-avatar {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; color: #fff;
    background: var(--brand); border: none; border-radius: 50%; cursor: pointer;
}
.shell-avatar:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Full-viewport transparent catcher so any outside click closes the menu. */
.account-backdrop { position: fixed; inset: 0; z-index: 40; background: transparent; }
.account-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 41;
    min-width: 220px; padding: 0.4rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow);
}
.account-head { padding: 0.5rem 0.6rem 0.6rem; border-bottom: 1px solid var(--border); }
.account-name { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.account-firm { font-size: 0.78rem; color: var(--muted); }
.account-section { padding: 0.35rem 0; }
.account-section + .account-section { border-top: 1px solid var(--border); }
.account-section-label {
    display: block;
    padding: 0.2rem 0.6rem; font-size: 0.68rem; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
/* The "View as" dropdown. */
.account-select {
    width: calc(100% - 1.2rem);
    margin: 0.15rem 0.6rem 0.35rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.86rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer;
}
.account-select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.account-item {
    display: flex; align-items: center; gap: 0.2rem;
    width: 100%; padding: 0.45rem 0.6rem;
    font-size: 0.86rem; text-align: left; color: var(--text);
    background: none; border: none; border-radius: 8px; cursor: pointer;
}
.account-item:hover { background: var(--surface-2, rgba(0,0,0,0.04)); }
.shell-body { flex: 1; display: flex; justify-content: center; padding: 2.4rem 1.4rem; }
.welcome-card {
    width: 100%;
    max-width: 620px;
    padding: 2.2rem;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.welcome-card h1 { margin: 0 0 0.6rem; font-size: 1.8rem; }
.welcome-sub { color: var(--muted); line-height: 1.55; margin: 0 0 1.6rem; }
.actor-grid {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 0.55rem 1rem;
    margin: 0 0 1.6rem;
    padding: 1.1rem 1.2rem;
    background: var(--background);
    border-radius: 12px;
}
.actor-grid dt { font-weight: 600; color: var(--muted); }
.actor-grid dd { margin: 0; font-weight: 600; }
.welcome-foot { font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin: 0; }

/* ── Offline banner ────────────────────────────────────────────────────── */
.offline-banner {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    text-align: center;
    color: #5a4500;
    background: #fff4cc;
    border-bottom: 1px solid #f0e2a8;
}

/* ── Client-scope chip (top bar) ───────────────────────────────────────── */
.scope-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 1.1rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.scope-chip.firm { color: var(--muted); }
.scope-chip.client { color: var(--brand); border-color: var(--brand); background: rgba(46,139,87,0.07); }
.scope-dot { font-size: 0.6rem; }
.scope-clear {
    border: none; background: transparent; cursor: pointer;
    color: var(--muted); font-size: 0.85rem; padding: 0 0.1rem; line-height: 1;
}
.scope-clear:hover { color: var(--danger); }

/* ── Pane scaffold ─────────────────────────────────────────────────────── */
.shell-body-pane { justify-content: stretch; padding: 1.6rem 1.8rem; }
.pane {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.pane-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
    padding: 1.3rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
}
.pane-title { margin: 0; font-size: 1.4rem; }
.pane-subtitle { margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--muted); }
.pane-toolbar { flex-shrink: 0; }
.pane-search { width: 240px; padding: 0.45rem 0.6rem; font-size: 0.9rem; }
.pane-body { padding: 0.4rem 0 0; }

.muted-row { padding: 2rem 1.5rem; color: var(--muted); text-align: center; }
.danger-row { padding: 1.4rem 1.5rem; color: var(--danger); }

/* ── Client table ──────────────────────────────────────────────────────── */
.client-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.client-table thead th {
    text-align: left; padding: 0.55rem 1.5rem;
    font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--muted); border-bottom: 1px solid var(--border);
}
.client-table tbody td { padding: 0.7rem 1.5rem; border-bottom: 1px solid var(--background); }
.client-table tbody tr { cursor: pointer; transition: background 0.1s; }
.client-table tbody tr:hover { background: var(--background); }
.client-table tbody tr.selected { background: rgba(46,139,87,0.08); }
.client-table .ref { color: var(--muted); font-variant-numeric: tabular-nums; }
.client-table .name { font-weight: 600; }
.client-table .muted { color: var(--muted); }
.client-table .row-actions { text-align: right; white-space: nowrap; }
.client-table .in-focus { color: var(--brand); font-weight: 600; font-size: 0.84rem; margin-right: 0.7rem; }
.row-edit {
    border: 1px solid var(--border); background: var(--surface); cursor: pointer;
    border-radius: 7px; padding: 0.25rem 0.7rem; font-size: 0.82rem; font-weight: 600; color: var(--brand);
}
.row-edit:hover { border-color: var(--brand); }

.pane-toolbar-row { display: flex; align-items: center; gap: 0.6rem; }
.pane-new { width: auto; padding: 0.5rem 1rem; margin: 0; font-size: 0.9rem; }
.pane-doc { cursor: pointer; white-space: nowrap; }
.pane-doc.disabled { opacity: 0.6; pointer-events: none; }

/* ── Form catalog (FormField / StatusLine / FormButtonRow) ─────────────── */
.form-stack { display: flex; flex-direction: column; gap: 0.2rem; }
.form-field { margin-bottom: 0.9rem; text-align: left; }
.form-field label {
    display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 0.3rem;
}
.form-field.has-error .control { border-color: var(--danger); }
.field-error { margin: 0.3rem 0 0; font-size: 0.8rem; color: var(--danger); }

.status-line { margin: 0.4rem 0 0.8rem; font-size: 0.86rem; padding: 0.55rem 0.7rem; border-radius: 8px; }
.status-line.danger { color: var(--danger); background: rgba(179,55,47,0.08); }
.status-line.muted { color: var(--muted); background: var(--background); }

.form-button-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    /* Pinned to the bottom of the scrolling drawer so Save/Create is always reachable
       on a long (10-field) form. Spans the drawer padding via negative margins. */
    position: sticky; bottom: 0;
    margin: 0.6rem -1.4rem 0; padding: 0.9rem 1.4rem;
    background: var(--surface); border-top: 1px solid var(--border);
}
.fbr-left { display: flex; align-items: center; gap: 0.7rem; }
.fbr-right { display: flex; align-items: center; gap: 0.6rem; }
.fbr-primary { width: auto; padding: 0.6rem 1.3rem; margin: 0; }
.dirty-pill { font-size: 0.8rem; color: var(--brand); font-weight: 600; }

/* ── Drawer (slide-over host) ──────────────────────────────────────────── */
.drawer-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(29,43,36,0.32);
    display: flex; justify-content: flex-end;
}
.drawer-panel {
    width: 100%; max-width: 440px; height: 100%;
    background: var(--surface); box-shadow: -10px 0 30px rgba(0,0,0,0.15);
    display: flex; flex-direction: column;
    animation: drawer-in 0.16s ease-out;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border);
}
.drawer-title { margin: 0; font-size: 1.2rem; }
.drawer-close { border: none; background: transparent; cursor: pointer; font-size: 1rem; color: var(--muted); }
.drawer-close:hover { color: var(--danger); }
.drawer-body { padding: 1.3rem 1.4rem; overflow-y: auto; }

/* ── Nav rail + content ────────────────────────────────────────────────── */
.shell-main { flex: 1; display: flex; min-height: 0; }
.nav-rail {
    width: 220px; flex-shrink: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 1rem 0.7rem; overflow-y: auto;
}
.nav-section-label {
    font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted); padding: 0.9rem 0.6rem 0.35rem;
}
.nav-item {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.5rem 0.6rem; margin-bottom: 0.1rem;
    font-size: 0.92rem; font-weight: 600; color: var(--text);
    background: transparent; border: none; border-radius: 9px; cursor: pointer;
    text-align: left;
}
.nav-item:hover { background: var(--background); }
.nav-item.active { background: rgba(46,139,87,0.10); color: var(--brand); }
/* Icons stay greyscale (currentColor=muted) even when the item is active —
   only the label/background carry the brand highlight. */
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; color: var(--muted); }
.nav-svg { display: block; }
/* Rail collapse toggle — lives in the header, to the LEFT of the wordmark. */
.nav-collapse {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; cursor: pointer;
    color: var(--muted); font-size: 1.05rem; line-height: 1;
    padding: 0.25rem 0.45rem; border-radius: 7px;
}
.nav-collapse:hover { background: var(--background); color: var(--text); }
.nav-collapse:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.nav-rail.collapsed { width: 62px; }
.nav-rail.collapsed .nav-label,
.nav-rail.collapsed .nav-section-label { display: none; }
.nav-rail.collapsed .nav-item { justify-content: center; padding: 0.55rem; }
.shell-content { flex: 1; overflow-y: auto; padding: 1.6rem 1.8rem; min-width: 0; }
.shell-content .pane { margin: 0 auto; }

/* Install-the-autofill-extension nudge (ADR 0090). A quiet, dismissible strip at
   the top of the content — informative, not alarming, so it uses the brand-tinted
   surface rather than a warning colour. */
.ext-install-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 auto 1.2rem;
    padding: 0.7rem 1rem;
    background: rgba(46, 139, 87, 0.08);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: 8px;
    font-size: 0.88rem;
}
.ext-install-icon { font-size: 1.1rem; line-height: 1; }
.ext-install-text { flex: 1; color: var(--text); }
.ext-install-action {
    flex: none;
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
    white-space: nowrap;
}
.ext-install-action:hover { text-decoration: underline; }
.ext-install-dismiss {
    flex: none;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.84rem;
    cursor: pointer;
    padding: 0.2rem 0.3rem;
    white-space: nowrap;
}
.ext-install-dismiss:hover { color: var(--text); }

/* ── Status chips + due dates ──────────────────────────────────────────── */
.chip {
    display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
    font-size: 0.76rem; font-weight: 600;
}
.chip-danger { color: var(--danger); background: rgba(179,55,47,0.10); }
.chip-ok { color: var(--brand); background: rgba(46,139,87,0.10); }
.chip-open { color: #8a6d00; background: #fff4cc; }
.chip-muted { color: var(--muted); background: var(--background); }
.client-table .due { font-variant-numeric: tabular-nums; color: var(--muted); }
.client-table .due.overdue { color: var(--danger); font-weight: 600; }
.pane-filter { width: auto; padding: 0.45rem 0.6rem; font-size: 0.9rem; }

/* ── Tab toggle (within a pane toolbar) ────────────────────────────────── */
.tab-toggle { display: inline-flex; gap: 0.25rem; background: var(--background); border-radius: 9px; padding: 0.2rem; }
.tab {
    padding: 0.4rem 0.9rem; font-size: 0.88rem; font-weight: 600; color: var(--muted);
    background: transparent; border: none; border-radius: 7px; cursor: pointer;
}
.tab.active { color: var(--brand); background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.role-chip { margin-right: 0.3rem; }

/* ── Per-member role editor (inline expand row) ────────────────────────── */
.role-editor-row td { background: var(--surface-muted, #f6f8f7); }
.role-editor { padding: 0.6rem 0.2rem; display: flex; flex-direction: column; gap: 0.7rem; }
.role-editor-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.role-checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.role-check { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.role-check input { width: auto; margin: 0; }
.role-editor-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.role-editor-actions button { width: auto; }

/* ── Overview actions + compliance-pack picker ─────────────────────────── */
/* ── Document-backed fields, document-centric (ADR 0077 + UX panel) ─────── */
/* The DOCUMENT is the unit: each source shows ONCE in a Sources strip with its
   temperature (freshness by tax year) + open; every field it backs carries a
   quiet letter tag pointing at it. Temperature colours are shared by chip+tag. */
.doc-temp-hot  { --tc-bg: #fde7e0; --tc-fg: #c0392b; --tc-bd: #f3c4b6; }
.doc-temp-warm { --tc-bg: #fdf0e3; --tc-fg: #9a5a00; --tc-bd: #f1d9b6; }
.doc-temp-cool { --tc-bg: #e3eff3; --tc-fg: #1f6f86; --tc-bd: #c2dde6; }
.doc-temp-cold { --tc-bg: #e7eef8; --tc-fg: #355f9a; --tc-bd: #c6d6ec; }

.doc-sources { margin: 0 0 1.2rem; }
.doc-sources-label {
    display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 0.45rem;
}
.doc-sources-strip { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.doc-source-chip {
    display: inline-flex; align-items: center; gap: 0.5rem; width: auto;
    padding: 0.35rem 0.7rem; border: 1px solid var(--tc-bd, #d8e0db);
    border-radius: 10px; background: var(--tc-bg, #fff); color: var(--brand-dark);
    cursor: pointer; text-align: left;
}
.doc-source-chip:hover { filter: brightness(0.97); }
.doc-source-letter {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.35rem; height: 1.35rem; border-radius: 50%;
    background: var(--tc-fg, #555); color: #fff; font-weight: 700; font-size: 0.8rem;
}
.doc-source-name { font-weight: 600; font-size: 0.85rem; color: #2b3a33; }
.doc-source-temp { font-size: 0.76rem; font-weight: 600; color: var(--tc-fg, #555); }
.doc-sources-hint { font-size: 0.78rem; color: var(--muted); margin: 0.5rem 0 0; }

/* Quiet per-field letter tag — keyed by colour to its Sources chip. */
.doc-fieldtag {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.25rem; height: 1.25rem; margin-left: 0.5rem; padding: 0;
    border: 1px solid var(--tc-fg, #888); border-radius: 50%;
    background: var(--tc-bg, #fff); color: var(--tc-fg, #555);
    font-size: 0.72rem; font-weight: 700; cursor: pointer; vertical-align: middle;
}
.doc-fieldtag:hover { background: var(--tc-fg, #555); color: #fff; }
.doc-edited {
    display: inline-block; margin-left: 0.4rem; padding: 0.02rem 0.4rem;
    border-radius: 999px; background: #fdf0e3; color: #9a5a00;
    font-size: 0.7rem; font-weight: 600; vertical-align: middle;
}

/* ── Labeled multi-valued contact points (ADR 0089) ────────────────────── */
.contacts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; margin-top: 1.2rem; }
.contact-group-head { display: flex; align-items: center; justify-content: space-between; }
.contact-group-head h3 { margin: 0; font-size: 0.9rem; }
.contact-empty { font-size: 0.82rem; margin: 0.3rem 0 0; }
.contact-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.contact-row {
    display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.6rem; align-items: baseline;
    padding-bottom: 0.5rem; border-bottom: 1px solid var(--border, #eef2f0);
}
.contact-label { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.contact-primary {
    margin-left: 0.4rem; padding: 0 0.35rem; border-radius: 999px;
    background: #e3f3ea; color: #1f7a4d; font-size: 0.62rem; font-weight: 700; letter-spacing: 0;
}
.contact-value { grid-column: 1; font-weight: 600; color: #2b3a33; }
.contact-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 0.3rem; align-items: center; }
.contact-remove { color: var(--danger, #c0392b); }
/* Contact-person cards: name+email+phone+note bundled under a role. */
.person-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.person-card {
    border: 1px solid var(--border, #e3e8e5); border-radius: 10px; padding: 0.6rem 0.8rem;
    display: flex; flex-direction: column; gap: 0.2rem;
}
.person-head { display: flex; align-items: center; justify-content: space-between; }
.person-name { font-weight: 700; color: #2b3a33; }
.person-line { font-size: 0.9rem; color: #2b3a33; }
.person-note { font-size: 0.82rem; color: var(--muted); font-style: italic; margin-top: 0.2rem; }
@media (max-width: 720px) { .contacts { grid-template-columns: 1fr; } }

/* ── Document viewer modal ──────────────────────────────────────────────── */
.doc-modal-backdrop {
    position: fixed; inset: 0; background: rgba(20, 30, 26, 0.55);
    display: flex; align-items: center; justify-content: center; z-index: 200; padding: 2rem;
}
.doc-modal {
    background: var(--surface, #fff); border-radius: 14px; width: min(900px, 95vw);
    max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}
.doc-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 1.1rem; border-bottom: 1px solid var(--border, #e3e8e5);
}
.doc-modal-title { font-weight: 700; }
.doc-modal-head .btn-ghost { width: auto; }
.doc-modal-body { padding: 1rem; overflow: auto; background: #f4f6f5; }
.doc-modal-pdf canvas, .doc-modal-img { max-width: 100%; height: auto; display: block; margin: 0 auto;
    box-shadow: 0 1px 6px rgba(0,0,0,0.15); }

.ws-overview-actions { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.ws-overview-actions .btn-primary { width: auto; }
.ws-apply-status { color: var(--brand-dark); font-size: 0.88rem; }
.pack-picker { display: flex; flex-direction: column; gap: 1rem; }
.pack-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.pack-list { display: flex; flex-direction: column; gap: 0.5rem; }
.pack-option {
    display: flex; flex-direction: column; gap: 0.2rem; text-align: left;
    padding: 0.7rem 0.9rem; border: 1px solid var(--border, #d8e0db);
    border-radius: 9px; background: var(--surface, #fff); cursor: pointer; width: 100%;
}
.pack-option:hover { border-color: var(--brand); }
.pack-option.selected { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.pack-name { font-weight: 600; }
.pack-desc { color: var(--muted); font-size: 0.82rem; }
.pack-preview { border-top: 1px solid var(--border, #e3e8e5); padding-top: 0.8rem; }
.pack-preview h4 { margin: 0 0 0.5rem; font-size: 0.9rem; }
.pack-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.pack-items li { display: flex; flex-direction: column; gap: 0.1rem; }
.pack-item-title { font-weight: 600; font-size: 0.9rem; }
.pack-item-cadence { color: var(--muted); font-size: 0.8rem; }
.pack-item-first { color: var(--brand-dark); font-size: 0.78rem; }
.pack-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.pack-actions button { width: auto; }

/* ── Client Comms tab (ADR 0084) ───────────────────────────────────────── */
.comms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.comms-card {
    border: 1px solid var(--border, #e3e8e5); border-radius: 11px;
    padding: 1rem 1.1rem; background: var(--surface, #fff);
    display: flex; flex-direction: column; gap: 0.6rem;
}
.comms-card h3 { margin: 0 0 0.2rem; font-size: 0.95rem; }
.comms-hint { font-size: 0.82rem; margin: 0; }
.comms-history { grid-column: 1 / -1; }
.comms-optout { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; cursor: pointer; }
.comms-optout input { width: auto; margin: 0; }
.comms-actions { display: flex; justify-content: flex-end; }
.comms-actions button { width: auto; }
/* "Draft with AI" control above the message box. */
.comms-ai-draft {
    display: flex; align-items: flex-end; gap: 0.6rem;
    padding: 0.6rem 0.7rem; margin-bottom: 0.2rem;
    background: var(--background, #f4f7f5); border-radius: 9px;
}
.comms-ai-draft > :first-child { flex: 1; margin: 0; }
.comms-ai-draft button { width: auto; white-space: nowrap; }
@media (max-width: 720px) { .comms-grid { grid-template-columns: 1fr; } }

/* ── Compliance calendar parity bits ───────────────────────────────────── */
.overdue-banner {
    display: block; width: 100%; text-align: left; margin: 0 0 0.8rem;
    padding: 0.55rem 0.9rem; border: 1px solid #f1d9b6; border-radius: 9px;
    background: #fdf0e3; color: #9a5a00; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.overdue-banner:hover { filter: brightness(0.98); }
.cal-recur { color: var(--brand); font-weight: 700; text-align: center; }
.when { white-space: nowrap; font-size: 0.82rem; }
.cal-more { font-size: 0.68rem; color: var(--muted); margin-top: 0.1rem; }
/* Compact per-row action buttons — wrap rather than overflow the table. */
.deadline-actions { display: flex; flex-wrap: wrap; gap: 0.2rem; justify-content: flex-end; max-width: 16rem; }
.deadline-actions .row-edit { padding: 0.12rem 0.4rem; margin: 0; font-size: 0.74rem; }
.client-table .due { white-space: nowrap; }
.quick-resched { display: flex; gap: 0.4rem; }
.quick-resched .row-edit { width: auto; }
.btn-destructive { background: var(--danger, #b3372f); }

/* ── Calendar month grid ───────────────────────────────────────────────── */
.cal-nav { display: flex; align-items: center; gap: 0.3rem; }
.cal-step { width: auto; padding: 0.3rem 0.6rem; }
.cal-month-label { font-weight: 600; min-width: 140px; text-align: center; font-size: 0.92rem; }
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
    background: var(--border); border: 1px solid var(--border); border-radius: 8px;
    overflow: hidden; margin: 0 1.5rem 1rem;
}
.cal-dow {
    background: var(--surface); padding: 0.4rem; text-align: center;
    font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.cal-cell { background: var(--surface); min-height: 92px; padding: 0.35rem; overflow: hidden; }
.cal-cell.other { background: #fafbfc; }
.cal-cell.other .cal-date { color: var(--border); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-date { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.cal-event {
    margin-top: 0.25rem; padding: 0.12rem 0.4rem; border-radius: 5px;
    font-size: 0.72rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: rgba(46,139,87,0.12); color: var(--brand);
}
.cal-event.overdue { background: rgba(179,55,47,0.12); color: var(--danger); }
.cal-event.done { background: var(--background); color: var(--muted); text-decoration: line-through; }

/* ── Client workspace ──────────────────────────────────────────────────── */
.workspace-head { align-items: center; }
.ws-back { width: auto; padding: 0.3rem 0.7rem; margin-bottom: 0.45rem; font-size: 0.84rem; }
.workspace-body { padding: 1.3rem 1.5rem; }
.ws-overview { max-width: 560px; margin: 0; }
.tx-head { display: flex; align-items: center; gap: 0.9rem; padding: 0 1.5rem 0.6rem; }
.tx-title { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.tx-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.tx-export-select { max-width: 11rem; }
.tx-delete { color: var(--danger); }
.client-table .num, .client-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tx-credit { color: var(--brand); font-weight: 600; }
.tx-debit { color: var(--text); }
.tx-desc { font-weight: 500; }

/* Side-by-side statement review (PDF + transactions) */
.stmt-split { display: flex; gap: 1rem; padding: 0 1.5rem 1rem; height: calc(100vh - 270px); min-height: 360px; }
.pdf-pane { flex: 1.05; overflow-y: auto; background: #eef1f4; border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem; }
.pdf-page { display: block; margin: 0 auto 0.6rem; max-width: 100%; box-shadow: 0 1px 5px rgba(0,0,0,0.18); border-radius: 2px; }
.pdf-loading { padding: 1.4rem; color: var(--muted); text-align: center; }
.ws-docs-bar { padding: 0 1.5rem 0.8rem; display: flex; align-items: center; gap: 0.8rem; }
.ws-upload-err { color: var(--danger); font-size: 0.85rem; }
.tx-pane { flex: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.tx-pane .client-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.tx-pane .client-table tbody td { padding: 0.45rem 0.9rem; font-size: 0.86rem; }
/* Editable category cell + learned-suggestion chip */
.tx-cat { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.tx-cat-input { min-width: 8rem; padding: 0.2rem 0.45rem; font-size: 0.82rem; }
.tx-suggest {
    border: 1px dashed var(--brand); color: var(--brand-dark); background: rgba(46,139,87,0.08);
    border-radius: 999px; padding: 0.1rem 0.55rem; font-size: 0.78rem; cursor: pointer; white-space: nowrap;
}
.tx-suggest:hover { background: rgba(46,139,87,0.16); }
@media (max-width: 720px) { .stmt-split { flex-direction: column; height: auto; } }

/* ── Settings ──────────────────────────────────────────────────────────── */
.settings-stack { display: flex; flex-direction: column; gap: 1.2rem; padding: 1.3rem 1.5rem; max-width: 620px; }
.settings-card { padding: 1.2rem 1.3rem; border: 1px solid var(--border); border-radius: 12px; }
.settings-card h2 { margin: 0 0 0.3rem; font-size: 1.05rem; }
.settings-help { margin: 0 0 0.9rem; font-size: 0.86rem; color: var(--muted); line-height: 1.5; }
.toggle-row { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; cursor: pointer; }
.toggle-row input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }

/* ── Accessibility: sr-only + visible focus ────────────────────────────── */
.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;
}
/* A visible focus ring for keyboard users on every interactive surface. */
.btn-primary:focus-visible, .btn-ghost:focus-visible, .row-edit:focus-visible,
.nav-item:focus-visible, .pane-doc:focus-visible, .scope-clear:focus-visible,
.drawer-close:focus-visible, .auth-tab:focus-visible,
.client-table tbody tr:focus-visible {
    outline: 2px solid var(--brand); outline-offset: 2px;
}
.client-table tbody tr:focus-visible { outline-offset: -2px; }
.pane-body { overflow-x: auto; } /* wide tables scroll rather than overflow the pane */

/* ── Responsive (PWA on a phone) ───────────────────────────────────────── */
@media (max-width: 720px) {
    .shell-bar { flex-wrap: wrap; gap: 0.5rem; padding: 0.7rem 1rem; }
    .scope-chip { margin-left: 0; order: 3; }
    .shell-main { flex-direction: column; }
    .nav-rail {
        width: 100%; display: flex; gap: 0.3rem; overflow-x: auto;
        border-right: none; border-bottom: 1px solid var(--border); padding: 0.5rem 0.7rem;
    }
    .nav-section-label { display: none; }
    .nav-item { width: auto; white-space: nowrap; margin: 0; }
    .shell-content { padding: 1rem; }
    .pane-head { flex-direction: column; align-items: stretch; gap: 0.6rem; }
    .pane-toolbar-row { flex-wrap: wrap; }
    .pane-search { width: 100%; }
    .drawer-panel { max-width: 100%; }
}

/* ── Boot / loading ────────────────────────────────────────────────────── */
.boot-text, .auth-tagline { color: var(--muted); }
.boot-screen { flex-direction: column; gap: 0.6rem; }

/* ── Blazor framework bits (kept, recoloured) ──────────────────────────── */
.loading-progress {
    position: relative; display: block;
    width: 8rem; height: 8rem; margin: 20vh auto 1rem auto;
}
.loading-progress circle {
    fill: none; stroke: #e0e0e0; stroke-width: 0.6rem;
    transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--brand);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute; text-align: center; font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: var(--danger); padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Billing — disbursement quick-add row + status-filter select. */
.disb-add { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; }
.disb-add .control { flex: 1; min-width: 8rem; }
.disb-add .disb-amount { flex: 0 0 7rem; }
.disb-add .disb-date { flex: 0 0 9.5rem; }
.disb-add button { width: auto; }
.billing-filter { width: auto; min-width: 11rem; }
.billing-ref { font-size: 0.8rem; margin-left: 0.3rem; }
