/* ADP Invest — design tokens from branding guidelines */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

[hidden],
.hidden {
    display: none !important;
}

:root,
[data-theme="light"] {
    /* Brand palette */
    --adp-deep-navy: #0B1D3A;
    --adp-primary-blue: #2563EB;
    --adp-sky-blue: #60A5FA;
    --adp-teal: #14B8A6;
    --adp-soft-mint: #E6F7F4;
    --adp-light-gray: #F2F4F7;
    --adp-slate: #64748B;
    --adp-white: #FFFFFF;
    --adp-border: #E2E8F0;
    --adp-input-border: #CBD5E1;
    --adp-warning: #D97706;
    --adp-warning-bg: #FEF3C7;
    --adp-danger: #DC2626;

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

    /* Type scale */
    --text-h1-size: 40px;
    --text-h1-line: 48px;
    --text-h2-size: 24px;
    --text-h2-line: 32px;
    --text-h3-size: 20px;
    --text-h3-line: 28px;
    --text-body-size: 16px;
    --text-body-line: 24px;
    --text-small-size: 14px;
    --text-small-line: 20px;

    /* Chart sequence */
    --chart-1: var(--adp-primary-blue);
    --chart-2: var(--adp-teal);
    --chart-3: var(--adp-sky-blue);
    --chart-4: var(--adp-deep-navy);
    --chart-5: var(--adp-slate);
    --chart-6: var(--adp-soft-mint);

    /* Semantic aliases */
    --header-bg: var(--adp-deep-navy);
    --header-height: 85px;
    --chrome-footer-height: 60px;
    --chrome-footer-padding-x: 12px;
    --sidebar-width: 240px;
    --sidebar-width-collapsed: 56px;
    --sidebar-brand-width: 240px;
    --list-panel-width: 300px;
    --primary: var(--adp-primary-blue);
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --danger: var(--adp-danger);
    --success: var(--adp-teal);
    --text: var(--adp-deep-navy);
    --text-muted: var(--adp-slate);
    --border: var(--adp-border);
    --bg-page: var(--adp-light-gray);
    --bg-white: var(--adp-white);
    --bg-hover: #F8FAFC;
    --bg-subtle: var(--adp-light-gray);
    --input-bg: var(--adp-white);
    --topbar-search-bg: rgba(255, 255, 255, 0.12);
    --topbar-search-border: rgba(255, 255, 255, 0.2);
    --topbar-fg: #ffffff;
    --radius: 8px;
    --radius-card: 12px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 3px rgba(11, 29, 58, 0.06);
    --shadow-dropdown: 0 8px 24px rgba(11, 29, 58, 0.12);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --badge-green-bg: var(--adp-soft-mint);
    --badge-green-fg: #0F766E;
    --badge-blue-bg: var(--primary-light);
    --badge-blue-fg: #1E40AF;
    --badge-purple-bg: #ede9fe;
    --badge-purple-fg: #5b21b6;
    --badge-cyan-bg: var(--adp-soft-mint);
    --badge-cyan-fg: #0F766E;
    --badge-orange-bg: var(--adp-warning-bg);
    --badge-orange-fg: #92400E;
    --badge-red-bg: #FEE2E2;
    --badge-red-fg: #B91C1C;
    --badge-grey-bg: var(--adp-light-gray);
    --badge-grey-fg: var(--adp-slate);
    --alert-danger-bg: #FEF2F2;
    --alert-danger-fg: #991B1B;
    --alert-danger-border: #FECACA;
    --alert-success-bg: var(--adp-soft-mint);
    --alert-success-fg: #0F766E;
    --alert-success-border: #99F6E4;
    --alert-info-bg: var(--primary-light);
    --alert-info-fg: #1E40AF;
    --alert-info-border: #BFDBFE;
    --danger-hover-bg: #FEF2F2;
    --outline-danger-hover: #FEF2F2;
    --comm-btn-border: var(--adp-input-border);
    --comm-btn-fg: var(--adp-slate);
    --overlay-backdrop: rgba(11, 29, 58, 0.88);
    --focus-ring: rgba(37, 99, 235, 0.2);
    color-scheme: light;
}

[data-theme="dark"] {
    --header-bg: #0d1117;
    --primary: #58a6ff;
    --primary-dark: #79b8ff;
    --primary-light: #1c2d4a;
    --danger: #f85149;
    --success: #3fb950;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --border: #30363d;
    --bg-page: #0d1117;
    --bg-white: #161b22;
    --bg-hover: #21262d;
    --bg-subtle: #1c2128;
    --input-bg: #0d1117;
    --topbar-search-bg: #21262d;
    --topbar-search-border: #30363d;
    --topbar-fg: #e6edf3;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, 0.45);
    --badge-green-bg: #1a3d2a;
    --badge-green-fg: #7ee787;
    --badge-blue-bg: #1a2f4d;
    --badge-blue-fg: #79c0ff;
    --badge-purple-bg: #2d2450;
    --badge-purple-fg: #d2a8ff;
    --badge-cyan-bg: #1a3333;
    --badge-cyan-fg: #56d4dd;
    --badge-orange-bg: #3d2a14;
    --badge-orange-fg: #ffa657;
    --badge-red-bg: #3d1f1f;
    --badge-red-fg: #ff7b72;
    --badge-grey-bg: #30363d;
    --badge-grey-fg: #8b949e;
    --alert-danger-bg: #3d1f1f;
    --alert-danger-fg: #ff7b72;
    --alert-danger-border: #6e3030;
    --alert-success-bg: #1a3d2a;
    --alert-success-fg: #7ee787;
    --alert-success-border: #2a4d3a;
    --alert-info-bg: #1a2f4d;
    --alert-info-fg: #79c0ff;
    --alert-info-border: #304d6e;
    --danger-hover-bg: #3d1f1f;
    --outline-danger-hover: #3d1f1f;
    --comm-btn-border: #484f58;
    --comm-btn-fg: #8b949e;
    --overlay-backdrop: rgba(0, 0, 0, 0.75);
    --focus-ring: rgba(88, 166, 255, 0.25);
    color-scheme: dark;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* —— App shell —— */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.topbar {
    height: var(--header-height);
    background: var(--header-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 0 0;
    flex-shrink: 0;
}
.topbar-logo,
.site-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 0;
    text-decoration: none;
    line-height: 0;
    box-sizing: border-box;
}
.topbar > .topbar-logo,
.topbar > .site-logo {
    width: var(--sidebar-brand-width);
    flex-shrink: 0;
    align-self: stretch;
}
.topbar-logo:hover,
.site-logo:hover { opacity: 0.9; }
.topbar-logo img,
.site-logo img {
    height: 69px;
    width: auto;
    max-width: 100%;
    display: block;
    object-fit: contain;
}

/* Login / standalone site-logo sizes stay independent of topbar */
.site-logo--login {
    justify-content: center;
    margin: 0 auto 20px;
    width: 100%;
}
.site-logo--login:not(.site-logo--login-mark) img {
    height: 44px;
    max-width: 100%;
}
/* Main sign-in page only — full OG wordmark (login-logo.png) inside login card */
.site-logo--login.site-logo--login-mark {
    margin: 0 auto 24px;
    width: 100%;
}
.site-logo--login.site-logo--login-mark img {
    height: auto;
    width: 100%;
    max-width: 100%;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    padding-right: 0;
}
.topbar-icon-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    color: rgba(255,255,255,0.85);
    background: transparent;
    border: none;
    cursor: pointer;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.1); }

.notifications-wrap { position: relative; }
.notifications-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border-radius: 999px;
    background: var(--danger, #dc2626);
    color: #fff;
}
.notifications-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.12));
    z-index: 200;
}
.notifications-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.notifications-list { list-style: none; margin: 0; padding: 0; }
.notifications-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.notifications-item.is-read { opacity: 0.65; }
.notifications-item-title a { color: var(--text); font-weight: 600; text-decoration: none; }
.notifications-item-body { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.notifications-item-time { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

.workflow-start-wrap { position: relative; display: inline-block; margin-left: 8px; }
.workflow-start-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    padding: 6px 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    z-index: 5000;
    color: var(--text);
}
.workflow-start-menu[hidden] {
    display: none !important;
}
.workflow-start-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
}
.workflow-start-item:hover { background: var(--bg-hover); }

/* Header global search */
.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}
.topbar-search-panel {
    display: none;
    flex-direction: column;
    position: relative;
    min-width: 0;
}
.topbar-search.is-open .topbar-search-panel {
    display: flex;
}
.topbar-search-input-wrap {
    position: relative;
}
.topbar-search-input {
    width: min(360px, calc(100vw - 200px));
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--topbar-search-border);
    border-radius: var(--radius);
    background: var(--topbar-search-bg);
    color: var(--topbar-fg);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.topbar-search-input::placeholder {
    color: rgba(255, 255, 255, 0.55);
}
[data-theme="dark"] .topbar-search-input::placeholder {
    color: var(--text-muted);
}
.topbar-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--focus-ring);
}
.topbar-search-input-wrap::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.65;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ffffff'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}
[data-theme="dark"] .topbar-search-input-wrap::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238b949e'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
}
.global-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 100%;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    max-height: 360px;
    overflow-y: auto;
    z-index: 2000;
}
.global-search-result {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border);
}
.global-search-result:last-child {
    border-bottom: none;
}
.global-search-result:hover,
.global-search-result:focus {
    background: var(--bg-hover);
    outline: none;
}
.global-search-result-title {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    line-height: 1.35;
}
.global-search-result-sub {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}
.global-search-empty {
    margin: 0;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Theme toggle icons */
.theme-icon {
    display: block;
}
[data-theme="light"] .theme-icon-moon,
[data-theme="dark"] .theme-icon-sun {
    display: none;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255,255,255,0.95);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: rgba(255,255,255,0.08);
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #4ade80;
}
.user-menu-wrap {
    position: relative;
    flex-shrink: 0;
}
.topbar-avatar,
.user-menu-trigger {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b8cce, #4a6fa5);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.user-menu-trigger:hover,
.user-menu-wrap.is-open .user-menu-trigger {
    opacity: 0.95;
    transform: scale(1.04);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.user-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: #ffffff;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    z-index: 210;
    overflow: hidden;
}
.user-menu-panel[hidden] {
    display: none !important;
}
.user-menu-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #ffffff;
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.user-menu-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-menu-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-menu-actions {
    padding: 6px 0;
    background: #ffffff;
    background: var(--bg-white);
}
.user-menu-logout-form {
    margin: 0;
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 0;
    font-size: 14px;
    font-weight: 400;
    font-family: inherit;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    box-sizing: border-box;
    line-height: 1.35;
    transition: background 0.12s ease;
}
.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: var(--bg-hover);
    outline: none;
}
.user-menu-item__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.user-menu-item:hover .user-menu-item__icon,
.user-menu-item:focus-visible .user-menu-item__icon {
    color: var(--text);
}
.user-menu-item__icon svg {
    width: 18px;
    height: 18px;
}
.user-menu-item--button {
    font-family: inherit;
}

.shell-body {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.mobile-nav-toggle {
    display: none;
}

.mobile-nav-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .mobile-nav-toggle {
        display: inline-flex;
        margin-left: 8px;
        margin-right: 4px;
        flex-shrink: 0;
    }

    .topbar > .topbar-logo,
    .topbar > .site-logo {
        width: auto;
        max-width: min(var(--sidebar-brand-width), calc(100vw - 140px));
        padding-left: 8px;
        padding-right: 8px;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }

    .sidebar.is-mobile-open {
        transform: translateX(0);
        box-shadow: var(--shadow-dropdown);
    }

    html.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: var(--header-height) 0 0 0;
        background: var(--overlay-backdrop);
        z-index: 35;
    }

    .mobile-nav-backdrop[hidden] {
        display: none !important;
    }

    .shell-body {
        display: block;
        overflow: auto;
    }
}

/* Main column beside sidebar — scrolls independently of the nav */
.shell-body > .entity-list-page,
.shell-body > .entity-detail-page,
.shell-body > .entity-form-page,
.shell-body > .page-content {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-width: none;
}

/* Main navigation sidebar */
html.sidebar-collapsed {
    --sidebar-width: var(--sidebar-width-collapsed);
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    transition: width 0.2s ease;
}
.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 10px 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-page);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    width: calc(100% - 20px);
}
.sidebar-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: transparent;
}
.sidebar-toggle svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
html.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-footer {
    height: var(--chrome-footer-height);
    padding: 0 var(--chrome-footer-padding-x);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}
.sidebar-footer .sidebar-logout-form {
    width: 100%;
}
.sidebar-footer .sidebar-logout {
    padding: 8px 12px;
}
.sidebar-logout-form { margin: 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    line-height: 1.3;
    white-space: nowrap;
}
.sidebar-link > span:not(:first-child),
.sidebar-group-label > span:last-child,
.sidebar-toggle-label {
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.sidebar-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.sidebar-link:hover svg { color: var(--primary); }
.sidebar-link.active {
    background: var(--primary-light);
    color: var(--primary);
}
.sidebar-link.active svg { color: var(--primary); }
.sidebar-sublink {
    padding-left: 12px;
    font-weight: 400;
}
.sidebar-group {
    margin: 8px 0 4px;
}
.sidebar-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.sidebar-group-label svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.sidebar-group.is-active .sidebar-group-label {
    color: var(--primary);
}
.sidebar-group.is-active .sidebar-group-label svg {
    color: var(--primary);
}

/* Admin nested submenu (Settings, Config) — match sidebar-sublink styling */
.sidebar-submenu {
    margin: 0;
}
.sidebar-submenu > summary {
    list-style: none;
}
.sidebar-submenu > summary::-webkit-details-marker,
.sidebar-submenu > summary::marker {
    display: none;
    content: '';
}
.sidebar-submenu__chevron {
    margin-left: auto;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
    transition: transform 0.15s ease;
}
.sidebar-submenu__chevron svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}
.sidebar-submenu[open] > .sidebar-submenu__summary .sidebar-submenu__chevron {
    transform: rotate(180deg);
}
.sidebar-submenu.is-active > .sidebar-submenu__summary {
    background: var(--primary-light);
    color: var(--primary);
}
.sidebar-submenu.is-active > .sidebar-submenu__summary svg,
.sidebar-submenu.is-active > .sidebar-submenu__summary .sidebar-submenu__chevron svg {
    color: var(--primary);
}
.sidebar-submenu--nested > .sidebar-submenu__summary,
.sidebar-submenu--nested > a.sidebar-sublink {
    padding-left: 24px;
}
.sidebar-logout {
    color: var(--text-muted);
}
.sidebar-logout:hover {
    color: var(--danger);
    background: var(--danger-hover-bg);
}
.sidebar-logout:hover svg { color: var(--danger); }

/* Collapsed sidebar */
html.sidebar-collapsed .sidebar-toggle {
    justify-content: center;
    padding: 8px;
}
html.sidebar-collapsed .sidebar-toggle-label,
html.sidebar-collapsed .sidebar-link > span,
html.sidebar-collapsed .sidebar-group-label > span:last-child {
    display: none;
}
html.sidebar-collapsed .sidebar-group-label {
    justify-content: center;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
html.sidebar-collapsed .sidebar-group-label svg {
    width: 18px;
    height: 18px;
}
html.sidebar-collapsed .sidebar-sublink {
    padding-left: 9px;
    justify-content: center;
}
html.sidebar-collapsed .sidebar-submenu > .sidebar-submenu__summary {
    justify-content: center;
}
html.sidebar-collapsed .sidebar-submenu > .sidebar-submenu__summary > span:not(.sidebar-submenu__chevron),
html.sidebar-collapsed .sidebar-submenu__chevron,
html.sidebar-collapsed .sidebar-submenu .sidebar-sublink:not(.sidebar-submenu__summary) {
    display: none;
}
html.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 9px;
}
html.sidebar-collapsed .sidebar-group {
    margin: 4px 0;
}

.workspace {
    flex: 1;
    display: flex;
    min-width: 0;
    background: var(--bg-page);
}

/* Split: list + detail (legacy sidebar layout) */
.workspace-split {
    display: flex;
    flex: 1;
    min-width: 0;
    height: calc(100vh - var(--header-height));
}

/* Full-page entity list (index) */
.entity-list-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-white);
}

.list-panel {
    width: var(--list-panel-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.list-panel--full {
    width: 100%;
    max-width: 100%;
    border-right: none;
    flex: 1;
    min-height: 0;
}

.entity-list-page .list-panel-header {
    padding: 20px 32px 12px;
}

.list-panel-toolbar {
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.entity-list-page .list-panel-toolbar .search-box {
    margin: 12px 32px 0;
    max-width: none;
}

.entity-list-page .list-panel-toolbar .filter-chips {
    padding: 8px 32px 12px;
}

/* Searchable client list embedded in entity detail tabs */
.entity-embedded-list {
    display: flex;
    flex-direction: column;
    min-height: 420px;
    max-height: calc(100vh - var(--header-height) - 260px);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.entity-embedded-list .list-panel--full {
    flex: 1;
    min-height: 0;
}
.entity-embedded-list .list-panel-header {
    padding: 16px 20px 8px;
}
.entity-embedded-list .list-panel-toolbar .search-box {
    margin: 8px 20px 0;
    max-width: none;
}
.entity-embedded-list .list-panel-toolbar .filter-chips {
    padding: 8px 20px 12px;
}
.entity-embedded-list .list-row-head {
    padding-left: 20px;
    padding-right: 20px;
}

.list-panel-toolbar .filter-chips {
    padding: 8px 16px 12px;
}

.list-empty-msg {
    padding: 24px 16px;
    color: var(--text-muted);
    margin: 0;
}

/* Full-page entity detail (show) */
.entity-detail-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.detail-panel--full {
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-height: 0;
}

.entity-detail-page .detail-top {
    padding-left: 32px;
    padding-right: 32px;
}

.entity-detail-page .detail-body {
    padding: 24px 32px;
}

.entity-detail-page .detail-footer {
    padding-left: 32px;
    padding-right: 32px;
}

.entity-detail-page .stat-cards {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.entity-detail-page .data-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.entity-detail-page .card .table {
    display: table;
    width: 100%;
}

/* Full-page create / edit forms */
.entity-form-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    padding: 24px 32px;
    overflow-y: auto;
    background: var(--bg-page);
    box-sizing: border-box;
}

.entity-form-page .investor-form,
.entity-form-page .form-section,
.entity-form-page > .card {
    max-width: none;
    width: 100%;
}

.investment-kind-card {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--primary-light);
}

/* Investment create / edit form — consistent field alignment */
.investment-form .form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    align-items: start;
}
.investment-form .form-row--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.investment-form .form-row--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.investment-form .form-row .form-group,
.investment-form .form-row .data-field {
    margin-bottom: 0;
    min-width: 0;
}
.investment-form .form-group--full {
    grid-column: 1 / -1;
}
.investment-form .form-row--calc {
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.investment-form .data-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}
.investment-form .data-field p {
    margin: 0;
    font-weight: 500;
}
.investment-investor-row {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(130px, 1fr) minmax(100px, 110px) auto;
    gap: 12px 16px;
    align-items: end;
    margin-bottom: 12px;
}
.investment-investor-row .form-group {
    margin-bottom: 0;
    min-width: 0;
}
.investment-investor-row [data-remove-investor-row] {
    align-self: end;
    margin-bottom: 2px;
}
@media (max-width: 900px) {
    .investment-form .form-row--3,
    .investment-form .form-row--4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .investment-investor-row {
        grid-template-columns: 1fr 1fr;
    }
    .investment-investor-row__investor {
        grid-column: 1 / -1;
    }
}
@media (max-width: 640px) {
    .investment-form .form-row,
    .investment-form .form-row--3,
    .investment-form .form-row--4,
    .investment-investor-row {
        grid-template-columns: 1fr;
    }
    .investment-investor-row [data-remove-investor-row] {
        justify-self: start;
    }
}

/* Searchable investor picker */
.investor-picker {
    position: relative;
    width: 100%;
}
.investor-picker-input-wrap {
    position: relative;
}
.investor-picker-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}
.investor-picker-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
.investor-picker-input-wrap::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.45;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7c93'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.investor-picker--has-value:not(:focus-within) .investor-picker-input-wrap::before {
    opacity: 0;
    width: 0;
}
.investor-picker--has-value:not(:focus-within) .investor-picker-input {
    padding-left: 12px;
}
.investor-picker-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1500;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    max-height: 240px;
    overflow-y: auto;
}
.investor-picker-option {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.investor-picker-option:last-child {
    border-bottom: none;
}
.investor-picker-option:hover,
.investor-picker-option:focus {
    background: var(--bg-hover);
    outline: none;
}
.investor-picker-option-title {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.investor-picker-option-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.investor-picker-empty {
    padding: 12px 14px;
    color: var(--text-muted);
    font-size: 13px;
}
.list-panel-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.list-panel-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}
.list-panel-meta {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}
.list-panel-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.btn-add {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.search-box {
    margin: 12px 16px;
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}
.search-box::before {
    content: '';
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    opacity: 0.4;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7c93'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    align-items: center;
}
.chip {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text-muted);
    cursor: pointer;
    pointer-events: auto;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.2;
}
button.chip {
    appearance: none;
    -webkit-appearance: none;
}
button.chip:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.chip.active, a.chip.active, button.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.list-scroll {
    flex: 1;
    overflow-y: auto;
}
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
}
.list-item--rich {
    padding: 0;
    gap: 0;
    cursor: pointer;
}
.list-item--rich .list-item-actions {
    cursor: default;
}
.list-item--rich.active {
    background: var(--primary-light);
    border-left-color: var(--primary);
}
.list-item-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 8px 14px 16px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}
.list-item-main:hover {
    background: var(--bg-hover);
}
.list-item--rich.active .list-item-main {
    background: transparent;
}
.list-item-body {
    flex: 1;
    min-width: 0;
}
.list-row-head {
    display: grid;
    grid-template-columns: 40px minmax(180px, 1.5fr) minmax(150px, 1fr) minmax(200px, 1.2fr) auto;
    gap: 12px 20px;
    align-items: center;
    padding: 8px 0 8px 32px;
    margin-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-page);
}
.list-row-head-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.list-row-head-label--name {
    padding-left: 0;
}
.list-row-head-spacer {
    width: 40px;
}
.list-row-head-spacer--actions {
    width: 120px;
}
.list-item--spread .list-item-main--spread {
    flex: 1;
    display: grid;
    grid-template-columns: 40px minmax(180px, 1.5fr) minmax(150px, 1fr) minmax(200px, 1.2fr);
    gap: 12px 20px;
    align-items: center;
    padding: 14px 8px 14px 32px;
    min-width: 0;
}
.list-item-avatar-link {
    display: flex;
    text-decoration: none;
    color: inherit;
}
.list-item-col--identity {
    text-decoration: none;
    color: inherit;
}
.list-item-col--identity:hover .list-item-name {
    color: var(--primary);
}
.list-item-col--identity {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.list-item-col--field {
    min-width: 0;
    display: flex;
    align-items: center;
}
.list-item-field-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}
.list-item-field-value--link {
    color: var(--primary);
}
.list-item-field-value--link:hover {
    text-decoration: underline;
}
.list-item-field-value--empty {
    color: var(--text-muted);
    font-weight: 400;
}
.list-item--spread .list-item-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item--spread .list-item-sub {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-grid--applications {
    grid-template-columns:
        72px
        minmax(200px, 1.8fr)
        minmax(120px, 1fr)
        minmax(150px, 1.1fr)
        minmax(120px, 0.9fr)
        minmax(100px, 0.8fr);
}
.list-row-head--columns.list-grid--applications {
    grid-template-columns:
        72px
        minmax(200px, 1.8fr)
        minmax(120px, 1fr)
        minmax(150px, 1.1fr)
        minmax(120px, 0.9fr)
        minmax(100px, 0.8fr)
        52px;
    padding: 8px 16px 8px 16px;
    gap: 12px 16px;
}
.list-grid--investments {
    grid-template-columns:
        72px
        minmax(150px, 1.3fr)
        minmax(100px, 0.9fr)
        minmax(95px, 0.8fr)
        minmax(72px, 0.65fr)
        minmax(64px, 0.55fr)
        minmax(88px, 0.75fr)
        minmax(76px, 0.7fr)
        minmax(100px, 0.85fr);
}
.list-row-head--columns.list-grid--investments {
    grid-template-columns:
        72px
        minmax(150px, 1.3fr)
        minmax(100px, 0.9fr)
        minmax(95px, 0.8fr)
        minmax(72px, 0.65fr)
        minmax(64px, 0.55fr)
        minmax(88px, 0.75fr)
        minmax(76px, 0.7fr)
        minmax(100px, 0.85fr)
        52px;
    padding: 8px 16px 8px 16px;
    gap: 12px 16px;
}
.list-item--columns .list-item-main--columns {
    flex: 1;
    display: grid;
    gap: 12px 16px;
    align-items: center;
    padding: 12px 8px 12px 16px;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.list-item--columns .list-item-col--data {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    justify-content: center;
}
.list-item--columns .list-item-col--data .badge {
    align-self: flex-start;
}
.list-item--columns .list-item-meta {
    font-size: 12px;
    color: var(--text-muted);
}
.list-item--columns .list-item-actions {
    padding-right: 12px;
}
.list-item--spread .list-item-meta {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item-meta {
    font-size: 13px;
    color: var(--text);
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item-actions {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    border-left: 1px solid var(--border);
}
.list-item-action-btn {
    width: 40px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: none;
    background: transparent;
    border-left: 1px solid var(--border);
    text-decoration: none;
    padding: 0;
    cursor: pointer;
}
.list-item-actions .list-item-action-btn:first-child {
    border-left: none;
}
.list-item-action-btn:hover {
    color: var(--primary);
    background: var(--bg-hover);
}
.list-item-action-btn svg {
    width: 18px;
    height: 18px;
}
.list-item-action-btn--view {
    color: var(--text-muted);
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active {
    background: var(--primary-light);
    border-left-color: var(--primary);
}
.table--context-menu tbody tr[data-list-row] {
    cursor: context-menu;
}
.table-actions-col {
    width: 52px;
    text-align: center;
    white-space: nowrap;
}
.table-row-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}
.table-kebab-btn {
    color: #666;
}
.table-kebab-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}
.table-kebab-btn svg {
    width: 20px;
    height: 20px;
}
.table-row-actions .list-item-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}
.table-row-actions .list-item-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.table-row-actions .list-item-action-btn svg {
    width: 18px;
    height: 18px;
}

.list-context-menu {
    position: fixed;
    z-index: 5000;
    min-width: 200px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    padding: 6px 0;
}
.list-context-menu[hidden],
.list-context-menu-item[hidden],
.list-context-menu-sep[hidden] {
    display: none !important;
}
.list-context-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
}
.list-context-menu-item:hover {
    background: var(--bg-hover);
}
.list-context-menu-item--danger {
    color: var(--danger);
}
.list-context-menu-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 6px 0;
}
.list-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.list-item-name { font-weight: 600; font-size: 14px; margin: 0; }
.list-item-sub { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }

.detail-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
}
.detail-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}

/* Detail header (Figma client view) */
.detail-top {
    padding: 16px 24px 0;
    background: var(--bg-white);
}
.detail-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.detail-top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.back-link {
    color: var(--primary);
    font-weight: 500;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
}
button.back-link {
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.back-link:hover,
button.back-link:hover {
    color: var(--primary-dark);
}
.edit-link {
    color: var(--primary);
    font-weight: 500;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.edit-link svg { width: 14px; height: 14px; }
.edit-link:hover { color: var(--primary-dark); }

.investment-chain-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin: 0 24px 16px;
    padding: 12px 16px;
    background: var(--bg-subtle, #f6f7f9);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 8px;
}
.investment-chain-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-width: 0;
}
.investment-chain-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6b7280);
}
.investment-chain-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.investment-chain-link {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-white, #fff);
    border: 1px solid var(--border-light, #e5e7eb);
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
}
.investment-chain-link:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}
.investment-chain-link-meta {
    font-weight: 400;
    color: var(--text-muted, #6b7280);
    font-size: 12px;
}

.detail-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.detail-hero-text {
    flex: 1;
    min-width: 200px;
}
.detail-title-row {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
}
.detail-title {
    color: var(--text);
}
.detail-title-sep {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 20px;
}
.detail-reference {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-muted);
}
.detail-reference strong {
    color: var(--text);
    font-weight: 700;
}
.detail-meta-line {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.detail-meta-line strong {
    color: var(--text);
    font-weight: 600;
}
.detail-header-extra {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.comm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}
.comm-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--comm-btn-border);
    background: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--comm-btn-fg);
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.comm-btn svg {
    width: 20px;
    height: 20px;
}
.comm-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.comm-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.detail-tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    list-style: none;
    margin: 0;
}
.detail-tabs li { margin: 0; }
.detail-tabs a {
    display: block;
    padding: 14px 20px;
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.detail-tabs a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.detail-tabs .tab-alert::after {
    content: '◆';
    color: var(--danger);
    font-size: 8px;
    margin-left: 4px;
    vertical-align: super;
}
.detail-tabs a.tab-badge {
    position: relative;
}
.detail-tabs .tab-badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

.detail-body { padding: 24px; flex: 1; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}
.badge-client, .badge-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.badge-lead, .badge-blue { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }
.badge-prospect, .badge-purple { background: var(--badge-purple-bg); color: var(--badge-purple-fg); }
.badge-cyan { background: var(--badge-cyan-bg); color: var(--badge-cyan-fg); }
.badge-orange { background: var(--badge-orange-bg); color: var(--badge-orange-fg); }
.badge-red { background: var(--badge-red-bg); color: var(--badge-red-fg); }
.badge-grey { background: var(--badge-grey-bg); color: var(--badge-grey-fg); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px;
    min-height: 40px;
    border-radius: var(--radius);
    border: none;
    font-size: var(--text-small-size);
    line-height: var(--text-small-line);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary {
    background: var(--bg-white);
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-page); color: var(--adp-deep-navy); }
.btn-tertiary {
    background: transparent;
    color: var(--primary);
    border: none;
    min-height: auto;
    padding: 6px 8px;
}
.btn-tertiary:hover { background: var(--primary-light); }
.btn-outline-danger,
.btn-destructive {
    background: var(--bg-white);
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-outline-danger:hover,
.btn-destructive:hover { background: var(--outline-danger-hover); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }

/* Cards & tables */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card { margin-bottom: 0; }
.stat-card .label { color: var(--text-muted); font-size: 12px; margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .value { font-size: 28px; font-weight: 700; margin: 0; }

/* Dashboard action cards */
.dashboard-action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.dashboard-action-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
}
.dashboard-action-card--blue { border-top: 4px solid #3b82f6; }
.dashboard-action-card--orange { border-top: 4px solid #1060f3; }
.dashboard-action-card--green { border-top: 4px solid #22c55e; }
.dashboard-action-card--purple { border-top: 4px solid #a855f7; }
.dashboard-action-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}
.dashboard-action-card__icon {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--surface-muted);
    color: var(--text);
}
.dashboard-action-card__icon svg { width: 22px; height: 22px; }
.dashboard-action-card__badge {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-radius: 999px;
    padding: 4px 10px;
}
.dashboard-action-card__badge--pending {
    color: #b45309;
    background: #fef3c7;
}
.dashboard-action-card__badge-count {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
}
.dashboard-action-card__badge--pending .dashboard-action-card__badge-count {
    color: #92400e;
}
.dashboard-action-card__badge-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
}
.dashboard-action-card__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}
.dashboard-action-card__description {
    margin: 0 0 8px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}
.dashboard-action-card__cta { align-self: flex-start; }
.dashboard-action-card__accordion {
    margin: 0 0 8px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}
.dashboard-action-card__accordion > summary { list-style: none; cursor: pointer; }
.dashboard-action-card__accordion > summary::-webkit-details-marker { display: none; }
.dashboard-action-card__accordion-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.dashboard-action-card__accordion-chevron svg { width: 16px; height: 16px; }
.dashboard-action-card__children {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dashboard-action-card__child-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: inherit;
    text-decoration: none;
    font-size: 13px;
}
.dashboard-action-card__child-link:hover { background: var(--border); }
.dashboard-quick-access h2,
.dashboard-my-tasks__header h2 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
}
.dashboard-quick-access__links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.dashboard-my-tasks {
    margin-top: 16px;
    padding: 0;
    overflow: hidden;
}
.dashboard-my-tasks__header {
    padding: 16px 16px 0;
}
.dashboard-my-tasks__header p {
    margin: 0 0 12px;
    color: var(--text-muted);
    font-size: 13px;
}
.dashboard-my-tasks__details {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}
.dashboard-my-tasks__empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

/* Investor compliance documents accordion */
.compliance-accordion {
    margin-top: 16px;
    margin-bottom: 0;
    padding: 0;
    overflow: hidden;
}
.compliance-accordion > summary {
    list-style: none;
}
.compliance-accordion > summary::-webkit-details-marker {
    display: none;
}
.compliance-accordion > summary::marker {
    content: '';
    display: none;
}
.compliance-accordion__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
}
.compliance-accordion__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
}
.compliance-accordion__meta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.compliance-accordion__chevron {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7c93' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
    transition: transform 0.2s ease;
}
.compliance-accordion[open] > .compliance-accordion__summary .compliance-accordion__chevron {
    transform: rotate(180deg);
}
.compliance-accordion[open] > .compliance-accordion__summary {
    border-bottom: 1px solid var(--border);
}
.compliance-accordion__body {
    padding: 16px 20px 20px;
}
.compliance-accordion__hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.compliance-accordion__body .table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.compliance-accordion__body .table {
    margin: 0;
}
.compliance-accordion__footer {
    margin: 12px 0 0;
    font-size: 13px;
}
.compliance-accordion__footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.compliance-accordion__footer a:hover {
    text-decoration: underline;
}

/* Application documents tab — accordion + split preview */
.app-doc-accordions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.app-doc-accordion {
    margin: 0;
}
.app-doc-accordion__body {
    padding: 0;
}
.app-doc-split {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.1fr);
    gap: 0;
    min-height: 420px;
}
.app-doc-split__panel {
    padding: 16px 20px 20px;
}
.app-doc-split__ai {
    border-right: 1px solid var(--border);
    background: var(--bg-subtle);
}
.app-doc-split__heading {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.app-doc-split__empty {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.app-doc-ai-section {
    margin-bottom: 16px;
}
.app-doc-ai-section__title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.app-doc-ai-dl {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(120px, 38%) 1fr;
    gap: 6px 12px;
    font-size: 13px;
}
.app-doc-ai-dl dt {
    margin: 0;
    font-weight: 600;
    color: var(--text-muted);
}
.app-doc-ai-dl dd {
    margin: 0;
    word-break: break-word;
}
.app-doc-ai-errors {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--danger);
}
.app-doc-raw-json {
    margin: 12px 0 16px;
    font-size: 12px;
}
.app-doc-raw-json summary {
    cursor: pointer;
    color: var(--text-muted);
}
.app-doc-raw-json pre {
    margin: 8px 0 0;
    max-height: 200px;
    overflow: auto;
    font-size: 11px;
    background: var(--bg-white);
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.app-doc-edit {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.app-doc-edit__title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
}
.app-doc-edit .form-group {
    margin-bottom: 10px;
}
.app-doc-edit .form-group label {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--text-muted);
}
.app-doc-edit input[type="text"],
.app-doc-edit select,
.app-doc-edit textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
}
.app-doc-preview__filename {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 500;
}
.app-doc-preview__frame-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-white);
    min-height: 480px;
}
.app-doc-preview__frame {
    display: block;
    width: 100%;
    height: 520px;
    border: none;
}
.app-doc-preview__hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.app-doc-preview__hint a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}
.app-doc-preview__hint a:hover {
    text-decoration: underline;
}
.app-doc-preview__placeholder {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
    min-height: 280px;
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-subtle);
    font-size: 13px;
    color: var(--text-muted);
}
@media (max-width: 960px) {
    .app-doc-split {
        grid-template-columns: 1fr;
    }
    .app-doc-split__ai {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .app-doc-preview__frame {
        height: 400px;
    }
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.data-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.data-field p { margin: 0; font-weight: 500; font-size: 14px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.table tbody tr:hover { background: var(--bg-hover); }

/* Activity log (Littsy-style timeline) */
.activity-log {
    padding: 20px 24px;
}
.activity-log__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.activity-log__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}
.activity-log__view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid transparent;
    font-weight: 500;
}
.activity-log__view-btn:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: rgba(43, 125, 233, 0.2);
    text-decoration: none;
}
.activity-log__view-btn-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
}
.activity-log__view-btn-icon svg {
    width: 16px;
    height: 16px;
}
.activity-log__filters {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.activity-log__filters[hidden] {
    display: none;
}
.activity-log__empty {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}
.activity-log__entries {
    position: relative;
    padding-left: 8px;
}
.activity-log__entries::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 18px;
    bottom: 18px;
    width: 0;
    border-left: 2px dashed var(--border);
}
.activity-log__item {
    display: grid;
    grid-template-columns: 32px 40px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px 0 16px;
}
.activity-log__item:last-child {
    padding-bottom: 8px;
}
.activity-log__marker {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: 2px;
}
.activity-log__marker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f0a030;
    color: #fff;
    box-shadow: 0 0 0 3px var(--bg-white);
}
.activity-log__item--alert .activity-log__marker-icon {
    background: var(--danger);
}
.activity-log__marker-icon svg {
    width: 14px;
    height: 14px;
}
.activity-log__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 0;
}
.activity-log__avatar svg {
    width: 22px;
    height: 22px;
}
.activity-log__content {
    min-width: 0;
    padding-top: 2px;
}
.activity-log__text {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 400;
    color: var(--text-muted);
}
.activity-log__details {
    margin: -4px 0 8px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
}
.activity-log__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-size: 12px;
    color: var(--text-muted);
}
.activity-log__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.activity-log__meta-icon {
    display: inline-flex;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}
.activity-log__meta-icon svg {
    width: 14px;
    height: 14px;
}
.activity-log__footer {
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.activity-log__end {
    font-size: 13px;
    color: var(--text-muted);
}

.activity-log__footer--truncated {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}
.activity-log__view-all {
    font-size: 13px;
    font-weight: 500;
}

.activity-filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.activity-filters-form .form-group {
    min-width: 180px;
}

/* Littsy-style payment details */
.payment-details-card--full {
    width: 100%;
    max-width: none;
}
.payment-details-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.payment-details-card-hint {
    margin: 0 0 20px;
}
.payment-details-card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}
.payment-details-panel .payment-details-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
    align-items: start;
    margin-bottom: 16px;
}
.payment-details-panel .payment-details-row .form-group,
.payment-details-panel .payment-details-row .copy-field {
    margin-bottom: 0;
    min-width: 0;
}
.copy-field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.copy-field-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.copy-field-value {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-subtle);
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
    user-select: all;
    cursor: text;
    word-break: break-word;
}
.copy-field-btn {
    flex-shrink: 0;
    align-self: stretch;
}
.copy-field-btn.is-copied {
    color: var(--success);
    border-color: var(--success);
}
.payment-details-panel--edit .form-group input,
.payment-details-panel--edit .form-group select {
    width: 100%;
}
@media (max-width: 768px) {
    .payment-details-panel .payment-details-row {
        grid-template-columns: 1fr;
    }
}

.sidebar-footer,
.detail-footer {
    height: var(--chrome-footer-height);
    padding: 0 var(--chrome-footer-padding-x);
    border-top: 1px solid var(--border);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background: var(--bg-white);
}

.detail-footer {
    margin-top: auto;
    justify-content: space-between;
}
.btn-delete { color: var(--danger); background: none; border: none; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 6px; font-family: inherit; }

/* Page (dashboard, call log) */
.page-content {
    flex: 1;
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
}
.page-title { margin: 0 0 8px; font-size: var(--text-h2-size); line-height: var(--text-h2-line); font-weight: 600; color: var(--adp-deep-navy); }
.page-subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: var(--text-body-size); line-height: var(--text-body-line); }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.toolbar .filter-chips { padding: 0; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-danger { background: var(--alert-danger-bg); color: var(--alert-danger-fg); border: 1px solid var(--alert-danger-border); }
.form-error-summary {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    background: var(--alert-danger-bg);
    color: var(--alert-danger-fg);
    border: 1px solid var(--alert-danger-border);
    font-size: 14px;
}
.form-error-summary ul { margin: 0; }
.form-group--error > label,
.form-group--error > .copy-field-label,
.copy-field.form-group--error > .copy-field-label {
    color: var(--alert-danger-fg);
}
.form-group--error input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.form-group--error select,
.form-group--error textarea,
.investor-picker--error .investor-picker-input {
    border-color: var(--alert-danger-fg) !important;
    box-shadow: 0 0 0 2px var(--alert-danger-bg);
}
.form-field-error {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--alert-danger-fg);
}
.alert-success { background: var(--alert-success-bg); color: var(--alert-success-fg); border: 1px solid var(--alert-success-border); }
.alert-info { background: var(--alert-info-bg); color: var(--alert-info-fg); border: 1px solid var(--alert-info-border); }
.currency-icon-cell { font-size: 18px; line-height: 1; }
.currency-icon-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-page);
    border-radius: 4px;
    color: var(--text-muted);
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--header-bg);
}
.login-wrap { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-card h1 { margin: 0 0 8px; font-size: var(--text-h2-size); line-height: var(--text-h2-line); font-weight: 600; color: var(--adp-deep-navy); }
.login-card .subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: var(--text-small-size); line-height: var(--text-small-line); }
.login-card .login-tagline {
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--adp-deep-navy); }
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="image"]):not([type="reset"]) {
    width: 100%;
    padding: 10px 12px;
    min-height: 42px;
    border: 1px solid var(--adp-input-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--adp-deep-navy);
}
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: 1rem;
    height: 1rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    vertical-align: middle;
    accent-color: var(--primary);
}
.form-audience-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}
.form-audience-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-white);
}
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-section { margin-bottom: 16px; }
.form-section-title {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
}
.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.form-row .form-group { flex: 1; min-width: 160px; }
.form-row-3 .form-group { min-width: 140px; }
.form-subheading {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}
.form-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.form-optional-label {
    font-size: 0.85em;
    font-weight: 400;
    color: var(--text-muted);
}

.task-compose-card {
    margin-bottom: 16px;
    padding: 20px 24px;
}
.task-compose-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.task-compose-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}
.task-compose-submit {
    min-width: 148px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
}

.comment-compose-card {
    margin-bottom: 16px;
    padding: 20px 24px;
}
.comment-compose-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.comment-compose-field {
    margin-bottom: 0;
}
.comment-compose-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}
.comment-compose-textarea {
    display: block;
    width: 100%;
    min-height: 140px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    resize: vertical;
}
.comment-compose-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.comment-compose-footer {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-top: 16px;
}
.comment-compose-visibility {
    flex: 1;
    min-width: 0;
    margin: 0;
}
.comment-compose-visibility label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}
.comment-compose-select {
    width: 100%;
    padding: 10px 36px 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7c93' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.comment-compose-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.comment-compose-submit {
    flex-shrink: 0;
    min-width: 148px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
}
@media (max-width: 640px) {
    .comment-compose-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .comment-compose-submit {
        width: 100%;
    }
}

.alert-compose-card {
    margin-bottom: 20px;
}
.alert-compose-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
}
.alert-compose-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 20px;
}
.alert-compose-span-full {
    grid-column: 1 / -1;
}
.alert-compose-grid label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}
.alert-compose-grid input[type="text"],
.alert-compose-grid textarea,
.alert-compose-readonly,
.alert-compose-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.alert-compose-readonly {
    background: var(--surface-muted, #f4f4f5);
    cursor: default;
}
.alert-compose-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}
.entity-alerts-scope-note {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.entity-alerts-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
.entity-alerts-delete-btn {
    color: var(--danger);
}
.entity-alerts-delete-btn:hover {
    background: var(--danger-hover-bg);
    border-color: var(--danger);
    color: var(--danger);
}
.entity-alert-banners {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.entity-alert-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
}
.entity-alert-banner__meta {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.85;
}
.entity-alert-banner__header {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}
.entity-alert-banner__message {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}
.entity-alert-banner--red {
    background: #fef2f2;
    border-color: #fecaca;
    color: #7f1d1d;
}
.entity-alert-banner--amber {
    background: #fffbeb;
    border-color: #fde68a;
    color: #78350f;
}
.entity-alert-banner--yellow {
    background: #fefce8;
    border-color: #fef08a;
    color: #713f12;
}
.entity-alert-banner--blue {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}
.entity-alert-banner--green {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
}
.entity-alert-banner--grey {
    background: #f4f4f5;
    border-color: #e4e4e7;
    color: #3f3f46;
}
.entity-alert-swatch {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
@media (max-width: 768px) {
    .alert-compose-grid {
        grid-template-columns: 1fr;
    }
}

.phone-row { align-items: center; }
.phone-primary-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
    margin: 0;
}
.phone-primary-btn {
    white-space: nowrap;
}
.joint-linked-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.unlink-label { font-size: 13px; font-weight: 400; cursor: pointer; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.table-wrap { overflow-x: auto; }

.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="submit"]):not([type="button"]):focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* App confirm modal */
.app-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-backdrop);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.app-modal-backdrop:not([hidden]) {
    display: flex;
}
.app-modal {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 24px 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
}
.app-modal-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
}
.app-modal-message {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
}
.app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Incoming call overlay */
.call-overlay-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-backdrop);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.call-overlay-backdrop.is-visible { display: flex; }
.call-overlay-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 28px 32px;
    min-width: 340px;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}
.call-overlay-card h2 {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.call-overlay-card h2::before {
    content: '';
    width: 22px; height: 22px;
    background: var(--primary);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z'/%3E%3C/svg%3E") center/contain;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z'/%3E%3C/svg%3E") center/contain;
    background: var(--primary);
}
.call-overlay-meta { margin: 8px 0; font-size: 14px; }
.call-overlay-meta strong { color: var(--text); min-width: 56px; display: inline-block; }
.call-overlay-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}
.call-matches { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.call-matches a { display: block; padding: 6px 0; font-weight: 500; }
.call-overlay-subtitle {
    margin: -12px 0 16px;
    font-size: 14px;
    color: var(--text-muted);
}

/* NFON telephony header & dialpad */
.telephony-header {
    display: flex;
    align-items: center;
    gap: 8px;
}
.telephony-status-pill {
    cursor: pointer;
    border: none;
    font: inherit;
    transition: background 0.15s;
}
.telephony-status-pill:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
}
.telephony-status-pill:disabled {
    cursor: default;
    opacity: 0.85;
}
.telephony-on-call-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-pill);
    background: #dc2626;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}
.telephony-on-call-btn:hover {
    background: #b91c1c;
}
.telephony-on-call-duration {
    font-variant-numeric: tabular-nums;
    opacity: 0.95;
}
.telephony-panel {
    position: fixed;
    top: var(--topbar-height, 56px);
    right: 0;
    bottom: 0;
    width: min(320px, 100vw);
    z-index: 9000;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    overflow: auto;
}
.telephony-panel-inner {
    padding: 20px 18px 24px;
}
.telephony-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.telephony-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.telephony-panel-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
}
.telephony-nav-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
}
.telephony-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.telephony-nav-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.telephony-nav-body strong {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.telephony-nav-number,
.telephony-nav-state {
    font-size: 12px;
    color: var(--text-muted);
}
.telephony-nav-empty {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0 16px;
}
.telephony-dialpad-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}
.telephony-dial-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 12px;
    background: var(--bg);
    color: var(--text);
}
.telephony-dialpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.telephony-dial-key {
    padding: 14px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-white);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text);
}
.telephony-dial-key:hover {
    background: var(--bg-muted, #f1f5f9);
}
.telephony-dial-call-btn {
    width: 100%;
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
    font-weight: 600;
    padding: 12px;
}
.telephony-dial-call-btn:hover:not(:disabled) {
    background: #15803d;
    border-color: #15803d;
}
.telephony-confirm-number {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin: 0 0 8px;
    color: var(--text);
}
.telephony-number-pick-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
}
.telephony-number-pick-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.telephony-modal .telephony-modal-card {
    min-width: 340px;
    max-width: 420px;
}
.telephony-confirm-hint {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(249, 115, 22, 0.12);
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
}
.telephony-cloudya-btn {
    position: relative;
}
.telephony-cloudya-card {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-muted, #f8fafc);
}
.telephony-cloudya-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.telephony-cloudya-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}
.telephony-cloudya-status-dot--connected {
    background: #22c55e;
}
.telephony-cloudya-status-dot--offline {
    background: #1060f3;
}
.telephony-cloudya-status-dot--unknown {
    background: #94a3b8;
}
.telephony-cloudya-message {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted);
}
.telephony-cloudya-actions {
    margin-bottom: 12px;
}
.telephony-cloudya-setup {
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.telephony-cloudya-setup-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.telephony-cloudya-setup-steps {
    margin: 0 0 10px 18px;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.entity-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }

/* Investment transactions tab (Littsy-style repayment schedule) */
.investment-transactions-card {
    padding: 0;
    overflow: hidden;
}
.investment-transactions-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}
.investment-transactions-title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.investment-transactions-icon {
    display: inline-flex;
    width: 28px;
    height: 28px;
    color: var(--success);
}
.investment-transactions-icon svg {
    width: 28px;
    height: 28px;
}
.investment-transactions-heading {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}
.investment-transactions-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.investment-transactions-actions .btn svg {
    width: 16px;
    height: 16px;
    vertical-align: -2px;
    margin-right: 4px;
}
.investment-transactions-form {
    margin: 0;
}
.investment-transactions-body {
    padding: 0;
}
.investment-transactions-hint {
    margin: 0;
    padding: 16px 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.investment-transactions-table {
    margin: 0;
    font-size: 12px;
}
.investment-transactions-table thead th {
    background: var(--bg-subtle);
    font-weight: 600;
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 10px;
}
.investment-transactions-table tbody td {
    padding: 7px 14px;
    line-height: 1.35;
}
.investment-transactions-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 500;
}
.investment-transactions-table tbody tr.txn-row td {
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    padding: 7px 14px;
}
.investment-transactions-table tbody tr.txn-row--primary td {
    background: var(--badge-blue-bg);
    color: var(--badge-blue-fg);
}
.investment-transactions-table tbody tr.txn-row--warning td {
    background: var(--badge-orange-bg);
    color: var(--badge-orange-fg);
}
.investment-transactions-table tbody tr.txn-row--success td {
    background: var(--alert-success-bg);
    color: var(--alert-success-fg);
}
.investment-transactions-table tbody tr.txn-row--info td {
    background: var(--alert-info-bg);
    color: var(--alert-info-fg);
}
.investment-transactions-table tbody tr.txn-row--muted td {
    background: var(--badge-grey-bg);
    color: var(--badge-grey-fg);
}
.investment-transactions-table tbody tr.investment-txn-row {
    cursor: context-menu;
}
.investment-transactions-empty {
    text-align: center;
    padding: 20px 16px !important;
    color: var(--text-muted);
}
.investment-amend-txn-modal {
    max-width: 440px;
}
.investment-amend-txn__body {
    padding: 20px 24px 8px;
}
.investment-amend-txn__meta {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border);
}
.investment-amend-txn__ledger {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}
.investment-amend-txn__meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}
.investment-amend-txn__type {
    font-size: 13px;
    color: var(--text-muted);
}
.investment-amend-txn__form {
    margin: 0;
}
.investment-amend-txn__form .form-row {
    margin-bottom: 0;
}
.investment-amend-txn-record {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.investment-amend-txn-record summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    list-style: none;
    user-select: none;
}
.investment-amend-txn-record summary::-webkit-details-marker {
    display: none;
}
.investment-amend-txn-record__form {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.investment-amend-txn-record__form .btn {
    align-self: flex-start;
}
.investment-amend-txn__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.investment-required-actions-card {
    margin-bottom: 16px;
}
.investment-required-actions-header {
    padding: 20px 24px 0;
}
.investment-required-actions-heading {
    margin: 0 0 6px;
    font-size: 1.125rem;
}
.investment-required-actions-meta {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}
.investment-required-actions-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}
.investment-required-actions-inline-form {
    display: inline;
}
.txn-status-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    vertical-align: middle;
    line-height: 1.3;
}
.txn-status-pill--due {
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
}
.txn-status-pill--paid {
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
}
.txn-status-pill--partial {
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
}
.investment-txn-context-menu {
    position: absolute;
    z-index: 1200;
    min-width: 220px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    padding: 4px 0;
}
.investment-txn-context-menu[hidden] {
    display: none !important;
}
.investment-txn-context-item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    cursor: pointer;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
}
.investment-txn-context-item:hover {
    background: var(--bg-hover);
}
.investment-txn-context-item[hidden] {
    display: none !important;
}

/* Entity Drive documents tab */
.entity-drive-documents__list-wrap {
    margin: 0 -1px -1px;
}
.entity-drive-documents__table {
    width: 100%;
}
.entity-drive-documents__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.entity-drive-documents__title {
    margin: 0;
    font-size: 1rem;
}
.entity-drive-documents__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.entity-drive-documents__view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.entity-drive-documents__view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 0;
    background: var(--bg-white);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
}
.entity-drive-documents__view-btn + .entity-drive-documents__view-btn {
    border-left: 1px solid var(--border);
}
.entity-drive-documents__view-btn.is-active,
.entity-drive-documents__view-btn[aria-pressed="true"] {
    background: var(--bg-hover);
    color: var(--text);
}
.entity-drive-documents__view-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.entity-drive-documents[data-view="list"] [data-documents-panel="grid"] {
    display: none;
}
.entity-drive-documents[data-view="grid"] [data-documents-panel="list"] {
    display: none;
}
.entity-drive-documents__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.drive-doc-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.drive-doc-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.drive-doc-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--bg-hover);
    color: var(--accent);
}
.drive-doc-card__icon svg {
    width: 22px;
    height: 22px;
}
.drive-doc-card__name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}
.drive-doc-card__meta {
    font-size: 12px;
    color: var(--text-muted);
}
.drive-doc-list__icon {
    display: inline-flex;
    vertical-align: middle;
    margin-right: 8px;
    color: var(--accent);
}
.drive-doc-list__icon svg {
    width: 18px;
    height: 18px;
}
.drive-doc-list__action {
    text-align: right;
    white-space: nowrap;
}
.entity-drive-documents__empty,
.entity-drive-documents__notice {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}
.entity-drive-documents__loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 28px 8px;
    color: var(--text-muted);
    font-size: 14px;
}
.entity-drive-documents__loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: entity-documents-spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes entity-documents-spin {
    to { transform: rotate(360deg); }
}
.entity-drive-documents__notice {
    margin-bottom: 12px;
}
.entity-drive-documents__embed {
    width: 100%;
    min-height: 480px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
}
.entity-drive-documents__embed--while-loading {
    min-height: 360px;
    margin-top: 8px;
}

/* Document template visual editor */
.page-content.document-template-editor {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 16px;
}
.document-template-editor__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.document-template-editor__head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.document-template-editor__placeholders {
    margin-bottom: 16px;
    padding: 16px 20px;
}
.document-template-editor__placeholders-title {
    margin: 0 0 4px;
    font-size: 15px;
}
.document-template-editor__placeholders-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.document-template-editor__placeholder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.document-template-editor__form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 24px;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    overflow: hidden;
}
.document-template-editor__form .wysiwyg-editor-card__header {
    flex-shrink: 0;
    margin-bottom: 16px;
}
.document-template-editor__editor-wrap {
    flex: 1 1 auto;
    min-height: 240px;
    margin-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.document-template-editor__editor-wrap .tox-tinymce {
    flex: 1 1 auto;
    min-height: 0;
}
.document-template-editor__form .form-group textarea {
    min-height: 0;
}
.document-template-editor__form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-top: 16px;
}
.document-template-editor .back-link,
.document-template-editor__head,
.document-template-editor .alert {
    flex-shrink: 0;
}
.document-template-editor__save-note {
    font-size: 13px;
    color: var(--text-muted);
}

/* Investment document generate */
/* Entity documents stack (template panel + folder card) */
.entity-documents-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.doc-template-panel {
    padding: 0;
    overflow: hidden;
}
.doc-template-panel__toolbar {
    padding: 16px 20px 0;
    margin-bottom: 12px;
}
.doc-template-panel__intro {
    margin: 0 20px 12px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.45;
}
.doc-template-panel__empty {
    padding: 0 20px 16px;
}
.doc-template-panel__table-wrap {
    margin: 0;
}
.doc-template-panel .entity-drive-documents__table {
    margin: 0;
}
/* Document generate modal (body-level overlay) */
.doc-generate-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: var(--overlay-backdrop);
    pointer-events: auto;
}
.doc-generate-modal-backdrop:not([hidden]) {
    display: flex;
}
.doc-generate-modal-backdrop[hidden] {
    display: none !important;
}
html.doc-generate-modal-open {
    overflow: hidden;
}
.doc-generate-modal {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    flex: 0 0 auto;
    margin: 0;
    background: var(--bg-white);
    border-radius: 12px;
    padding: 24px 28px 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    pointer-events: auto;
}
.doc-generate-modal__title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
}
.doc-generate-modal__template {
    margin: 0 0 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.doc-generate-modal__section {
    margin-bottom: 20px;
}
.doc-generate-modal__legend {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.doc-generate-modal__section-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}
.doc-generate-modal__format-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.doc-generate-format-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.doc-generate-format-btn:hover:not(.is-active) {
    border-color: var(--primary);
    background: var(--primary-light);
}
.doc-generate-format-btn.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
.doc-generate-modal__action-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.doc-generate-action-btn {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.doc-generate-action-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
.doc-generate-action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.doc-generate-action-btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}
.doc-generate-action-btn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--bg-hover);
    color: var(--primary);
}
.doc-generate-action-btn__icon svg {
    width: 20px;
    height: 20px;
}
.doc-generate-action-btn__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.doc-generate-action-btn__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.doc-generate-action-btn__desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.35;
}
.doc-generate-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
    padding-top: 4px;
}

/* Application review actions */
.entity-detail-page .application-review-actions {
    margin: 0 0 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.application-review-actions__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: start;
}
@media (max-width: 860px) {
    .application-review-actions__layout {
        grid-template-columns: 1fr;
    }
}
.application-review-actions__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.application-review-actions__hint {
    margin: 6px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}
.application-review-actions__warning {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--danger);
}
.application-review-actions__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}
.application-review-actions__form {
    margin: 0;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}
.application-review-actions__notes {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.application-review-actions__notes summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
}
.application-review-actions__notes-field {
    margin: 12px 0 0;
}
.application-review-actions__notes-form textarea {
    width: 100%;
    max-width: 100%;
}
.application-review-actions__notes-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.app-doc-split__heading-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.app-doc-split__heading-row .app-doc-split__heading {
    margin: 0;
}
.app-doc-ai-rerun-form {
    margin: 0;
}

/* Application create */
.application-create-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.application-create-tabs__btn {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.application-create-tabs__btn.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.application-create-investor-mode {
    border: 0;
    margin: 0 0 16px;
    padding: 0;
}
.application-create-investor-mode__legend {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}
.application-create-investor-mode__options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.application-create-investor-mode__options label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.application-create-actions {
    margin-top: 16px;
}
.application-create-panel--drive {
    max-width: 640px;
}
.application-create-drive-intro {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--primary-light);
    border: 1px solid rgba(43, 125, 233, 0.2);
}
.application-create-drive-intro__icon {
    flex-shrink: 0;
    color: var(--primary);
    margin-top: 2px;
}
.application-create-panel-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 820px;
}

/* Document template letter preview */
.document-letter-preview-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.document-letter-preview-card__label {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.document-letter-preview-card__sample {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}
.document-template-preview-page {
    margin: 0;
    background: var(--bg-muted, #eef1f5);
    min-height: 100vh;
}
.document-template-preview-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface, #fff);
    border-bottom: 1px solid var(--border, #e2e8f0);
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.document-template-preview-toolbar__inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
}
.document-template-preview-toolbar__title {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.document-template-preview-toolbar__meta {
    margin: 4px 0 0;
    font-size: 16px;
    font-weight: 600;
}
.document-template-preview-toolbar__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.document-template-preview-pdf-form {
    display: inline;
    margin: 0;
}
.document-template-preview-toolbar__sample {
    max-width: 1200px;
    margin: 10px auto 0;
    font-size: 13px;
    color: var(--text-muted);
}
.document-template-preview-main {
    padding: 24px 16px 48px;
}
.document-template-preview-alert {
    max-width: 720px;
    margin: 0 auto;
}
@media print {
    @page {
        size: A4;
        margin: 18mm 16mm;
    }
    html,
    body.document-template-preview-page {
        height: auto !important;
        background: #fff !important;
    }
    body.document-template-preview-page * {
        visibility: hidden;
    }
    .document-template-print-area,
    .document-template-print-area * {
        visibility: visible;
    }
    .document-template-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-width: none !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
        color: var(--text) !important;
    }
    .document-template-print-area .document-letter-preview__content {
        font-size: 14px;
    }
    .document-template-print-area .doc-page-break,
    .document-template-print-area img.mce-pagebreak,
    .document-template-print-area .sln-page {
        page-break-after: always;
        break-after: page;
    }
    .document-template-print-area .sln-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }
}
.document-letter-preview__content .doc-page-break,
.document-letter-preview__content img.mce-pagebreak {
    display: block;
    width: 100%;
    margin: 20px 0;
    border: 0;
    border-top: 2px dashed var(--border, #94a3b8);
    height: 0;
    padding: 0;
}
.document-letter-preview {
    background: #d8dce3;
    border-radius: var(--radius);
    padding: 28px 20px 36px;
}
.document-letter-preview__page {
    max-width: 210mm;
    min-height: 280mm;
    margin: 0 auto;
    padding: 20mm 18mm 22mm;
    background: #fff;
    color: #1a1a1a;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 8px 24px rgba(15, 23, 42, 0.12);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-sizing: border-box;
}
.document-letter-preview__content {
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
}
/* Respect template typography (e.g. Secured Loan Note) instead of forcing Inter */
.document-letter-preview__content:not(:has(.sln-doc)),
.document-letter-preview__content:not(:has(.sln-doc)) * {
    font-family: var(--font);
}
.document-letter-preview__content table:not(.sln-t):not(.sln-kv):not(.sln-sig) {
    width: 100%;
    border-collapse: collapse;
}
.document-letter-preview__content table:not(.sln-t):not(.sln-kv):not(.sln-sig) td,
.document-letter-preview__content table:not(.sln-t):not(.sln-kv):not(.sln-sig) th {
    border: 1px solid #ccc;
    padding: 6px 8px;
    vertical-align: top;
}
/* Multi-page legal templates: render each .sln-page as its own sheet (like PDF) */
.document-letter-preview__page:has(.sln-doc) {
    max-width: none;
    min-height: auto;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}
.document-letter-preview__content .sln-page {
    max-width: 210mm;
    margin: 0 auto 20px;
    padding: 15mm 25mm 18mm;
    background: #fff;
    box-sizing: border-box;
    position: relative;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 8px 24px rgba(15, 23, 42, 0.12);
    border: 1px solid rgba(15, 23, 42, 0.08);
}
.document-letter-preview__content .sln-page:last-child {
    margin-bottom: 0;
}
.document-letter-preview__content .sln-footer {
    position: absolute;
    left: 25mm;
    bottom: 18mm;
}
.document-letter-preview__empty {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}
@media (max-width: 900px) {
    .document-letter-preview {
        padding: 16px 12px 24px;
    }
    .document-letter-preview__page {
        min-height: auto;
        padding: 16mm 14mm;
    }
}

/* Email template preview */
.email-template-preview__html {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}
.email-template-preview__html p {
    margin: 0 0 0.75em;
}
.email-template-preview__text {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}
.email-template-form {
    width: 100%;
    max-width: none;
}
.email-template-form__meta,
.email-template-form__body {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}
.email-template-form__meta {
    margin-bottom: 16px;
    padding: 20px 24px;
}
.email-template-form__body {
    padding: 20px 24px;
}
.email-template-form__body .form-group textarea {
    min-height: 280px;
}

/* WYSIWYG editor card + variable drawer */
.wysiwyg-editor-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.wysiwyg-editor-card__title {
    margin: 0;
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
html.template-variables-drawer-open,
html.doc-template-settings-drawer-open {
    overflow: hidden;
}

/* Document template settings drawer */
.doc-template-settings-drawer[hidden] {
    display: none !important;
}
.doc-template-settings-drawer {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    justify-content: flex-end;
    pointer-events: auto;
}
.doc-template-settings-drawer__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.45);
    cursor: pointer;
}
.doc-template-settings-drawer__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(440px, 100vw);
    max-width: 100%;
    height: 100%;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.doc-template-settings-drawer:not([hidden]) .doc-template-settings-drawer__panel {
    transform: translateX(0);
}
.doc-template-settings-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.doc-template-settings-drawer__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.doc-template-settings-drawer__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}
.doc-template-settings-form .form-group:last-of-type {
    margin-bottom: 20px;
}
.template-variables-drawer[hidden] {
    display: none !important;
}
.template-variables-drawer {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    justify-content: flex-end;
    pointer-events: auto;
}
.template-variables-drawer__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.45);
    cursor: pointer;
}
.template-variables-drawer__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(400px, 100vw);
    max-width: 100%;
    height: 100%;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.template-variables-drawer:not([hidden]) .template-variables-drawer__panel {
    transform: translateX(0);
}
.template-variables-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.template-variables-drawer__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.template-variables-drawer__intro,
.template-variables-drawer__legacy {
    margin: 0;
    padding: 12px 20px 0;
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.template-variables-drawer__legacy {
    padding-top: 8px;
}
.template-variables-drawer__search-wrap {
    padding: 12px 20px;
    flex-shrink: 0;
}
.template-variables-drawer__search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-white);
    color: var(--text);
}
.template-variables-drawer__search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
.template-variables-drawer__groups {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 20px 20px;
}
.template-variables-group {
    margin-bottom: 16px;
}
.template-variables-group__heading {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.template-variables-group__list {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.template-variables-item + .template-variables-item {
    border-top: 1px solid var(--border);
}
.template-variables-item__btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: var(--bg-white);
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    color: inherit;
}
.template-variables-item__btn:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}
.template-variables-item__key {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.template-variables-drawer__empty {
    margin: 0;
    padding: 0 20px 20px;
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Entity preview drawer (investor / introducer quick view) */
html.entity-preview-drawer-open {
    overflow: hidden;
}
.entity-preview-drawer[hidden] {
    display: none !important;
}
.entity-preview-drawer {
    position: fixed;
    inset: 0;
    z-index: 1150;
    display: flex;
    justify-content: flex-end;
    pointer-events: auto;
}
.entity-preview-drawer__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.45);
    cursor: pointer;
}
.entity-preview-drawer__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(600px, 100vw);
    max-width: 100%;
    height: 100%;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.entity-preview-drawer:not([hidden]) .entity-preview-drawer__panel {
    transform: translateX(0);
}
.entity-preview-drawer__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px 0;
    flex-shrink: 0;
}
.entity-preview-drawer__top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.entity-preview-drawer__popout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.entity-preview-drawer__popout:hover {
    color: var(--primary);
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}
.entity-preview-drawer__popout svg {
    width: 18px;
    height: 18px;
}
.entity-preview-drawer__hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px 0;
    flex-shrink: 0;
}
.entity-preview-drawer__title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}
.entity-preview-drawer__status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.entity-preview-drawer__tabs {
    display: flex;
    gap: 20px;
    padding: 16px 20px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.entity-preview-drawer__tab {
    margin: 0;
    padding: 0 0 12px;
    border: 0;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: default;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.entity-preview-drawer__tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.entity-preview-drawer__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 24px;
}
.entity-preview-drawer__loading,
.entity-preview-drawer__error,
.entity-preview-drawer__empty {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}
.entity-preview-drawer__error {
    color: var(--danger, #b91c1c);
}
.entity-preview-drawer__section {
    margin-bottom: 20px;
}
.entity-preview-drawer__section-title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.entity-preview-drawer__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
}
.entity-preview-drawer__field label {
    display: block;
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
}
.entity-preview-drawer__field p {
    margin: 0;
    font-size: 13px;
    color: var(--text);
    word-break: break-word;
}
.entity-preview-drawer__table {
    font-size: 13px;
}
.entity-preview-drawer__table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.entity-preview-drawer__investment-cell {
    font-weight: 600;
    max-width: 0;
    width: 38%;
}
.entity-preview-drawer__investment-cell a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}
.entity-preview-drawer__investment-cell a:hover {
    color: var(--primary);
}
.entity-preview-drawer__more {
    margin: 10px 0 0;
    font-size: 13px;
}
.entity-preview-drawer__more a {
    color: var(--primary);
    font-weight: 500;
}
a.entity-preview-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}
a.entity-preview-link:hover {
    text-decoration: underline;
}
/* Preview triggers in the header toolbar keep circular comm-btn styling */
.comm-actions a.comm-btn[data-entity-preview] {
    color: var(--comm-btn-fg);
    font-weight: inherit;
    text-decoration: none;
}
.comm-actions a.comm-btn[data-entity-preview]:hover {
    text-decoration: none;
}
@media (max-width: 520px) {
    .entity-preview-drawer__grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Inbox triage */
.inbox-triage-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 16px;
}
.inbox-triage-week-label {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}
.inbox-triage-score-line {
    margin: 4px 0 0;
    font-size: 14px;
}
.inbox-triage-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.inbox-triage-panel-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 600;
}
.inbox-triage-leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.inbox-triage-leaderboard-list li {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.inbox-triage-leaderboard-list li:last-child {
    border-bottom: none;
}
.inbox-triage-rank {
    font-weight: 700;
    color: var(--text-muted);
}
.inbox-triage-points {
    font-weight: 600;
}
.inbox-triage-progress {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.inbox-triage-email-card {
    margin-bottom: 16px;
    min-height: 200px;
}
.inbox-triage-email-meta p {
    margin: 0 0 6px;
    font-size: 13px;
}
.inbox-triage-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}
.inbox-triage-body {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.5;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.inbox-triage-pad-wrap {
    text-align: center;
}
.inbox-triage-pad {
    display: inline-grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-width: 420px;
    width: 100%;
}
.inbox-triage-pad-middle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.inbox-triage-pad-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.inbox-triage-pad-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-soft, rgba(59, 130, 246, 0.08));
}
.inbox-triage-pad-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.inbox-triage-pad-flash {
    transform: scale(0.97);
    border-color: var(--primary);
}
.inbox-triage-pad-key {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}
.inbox-triage-pad-label {
    font-size: 12px;
    font-weight: 600;
}
.inbox-triage-hints {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.inbox-triage-empty-state,
.inbox-triage-empty {
    color: var(--text-muted);
    font-size: 14px;
}
.inbox-triage-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}
.inbox-triage-help-overlay[hidden] {
    display: none;
}
.inbox-triage-help-card {
    max-width: 360px;
    width: 100%;
}
.inbox-triage-help-card ul {
    margin: 0 0 16px;
    padding-left: 0;
    list-style: none;
}
.inbox-triage-help-card li {
    margin: 8px 0;
    font-size: 14px;
}
@media (max-width: 900px) {
    .inbox-triage-layout {
        grid-template-columns: 1fr;
    }
}

/* Email compose dock (Gmail-style) */
.email-compose-dock {
    position: fixed;
    bottom: 0;
    right: 24px;
    width: min(560px, calc(100vw - 32px));
    background: #ffffff;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 12000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-compose-dock[hidden] {
    display: none !important;
}
.email-compose-dock--minimized {
    width: min(320px, calc(100vw - 32px));
    height: auto;
}
.email-compose-dock--minimized .email-compose-dock__body,
.email-compose-dock--minimized .email-compose-dock__footer {
    display: none;
}
.email-compose-dock--expanded {
    width: min(640px, calc(100vw - 48px));
    height: min(85vh, 820px);
}
.email-compose-dock--expanded .email-compose-dock__body {
    flex: 1;
    min-height: 0;
    max-height: none;
}
.email-compose-dock--expanded .email-compose-dock__editor-wrap {
    flex: 1;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}
.email-compose-dock--expanded .email-compose-dock__body-input {
    flex: 1;
    min-height: 320px;
    resize: none;
}
.email-compose-dock--fullscreen {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100% !important;
    max-width: none;
    height: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
}
.email-compose-dock--fullscreen .email-compose-dock__body {
    flex: 1;
    min-height: 0;
    max-height: none;
}
.email-compose-dock--fullscreen .email-compose-dock__editor-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.email-compose-dock--fullscreen .email-compose-dock__body-input {
    flex: 1;
    min-height: 0;
    resize: none;
}
html.email-compose-fullscreen-open {
    overflow: hidden;
}
.email-compose-dock__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    cursor: default;
}
.email-compose-dock--minimized .email-compose-dock__header {
    cursor: pointer;
}
.email-compose-dock__title {
    font-size: 14px;
    font-weight: 600;
}
.email-compose-dock__window-actions {
    display: flex;
    gap: 4px;
}
.email-compose-dock__action {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.email-compose-dock__action:hover {
    background: rgba(255, 255, 255, 0.15);
}
.email-compose-dock__action--fullscreen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.email-compose-dock__action--fullscreen svg {
    width: 16px;
    height: 16px;
}
.email-compose-dock__icon--restore {
    display: none;
}
.email-compose-dock--fullscreen .email-compose-dock__action--fullscreen .email-compose-dock__icon--expand {
    display: none;
}
.email-compose-dock--fullscreen .email-compose-dock__action--fullscreen .email-compose-dock__icon--restore {
    display: block;
}
.email-compose-dock__body {
    display: flex;
    flex-direction: column;
    overflow: auto;
}
.email-compose-dock__row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.email-compose-dock__row label {
    flex: 0 0 42px;
    color: var(--text-muted);
    padding-top: 6px;
}
.email-compose-dock__row--from label {
    padding-top: 0;
}
.email-compose-dock__from-value {
    color: var(--text);
    font-weight: 500;
}
.email-compose-dock__row--recipients {
    align-items: center;
    flex-wrap: wrap;
}
.email-compose-dock__chips-wrap {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.email-compose-dock__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.email-compose-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 16px;
    background: var(--bg-hover);
    font-size: 12px;
    max-width: 100%;
}
.email-compose-chip--auto {
    background: #e8f0fe;
    color: #1a4a8a;
}
.email-compose-chip__remove {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
}
.email-compose-dock__recipient-input {
    flex: 1;
    min-width: 120px;
    border: none;
    background: transparent;
    font: inherit;
    color: var(--text);
    padding: 4px 0;
    outline: none;
}
.email-compose-dock__row-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}
.email-compose-dock__link {
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}
.email-compose-dock__subject-input {
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    color: var(--text);
    padding: 10px 14px;
    outline: none;
}
.email-compose-dock__row--subject {
    padding: 0;
    border-bottom: 1px solid var(--border);
}
.email-compose-dock__row--template {
    align-items: center;
}
.email-compose-dock__template-select {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 8px;
    font: inherit;
    background: var(--bg-white);
    color: var(--text);
}
.email-compose-dock__editor-wrap {
    flex: 1;
    min-height: 180px;
}
.email-compose-dock__body-input {
    width: 100%;
    min-height: 180px;
    border: none;
    resize: vertical;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: transparent;
    outline: none;
    box-sizing: border-box;
}
.email-compose-dock__attachments {
    padding: 8px 14px;
    border-top: 1px solid var(--border);
}
.email-compose-dock__attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.email-compose-attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius);
    background: var(--bg-hover);
    font-size: 12px;
}
.email-compose-attachment-item__remove {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
}
.email-compose-dock__error {
    margin: 0 14px 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: #fef2f2;
    color: #991b1b;
    font-size: 13px;
}
.email-compose-dock__success {
    margin: 0 14px 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: #ecfdf5;
    color: #065f46;
    font-size: 13px;
}
.email-compose-dock__success a {
    color: inherit;
    font-weight: 600;
}
.email-compose-dock__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
}
.email-compose-dock__send {
    min-width: 72px;
}
.email-compose-dock__footer-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}
.email-compose-dock__tool {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.email-compose-dock__tool:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.email-compose-dock__tool svg {
    width: 18px;
    height: 18px;
}
.email-compose-dock__discard {
    margin-left: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.7;
}
.email-compose-dock__suggest {
    position: fixed;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-dropdown);
    max-height: 280px;
    overflow: auto;
    z-index: 13050;
    padding: 6px 0;
}
.email-compose-suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
}
.email-compose-suggest-item:hover,
.email-compose-suggest-item.is-active {
    background: var(--bg-hover);
}
.email-compose-suggest-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.email-compose-suggest-avatar--group {
    background: linear-gradient(135deg, #0f766e 0%, #0f766e 50%, #64748b 50%, #64748b 100%);
    font-size: 11px;
}
.email-compose-suggest-avatar--email {
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 500;
}
.email-compose-suggest-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.email-compose-suggest-title {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-compose-suggest-sub {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.investor-picker-option.is-active {
    background: var(--bg-hover);
}
.email-compose-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay-backdrop);
    z-index: 13000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.email-compose-modal-backdrop[hidden] {
    display: none !important;
}
.email-compose-modal {
    width: 100%;
    max-width: 480px;
    max-height: min(80vh, 560px);
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-compose-modal--wide {
    max-width: 640px;
}
.email-compose-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.email-compose-modal__head h2 {
    margin: 0;
    font-size: 16px;
}
.email-compose-modal__close {
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}
.email-compose-modal__search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.email-compose-modal__search input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
}
.email-compose-modal__list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
    flex: 1;
}
.email-compose-modal__item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.email-compose-modal__item:hover {
    background: var(--bg-hover);
}
.email-compose-modal__hint {
    margin: 0;
    padding: 10px 16px 14px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Investment star menu (secondary actions) */
.comm-btn--star {
    border-color: #d4a017;
    color: #b8860b;
}
.comm-btn--star:hover:not(:disabled),
.comm-btn--star[aria-expanded="true"] {
    border-color: #d4a017;
    color: #b8860b;
    box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.2);
}
.comm-btn--star svg {
    fill: rgba(212, 160, 23, 0.15);
}
.investment-star-menu {
    min-width: 240px;
    z-index: 5100;
}
.investment-star-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.investment-star-menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
html.investment-star-modal-open {
    overflow: hidden;
}
.investment-star-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 5200;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
    overflow-y: auto;
}
.investment-star-modal-backdrop[hidden] {
    display: none !important;
}
.investment-star-modal {
    width: 100%;
    max-width: 520px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-dropdown);
    padding: 0 0 16px;
}
.investment-star-modal--wide {
    max-width: 920px;
}
.investment-star-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--border);
}
.investment-star-modal__head h2 {
    margin: 0;
    font-size: 1.125rem;
}
.investment-star-modal__close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
}
.investment-star-modal__hint {
    margin: 0;
    padding: 12px 24px;
    font-size: 14px;
    color: var(--text-muted);
}
.investment-star-modal__form {
    padding: 0 24px;
}
.investment-star-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 0;
}
.investment-repayments-section {
    padding: 0 24px 16px;
}
.investment-repayments-section__title {
    margin: 0 0 12px;
    font-size: 0.95rem;
}
.investment-repayments-row-wrap {
    padding: 12px 16px !important;
    background: var(--bg-subtle, #f8fafc);
    border-top: 1px solid var(--border);
}
.investment-repayments-edit-grid {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(120px, 1.2fr) minmax(100px, 0.8fr) minmax(90px, 0.7fr) auto;
    gap: 12px;
    align-items: end;
}
.investment-repayments-type,
.investment-repayments-status {
    font-size: 14px;
    color: var(--text-muted);
    padding-bottom: 10px;
}
.investment-repayments-record {
    margin-top: 10px;
}
.investment-repayments-record summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}
.investment-repayments-record-form {
    margin-top: 10px;
}
.investment-repayments-add-form {
    margin-top: 8px;
}
@media (max-width: 768px) {
    .investment-repayments-edit-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.entity-emails-table__date {
    white-space: nowrap;
}
.entity-emails-table__recipients {
    max-width: 220px;
    word-break: break-word;
}
.entity-emails-table__cc,
.entity-emails-table__meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.entity-emails-table__preview {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}
.entity-emails-table__error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--danger);
}
.entity-emails-table__actions {
    white-space: nowrap;
}

/* Law Firm Intelligence Centre */
.law-firm-list-page .law-firm-list-hero {
    margin-bottom: 16px;
}

.law-firm-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.law-firm-list-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.law-firm-list-hero__subtitle {
    margin: 0;
}

.law-firm-list-stat-cards {
    margin-bottom: 16px;
}

.law-firm-list-filters {
    margin-bottom: 0;
}

.law-firm-list-filters__actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.law-firm-list-page .list-panel--full {
    margin-top: 0;
}

.list-grid--law-firms {
    grid-template-columns:
        minmax(260px, 2.4fr)
        minmax(56px, 0.4fr)
        minmax(100px, 0.75fr)
        minmax(130px, 1fr)
        minmax(180px, 1.2fr);
}

.list-grid--investment-claims-firms {
    grid-template-columns:
        minmax(260px, 2.4fr)
        minmax(110px, 0.85fr)
        minmax(100px, 0.75fr)
        minmax(130px, 1fr)
        minmax(180px, 1.2fr);
}

.list-row-head--columns.list-grid--law-firms {
    grid-template-columns:
        minmax(260px, 2.4fr)
        minmax(56px, 0.4fr)
        minmax(100px, 0.75fr)
        minmax(130px, 1fr)
        minmax(180px, 1.2fr)
        52px;
    padding: 8px 16px;
    gap: 12px 16px;
}

.list-row-head--columns.list-grid--investment-claims-firms {
    grid-template-columns:
        minmax(260px, 2.4fr)
        minmax(110px, 0.85fr)
        minmax(100px, 0.75fr)
        minmax(130px, 1fr)
        minmax(180px, 1.2fr)
        52px;
    padding: 8px 16px;
    gap: 12px 16px;
}

.investment-claims-tab {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.investment-claims-firms-list {
    min-height: 280px;
    max-height: 420px;
}

.investment-claims-table-card {
    padding: 0;
    overflow: hidden;
}

.investment-claims-table-card__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.investment-claims-table-card .table-wrap {
    overflow-x: auto;
}

.investment-claims-table th {
    white-space: nowrap;
}

.list-item-identity-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.list-item-identity-inline .list-avatar {
    flex-shrink: 0;
}

.list-item-identity-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.list-item-identity-text .list-item-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.list-item-identity-text .list-item-name.list-item-field-value--link {
    color: var(--primary);
}

.list-item-identity-text .list-item-name.list-item-field-value--link:hover {
    text-decoration: underline;
}

.list-item-identity-text .list-item-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-grid--law-firms .list-item-col--data:first-child .list-item-name,
.list-grid--investment-claims-firms .list-item-col--data:first-child .list-item-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-grid--law-firms .list-item-col--data:first-child .list-item-sub,
.list-grid--investment-claims-firms .list-item-col--data:first-child .list-item-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.law-firm-health-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 0 0 16px;
}

.detail-body > .law-firm-health-row {
    margin-top: 0;
}

.law-firm-health-card {
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.law-firm-health-card .label {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.law-firm-health-card .value {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.law-firm-profile-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}

.law-firm-summary-panel {
    position: sticky;
    top: 16px;
}

.monitoring-report-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 960px) {
    .law-firm-health-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .law-firm-profile-layout {
        grid-template-columns: 1fr;
    }
    .monitoring-report-cards {
        grid-template-columns: 1fr;
    }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.45);
}

.modal-overlay[hidden] {
    display: none !important;
}
