/* ═══════════════════════════════════════
   DESIGN TOKENS
════════════════════════════════════════ */
:root {
    /* Brand */
    --navy: #0a1f44;
    --navy-mid: #173877;
    --gold: #c59d5f;
    --gold-soft: rgba(197, 157, 95, 0.14);

    /* Layout */
    --sidebar-w: 248px;

    /* Surface */
    --bg: #eef2f9;
    --surface: #ffffff;
    --border: rgba(10, 31, 68, 0.1);
    --border-solid: #d8e1f0;

    /* Text */
    --text: #0d1f3c;
    --muted: #5a6a8a;
    --label: #8898b8;
    /* Aliases — kept for older components (.bk-table, team comp-history) that
       reference these names; point at the same values as --text/--muted so
       nothing renders with an invalid (dropped) color. */
    --text-primary: var(--text);
    --text-secondary: var(--muted);
    --border-faint: rgba(10, 31, 68, 0.06);

    /* Status */
    --warning-bg: #fff6db;
    --warning-border: #f1cf6b;
    --warning-text: #8a6300;
    --success-bg: #eaf8ee;
    --success-border: #9fd6ac;
    --success-text: #18794e;
    --info-bg: #eaf1fb;
    --info-border: #a9c6ec;
    --info-text: #1c4d8a;
    --danger-bg: #ffe1e1;
    --danger-border: #f3a9a9;
    --danger-text: #b42318;
    /* "Partial" status (e.g. part-paid invoices) — a 5th status hue alongside warning/success/danger */
    --partial-bg: #faf5ff;
    --partial-border: #805ad5;
    --partial-text: #553c9a;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(10, 31, 68, 0.07), 0 1px 2px rgba(10, 31, 68, 0.04);
    --shadow-md: 0 4px 12px rgba(10, 31, 68, 0.08), 0 2px 4px rgba(10, 31, 68, 0.04);

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

    /* Radius scale */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Input width caps */
    --input-sm: 180px;
    --input-md: 320px;
    --input-lg: 460px;

    /* Legacy aliases kept for any inline usage */
    --white: #ffffff;
    --black: #0d1f3c;
    --ink-soft: #5a6a8a;
    --mist: #eef3fb;
    --warm: #fbf7f0;
    --card-shadow: var(--shadow-md);
    --card-bg: var(--surface);
    --line: var(--border);
    --primary: var(--navy);
    --primary-strong: #173877;
    --accent: var(--gold);
    --accent-soft: var(--gold-soft);
    --shadow: var(--shadow-md);
}


/* ═══════════════════════════════════════
   RESET & BASE
════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    height: 100%;
}

body {
    font-family: "Inter", sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    height: 100%;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
    font-family: "Familjen Grotesk", sans-serif;
    color: var(--navy);
    line-height: 1.15;
}

p {
    margin: 0 0 0.75em;
    line-height: 1.65;
}

p:last-child {
    margin-bottom: 0;
}


/* ═══════════════════════════════════════
   APP SHELL LAYOUT
════════════════════════════════════════ */

/* Collapsed width of the sidebar rail */
:root { --sb-rail: 52px; --sb-full: 248px; }

.app-shell {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* ── Sidebar host ── (the flex item that occupies layout space) */
.sidebar-host {
    position: relative;
    flex-shrink: 0;
    width: var(--sb-rail);        /* collapsed: only rail visible */
    height: 100%;
    z-index: 200;
    transition: width 0.22s ease;
}

/* Pinned: host takes full width in layout */
html[data-sb="pinned"] .sidebar-host {
    width: var(--sb-full);
}

/* ── Sidebar ── (the actual panel, always full width, clips or overlays)
   position: fixed, not absolute — .sidebar-host's height:100% collapses to
   0 under a legacy rule further down (`@media (max-width: 900px)`) that
   switches .app-shell to height:auto, and an absolutely-positioned
   child's top/bottom offsets resolve against that zero-height containing
   block, making the whole panel disappear from 768px up to 900px. Fixed
   positioning resolves top/bottom against the viewport instead, which is
   visually identical here since .sidebar-host itself always sits at the
   page's own top-left origin — so this is safe at every breakpoint, not
   just the < 768px one this was first found on. ── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sb-rail);        /* visually narrow when collapsed */
    display: flex;
    flex-direction: column;
    background: var(--navy);
    overflow: hidden;
    transition: width 0.22s ease, box-shadow 0.22s ease;
}

/* Expanded states: hover or pinned */
.sidebar-host.sb-hover .sidebar,
html[data-sb="pinned"] .sidebar {
    width: var(--sb-full);
}

/* Drop-shadow only when overlaying (hover, not pinned) */
.sidebar-host.sb-hover:not(html[data-sb="pinned"] .sidebar-host) .sidebar {
    box-shadow: 4px 0 24px rgba(10, 31, 68, 0.28);
}

/* ── Sidebar brand ── */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 64px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

/* Full logo — shown when expanded */
.sidebar-brand-logo {
    display: block;
    height: 28px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    object-position: left center;
    opacity: 1;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}

/* Favicon icon — shown when collapsed */
.sidebar-brand-icon {
    display: block;
    width: 26px;
    height: 26px;
    object-fit: contain;
    position: absolute;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

/* Swap logo ↔ icon based on expand state */
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-brand-logo {
    opacity: 0;
}
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-brand-icon {
    opacity: 1;
}

/* Pin button — always rendered, visible only when sidebar expanded */
.sidebar-pin-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    pointer-events: none;
}

/* Show pin button only when expanded */
.sidebar-host.sb-hover .sidebar-pin-btn,
html[data-sb="pinned"] .sidebar-pin-btn {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-pin-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

/* Which icon to show */
.sb-icon-unpin { display: none; }
.sb-icon-pin   { display: block; }
html[data-sb="pinned"] .sb-icon-pin   { display: none; }
html[data-sb="pinned"] .sb-icon-unpin { display: block; }

/* ── Nav ── */
.sidebar-nav {
    flex: 1;
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section-label {
    display: block;
    padding: var(--space-2) var(--space-2) var(--space-1);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    overflow: hidden;
    /* Collapsed: render as a thin divider line */
    transition: color 0.15s, padding 0.15s;
}

/* Sub-headings inside the Accounting group (Bookkeeping / Sales / Revenue /
   Reports / Ledger). Static labels — no collapse — so no nested accordion
   fights the single-group toggle JS. */
.sidebar-subsection-label {
    margin-top: var(--space-1);
    padding-top: var(--space-1);
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.24);
}

/* ── Collapsible sidebar groups (accordion) ──────────────────────────────
   A section with 2+ links (Price Tracker, QBF Finance, Accounting, Team)
   becomes a click-to-expand group; only one open at a time. Sections with
   a single link (Central Settings, Admin, Tool Promos) stay plain links —
   nothing to collapse. ── */
.sidebar-group-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.sidebar-group-summary:hover {
    color: rgba(255, 255, 255, 0.55);
}

.sidebar-group-caret {
    flex-shrink: 0;
    opacity: 0.6;
    transition: transform 0.15s;
}

.sidebar-group.is-open .sidebar-group-caret {
    transform: rotate(180deg);
}

.sidebar-group-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-group-links[hidden] {
    display: none;
}

/* Rail (icon-only) mode respects the accordion's open/closed state, same
   as expanded mode — a collapsed section's icons stay hidden there too,
   so "collapsed" means the same thing everywhere rather than only in the
   expanded view. Only the currently-open section's icons (plus the
   single-link items, which have no accordion at all) are reachable
   directly from the rail; switching to a different section from rail
   view means hover-expand → open that section → click its link. */

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.92);
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-weight: 600;
    border-left-color: var(--gold);
    padding-left: 7px;
}

/* Center icons in rail when collapsed */
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-link {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
    border-left-color: transparent !important;
    padding-left: 0 !important;
}

.sidebar-link-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active .sidebar-link-icon { opacity: 1; }

.sidebar-link-text {
    white-space: nowrap;
    overflow: hidden;
}

html:not([data-sb="pinned"]) .sidebar-host:not(.sb-hover) .sidebar-section-label,
html:not([data-sb="pinned"]) .sidebar-host:not(.sb-hover) .sidebar-link-text {
    display: none;
}

/* ── Footer ── */
.sidebar-footer {
    padding: 10px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-footer-link {
    display: block;
    padding: 2px 4px;
    font-size: 0.76rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    transition: color 0.15s, opacity 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer-link:hover,
.sidebar-footer-link.active {
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-footer-icon {
    flex-shrink: 0;
    opacity: 0.5;
    width: 15px;
    height: 15px;
}

/* Collapsed: center the user icon, hide text */
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-footer {
    justify-content: center;
}
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-user,
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-logout-btn,
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-footer-link {
    opacity: 0;
    pointer-events: none;
}

.sidebar-user {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.sidebar-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    flex-shrink: 0;
}

.sidebar-logout-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

/* ── Sidebar profile button ── */
.sidebar-profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 4px 4px 4px 2px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s;
}

.sidebar-profile-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-profile-btn:hover .sidebar-footer-icon {
    opacity: 0.8;
}

/* Collapsed state: keep button centered, hide username text */
.sidebar-host:not(.sb-hover):not(html[data-sb="pinned"] .sidebar-host) .sidebar-profile-btn {
    justify-content: center;
    flex: none;
}

/* ── Modal (universal base — .profile-* below extends it for the profile
   modal's specific width/animation; a new modal instance should use
   .modal-overlay/.modal/.modal-header/.modal-title-block/.modal-close-btn
   /.modal-body directly and add its own width via a modifier class if it
   needs something other than the 420px default). ── */
.modal-overlay,
.profile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 31, 68, 0.5);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay[hidden],
.profile-overlay[hidden] {
    display: none;
}

.modal,
.profile-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 48px rgba(10, 31, 68, 0.24);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    animation: profile-pop-in 0.18s ease;
}

/* Narrower default for short-content modals (e.g. confirmation dialogs). */
.modal--sm {
    max-width: 360px;
}

/* Wider variant for a modal that hosts a real multi-field form (e.g. a
   two-column grouped form) — same 760px cap already used for wide inline
   forms via .stack-form--wide, for the same reason. */
.modal--lg {
    max-width: 760px;
}

/* Small uppercase divider label grouping a block of fields inside a form —
   e.g. inside a modal, where .section-heading's h2 is too large. */
.form-section-title {
    margin: 18px 0 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-solid);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.form-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

@keyframes profile-pop-in {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.modal-header,
.profile-modal-header {
    background: var(--navy);
    padding: 20px 20px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.profile-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--navy-mid);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.18);
}

.modal-title-block,
.profile-modal-title-block {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.modal-title-block h3,
.profile-modal-title-block h3 {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-role-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    width: fit-content;
}

.profile-role-badge.role-admin {
    background: rgba(255, 214, 0, 0.2);
    color: #ffd600;
}

.profile-role-badge.role-member {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.65);
}

.modal-close-btn,
.profile-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.modal-close-btn:hover,
.profile-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.modal-body,
.profile-modal-body {
    padding: 20px;
}

.profile-detail-list {
    margin: 0;
}

.profile-detail-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-solid);
}

.profile-detail-row:last-child {
    border-bottom: none;
}

.profile-detail-row dt {
    min-width: 78px;
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    flex-shrink: 0;
}

.profile-detail-row dd {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text, #1a2b4a);
    word-break: break-all;
}

.profile-info-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.profile-info-submit {
    width: 100%;
    justify-content: center;
}

.profile-info-message {
    padding: 10px 13px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.profile-info-message.is-success {
    background: #dcfce7;
    color: #166534;
}

.profile-info-message.is-error {
    background: #fee2e2;
    color: #991b1b;
}

.profile-password-section {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border-solid);
}

.profile-password-section h4 {
    margin: 0 0 14px;
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.profile-pw-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-pw-submit {
    width: 100%;
    justify-content: center;
}

.profile-pw-message {
    padding: 10px 13px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.profile-pw-message.is-success {
    background: #dcfce7;
    color: #166534;
}

.profile-pw-message.is-error {
    background: #fee2e2;
    color: #991b1b;
}

/* ── Main area ── */
.main-area {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
    /* Smooth resize when pin state changes */
    transition: flex 0.22s ease;
}

.page-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 50px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-solid);
    flex-shrink: 0;
}

.page-topbar-title {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--navy);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Top bar actions (settings gear, account menu) ── */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    flex: 1;
}

.page-topbar-title {
    min-width: 0;
    flex: 1;
}

/* Hamburger — mobile only (<768px), see media query below */
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--navy);
    cursor: pointer;
}

.mobile-nav-toggle:hover {
    background: var(--bg);
}

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

.profile-menu {
    position: relative;
}

.profile-menu-trigger {
    display: flex;
    align-items: center;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.profile-menu-trigger:focus-visible {
    outline: 2px solid var(--navy-mid);
    outline-offset: 2px;
}

.profile-avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 0.72rem;
    border: 2px solid var(--border-solid);
}

.profile-menu-trigger:hover .profile-avatar-sm {
    border-color: var(--navy-mid);
}

.profile-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 500;
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    animation: menu-select-pop-in 0.12s ease;
}

.profile-menu-user {
    padding: var(--space-2) var(--space-3);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border-solid);
    margin-bottom: var(--space-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-menu-item-form {
    margin: 0;
}

.profile-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
}

.profile-menu-item:hover {
    background: var(--bg);
}

.profile-menu-item-danger {
    color: var(--danger-text);
}

.page-content-wrap {
    flex: 1;
    padding: 22px 26px 48px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Auth shell (login page) ── */
.auth-shell {
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

.auth-brand {
    margin-bottom: 28px;
}

.auth-brand-logo {
    display: block;
    height: 52px;
    width: auto;
    object-fit: contain;
}

/* Legacy shell — kept as no-op so any stray references don't break layout */
.shell {
    width: 100%;
}

/* ── Messages ── */
.messages {
    display: grid;
    gap: 8px;
}

.message {
    border-radius: 7px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 500;
}

.message.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.message.error,
.message.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.message.info {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}


/* ═══════════════════════════════════════
   TYPOGRAPHY & UTILITIES
════════════════════════════════════════ */
.eyebrow {
    margin: 0 0 6px;
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.small-note {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.full-width {
    width: 100%;
}


/* ═══════════════════════════════════════
   CARDS
════════════════════════════════════════ */
.hero-card,
.form-card,
.table-card,
.login-card {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

/* ── Bookkeeping FY collapsible groups ─────────────────────────────── */
.bk-fy-group {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 10px;
}

.bk-fy-group[open] .bk-fy-caret {
    transform: rotate(180deg);
}

.bk-fy-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.bk-fy-summary::-webkit-details-marker { display: none; }
.bk-fy-summary:hover { background: var(--bg); }

.bk-fy-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--navy);
    flex: 1;
}

.bk-fy-count {
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border-solid);
    border-radius: 20px;
    padding: 2px 10px;
}

.bk-fy-caret {
    color: var(--text-secondary);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.bk-fy-body {
    border-top: 1px solid var(--border-solid);
    overflow-x: auto;
}

.bk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.857rem;
}

.bk-table thead tr {
    background: var(--bg);
}

.bk-table th {
    padding: 9px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-solid);
}

.bk-table td {
    padding: 10px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-faint);
    vertical-align: middle;
}

.bk-table tbody tr:last-child td { border-bottom: none; }
.bk-table tbody tr:hover { background: var(--bg); }

.bk-id {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.bk-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.bk-badge--warn { background: #fff3cd; color: #92400e; }
.bk-badge--ok   { background: #d1fae5; color: #065f46; }

.hero-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
}

.form-card {
    padding: 20px 24px;
}

/* `.form-card` is reused across the app as a generic card wrapper (~100
   usages: forms, lists, reports, dashboards, filter panels) — NOT
   exclusively for actual data-entry forms. Capping it to 640px by default
   broke every non-form screen reusing the class (found via a real
   regression: qbf/documents_list.html's quote list shrank to a narrow
   column with a huge blank area beside it). The width cap is therefore
   opt-in, applied explicitly per screen only where it's actually a narrow
   single-column form (per the original "forms stretch full window"
   complaint) — add `.form-card--narrow` to that specific `.form-card`
   element, do not change the base rule again. */
.form-card--narrow {
    max-width: 640px;
}

/* For a multi-section form with a genuine 2-column grid (e.g.
   team/member_form.html), capping the whole .form-card (as --narrow does)
   leaves an odd grey gap beside it — every other card on the page fills the
   row. Cap the <form> itself instead: the white card stays full-width like
   its neighbours, only the fields inside stay a readable width. 760px, not
   640px, because two field-groups side by side need more room than a
   single-column form (TICKET-19 style-guide "Long Form" demo — compared
   both options live before picking this one). */
.stack-form--wide {
    max-width: 760px;
}

/* Same 760px cap, but for wrapping just a *subset* of a form's fields —
   used where a form also contains something genuinely wide (a data table,
   a pricing matrix) that needs the full card width and shouldn't be capped
   alongside the simple fields around it (found live: hub/user_form.html's
   access checklist table and course/price_entry_form.html's currency
   matrix were both squeezed to 760px along with the fields above them). */
.form-fields-wide {
    max-width: 760px;
}

.table-card {
    overflow-x: auto;
    /* .page-content-wrap is a column-direction flex container, so its direct
       children size along the main (vertical) axis via flex-shrink. Setting
       overflow-x here implicitly computes overflow-y to auto too (a legacy
       CSS rule: an axis left "visible" while the other isn't gets promoted
       to auto) — and a flex item with non-visible overflow gets an automatic
       *minimum* size of 0 instead of content-based, so on any page where the
       page column has more room than this card's natural content (found live
       on the low-content style-guide page, TICKET-19), the card would shrink
       to whatever space was left and clip its own content behind a scrollbar
       instead of sizing to it. flex-shrink: 0 keeps this card's height fixed
       to its content, exactly like a normal (non-flex-item) block; the
       overflow-x scroll behavior for wide tables is unaffected. */
    flex-shrink: 0;
}

.table-card-heading {
    padding: 18px 20px 0;
}

.table-card-heading-row {
    justify-content: space-between;
}

.inline-form {
    margin: 0;
}

.payroll-row-actions {
    padding: 14px 20px 18px;
}

.pt-table textarea {
    min-width: 180px;
}

.pt-table input,
.pt-table textarea {
    font-size: 0.84rem;
}

.team-comp-history-list {
    display: grid;
    gap: 12px;
}

.team-comp-history-item {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: var(--bg);
}

.team-comp-history-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.team-comp-history-main h3 {
    margin: 0 0 2px;
    font-size: 1rem;
}

.team-comp-history-main p {
    margin: 0;
}

.team-comp-history-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.team-comp-history-grid div {
    display: grid;
    gap: 2px;
    padding: 10px;
    border: 1px solid var(--border-faint);
    border-radius: 6px;
    background: var(--surface);
}

.team-comp-history-grid span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.team-comp-history-grid strong {
    color: var(--text);
    font-size: 0.9rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px;
}

.dashboard-hero-copy {
    display: grid;
    gap: 6px;
}

.dashboard-hero-copy h2 {
    margin: 0;
    font-size: 1.4rem;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading h2 {
    font-size: 1.35rem;
    margin-bottom: 5px;
}

.section-heading p {
    color: var(--muted);
}


/* ═══════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.primary-button,
.ghost-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    min-height: 40px;
    padding: 0 16px;
    font-size: 0.875rem;
    line-height: 1;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: "Familjen Grotesk", sans-serif;
    white-space: nowrap;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    transition: filter 0.15s, background 0.15s;
}

.primary-button,
.primary-button:visited,
.primary-button:link,
.primary-button:hover,
.primary-button:active {
    background: var(--navy);
    color: #ffffff;
}

.primary-button:hover {
    filter: brightness(1.12);
}

.ghost-button {
    background: var(--surface);
    color: var(--navy);
    border-color: var(--border-solid);
}

.ghost-button:hover {
    background: #f0f4fb;
}

.hero-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.danger-button {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger-text);
}

.danger-button:hover {
    filter: brightness(0.97);
}

.icon-button {
    padding: 0 10px;
    min-width: 38px;
}

/* Generic small-size modifier, usable with any of the three variants above
   e.g. <button class="ghost-button button-sm">. Equivalent to .qbf-small-button. */
.button-sm {
    min-height: 32px;
    padding: 0 14px;
    font-size: 0.84rem;
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.danger-button:focus-visible,
.icon-button:focus-visible,
.table-icon-button:focus-visible {
    outline: 2px solid var(--navy-mid);
    outline-offset: 2px;
}

.button-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

/* ── Table icon buttons ── */
.table-icon-button {
    min-height: 32px;
    min-width: 32px;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-solid);
    background: var(--surface);
    color: var(--navy);
    cursor: pointer;
    transition: background 0.15s;
}

.table-icon-button:hover {
    background: #f0f4fb;
}

.danger-icon-button {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger-text);
}

.danger-icon-button:hover {
    filter: brightness(0.95);
}

/* ── Form / hero action rows ── */
.form-actions,
.topbar-actions,
.entry-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.topbar-actions form,
.entry-actions form {
    margin: 0;
}

.topbar-actions form button,
.entry-actions form button {
    width: 100%;
}


/* ═══════════════════════════════════════
   NAVIGATION & BACK LINK
════════════════════════════════════════ */
.page-back-row {
    margin-bottom: 4px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px 0 8px;
    border-radius: 6px;
    border: 1px solid var(--border-solid);
    background: var(--surface);
    color: var(--navy);
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.84rem;
    font-weight: 600;
    transition: background 0.15s;
}

.back-link:hover {
    background: #f0f4fb;
}

.back-link .button-icon {
    width: 14px;
    height: 14px;
}

/* ── Pills / badges ── */
.user-chip,
.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(10, 31, 68, 0.07);
    color: var(--navy);
    font-size: 0.78rem;
    font-weight: 700;
    font-family: "Familjen Grotesk", sans-serif;
}

.status-pill {
    background: rgba(24, 121, 78, 0.1);
    color: var(--success-text);
}

.status-pill.status-finalized {
    background: rgba(24, 121, 78, 0.1);
    color: var(--success-text);
}

.status-pill.status-draft {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-pill.status-other {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.inactive-pill {
    background: rgba(10, 31, 68, 0.06);
    color: var(--muted);
}


/* ═══════════════════════════════════════
   TABLES
════════════════════════════════════════ */
table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-solid);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--label);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: "Familjen Grotesk", sans-serif;
    background: #f7faff;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: #f7faff;
}

.empty-state {
    color: var(--muted);
    background: transparent;
    border: none;
    font-size: 0.875rem;
    text-align: center;
    padding: 28px 16px;
}

.dashboard-action-cell {
    width: 56px;
}

.dashboard-action-cell form {
    margin: 0;
}


/* ═══════════════════════════════════════
   FORMS
════════════════════════════════════════ */
.stack-form {
    display: grid;
    gap: 16px;
}

.form-row {
    display: grid;
    gap: 5px;
}

.form-row[hidden] {
    display: none !important;
}

/* ── Universal field wrapper ──────────────────────────────────────────────
   <label class="field-group"><span>Label</span><input …></label>
   Was previously only styled where nested under a filter grid; this is the
   general-purpose definition usable in any form. ─────────────────────── */
.field-group {
    display: grid;
    gap: var(--space-2);
    margin: 0;
}

.field-group > span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--label);
    text-transform: none;
}

.field-group input:not([type="file"]),
.field-group select,
.field-group textarea {
    width: 100%;
    min-height: 40px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.875rem;
    font-family: "Inter", sans-serif;
    color: var(--text);
}

.field-group select {
    padding-right: 30px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6a8a'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.field-group textarea {
    min-height: 80px;
    padding: var(--space-2) var(--space-3);
}

.field-group input:not([type="file"]):focus,
.field-group select:focus,
.field-group textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.field-group input:disabled,
.field-group select:disabled,
.field-group textarea:disabled {
    background: var(--bg);
    color: var(--muted);
    cursor: not-allowed;
}

.field-group input.field-error-input,
.field-group.has-error input,
.field-group.has-error select,
.field-group.has-error textarea {
    border-color: var(--danger-border);
}

/* Width caps — apply to an individual .field-group to size it by content,
   instead of letting it stretch to fill the row. */
.field-group.input-sm { max-width: var(--input-sm); }
.field-group.input-md { max-width: var(--input-md); }
.field-group.input-lg { max-width: var(--input-lg); }

/* ── Styled file input (drop-zone style) ──────────────────────────────────
   Replaces a bare <input type="file"> with a clickable bordered zone that
   clearly shows the chosen filename. Markup:
   <div class="file-drop">
     <input type="file" id="…" class="file-drop-input">
     <label for="…" class="file-drop-label">
       <svg class="file-drop-icon">…</svg>
       <span class="file-drop-text">Click to choose a file</span>
       <span class="file-drop-filename">No file selected</span>
     </label>
   </div>
   JS (per-instance) should update .file-drop-filename's text on change. ── */
.file-drop-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 96px;
    padding: var(--space-4);
    border: 1.5px dashed var(--border-solid);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.file-drop-label:hover {
    border-color: var(--navy-mid);
    background: var(--surface);
}

.file-drop-input:focus-visible + .file-drop-label {
    outline: 2px solid var(--navy-mid);
    outline-offset: 2px;
}

.file-drop-icon {
    color: var(--label);
    flex-shrink: 0;
}

.file-drop-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--navy);
}

.file-drop-filename {
    font-size: 0.75rem;
    color: var(--muted);
}

.file-drop-filename.has-file {
    color: var(--success-text);
    font-weight: 600;
}

/* ── Menu select (custom dropdown) ────────────────────────────────────────
   Scoped use: dense, repeated inline selects (e.g. a table's "Set type" /
   "Set category" columns) where the bare native <select> reads as dated.
   Not a project-wide <select> replacement — plain filter/form dropdowns
   keep the native element (Frontend Spec A5) for free accessibility and
   the native mobile picker.

   Markup:
   <div class="menu-select" data-value="expense">
     <button type="button" class="menu-select-trigger" aria-haspopup="listbox" aria-expanded="false">
       <span class="menu-select-value">Expense</span>
       <svg class="menu-select-caret">…</svg>
     </button>
     <ul class="menu-select-panel" role="listbox" hidden>
       <li class="menu-select-option is-selected" role="option" aria-selected="true" data-value="expense">
         <span>Expense</span>
         <svg class="menu-select-check">…</svg>
       </li>
       …
     </ul>
     <select class="menu-select-native sr-only" name="…">…</select>  <!-- real form field, kept in sync -->
   </div>
   JS: see menu-select.js pattern used in the style guide demo — click/keyboard
   on an option updates the hidden <select>'s value and dispatches "change",
   so existing change-listener logic (e.g. cascading kind→category) keeps
   working unmodified. ── */
.menu-select {
    position: relative;
    display: inline-block;
    width: 100%;
}

.menu-select-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.menu-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    min-height: 36px;
    padding: 0 var(--space-2) 0 var(--space-3);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: "Inter", sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.menu-select-trigger:hover {
    border-color: var(--navy-mid);
}

.menu-select-trigger:focus-visible,
.menu-select-native:focus-visible + .menu-select-trigger {
    outline: 2px solid var(--navy-mid);
    outline-offset: 2px;
}

.menu-select.is-open .menu-select-trigger {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.menu-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-select-caret {
    flex-shrink: 0;
    color: var(--label);
    transition: transform 0.15s;
}

.menu-select.is-open .menu-select-caret {
    transform: rotate(180deg);
}

.menu-select-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 40;
    min-width: 100%;
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: var(--space-1);
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    animation: menu-select-pop-in 0.12s ease;
}

@keyframes menu-select-pop-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.menu-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
}

.menu-select-option:hover,
.menu-select-option.is-active {
    background: var(--bg);
}

.menu-select-option.is-selected {
    color: var(--navy);
    font-weight: 600;
}

.menu-select-check {
    flex-shrink: 0;
    color: var(--navy);
    visibility: hidden;
}

.menu-select-option.is-selected .menu-select-check {
    visibility: visible;
}

.menu-select-option-empty {
    padding: var(--space-2) var(--space-3);
    font-size: 0.8rem;
    color: var(--muted);
}

.qbf-static-field {
    min-height: 41px;
    padding: 10px 12px;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.35;
}

.rs-paid-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.rs-paid-actions .settings-form {
    max-width: 240px;
}

.form-row.wide {
    grid-column: 1 / -1;
}

/* Width caps — apply to an individual .form-row to size it by content
   (e.g. a lone date field) instead of letting it stretch to fill a wide
   wrapper like .form-fields-wide. Same tokens as .field-group's caps. */
.form-row.input-sm { max-width: var(--input-sm); }
.form-row.input-md { max-width: var(--input-md); }

.form-grid {
    display: grid;
    gap: 16px;
    /* Without this, grid's default align-items:stretch forces every
       .form-row in a shared row to match the tallest sibling's height (e.g.
       a field with help text next to one without) — then .form-row's own
       internal grid stretches to fill that extra space, pushing its input
       down and misaligning it with its neighbor's. Fields should sit at
       their natural height instead. */
    align-items: start;
}

.two-col-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

/* [type="checkbox"] bumps specificity to (0,2,1), reliably beating
   ".form-row input" (also (0,1,1)) regardless of source order — without it,
   a checkbox inside a .form-row (e.g. the "Active account" toggle on the
   user edit page) inherits that rule's width:100% and stretches to fill the
   row, shoving its label text off to the far right. flex-shrink:0 guards
   against the same stretch via the flex parent instead of width. */
.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.access-check-panel {
    display: grid;
    gap: 14px;
    padding-top: 4px;
}

.access-check-heading {
    margin-bottom: 0;
}

.access-check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.access-check-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: var(--surface);
}

.access-check-item input {
    margin-top: 3px;
}

.access-check-item strong,
.access-check-item small {
    display: block;
}

.access-check-item small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
}

.access-hidden-permissions {
    display: none;
}

.access-matrix-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: var(--surface);
}

.access-matrix-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.access-matrix-table th,
.access-matrix-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-solid);
    text-align: left;
    vertical-align: middle;
}

.access-matrix-table th {
    font-size: 0.76rem;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--bg);
}

.access-matrix-table th:nth-child(2),
.access-matrix-table th:nth-child(3),
.access-matrix-table td:nth-child(2),
.access-matrix-table td:nth-child(3) {
    width: 160px;
    text-align: center;
}

.access-matrix-table tbody tr:last-child td {
    border-bottom: 0;
}

.access-matrix-group-row td {
    padding: 10px 14px;
    background: var(--bg);
    border-top: 1px solid var(--border-solid);
    border-bottom: 1px solid var(--border-solid);
}

.access-matrix-group-row:first-child td {
    border-top: 0;
}

.access-matrix-group-row strong {
    color: var(--navy);
    font-size: 0.86rem;
}

.access-matrix-group-row small {
    color: var(--muted);
    font-size: 0.76rem;
}

.access-matrix-table td strong,
.access-matrix-table td small {
    display: block;
}

.access-matrix-table td small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
}

.access-matrix-choice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 86px;
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: var(--bg);
    color: var(--navy);
    cursor: pointer;
}

.access-matrix-choice input {
    width: auto;
    margin: 0;
}

.access-matrix-choice:has(input:checked) {
    border-color: var(--gold);
    background: rgba(245, 200, 66, 0.14);
}

.access-matrix-na {
    color: var(--muted);
}

.user-access-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-access-actions form {
    margin: 0;
}

.read-only-fieldset {
    display: contents;
    border: 0;
    padding: 0;
    margin: 0;
}

.read-only-fieldset input,
.read-only-fieldset select,
.read-only-fieldset textarea {
    color: var(--text);
    opacity: 1;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--navy);
}

@media (max-width: 760px) {
    .two-col-grid {
        grid-template-columns: 1fr;
    }

    .access-check-grid {
        grid-template-columns: 1fr;
    }
}

.form-row input,
.form-row select,
.form-row textarea,
td input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-solid);
    border-radius: 6px;
    background: var(--surface);
    font-size: 0.875rem;
    font-family: "Inter", sans-serif;
    color: var(--text);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
td input:focus {
    outline: none;
    border-color: var(--navy-mid);
    box-shadow: 0 0 0 3px rgba(23, 56, 119, 0.1);
}

.form-row ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.form-row li label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 500;
    font-size: 0.875rem;
}

.section-heading p,
.hero-card p,
td,
label,
small {
    line-height: 1.6;
}

.form-errors,
.field-error {
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 0.875rem;
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border: 1px solid var(--warning-border);
    border-radius: 7px;
    background: var(--warning-bg);
    color: var(--warning-text);
    font-size: 0.875rem;
}

/* ── Filter card ── */
.filter-card {
    padding: 14px 20px;
}

.filter-details {
    display: grid;
    gap: 14px;
}

.filter-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--navy);
    list-style: none;
}

.filter-summary::-webkit-details-marker {
    display: none;
}

.filter-summary-note {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.filter-details[open] .filter-summary {
    margin-bottom: 2px;
}

.dashboard-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Settings ── */
.settings-form {
    max-width: 540px;
}

.settings-row {
    max-width: 320px;
}


/* ═══════════════════════════════════════
   MODE CARDS (course type choice)
════════════════════════════════════════ */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.mode-card {
    display: grid;
    gap: 10px;
    padding: 20px;
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s, box-shadow 0.18s;
    cursor: pointer;
}

.mode-card:hover {
    border-color: rgba(23, 56, 119, 0.3);
    box-shadow: var(--shadow-md);
}

.mode-card h3 {
    font-size: 1.2rem;
}

.mode-card p {
    color: var(--muted);
    line-height: 1.6;
}


/* ═══════════════════════════════════════
   PACKAGE FORM
════════════════════════════════════════ */
.package-course-list,
.discount-choice-list {
    display: grid;
    gap: 8px;
}

.package-course-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.package-course-option,
.discount-choice-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border-solid);
    border-radius: 7px;
    background: var(--surface);
    font-weight: 600;
}

.package-course-option {
    justify-content: space-between;
}

.package-course-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-weight: 700;
    color: var(--navy);
    font-size: 0.875rem;
}

.package-course-check span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.package-plan-control {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.package-plan-control select {
    min-height: 32px;
    min-width: 130px;
    padding: 5px 10px;
    font-size: 0.875rem;
    text-transform: none;
    letter-spacing: normal;
}

.package-course-option input,
.discount-choice-option input {
    width: auto;
    margin: 0;
}

.discount-choice-list {
    grid-template-columns: repeat(4, minmax(0, max-content));
    align-items: stretch;
    gap: 10px;
}

.discount-choice-option {
    min-height: 68px;
    min-width: 68px;
    padding: 0 18px;
    border-radius: 8px;
    background: rgba(10, 31, 68, 0.06);
    border-color: transparent;
    justify-content: center;
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--navy);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
}

.discount-choice-option:last-child {
    min-width: 130px;
}

.discount-choice-option:hover {
    background: rgba(10, 31, 68, 0.1);
}

.discount-choice-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.discount-choice-option.selected {
    background: var(--navy);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(10, 31, 68, 0.2);
}

.custom-discount-wrap {
    max-width: 260px;
}

/* ── Enrollment plan checkboxes (course form, individual mode) ──────────────
   Same card-pill language as .discount-choice-option, but for a checkbox
   group (multiple can be selected at once) instead of a radio group. ── */
.plan-choice-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    max-width: 460px;
}

.plan-choice-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 8px;
    background: rgba(10, 31, 68, 0.06);
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--navy);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
}

.plan-choice-option:hover {
    background: rgba(10, 31, 68, 0.1);
}

.plan-choice-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.plan-choice-option.selected {
    background: var(--navy);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(10, 31, 68, 0.2);
}

.plan-check-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.plan-choice-option.selected .plan-check-icon {
    opacity: 1;
}

.custom-active {
    border-color: var(--navy-mid) !important;
    box-shadow: 0 0 0 3px rgba(23, 56, 119, 0.1) !important;
}


/* ═══════════════════════════════════════
   ENTRY CARDS (course detail)
════════════════════════════════════════ */
.entry-stack {
    display: grid;
    gap: 16px;
}

.entry-card {
    display: grid;
    gap: 14px;
}

.entry-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 0 4px;
}

.entry-card-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.entry-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.entry-status-row {
    margin-top: 8px;
}

.entry-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.entry-stack .entry-actions a {
    color: inherit;
}


/* ═══════════════════════════════════════
   PRICE MATRIX TABLE
════════════════════════════════════════ */
.matrix-table th[scope="row"] {
    color: var(--navy);
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    background: #f7faff;
}

.matrix-table thead th:first-child {
    min-width: 140px;
}

.cell-note {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.4;
}

.price-primary {
    color: var(--navy);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
}

.discount-note {
    color: var(--success-text);
    font-weight: 700;
}

.included-courses-note {
    display: grid;
    gap: 6px;
    padding: 0 4px;
}

.breakdown-heading {
    font-weight: 700;
    color: var(--navy);
}

.included-course-card {
    padding: 11px 14px;
    border: 1px solid var(--border-solid);
    border-radius: 7px;
    background: var(--surface);
}

.package-breakdown-block {
    display: grid;
    gap: 5px;
}

.package-breakdown-table th:first-child,
.package-breakdown-table td:first-child {
    min-width: 200px;
}

.package-breakdown-table th,
.package-breakdown-table td {
    padding: 8px 12px;
}

.package-plan-header-row th,
.package-plan-header-row td {
    background: rgba(10, 31, 68, 0.04);
    border-bottom: 1px solid var(--border-solid);
}

.package-plan-header-row th {
    color: var(--navy);
    font-size: 0.875rem;
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
}

.package-plan-header-row td {
    padding: 0;
}

.package-row-component th,
.package-row-component td {
    background: var(--surface);
}

.package-row-total th,
.package-row-total td,
.package-row-discount th,
.package-row-discount td {
    font-weight: 800;
}

.package-row-total th,
.package-row-total td {
    background: rgba(10, 31, 68, 0.05);
    color: var(--navy);
}

.package-row-discount th,
.package-row-discount td {
    background: rgba(24, 121, 78, 0.08);
    color: var(--success-text);
}

.package-row-total th,
.package-row-discount th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.875rem;
}

.package-row-component th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.875rem;
    color: var(--navy);
}


/* ═══════════════════════════════════════
   HUB — APP GRID
════════════════════════════════════════ */
.app-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.app-card {
    display: grid;
    gap: 12px;
    padding: 22px;
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.app-card:hover {
    border-color: rgba(23, 56, 119, 0.2);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.app-card-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(10, 31, 68, 0.07);
    color: var(--navy);
}

.app-card-icon svg {
    width: 24px;
    height: 24px;
}

.app-card h3 {
    font-size: 1.15rem;
    margin: 0;
}

.app-card p {
    color: var(--muted);
    line-height: 1.6;
}

.app-card-link {
    justify-self: start;
}


/* ═══════════════════════════════════════
   QBF FINANCE
════════════════════════════════════════ */

/* Flatten old 2-col layout — nav is now in global sidebar */
.qbf-layout {
    display: block;
}

.qbf-sidebar {
    display: none;
}

.qbf-main {
    display: grid;
    gap: 16px;
}

.qbf-dashboard-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.qbf-dashboard-filter-bar {
    display: flex;
    align-items: end;
    gap: 14px;
    flex-wrap: wrap;
}

.qbf-dashboard-filter-bar .form-row {
    min-width: 160px;
}

.qbf-financial-filter-bar .form-row {
    min-width: 140px;
}

.qbf-small-button {
    min-height: 34px;
    padding: 0 14px;
    font-size: 0.84rem;
}

.qbf-tab-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

.qbf-settings-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
}

.qbf-tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 6px;
    border: 1px solid var(--border-solid);
    background: var(--surface);
    color: var(--navy);
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.84rem;
    font-weight: 700;
    transition: background 0.15s;
}

.qbf-tab-link.active {
    background: var(--navy);
    color: #ffffff;
    border-color: transparent;
}

.qbf-tab-link:hover:not(.active) {
    background: #f0f4fb;
}

/* UTM links tab (course detail) */
.utm-links-card {
    padding: 18px;
}

.utm-links-table .utm-url-cell {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-all;
    font-size: 0.82rem;
}

.utm-links-table .utm-actual-cell {
    width: 180px;
    max-width: 180px;
    color: var(--muted, inherit);
}

.utm-final-inner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 280px;
}

.utm-final-inner .utm-url-cell {
    flex: 1;
}

.utm-final-inner [data-icon-done],
.utm-final-inner .is-copied [data-icon-copy] {
    display: none;
}

.utm-final-inner .is-copied [data-icon-done] {
    display: block;
}

.table-icon-button.is-copied {
    color: var(--success-text);
}

.qbf-upload-grid,
.qbf-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* Three side-by-side file drops (e.g. Graphy/Stripe/Razorpay on the combined
   revenue upload) — same row, same width, same height, instead of native
   unstyled <input type="file"> elements sized however the browser feels
   like sizing them. */
.qbf-upload-grid--3col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.qbf-email-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
}

.qbf-email-chip {
    font-size: 0.78rem;
    padding: 6px 10px;
}

.qbf-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── LMS / Platform settings panel ────────────────────────────────────────── */
.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--muted, #6b7a99);
    line-height: 1.4;
}

.qbf-lms-summary {
    margin-top: 20px;
    padding: 16px 18px;
    background: var(--surface-tint, #f7faff);
    border: 1px solid var(--border-solid, #d8e1f0);
    border-radius: 8px;
}

.qbf-lms-summary .eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted, #6b7a99);
    margin-bottom: 4px;
}

.qbf-lms-summary strong {
    font-size: 1rem;
    color: var(--navy, #0a1f44);
}

.qbf-lms-charges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.qbf-lms-charge-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid var(--border-solid, #d8e1f0);
    border-radius: 8px;
    min-width: 120px;
}

.qbf-charge-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted, #6b7a99);
}

.qbf-charge-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy, #0a1f44);
}

.qbf-period-grid {
    grid-template-columns: minmax(140px, 0.7fr) minmax(120px, 0.55fr);
    align-items: end;
    margin-bottom: 12px;
}

.period-mode-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 6px 0 2px;
}

.period-mode-option {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 400;
}

.period-mode-option input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: var(--navy);
    cursor: pointer;
    flex-shrink: 0;
}

.qbf-upload-action-cell {
    align-self: end;
}

.qbf-upload-action-cell .primary-button {
    min-height: 38px;
}

.qbf-action-label {
    visibility: hidden;
}

.qbf-upload-actions {
    justify-content: flex-end;
    margin-top: -4px;
}

.qbf-manual-wide {
    grid-column: 1 / -1;
}

.qbf-category-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.qbf-inline-table {
    margin: 0;
}

.qbf-review-row {
    background: rgba(197, 157, 95, 0.06);
}

.qbf-transaction-form {
    display: contents;
}

.qbf-compact-card {
    padding: 16px 18px;
    min-height: 0;
}

.qbf-compact-card h3 {
    margin: 0 0 3px;
    font-size: 1.8rem;
    line-height: 1;
}

.qbf-compact-card p {
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--muted);
}

.qbf-review-panel {
    padding: 14px 14px 8px;
}

.qbf-review-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    /* Plain layout wrapper only — the visual card treatment lives on the
       .pt-filter-bar form itself (Frontend Spec A9), so this toolbar just
       arranges the filter bar and the Fullscreen button side by side.
       (Corrected during TICKET-08B: an earlier version gave this wrapper
       its own card styling to match .pt-filter-bar, which double-boxed
       once the filter form was switched to actually use .pt-filter-bar.) */
}

.qbf-review-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.qbf-review-filter-form {
    flex: 1 1 680px;
    display: grid;
    gap: 10px;
}

.qbf-review-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.qbf-review-filter-grid .field-group {
    margin: 0;
}

.qbf-review-filter-grid .field-group span {
    display: block;
    margin-bottom: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.qbf-review-filter-grid input,
.qbf-review-filter-grid select {
    min-height: 36px;
}

.qbf-review-table th,
.qbf-review-table td {
    padding: 9px 10px;
    vertical-align: top;
}

.qbf-review-table th {
    font-size: 0.7rem;
}

.qbf-review-table td {
    white-space: normal;
}

.qbf-review-table th:nth-child(1),
.qbf-review-table td:nth-child(1) {
    width: 120px;
    min-width: 120px;
}

.qbf-review-table th:nth-child(2),
.qbf-review-table td:nth-child(2) {
    min-width: 320px;
    max-width: 500px;
}

.qbf-review-table th:nth-child(3),
.qbf-review-table td:nth-child(3) {
    width: 110px;
    min-width: 110px;
}

.qbf-review-table th:nth-child(4),
.qbf-review-table td:nth-child(4) {
    width: 140px;
    min-width: 140px;
}

.qbf-review-table th:nth-child(5),
.qbf-review-table td:nth-child(5) {
    width: 150px;
    min-width: 150px;
}

.qbf-review-table th:nth-child(6),
.qbf-review-table td:nth-child(6) {
    width: 200px;
    min-width: 200px;
}

.qbf-review-table th:nth-child(7),
.qbf-review-table td:nth-child(7) {
    width: 100px;
    min-width: 100px;
}

.qbf-review-table th:nth-child(8),
.qbf-review-table td:nth-child(8) {
    width: 70px;
    min-width: 70px;
}

.qbf-review-table strong {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.qbf-review-panel.is-fullscreen {
    position: fixed;
    inset: 12px;
    width: auto;
    height: auto;
    margin: 0;
    z-index: 1200;
    border-radius: 10px;
    padding: 16px 16px 10px;
    background: rgba(255, 255, 255, 0.99);
    overflow: auto;
    box-shadow: 0 20px 64px rgba(10, 31, 68, 0.2);
}

.qbf-review-panel.is-fullscreen .qbf-review-table th:nth-child(2),
.qbf-review-panel.is-fullscreen .qbf-review-table td:nth-child(2) {
    max-width: none;
}

.qbf-review-panel.is-fullscreen .qbf-review-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: inset 0 -1px 0 var(--border-solid);
}

.qbf-combined-panel {
    padding: 12px;
}

/* ── Combined toolbar ─────────────────────── */
.qbf-combined-toolbar {
    /* Stacked, not side-by-side: the title sitting beside the filter bar
       (as this screen originally had it) ate real width from the row,
       causing the filter bar to wrap even with `flex:1 1 auto` — the
       reference filter bar (course/dashboard.html) never shares its row
       with anything, so give it the same full-width row here. */
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
}

.qbf-combined-toolbar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.qbf-combined-toolbar-title {
    min-width: 160px;
}

.qbf-combined-toolbar-title h2 {
    margin: 0 0 2px;
}

.qbf-combined-toolbar-title p {
    margin: 0;
}

.qbf-combined-filter-bar {
    flex: 1 1 520px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.qbf-combined-filter-grid {
    display: grid;
    grid-template-columns: 160px 130px 1fr;
    gap: 10px;
    flex: 1 1 380px;
}

.qbf-combined-filter-grid .field-group {
    margin: 0;
}

.qbf-combined-filter-grid .field-group span {
    display: block;
    margin-bottom: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.qbf-combined-filter-grid input,
.qbf-combined-filter-grid select {
    min-height: 36px;
}

.qbf-combined-filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding-bottom: 1px;
}

.qbf-row-count {
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ── Combined table wrapper ───────────────── */
.qbf-combined-table-wrap {
    width: 100%;
    max-height: 72vh;
    overflow: auto;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
}

.qbf-combined-table {
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
    font-size: 0.78rem;
}

.qbf-combined-table th,
.qbf-combined-table td {
    padding: 7px 9px;
    min-width: 90px;
    max-width: 180px;
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

.qbf-combined-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--bg);
    box-shadow: inset 0 -1px 0 var(--border-solid);
}

.qbf-combined-table th:first-child,
.qbf-combined-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 116px;
    max-width: 116px;
    background: var(--surface);
    box-shadow: inset -1px 0 0 var(--border-solid);
}

.qbf-combined-table thead th:first-child {
    z-index: 5;
    background: var(--bg);
}

.qbf-combined-table td.is-wide {
    min-width: 200px;
    max-width: 320px;
}

.qbf-combined-table td.is-compact {
    min-width: 118px;
    max-width: 148px;
}

.qbf-combined-table td.is-number {
    min-width: 80px;
    max-width: 120px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.qbf-combined-table td.is-editable {
    min-width: 100px;
    background: rgba(255, 255, 255, 0.72);
}

.qbf-combined-table td.is-number.is-editable {
    min-width: 96px;
}

.qbf-combined-table tbody tr.qbf-combined-review-row td {
    background: #fff7ed;
}

.qbf-combined-table tbody tr.qbf-combined-review-row td:first-child {
    background: #ffedd5;
}

.qbf-combined-table tbody tr.qbf-combined-review-row td.is-editable {
    background: #fffbeb;
}

.qbf-combined-table td.is-locked {
    background: rgba(241, 245, 249, 0.78);
}

.qbf-combined-table input,
.qbf-combined-table select {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
}

.qbf-combined-table input:disabled,
.qbf-combined-table select:disabled {
    color: var(--text-muted);
    background: #f1f5f9;
    border-color: var(--border-solid);
    cursor: not-allowed;
}

.qbf-combined-table select {
    min-width: 0;
}

.qbf-combined-table td:first-child select {
    font-size: 0.72rem;
    padding: 5px 6px;
}

.qbf-row-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-solid);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.qbf-row-delete-btn:hover {
    background: rgba(197, 48, 48, 0.08);
    border-color: #c53030;
    color: #c53030;
}
.qbf-row-edit-btn:hover {
    background: var(--accent-soft, rgba(37, 99, 235, 0.08));
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
}

.qbf-match-reason {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qbf-review-code-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    max-width: 230px;
}

.qbf-review-code {
    border: 1px solid rgba(165, 67, 67, 0.28);
    border-radius: 6px;
    background: rgba(255, 245, 238, 0.92);
    color: #9f342e;
    font: 600 0.62rem/1.2 var(--font-body);
    padding: 3px 5px;
    white-space: nowrap;
}

.qbf-combined-panel.is-fullscreen .qbf-combined-table-wrap {
    max-height: calc(100vh - 140px);
}

body.qbf-fullscreen-open {
    overflow: hidden;
}

/* ── Shared fullscreen-panel base (TICKET-08B) ────────────────────────────
   Generalizes the .qbf-review-panel.is-fullscreen / .qbf-combined-panel
   .is-fullscreen duplication into one reusable rule. New/migrated screens
   should add .fullscreen-panel alongside their existing panel class, e.g.
   <section class="table-card qbf-review-panel fullscreen-panel">, and their
   toggle JS should target [data-fullscreen-key] instead of a hardcoded id
   so more than one such panel can exist on a page. Any screen-specific
   tweaks (e.g. which table column stays capped) stay in that screen's own
   selector, layered on top of this base. ── */
.fullscreen-panel.is-fullscreen {
    position: fixed;
    inset: 12px;
    width: auto;
    height: auto;
    margin: 0;
    z-index: 1200;
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-4) var(--space-2);
    background: rgba(255, 255, 255, 0.99);
    overflow: auto;
    box-shadow: 0 20px 64px rgba(10, 31, 68, 0.2);
}

body.fullscreen-open {
    overflow: hidden;
}

/* Column group divider — applied via JS to the first "calculated" column */
.qbf-combined-table th.is-group-start,
.qbf-combined-table td.is-group-start {
    border-left: 2px solid var(--border-solid);
}

/* Filter: hidden rows */
.qbf-combined-table tbody tr[data-review-row].is-filtered-out {
    display: none;
}

/* Status badge chips in match column */
.qbf-match-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    margin-bottom: 4px;
}

.qbf-match-badge.badge-matched     { background: #dcfce7; color: #166534; }
.qbf-match-badge.badge-inr-only    { background: #e0f2fe; color: #0369a1; }
.qbf-match-badge.badge-needs-review { background: #fef3c7; color: #92400e; }
.qbf-match-badge.badge-unmatched   { background: #fee2e2; color: #991b1b; }


/* ═══════════════════════════════════════
   FINANCIAL CHARTS
════════════════════════════════════════ */
.financial-report-card {
    display: grid;
    gap: 16px;
}

.financial-report-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.financial-report-header h2,
.financial-chart-card h3 {
    margin: 0;
}

.financial-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.financial-chart-card {
    padding: 20px;
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.financial-doughnut-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

/* ── GST Summary Report ──────────────────────── */
.gst-report {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gst-section {
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    overflow: hidden;
}

/* Section label / heading strip */
.gst-section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border-solid);
}

.gst-section-revenue .gst-section-label { color: var(--navy);   background: #f0f4ff; border-color: #dce6ff; }
.gst-section-output  .gst-section-label { color: #0369a1;       background: #f0f9ff; border-color: #bae6fd; }
.gst-section-net     .gst-section-label { color: #92400e;       background: #fffbeb; border-color: #fde68a; }

/* Individual row */
.gst-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-solid);
    gap: 12px;
}

.gst-row:last-child { border-bottom: none; }

.gst-row-name   { font-size: 0.875rem; }
.gst-row-amount { font-size: 0.875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Detail rows */
.gst-row-detail .gst-row-name   { color: var(--text); }
.gst-row-detail .gst-row-amount { color: var(--text); }

/* Sub-rows (Courses / Client Invoices inside Total Taxable Revenue) */
.gst-row-sub {
    padding-left: 2rem;
    background: #fafbff;
}
.gst-row-sub .gst-row-name   { color: var(--muted, #6b7280); font-style: italic; }
.gst-row-sub .gst-row-amount { color: var(--muted, #6b7280); }

/* Hero (taxable revenue) row */
.gst-row-hero {
    background: #f8faff;
}

.gst-row-hero .gst-row-name   { font-weight: 500; }
.gst-row-hero .gst-row-amount { font-size: 1.05rem; font-weight: 700; color: var(--navy); }

/* Sub-total rows (e.g. Total GST collected) */
.gst-row-total {
    background: var(--bg);
    border-top: 2px solid var(--border-solid);
}

.gst-row-total .gst-row-name,
.gst-row-total .gst-row-amount {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--navy);
}

/* Net GST liability — most important row */
.gst-row-net {
    background: var(--navy);
    border-top: none;
}

.gst-row-net .gst-row-name,
.gst-row-net .gst-row-amount {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
}

.financial-doughnut-header p {
    margin: 5px 0 0;
}

/* Generic totals row for a plain <table>'s <tfoot> (e.g. TDS Summary) —
   same navy/bold treatment as .gst-row-total, for any inline-table report. */
.qbf-table-totals-row td {
    background: var(--bg);
    border-top: 2px solid var(--border-solid);
    color: var(--navy);
    white-space: nowrap;
}

.financial-doughnut-total {
    font-size: 1rem;
    color: var(--navy);
    white-space: nowrap;
}

.financial-doughnut-card {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.financial-doughnut-wrap {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 0 auto;
}

.financial-doughnut-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.financial-doughnut-track,
.financial-doughnut-segment {
    fill: none;
    stroke-width: 13;
    transform-origin: 60px 60px;
    transform: rotate(-90deg);
}

.financial-doughnut-track {
    stroke: rgba(10, 31, 68, 0.07);
}

.financial-doughnut-segment {
    stroke-linecap: butt;
    transition: stroke-width 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
}

.financial-doughnut-segment:hover {
    stroke-width: 16;
    opacity: 0.96;
}

.financial-doughnut-empty {
    min-height: 200px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(10, 31, 68, 0.03);
    color: var(--muted);
    text-align: center;
    padding: 20px;
    font-size: 0.875rem;
}

.financial-doughnut-hole {
    position: absolute;
    inset: 50px;
    display: grid;
    place-content: center;
    gap: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.97);
    text-align: center;
    box-shadow: inset 0 0 0 1px rgba(10, 31, 68, 0.05);
}

.financial-doughnut-hole span {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.financial-doughnut-hole strong {
    font-size: 1.05rem;
    color: var(--navy);
    font-family: "Familjen Grotesk", sans-serif;
}

.financial-doughnut-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 10px;
}

.financial-doughnut-legend-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto auto;
    gap: 7px;
    align-items: center;
    padding: 6px 9px;
    border-radius: 6px;
    background: rgba(10, 31, 68, 0.025);
}

.financial-doughnut-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.financial-doughnut-label,
.financial-doughnut-value,
.financial-doughnut-meta {
    color: var(--navy);
    font-size: 0.8rem;
    font-weight: 700;
}

.financial-doughnut-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.financial-doughnut-meta {
    color: var(--muted);
    font-weight: 600;
}

.financial-chart-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.financial-chart-row {
    display: grid;
    grid-template-columns: minmax(110px, 170px) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.financial-chart-label,
.financial-chart-value {
    font-size: 0.875rem;
    color: var(--navy);
    font-weight: 700;
}

.financial-chart-track {
    height: 9px;
    border-radius: 999px;
    background: rgba(10, 31, 68, 0.07);
    overflow: hidden;
}

.financial-chart-bar {
    height: 100%;
    border-radius: 999px;
}

.financial-chart-bar.positive {
    background: linear-gradient(135deg, var(--navy), var(--navy-mid));
}

.financial-chart-bar.negative {
    background: linear-gradient(135deg, #d04b4b, #b42318);
}

/* ═══════════════════════════════════════
   TOOL PROMOS
════════════════════════════════════════ */
.tool-promo-page {
    display: grid;
    gap: 14px;
}

.tool-promo-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-solid);
}

.tool-promo-section-header h3 {
    margin: 0;
    font-size: 1.08rem;
}

.tool-promo-count {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border-solid);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    font-family: "Familjen Grotesk", sans-serif;
    white-space: nowrap;
}

.tool-promo-table th,
.tool-promo-table td {
    padding: 13px 20px;
}

.tool-promo-page .table-card form > .form-actions {
    padding: 16px 20px 18px;
}

.tool-promo-tool-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-promo-tool-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--gold-soft);
    color: #8a6300;
    flex: 0 0 34px;
}

.tool-promo-tool-icon svg {
    width: 17px;
    height: 17px;
}

.tool-promo-tool-cell strong,
.tool-promo-tool-cell .cell-note {
    display: block;
}

.tool-promo-select {
    width: 100%;
    min-width: 280px;
    padding: 9px 34px 9px 12px;
    border: 1px solid var(--border-solid);
    border-radius: 7px;
    background-color: var(--surface);
    color: var(--text);
    font-family: "Inter", sans-serif;
    font-size: 0.875rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6a8a'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.tool-promo-select:focus {
    outline: none;
    border-color: var(--navy-mid);
    box-shadow: 0 0 0 3px rgba(23, 56, 119, 0.1);
}

.tool-promo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 14px;
    padding: 18px 20px 20px;
}

.tool-promo-card {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: #fbfdff;
    box-shadow: 0 1px 2px rgba(10, 31, 68, 0.04);
}

.tool-promo-media {
    width: 116px;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border-solid);
}

.tool-promo-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tool-promo-media-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(10, 31, 68, 0.36);
}

.tool-promo-media-placeholder svg {
    width: 34px;
    height: 34px;
}

.tool-promo-card-body {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 8px;
}

.tool-promo-card-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tool-promo-name {
    min-width: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-promo-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.tool-promo-card-actions form {
    margin: 0;
}

.tool-promo-card h4 {
    margin: 0;
    color: var(--navy);
    font-size: 1rem;
    line-height: 1.25;
}

.tool-promo-headline,
.tool-promo-description {
    margin: 0;
    color: var(--text);
    font-size: 0.86rem;
    line-height: 1.5;
}

.tool-promo-description {
    color: var(--muted);
}

.tool-promo-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-promo-default-pill {
    background: rgba(197, 157, 95, 0.18);
    color: #7a5a1a;
}

.tool-promo-link-row {
    display: grid;
    gap: 2px;
    padding-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
}

.tool-promo-link-row span {
    font-weight: 700;
    color: var(--navy);
}

.tool-promo-link-row a {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

.tool-promo-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

.tool-promo-form-grid .wide {
    grid-column: 1 / -1;
}

.tool-promo-form-grid .form-row {
    align-content: start;
    min-width: 0;
}

.tool-promo-form-grid .form-row label {
    min-height: 20px;
}

.tool-promo-form-grid .form-row input,
.tool-promo-form-grid .form-row select,
.tool-promo-form-grid .form-row textarea {
    min-height: 40px;
}

.tool-promo-form-grid .form-row input[type="file"] {
    padding-top: 9px;
}

.tool-promo-url-status {
    min-height: 18px;
    font-size: 0.78rem;
    font-weight: 700;
}

.tool-promo-url-status.is-empty,
.tool-promo-url-status.is-checking {
    color: var(--muted);
}

.tool-promo-url-status.is-ok {
    color: var(--success-text);
}

.tool-promo-url-status.is-error {
    color: var(--danger-text);
}

.tool-promo-form .primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    filter: none;
}

.tool-promo-checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.tool-promo-check {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    background: var(--bg);
    cursor: pointer;
}

.tool-promo-check input {
    width: auto;
    margin-top: 3px;
}

.tool-promo-check strong,
.tool-promo-check small {
    display: block;
}

.tool-promo-check strong {
    color: var(--navy);
    font-size: 0.88rem;
}

.tool-promo-check small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.45;
}


/* ═══════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    /* Sidebar visibility below 900px is now governed by the off-canvas
       system (TICKET-13, see the 767px query further down) — this used to
       unconditionally hide the sidebar with no way to open it at all. */

    .main-area {
        height: auto;
        overflow: visible;
    }

    .page-content-wrap {
        overflow-y: visible;
        padding: 16px 18px 36px;
    }
}

@media (max-width: 768px) {
    .hero-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .tool-promo-section-header {
        flex-direction: column;
        gap: 8px;
    }

    .tool-promo-grid {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .tool-promo-card {
        grid-template-columns: 1fr;
    }

    .tool-promo-media {
        width: 100%;
        max-height: 190px;
        aspect-ratio: 16 / 9;
    }

    .tool-promo-form-grid,
    .tool-promo-checks {
        grid-template-columns: 1fr;
    }

    .entry-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-filter-grid {
        grid-template-columns: 1fr;
    }

    .mode-grid,
    .app-grid,
    .qbf-upload-grid,
    .qbf-upload-grid--3col,
    .qbf-settings-grid,
    .qbf-metric-grid,
    .qbf-category-layout,
    .qbf-dashboard-metrics,
    .financial-chart-grid {
        grid-template-columns: 1fr;
    }

    .qbf-tab-strip {
        flex-wrap: wrap;
    }

    .qbf-review-toolbar {
        align-items: stretch;
    }

    .qbf-review-filter-grid,
    .qbf-review-toolbar-group {
        width: 100%;
    }

    .qbf-review-filter-grid {
        grid-template-columns: 1fr;
    }

    .financial-report-header,
    .financial-doughnut-header {
        flex-direction: column;
    }

    .financial-doughnut-legend {
        grid-template-columns: 1fr;
    }

    .financial-doughnut-wrap {
        width: 180px;
        height: 180px;
    }

    .financial-doughnut-hole {
        inset: 40px;
    }
}


/* ═══════════════════════════════════════
   HUB HOME PAGE
════════════════════════════════════════ */

.hub-welcome {
    margin-bottom: 22px;
}

.hub-welcome-title {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
    margin: 2px 0 4px;
    line-height: 1.2;
}

.hub-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 18px;
    align-items: start;
}

.hub-section-title {
    font-size: 0.857rem;
    font-weight: 700;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

/* App grid */
.hub-app-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.hub-app-card {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 18px;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.18s, transform 0.18s;
}

.hub-app-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* App icon */
.hub-app-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.hub-app-icon--navy {
    background: linear-gradient(135deg, var(--navy-mid), var(--navy));
}

.hub-app-icon--gold {
    background: linear-gradient(135deg, #d4b07a, var(--gold));
}

.hub-app-name {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 5px;
}

.hub-app-desc {
    font-size: 0.857rem;
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 14px;
}

/* Feature list */
.hub-app-features {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.hub-app-feature {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.843rem;
    color: var(--muted);
}

.hub-app-feature svg {
    color: var(--gold);
    flex-shrink: 0;
}

/* CTA button */
.hub-app-cta {
    align-self: flex-start;
    margin-top: auto;
}

.hub-app-cta--gold {
    background: linear-gradient(135deg, #d4b07a, var(--gold));
    color: var(--navy);
    border-color: transparent;
}

.hub-app-cta--gold:hover {
    background: linear-gradient(135deg, var(--gold), #b8893e);
    color: var(--navy);
}

/* Quick links panel */
.hub-panel {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.hub-panel-header {
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--border-solid);
}

.hub-panel-title {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.857rem;
    font-weight: 700;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hub-panel-body {
    padding: 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hub-quick-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: 7px;
    font-size: 0.857rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: background 0.14s;
}

.hub-quick-link:hover {
    background: #eef2fb;
    color: var(--navy);
}

.hub-quick-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(10, 31, 68, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--navy);
}

/* Hub responsive */
@media (max-width: 900px) {
    .hub-layout {
        grid-template-columns: 1fr;
    }

    .hub-app-grid {
        grid-template-columns: 1fr;
    }
}


/* ═══════════════════════════════════════
   KPI CARDS (QBF DASHBOARD)
════════════════════════════════════════ */

.kpi-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.16s, transform 0.16s;
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.kpi-card.k-gold::before  { background: var(--gold); }
.kpi-card.k-navy::before  { background: var(--navy); }
.kpi-card.k-green::before { background: #16a34a; }
.kpi-card.k-red::before   { background: #dc2626; }
.kpi-card.k-blue::before  { background: #0369a1; }

.kpi-eyebrow {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
    margin-bottom: 7px;
}

.kpi-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
}

.trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
}

.t-up   { color: #16a34a; background: #f0fdf4; }
.t-down { color: #dc2626; background: #fef2f2; }
.t-flat { color: var(--muted); background: var(--bg); }


/* ═══════════════════════════════════════
   QBF DASHBOARD LAYOUT
════════════════════════════════════════ */

.db-sec-hdr {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.db-sec-title {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy);
    margin: 2px 0 0;
}

.db-reset-btn {
    font-size: 0.857rem;
    padding: 6px 12px;
    align-self: center;
}

/* ── Trend charts range control (independent of the period matrix picker
   above — see 04-Chart-Guidelines.md) ───────────────────────────────── */
.db-trend-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 28px 0 14px;
}

.db-trend-hdr-title {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--navy);
}

.db-trend-range-picker {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 8px;
}

.db-trend-range-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.db-trend-range-btn:hover { background: var(--bg); color: var(--navy); }
.db-trend-range-btn--active { background: var(--navy); color: #fff; }

.db-trend-avg {
    font-weight: 600;
}
/* Same colors as the Gross Revenue / Total Expenses lines on the Monthly
   Revenue & Expenses chart, so the stat line and the chart read as one. */
.db-trend-avg--rev { color: #2f855a; }
.db-trend-avg--exp { color: #c53030; }

/* ── Period matrix picker ──────────────────────────────────────────── */
.pm-wrap {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
}

.pm-all-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-solid);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.pm-all-btn:hover { background: var(--bg); color: var(--navy); }
.pm-all-btn.pm--active { background: var(--navy); color: #fff; border-color: var(--navy); }

.pm-fy-block {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.pm-fy-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1.5;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-solid);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.pm-fy-tab:hover,
.pm-fy-tab--has-active { background: var(--bg); color: var(--navy); }
.pm-fy-block--open .pm-fy-tab { background: var(--navy); color: #fff; border-color: var(--navy); }

.pm-caret {
    transition: transform 0.2s;
    opacity: 0.7;
}
.pm-fy-block--open .pm-caret { transform: rotate(180deg); }

.pm-grid {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border-solid);
    border-radius: 8px;
    min-width: 340px;
}
.pm-fy-block--open .pm-grid { display: flex; }

.pm-fy-all-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 3px 6px;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
    align-self: flex-start;
}
.pm-fy-all-link:hover { background: var(--surface); color: var(--navy); }
.pm-fy-all-link.pm--active { color: var(--navy); font-weight: 700; }

.pm-quarters {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.pm-quarter-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pm-q-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 4px 3px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--navy);
    background: var(--surface);
    border: 1px solid var(--border-solid);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    line-height: 1.2;
}
.pm-q-btn:hover { background: #dde5f0; }
.pm-q-btn.pm--active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pm-q-btn.pm--no-data { opacity: 0.35; pointer-events: none; }

.pm-q-range {
    font-size: 0.62rem;
    font-weight: 400;
    opacity: 0.75;
    margin-top: 1px;
}

.pm-month-row {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.pm-month-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border-solid);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}
.pm-month-btn:hover { background: #dde5f0; color: var(--navy); }
.pm-month-btn.pm--active { background: var(--gold); color: #fff; border-color: var(--gold); font-weight: 700; }
.pm-month-btn.pm--no-data { opacity: 0.3; pointer-events: none; }

/* ── Chart.js canvas wrapper (Chart Guidelines §7/§8,
   docs/ui-standardization/04-Chart-Guidelines.md) — Chart.js is responsive
   to its container's *width* automatically, but height must come from a
   fixed-height wrapper, with maintainAspectRatio:false set on every chart
   config so it actually fills that height. ──────────────────────────── */
.chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 260px;
}

.chart-canvas-wrap--sm {
    height: 220px;
}

/* Sparkline cards sit the chart beside text in a flex row (.db-spark-card)
   — the base .chart-canvas-wrap's width:100% would claim the whole row and
   squeeze .db-spark-info's text (category name/total/trend) down to nothing,
   since it has min-width:0. Fixed, small, non-shrinking size instead. */
.chart-canvas-wrap--spark {
    width: 120px;
    height: 44px;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .chart-canvas-wrap { height: 200px; }
    .chart-canvas-wrap--sm { height: 180px; }
}

/* ── Expense sparklines grid ───────────────────────────────────────── */
.db-sparklines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.db-spark-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border-solid);
    border-radius: 8px;
}

.db-spark-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.db-spark-cat {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.db-spark-total {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sp-trend-up { font-size: 0.7rem; color: #2f855a; }
.sp-trend-dn { font-size: 0.7rem; color: #c53030; }
.sp-trend-flat { font-size: 0.7rem; color: var(--text-secondary); }

.db-period-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--gold-soft);
    color: var(--gold);
    font-family: "Inter", sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
    letter-spacing: 0.01em;
}

/* Charts two-column row */
.db-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

/* Generic dashboard card */
.db-card {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 14px;
}

.db-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px 11px;
    border-bottom: 1px solid var(--border-solid);
}

.db-card-title {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--navy);
}

.db-card-meta {
    font-size: 0.857rem;
    color: var(--muted);
    font-weight: 600;
}

.db-card-body {
    padding: 16px 18px;
}

.db-card-body--table {
    padding: 0;
    overflow-x: auto;
}

.db-sm-btn {
    font-size: 0.857rem;
    padding: 5px 12px;
}

.db-empty {
    color: var(--muted);
    font-size: 0.857rem;
    text-align: center;
    padding: 24px 0;
    margin: 0;
}

/* ── Bank Income Split donut — side-by-side layout ──────────────────── */
.db-donut2-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 28px;
}

.db-donut2-ring {
    position: relative;
    width: 190px;
    height: 190px;
    flex-shrink: 0;
}

.db-donut2-svg {
    width: 190px;
    height: 190px;
    display: block;
}

.db-donut2-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}

.db-donut2-val {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
}

.db-donut2-lbl {
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Legend — vertical stack filling the remaining width */
.db-donut2-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 0;
}

.db-donut2-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.db-donut2-item-hdr {
    display: flex;
    align-items: center;
    gap: 7px;
}

.db-donut2-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.db-donut2-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.db-donut2-nums {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 16px;
}

.db-donut2-amount {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--navy);
}

.db-donut2-pct {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 36px;
    text-align: right;
}

/* Proportion bar inside each legend row */
.db-donut2-bar-track {
    height: 5px;
    background: var(--border-solid);
    border-radius: 3px;
    margin-left: 16px;
    overflow: hidden;
}

.db-donut2-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── Revenue by State (India) map ────────────────────────────────────── */
.db-statemap-wrap {
    display: flex;
    align-items: flex-start;
    gap: 28px;
    flex-wrap: wrap;
}

.db-statemap-svg-wrap {
    position: relative;
    width: 320px;
    flex-shrink: 0;
}
.db-statemap-svg-wrap svg {
    width: 100%;
    height: auto;
    display: block;
}

.db-statemap-path {
    stroke: #fff;
    stroke-width: 0.7;
    cursor: pointer;
    transition: opacity 0.15s;
}
.db-statemap-path:hover { opacity: 0.75; }
.db-statemap-path--empty { cursor: default; }
.db-statemap-path--empty:hover { opacity: 1; }

.db-statemap-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--navy);
    color: #fff;
    font-size: 0.72rem;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    transform: translate(-50%, -110%);
    z-index: 5;
    box-shadow: 0 4px 10px rgba(10, 31, 68, 0.25);
}
.db-statemap-tooltip strong {
    display: block;
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.78rem;
    margin-bottom: 2px;
}

.db-statemap-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
}

.db-statemap-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Bar chart */
.db-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.db-bar-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.db-bar-hdr {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.db-bar-lbl {
    font-size: 0.857rem;
    font-weight: 500;
    color: var(--text);
}

.db-bar-val {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.857rem;
    font-weight: 700;
    color: var(--navy);
}

.db-bar-track {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.db-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Currency revenue */
.db-currency-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.db-currency-item {
    display: flex;
    align-items: center;
    gap: 14px;
}

.db-currency-badge {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
    letter-spacing: 0.03em;
}

.db-currency-info {
    flex: 1;
    min-width: 0;
}

.db-currency-amount {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}

.db-currency-bar-wrap {
    height: 5px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 3px;
}

.db-currency-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.db-currency-pct {
    font-size: 0.786rem;
    color: var(--muted);
}

/* Inner tables (inside db-card) */
.db-inner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.857rem;
}

.db-inner-table thead tr {
    border-bottom: 1px solid var(--border-solid);
}

.db-inner-table th {
    padding: 10px 16px;
    font-size: 0.786rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: transparent;
    white-space: nowrap;
}

.db-inner-table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(10, 31, 68, 0.05);
    vertical-align: middle;
}

.db-inner-table tbody tr:last-child td {
    border-bottom: none;
}

.db-inner-table tbody tr:hover td {
    background: #f8fafd;
}

.ta-r { text-align: right; }

.db-num {
    font-family: "Familjen Grotesk", sans-serif;
    font-weight: 700;
    color: var(--navy);
}

.db-muted { color: var(--muted) !important; font-weight: 500 !important; }
.db-income { color: #16a34a !important; }
.db-expense { color: #dc2626 !important; }

.db-month-name, .db-course-name {
    font-weight: 600;
    color: var(--navy);
}

/* Share bar in course table */
.db-share-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.db-share-bar-wrap {
    width: 60px;
    height: 5px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.db-share-bar {
    height: 100%;
    background: var(--navy);
    border-radius: 3px;
}

.db-share-pct {
    font-size: 0.786rem;
    color: var(--muted);
    min-width: 36px;
    text-align: right;
}

/* Badges for margin/review */
.db-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.786rem;
    font-weight: 700;
}

.db-badge--green { color: #15803d; background: #f0fdf4; }
.db-badge--gold  { color: #92400e; background: #fffbeb; }
.db-badge--grey  { color: var(--muted); background: var(--bg); }
.db-badge--red   { color: #b91c1c; background: #fef2f2; }

/* Top countries card */
.db-country-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.db-viewmore-btn {
    margin-top: 16px;
    width: 100%;
    justify-content: center;
}

.db-viewmore-count {
    margin: 0 0 16px;
    font-size: 0.8rem;
}

.db-viewmore-list {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.db-country-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.db-country-rank {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.db-country-info {
    flex: 1;
    min-width: 0;
}

.db-country-name-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}

.db-country-name {
    font-size: 0.857rem;
    font-weight: 600;
    color: var(--text);
}

.db-country-amount {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 0.857rem;
    font-weight: 700;
    color: var(--navy);
}

.db-country-pct {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 3px;
}

/* Enrolment breakdown card */
.db-enrol-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.db-enrol-stats {
    display: flex;
    align-items: center;
    gap: 0;
}

.db-enrol-stat {
    flex: 1;
    text-align: center;
    padding: 8px 16px;
}

.db-enrol-divider {
    width: 1px;
    height: 48px;
    background: var(--border-solid);
    flex-shrink: 0;
}

.db-enrol-number {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
    margin-bottom: 4px;
}

.db-enrol-number--new { color: #16a34a; }
.db-enrol-number--ret { color: #0369a1; }

.db-enrol-label {
    font-size: 0.786rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 2px;
}

.db-enrol-pct {
    font-size: 0.857rem;
    font-weight: 700;
    color: var(--muted);
}

.db-enrol-bar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.db-enrol-bar-track {
    height: 28px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
}

.db-enrol-bar-new {
    height: 100%;
    background: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.786rem;
    font-weight: 700;
    color: #ffffff;
    transition: width 0.4s ease;
    min-width: 0;
}

.db-enrol-bar-ret {
    height: 100%;
    background: #0369a1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.786rem;
    font-weight: 700;
    color: #ffffff;
    transition: width 0.4s ease;
    min-width: 0;
}

.db-enrol-legend {
    display: flex;
    align-items: center;
    font-size: 0.786rem;
    color: var(--muted);
}

.db-enrol-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.db-enrol-dot--new { background: #16a34a; }
.db-enrol-dot--ret { background: #0369a1; }

/* Responsive */
@media (max-width: 900px) {
    .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .db-charts-row { grid-template-columns: 1fr; }
    .db-enrol-stats { flex-direction: column; gap: 12px; }
    .db-enrol-divider { width: 100%; height: 1px; }
}

@media (max-width: 767px) {
    .kpi-grid-4,
    .kpi-grid-3 { grid-template-columns: 1fr; }
}

/* ── Revenue Share ─────────────────────────────────────────────────────────── */

.rs-instructor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.rs-instructor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.rs-instructor-card:hover {
    box-shadow: 0 4px 16px rgba(23,56,119,.10);
    border-color: var(--brand-mid);
}

.rs-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.rs-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-dark);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rs-card-info {
    flex: 1;
    min-width: 0;
}
.rs-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rs-card-email {
    font-size: 12px;
    margin-top: 2px;
}

.rs-card-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.rs-card-meta-row {
    display: flex;
    gap: 14px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    flex-wrap: wrap;
}
.rs-meta-item {
    font-size: 12px;
    color: var(--text-muted);
}
.rs-meta-item strong {
    color: var(--text-primary);
}

/* Period link in tables */
.rs-period-link {
    font-weight: 500;
    color: var(--brand-mid);
    text-decoration: none;
}
.rs-period-link:hover { text-decoration: underline; }

/* Verified / paid status icons */
.rs-status-tick {
    display: inline-flex;
    align-items: center;
    color: var(--green);
    font-weight: 700;
}
.rs-status-pending {
    color: var(--text-muted);
}

/* Verified button (green outline when active) */
.rs-verified-btn {
    color: var(--green);
    border-color: var(--green);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.rs-verified-btn:hover {
    background: rgba(47,133,90,.08);
}

/* Status row under hero */
.rs-status-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 0 2px;
}
.rs-pill-verified {
    background: rgba(47,133,90,.12);
    color: var(--green);
    border: 1px solid rgba(47,133,90,.3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.rs-pill-paid {
    background: rgba(23,56,119,.10);
    color: var(--brand-mid);
    border: 1px solid rgba(23,56,119,.2);
}

/* Total row in period detail table */
.rs-total-row td {
    background: var(--brand-dark);
    color: #fff;
    border-top: 2px solid var(--brand-mid);
}
.rs-total-row td strong { color: #fff; }
.rs-total-final strong {
    color: #f5c842 !important;
    font-size: 15px;
}
/* Bundle proration sub-rows */
.rs-bundle-row td {
    background: var(--surface-2, #f8fafc);
    border-top: none;
    border-bottom: 1px dashed var(--border-solid);
}
.rs-bundle-row:last-of-type td { border-bottom: none; }

/* Final earnings summary card */
.rs-final-card {
    background: linear-gradient(135deg, var(--brand-dark) 0%, #1e3f7a 100%);
    border-color: var(--brand-mid);
}
.rs-final-row {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.rs-final-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rs-final-item--total {
    margin-left: auto;
    text-align: right;
}
.rs-final-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.6);
}
.rs-final-value {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}
.rs-final-value--big {
    font-size: 28px;
    color: var(--gold);
}
.rs-final-sep {
    color: rgba(255,255,255,.5);
    font-size: 13px;
}
.rs-final-adj {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    color: #fff;
}
.rs-final-adj--deduct {
    background: rgba(220,60,60,.18);
    border-color: rgba(220,60,60,.35);
    color: #ffaaaa;
}

/* Formset rows in instructor form */
.rs-formset-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.rs-formset-row:last-child { border-bottom: none; }
.rs-formset-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr;
    gap: 12px;
    flex: 1;
}
.rs-formset-delete {
    padding-top: 24px;
}
.rs-delete-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--danger);
    cursor: pointer;
}
.rs-delete-label input[type="checkbox"] {
    accent-color: var(--danger);
}

/* ta-r helper (right-align) — may already exist */
.ta-r { text-align: right; }
.db-muted { color: var(--text-muted); font-size: 12px; }


/* ═══════════════════════════════════════
   PRICE TRACKER DASHBOARD
════════════════════════════════════════ */

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.pt-hero {
    align-items: flex-start;
    padding: 20px 24px 18px;
    gap: 16px;
}

.pt-hero-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pt-breadcrumb {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 4px;
}
.pt-breadcrumb a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s;
}
.pt-breadcrumb a:hover { color: var(--navy); }
.pt-breadcrumb-sep { opacity: .5; }

.pt-hero-title {
    font-size: 1.5rem;
    margin: 0;
}

.pt-hero-meta {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0;
}

/* ── KPI stat cards ───────────────────────────────────────────────────────── */
.pt-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.pt-stat-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.pt-stat-card {
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    padding: 12px 16px 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.pt-stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 10px 10px 0 0;
}
.pt-stat-navy::before  { background: var(--navy); }
.pt-stat-gold::before  { background: var(--gold); }
.pt-stat-teal::before  { background: #0891b2; }
.pt-stat-green::before { background: #16a34a; }

.pt-stat-eyebrow {
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 5px;
}

.pt-stat-value {
    font-family: "Familjen Grotesk", sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
    margin-bottom: 4px;
}

.pt-stat-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ── Inline filter bar ────────────────────────────────────────────────────── */
.pt-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
}

/* When nested inside a *row*-direction flex toolbar (e.g. .qbf-review-toolbar,
   to sit beside a "Fullscreen view" button), a flex item defaults to
   shrink-to-content width, which was forcing this bar to wrap internally
   even with plenty of row space available — flex-grow lets it actually fill
   that space. Scoped to these row-toolbar contexts only: giving .pt-filter-bar
   flex-grow unconditionally made it grow along whatever the *parent's* main
   axis is, so as a plain child of .page-content-wrap (a *column*-direction
   flex container), it grew vertically instead — filling the entire leftover
   page height on any screen with few enough rows to leave slack (found live
   on team/member_list.html, which has few rows). */
.qbf-review-toolbar .pt-filter-bar,
.qbf-combined-toolbar-row .pt-filter-bar {
    flex: 1 1 auto;
}

.pt-filter-search {
    position: relative;
    /* Fixed-ish width, not flex-grow — a growing search box was eating the
       row on toolbars with 3+ selects (found on the statement review
       screen, where it stretched to 482px and pushed a select to a second
       line). 240px comfortably fits placeholder text without over-growing
       just because the row has spare width. */
    flex: 0 1 240px;
    min-width: 160px;
}

.pt-filter-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.pt-filter-search-input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    border: 1px solid var(--border-solid);
    border-radius: 7px;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.pt-filter-search-input:focus {
    border-color: var(--navy);
    background: var(--surface);
}
.pt-filter-search-input::placeholder { color: var(--muted); }

.pt-filter-select {
    padding: 7px 28px 7px 10px;
    /* Native selects otherwise size to their widest option's text — a
       "Category" filter with long option labels (e.g. "Expense - Software
       & Subscriptions") could blow past 290px and force the row to wrap.
       Cap and truncate instead; the full label is still in the option
       list on open. */
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid var(--border-solid);
    border-radius: 7px;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6a8a'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    transition: border-color 0.15s;
}
.pt-filter-select:focus { border-color: var(--navy); }

.pt-filter-clear {
    font-size: 0.8rem;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    /* Usable on <a> (server-filtered screens, e.g. course/dashboard.html)
       or <button> (client-side filtered screens, e.g. the revenue draft
       review table) — reset native button chrome so both look identical. */
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.pt-filter-clear:hover { color: var(--navy); background: var(--bg); }

/* ── Course table ─────────────────────────────────────────────────────────── */
.pt-table th { background: var(--bg); }

.pt-th-sub {
    display: block;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: none;
    color: var(--muted);
    margin-top: 1px;
}

.pt-course-name {
    font-weight: 600;
    color: var(--navy);
}

/* Type badges */
.pt-type-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.pt-type-flagship    { background: rgba(197,157,95,.15); color: #7a5a1a; }
.pt-type-professional { background: rgba(10,31,68,.09);  color: var(--navy); }
.pt-type-foundation  { background: rgba(3,105,161,.1);   color: #0369a1; }

/* Mode badges */
.pt-mode-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.pt-mode-individual { background: rgba(10,31,68,.06); color: var(--muted); }
.pt-mode-package    { background: rgba(22,163,74,.12); color: #15803d; }

/* Price cells */
.pt-price-cell { white-space: nowrap; }

.pt-price {
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    color: var(--navy);
    font-weight: 500;
}

.pt-discount-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(220,38,38,.1);
    color: #b91c1c;
    vertical-align: middle;
}

.pt-price-na { color: var(--muted); font-size: 0.85rem; }

.pt-date-cell {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}

.pt-action-col {
    width: 44px;
    text-align: center;
}

/* Opt-in per-column mobile hide — for a .pt-table column that's useful on
   desktop but not essential on a phone screen (e.g. team/member_list.html's
   Manager / Joining Date columns). Mark both the <th> and its matching <td>
   with this class; .table-card's own overflow-x:auto still covers any
   column that isn't marked, so this is additive, not a replacement for
   horizontal scroll. */
@media (max-width: 767px) {
    .pt-col-optional {
        display: none;
    }
}

/* Inverse of .pt-col-optional — content that only earns its place once a
   column it duplicates (for space) has already been hidden on mobile, e.g.
   a role name folded into the member cell once the dedicated Role column
   is gone. */
.pt-mobile-note {
    display: none;
}

@media (max-width: 767px) {
    .pt-mobile-note {
        display: block;
    }
}

/* Table footer / pagination */
.pt-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border-solid);
    background: var(--bg);
    border-radius: 0 0 10px 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.pt-table-count {
    font-size: 0.8rem;
    color: var(--muted);
}

.pt-pagination {
    display: flex;
    gap: 6px;
}

.pt-page-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-solid);
    background: var(--surface);
    color: var(--navy);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}
.pt-page-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }
.pt-page-btn--disabled {
    color: var(--muted);
    background: transparent;
    border-color: var(--border-solid);
    cursor: not-allowed;
    pointer-events: none;
    opacity: .5;
}

/* ── Universal pagination (app-agnostic name; visually identical to
   .pt-pagination above, which stays as-is so no template needs to change
   yet). New/migrated screens should use these classes directly. ────────── */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.pagination-count {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Groups the row count with the page-size selector on the left side of
   .pagination-bar, so the right side stays just the Prev/Next controls. */
.pagination-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.page-size-select {
    padding: 4px 24px 4px 8px;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6a8a'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s;
}
.page-size-select:focus { border-color: var(--navy); }

.pagination {
    display: flex;
    gap: 6px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-solid);
    background: var(--surface);
    color: var(--navy);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}
.page-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }
.page-btn--disabled {
    color: var(--muted);
    background: transparent;
    border-color: var(--border-solid);
    cursor: not-allowed;
    pointer-events: none;
    opacity: .5;
}

/* ── Notice banners ──────────────────────────────────────────────────────────
   Usage: <div class="notice-banner notice-warning">…</div>
   Variants: notice-warning | notice-info | notice-success | notice-danger
   ───────────────────────────────────────────────────────────────────────── */
.notice-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-radius: 7px;
    font-size: 0.875rem;
    line-height: 1.55;
    border: 1px solid var(--border-solid);
    background: var(--surface);
    color: var(--text);
}
.notice-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}
.notice-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}
.notice-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}
.notice-info {
    background: #e8f0fe;
    border-color: #93b4f5;
    color: #1e3a7c;
}

/* ── Toggle switch ───────────────────────────────────────────────────────────
   Usage:
   <label class="toggle-switch" for="id">
     <input type="checkbox" id="id">
     <span class="toggle-slider"></span>
   </label>
   ───────────────────────────────────────────────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-solid);
    border-radius: 999px;
    transition: background 0.2s;
}
.toggle-slider::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: left 0.2s;
}
.toggle-switch input:checked ~ .toggle-slider {
    background: var(--navy);
}
.toggle-switch input:checked ~ .toggle-slider::after {
    left: calc(100% - 21px);
}
.toggle-switch input:focus-visible ~ .toggle-slider {
    outline: 2px solid var(--navy);
    outline-offset: 2px;
}

/* ── Toggle row (label + toggle side-by-side) ───────────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.toggle-row-text {
    flex: 1;
    min-width: 0;
}
.toggle-row-text .muted {
    font-size: 0.825rem;
}


/* ── Version / Release Notes ─────────────────────────────────────────────── */
.version-current-header {
    margin-bottom: 4px;
}

.version-change-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
}

.version-history-list {
    display: flex;
    flex-direction: column;
}

.version-history-item {
    border-bottom: 1px solid var(--border);
}

.version-history-item:last-child {
    border-bottom: none;
}

.version-history-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.version-history-summary::-webkit-details-marker { display: none; }

.version-history-summary:hover {
    background: var(--bg);
    border-radius: 6px;
}

.version-history-name {
    flex-shrink: 0;
    min-width: 72px;
}

.version-history-title {
    flex: 1;
    font-weight: 500;
    font-size: 0.875rem;
}

.version-history-date {
    flex-shrink: 0;
    font-size: 0.8rem;
    min-width: 80px;
    text-align: right;
}

.version-history-chevron {
    flex-shrink: 0;
    color: var(--muted);
    transition: transform 0.2s;
}

details[open] .version-history-chevron {
    transform: rotate(180deg);
}

.version-history-body {
    padding: 4px 4px 16px 4px;
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--text);
}

/* ── Markdown toolbar ────────────────────────────────────────────────────── */
.md-toolbar {
    display: flex;
    gap: 3px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.md-btn {
    padding: 2px 8px;
    border: 1px solid var(--border-solid);
    border-radius: 4px;
    background: var(--surface);
    font-size: 0.76rem;
    cursor: pointer;
    color: var(--text);
    line-height: 1.6;
    font-family: inherit;
    transition: background 0.12s, border-color 0.12s;
}

.md-btn:hover {
    background: var(--bg);
    border-color: var(--navy);
}

.md-btn b { font-weight: 800; }
.md-btn i { font-style: italic; }

/* Rendered markdown in views */
.md-body { font-size: 0.9rem; line-height: 1.7; }
.md-body p { margin: 0 0 6px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body strong { font-weight: 700; }
.md-body em { font-style: italic; }
.md-body ul, .md-body ol { margin: 4px 0 6px 20px; padding: 0; }
.md-body li { margin-bottom: 2px; }
.md-body h1,
.md-body h2,
.md-body h3 {
    color: var(--navy);
    line-height: 1.25;
    margin: 14px 0 8px;
}
.md-body h1 { font-size: 1.1rem; }
.md-body h2 { font-size: 1rem; }
.md-body h3 { font-size: 0.94rem; }
.md-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0 14px;
    font-size: 0.86rem;
}
.md-body th,
.md-body td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    vertical-align: top;
}
.md-body th {
    background: var(--bg);
    color: var(--navy);
    font-weight: 700;
}
.ai-suggestion-body {
    color: var(--text);
}

/* ═══════════════════════════════════════
   MOBILE SHELL (TICKET-13)
   <768px: sidebar becomes a fully off-canvas
   overlay, opened via the hamburger in the top
   bar, instead of the desktop rail/hover system.
════════════════════════════════════════ */
@media (max-width: 767px) {
    .mobile-nav-toggle {
        display: inline-flex;
    }

    /* No persistent rail on mobile, not even 52px, regardless of any
       pinned preference carried over from a desktop session — the
       ticket calls for hidden-by-default off-canvas, not a mobile rail. */
    .sidebar-host,
    html[data-sb="pinned"] .sidebar-host {
        width: 0 !important;
        overflow: visible;
    }

    /* The sidebar panel itself still renders at full width (so its
       content lays out correctly) but is pushed off-screen via
       transform until explicitly opened — reuses the existing
       .sb-hover class (added/removed by the hamburger's JS) rather
       than inventing a parallel state, so every "expanded" style
       already keyed off .sb-hover (labels, full logo, pin button,
       etc.) applies for free. (position: fixed already comes from the
       base .sidebar rule — see its comment for why.) */
    .sidebar {
        width: var(--sb-full) !important;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(10, 31, 68, 0.28);
    }

    .sidebar-host.sb-hover .sidebar {
        transform: translateX(0);
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 199;
        background: rgba(10, 31, 68, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

    body.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

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


/* ═══════════════════════════════════════
   COURSE FINDER — Decision tree view (08-Decision-Tree-Plan.md §4)
   Nesting is shown with indent + a left hairline, per the UI/UX doc —
   composed from existing tokens/components, no new visual language.
════════════════════════════════════════ */
.cf-tree,
.cf-tree-options {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cf-tree-options {
    margin-top: var(--space-2);
    padding-left: var(--space-5);
    border-left: 1px solid var(--border);
}

.cf-tree-option + .cf-tree-option {
    margin-top: var(--space-2);
}

.cf-tree-node {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.cf-tree-node--question {
    background: var(--surface, var(--bg));
}

.cf-tree-option.has-issue > .cf-tree-node {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.cf-tree-issue {
    color: var(--danger-text);
    font-size: 0.8rem;
}

.cf-tree-recommendation {
    font-weight: 600;
}

.cf-option-line {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
    margin: 2px 0;
}

.cf-option-arrow {
    color: var(--label);
    font-size: 0.8rem;
}

.cf-option-missing {
    color: var(--danger-text);
}

/* Course Finder's sub-nav (Questions / Tree / Recommendations) — plain reuse of the
   existing primary/ghost button pair, not a new tab component. */
.cf-subnav {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}


/* ═══════════════════════════════════════
   COURSE FINDER — Rule Output Path Builder (TICKET-06)
   Same "compose from existing tokens/components" rule as the condition
   builder (TICKET-05) — .form-row/.field-error/.ghost-button/.icon-button
   are all reused as-is; only the container/badge/fetch-status pieces below
   are genuinely new.
════════════════════════════════════════ */
.os-list {
    display: grid;
    gap: var(--space-4);
    margin: var(--space-4) 0 var(--space-5);
}

.os-row {
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--surface);
    display: grid;
    gap: var(--space-3);
}

.os-row-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.os-step-badge {
    font-family: "Familjen Grotesk", sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--navy);
}

.os-fetch-status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--muted);
}

.os-fetch-status--ok { background: var(--success-bg); color: var(--success-text); }
.os-fetch-status--failed { background: var(--danger-bg); color: var(--danger-text); }
.os-fetch-status--manual_override { background: var(--gold-soft); color: var(--navy); }

.os-row-header .icon-button {
    margin-left: auto;
}

.os-url-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

.os-url-row input {
    flex: 1 1 260px;
}

.os-fetch-message {
    display: block;
    font-size: 0.78rem;
    margin-top: var(--space-1);
    color: var(--muted);
}

.os-fetch-message.is-ok { color: var(--success-text); }
.os-fetch-message.is-error { color: var(--danger-text); }

.os-char-counter {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: var(--space-1);
}

.os-char-counter.is-over {
    color: var(--danger-text);
    font-weight: 600;
}

.os-thumb-preview {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-solid);
    margin-top: var(--space-2);
}

.os-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

/* The formset's DELETE checkbox is a real form field (Django needs it in
   the POST body) but never a UI element staff interact with directly —
   the Remove button (output-step-builder.js's / answer-option-builder.js's
   removeRow()) checks it programmatically. Hide it rather than styling it. */
.os-row input[name$="-DELETE"],
[data-ao-row] input[name$="-DELETE"] {
    display: none;
}

.logic-issue-list {
    list-style: none;
    margin: var(--space-3) 0 0;
    padding: 0;
    display: grid;
    gap: var(--space-2);
}

/* .table-card has no padding of its own by design (so wide tables can
   scroll edge-to-edge) — .tool-promo-section-header supplies its own inset
   for headings, but plain body content (a paragraph, a list) dropped
   directly into a .table-card needs an explicit wrapper or it renders
   flush against the card's edges. Matches .tool-promo-section-header's
   20px horizontal inset. */
.table-card-body {
    padding: 0 20px 20px;
}

/* Price preview (TICKET-09) — read-only, shown under the course picker in
   the output-step builder so staff can sanity-check Price Tracker's
   numbers without re-typing them. */
.os-price-preview {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
    min-height: 1px; /* avoids a layout jump between empty and populated */
}

.os-price-pill {
    background: var(--gold-soft);
    color: var(--navy);
    font-weight: 600;
}

.os-price-loading,
.os-price-empty {
    font-size: 0.8rem;
    color: var(--label);
}

/* Shown only while #os-list has no visible rows. Toggled via the `hidden`
   attribute (not CSS :empty — that pseudo-class requires zero child NODES,
   and Django's {% for %}/{% endfor %} tags leave whitespace text nodes in
   the container even on a zero-iteration loop, so :empty never actually
   matches here). Initial state is set server-side in the template;
   output-step-builder.js keeps it in sync after add/remove. */

/* ── Question list drag-to-reorder (question-reorder.js) ─────────────────── */
.cf-drag-handle {
    width: 28px;
    color: var(--muted);
    cursor: grab;
    text-align: center;
}
.cf-drag-handle svg { display: block; margin: 0 auto; }
[data-question-row].is-dragging {
    opacity: 0.4;
}
[data-question-row] { cursor: default; }
[data-question-row] .cf-drag-handle { cursor: grab; }
[data-question-row].is-dragging .cf-drag-handle { cursor: grabbing; }

/* ═══════════════════════════════════════════════════════════════════════════
   Course Projects (course_projects app). Everything below is built from the
   existing tokens above; no new colours or fonts. Prefix: cp-
   ═══════════════════════════════════════════════════════════════════════════ */

.cp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Progress bar */
.cp-progress {
    height: 6px;
    background: var(--border-solid);
    border-radius: 999px;
    overflow: hidden;
}
.cp-progress__bar {
    display: block;
    height: 100%;
    background: var(--navy-mid);
    border-radius: 999px;
}
.cp-progress--good .cp-progress__bar { background: var(--success-text); }
.cp-progress--bad .cp-progress__bar { background: var(--danger-text); }

/* Health / status pill (same shape as .pill, coloured by the shared status tokens) */
.cp-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: "Familjen Grotesk", sans-serif;
    white-space: nowrap;
}
.cp-pill--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.cp-pill--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.cp-pill--danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }
.cp-pill--info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }

/* Initials avatar: six stable colours, white text on dark brand tokens */
.cp-avatar-wrap {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
}
.cp-avatar {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--white);
    font-size: 0.68rem;
    font-weight: 700;
    font-family: "Familjen Grotesk", sans-serif;
    flex: none;
}
.cp-avatar--0 { background: var(--navy); }
.cp-avatar--1 { background: var(--navy-mid); }
.cp-avatar--2 { background: var(--info-text); }
.cp-avatar--3 { background: var(--success-text); }
.cp-avatar--4 { background: var(--partial-text); }
.cp-avatar--5 { background: var(--danger-text); }
.cp-avatar-name { font-size: 0.85rem; color: var(--text); }

/* ── Courses list ── */
.cp-page { display: grid; gap: var(--space-4); }
.cp-num { font-variant-numeric: tabular-nums; }
.cp-text-danger { color: var(--danger-text); }
.cp-filter-bar { margin: 0; }

.cp-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: var(--space-4);
}
.cp-card,
.cp-card:visited {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    text-decoration: none;
}
.cp-card:hover { border-color: var(--gold); box-shadow: var(--shadow-md); }
.cp-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cp-card-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cp-card-title { margin: 0; font-family: "Familjen Grotesk", sans-serif; font-size: 1.1rem; line-height: 1.25; color: var(--navy); overflow-wrap: anywhere; }
.cp-card-meta { margin: 2px 0 0; font-size: 0.82rem; color: var(--muted); }
.cp-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: 0; }
.cp-card-stats dt { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.cp-card-stats dd { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.cp-card-meter { display: grid; gap: 6px; }
.cp-card-meter-row { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.cp-card-meter-row b { color: var(--text); }
.cp-card--add {
    align-items: center;
    justify-content: center;
    min-height: 220px;
    border-style: dashed;
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    text-align: center;
}
.cp-card--add:hover { color: var(--navy); box-shadow: none; }
.cp-add-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-size: 1.7rem;
    line-height: 1;
}
.cp-empty { padding: var(--space-5) var(--space-4); text-align: center; color: var(--muted); }
.cp-empty p { margin: 0; }

/* ── New course modal ── */
.cp-modal-lead { margin: 0 0 var(--space-4); }
.cp-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
.cp-form-grid .field-group { min-width: 0; }
.cp-span-2 { grid-column: 1 / -1; }
.cp-form .field-error { margin-top: 4px; padding: 5px 9px; font-size: 0.8rem; }
.cp-form-actions { justify-content: flex-end; margin-top: var(--space-4); }
.cp-form-grid textarea { resize: vertical; }

/* ── Project screen ── */
.cp-hero-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 0; }
.cp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: var(--space-3); }
.cp-tiles .kpi-card { margin: 0; min-width: 0; }
.cp-tiles .kpi-card .cp-progress { margin-top: var(--space-2); }
.cp-value-sm { font-size: 1.3rem; }
.cp-tabs {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-solid);
}
.cp-tab,
.cp-tab:visited {
    padding: 10px 14px;
    white-space: nowrap;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.cp-tab:hover { color: var(--navy); }
.cp-tab.is-active { color: var(--navy); border-bottom-color: var(--gold); }
.cp-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.cp-tab-count { margin-left: 6px; font-size: 0.72rem; font-weight: 500; color: var(--label); }
.cp-panel { padding: 0; overflow: hidden; }
.cp-phase-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-solid); }
.cp-phase-bar { flex: 1 1 140px; min-width: 100px; }
.cp-tasks { list-style: none; margin: 0; padding: 0; }
.cp-task {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-solid);
}
.cp-task:first-child { border-top: 0; }
.cp-check {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex: none;
    width: 24px;
    height: 24px;
    margin: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
}
.cp-check::before {
    content: "";
    position: absolute;
    inset: 3px;
    border: 1.6px solid var(--muted);
    border-radius: 5px;
    background: var(--surface);
}
.cp-check:checked::before { background: var(--success-text); border-color: var(--success-text); }
.cp-check:checked::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 5px;
    margin: -4px 0 0 -5px;
    border-left: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    transform: rotate(-45deg);
}
.cp-check:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; border-radius: 6px; }
.cp-check:disabled { cursor: not-allowed; opacity: 0.45; }
.cp-task-title { font-weight: 600; color: var(--text); cursor: pointer; overflow-wrap: anywhere; }
.cp-task.is-done .cp-task-title { color: var(--muted); text-decoration: line-through; }
.cp-task-note { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.cp-task-due { font-size: 0.82rem; white-space: nowrap; text-align: right; color: var(--muted); }
.cp-due-overdue { color: var(--danger-text); font-weight: 600; }
.cp-due-today { color: var(--warning-text); font-weight: 600; }
.cp-due-done { color: var(--success-text); }
.cp-panel-summary { margin: 0; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-solid); }
.cp-outline, .cp-outline-topics { list-style: none; margin: 0; padding: 0; }
.cp-outline > li { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-outline > li:first-child { border-top: 0; }
.cp-outline-module { font-family: "Familjen Grotesk", sans-serif; font-weight: 700; color: var(--navy); }
.cp-outline-topics { margin-top: var(--space-2); padding-left: var(--space-5); display: grid; gap: 4px; }

@media (max-width: 720px) {
    .cp-form-grid { grid-template-columns: minmax(0, 1fr); }
    .cp-span-2 { grid-column: auto; }
    .cp-task { grid-template-columns: auto minmax(0, 1fr); }
    .cp-task-who, .cp-task-due { grid-column: 2; text-align: left; }
}

/* ── Task ticking ── */
.cp-toggle-form { margin: 0; display: inline-flex; align-items: center; }
.cp-toggle-btn { padding: 4px 10px; font-size: 0.75rem; }
.cp-inline-error { margin: 0 0 var(--space-3); }

/* ── Syllabus tab ── */
.cp-syl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-solid); }
.cp-syl-summary { margin: 0; }
.cp-syl-downloads { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.cp-locked-note { margin: 0; padding: var(--space-2) var(--space-4); font-size: 0.82rem; background: var(--warning-bg); color: var(--warning-text); border-bottom: 1px solid var(--warning-border); }
.cp-syllabus.is-saving { cursor: progress; }
.cp-syl-modules, .cp-syl-topics { list-style: none; margin: 0; padding: 0; }
.cp-syl-module { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); background: var(--surface); }
.cp-syl-module:first-child { border-top: 0; }
.cp-syl-module-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.cp-syl-module-title { flex: 1 1 200px; min-width: 0; font-family: "Familjen Grotesk", sans-serif; color: var(--navy); overflow-wrap: anywhere; }
.cp-syl-meta { margin-left: var(--space-2); font-family: "Inter", sans-serif; font-size: 0.78rem; }
.cp-syl-num { min-width: 2.4em; font-weight: 700; color: var(--navy-mid); }
.cp-syl-module-num { font-size: 1rem; }
.cp-syl-desc { margin-top: 2px; font-size: 0.82rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.cp-syl-module-desc { margin: var(--space-2) 0 0 calc(var(--space-3) + 2.4em); }
.cp-syl-topics { margin-top: var(--space-2); padding-left: var(--space-5); }
.cp-syl-topic { padding: 6px 0; border-top: 1px dashed var(--border-solid); }
.cp-syl-topic:first-child { border-top: 0; }
.cp-syl-topic-row { display: flex; align-items: flex-start; gap: var(--space-3); flex-wrap: wrap; }
.cp-syl-topic-body { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.cp-syl-topic-title { font-weight: 500; color: var(--text); }
.cp-syl-topic-dur { font-size: 0.78rem; }
.cp-syl-empty { margin: var(--space-2) 0 0 var(--space-5); font-size: 0.82rem; }
.cp-syl-empty[hidden] { display: none; }
.cp-syl-move { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cp-icon-btn {
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--border-solid); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--navy); font-size: 0.95rem; line-height: 1; cursor: pointer;
}
.cp-icon-btn:hover { border-color: var(--gold); background: var(--gold-soft); }
.cp-icon-btn:focus-visible, .cp-move-to:focus-visible, .cp-drag-handle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cp-move-to { height: 28px; max-width: 150px; padding: 0 6px; font-size: 0.75rem; border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.cp-drag-handle { display: inline-grid; place-items: center; width: 22px; height: 26px; padding: 0; border: 0; background: transparent; color: var(--label); cursor: grab; touch-action: none; }
.cp-drag-handle:hover { color: var(--navy); }
.cp-drag-handle:active { cursor: grabbing; }
.cp-syl-module.is-dragging, .cp-syl-topic.is-dragging { opacity: 0.4; }
.cp-drop-before { box-shadow: 0 -3px 0 0 var(--gold); }
.cp-drop-after { box-shadow: 0 3px 0 0 var(--gold); }
.cp-drop-into { outline: 2px dashed var(--gold); outline-offset: 2px; min-height: 24px; }
.cp-syl-topics:empty { min-height: 8px; }

.cp-syl-tools { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: 4px; }
.cp-syl-module-tools { margin-top: var(--space-2); padding-left: var(--space-5); }
.cp-fold { font-size: 0.82rem; }
.cp-fold > summary { cursor: pointer; color: var(--navy-mid); font-weight: 600; list-style-position: inside; }
.cp-fold > summary:hover { color: var(--navy); text-decoration: underline; }
.cp-fold[open] > summary { margin-bottom: var(--space-2); }
.cp-syl-form { display: grid; gap: var(--space-2); width: min(100%, 520px); padding: var(--space-3); margin-bottom: var(--space-2); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--pale, var(--surface)); }
.cp-syl-form .field-error { margin: 0; padding: 5px 9px; font-size: 0.8rem; }
.cp-syl-add-module { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }

@media (max-width: 720px) {
    .cp-syl-topics { padding-left: 0; }
    .cp-syl-module-tools { padding-left: 0; }
    .cp-syl-module { padding: var(--space-3); }
    .cp-syl-quick-add { padding-left: 0; }
    .cp-syl-quick-module { padding: var(--space-3); }
    .cp-syl-toolbar { padding: var(--space-3); }
    .cp-syl-downloads { width: 100%; }
    .cp-syl-downloads .ghost-button { flex: 1 1 0; text-align: center; }

    /* A topic stacks: grip + number + text on top, then the minutes, then a full-width row of tools. */
    .cp-syl-topic-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: 0 var(--space-2); }
    .cp-syl-topic-row > .cp-syl-topic-body { flex: none; min-width: 0; }
    .cp-syl-topic-row > .cp-syl-move { grid-column: 1 / -1; padding-top: 4px; }
    .cp-syl-line { flex-wrap: wrap; }
    .cp-inline-dur-wrap { width: auto; }
    .cp-inline-dur { width: 3.2rem; text-align: left; }

    /* Module header: grip, number, title; the module's tools drop to their own row. */
    .cp-syl-module-head { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: 0 var(--space-2); }
    .cp-syl-module-head > .cp-syl-move { grid-column: 1 / -1; padding-top: 4px; }
    .cp-syl-module-title .cp-inline-module-title { flex: 1 1 100%; }
    .cp-inline-module-desc { margin-left: 0; width: 100%; }

    /* Untouched rows stay compact: tools and an empty minutes box appear for the row you tap (focus moves into it). */
    .cp-syllabus.cp-inline-on .cp-syl-topic:not(:focus-within) .cp-syl-move,
    .cp-syllabus.cp-inline-on .cp-syl-module-head:not(:focus-within) .cp-syl-move { display: none; }
    .cp-syllabus.cp-inline-on .cp-syl-topic:not(:focus-within) .cp-inline-dur-wrap:not(:has(.cp-inline-dur:not(:placeholder-shown))) { display: none; }
    .cp-syl-topic:focus-within, .cp-syl-module-head:focus-within { background: var(--gold-soft); border-radius: var(--radius-sm); }
    .cp-syl-topic-row > .cp-syl-num, .cp-syl-module-head > .cp-syl-num { padding-top: 5px; }
    .cp-syl-topic-row > .cp-drag-handle, .cp-syl-module-head > .cp-drag-handle { margin-top: -4px; }

    /* Tools never wrap into a ragged stack: one row, the "Move to" menu takes the spare width. */
    .cp-syl-move { flex-wrap: nowrap; gap: 6px; }
    .cp-syl-move .cp-move-to { flex: 1 1 auto; min-width: 0; max-width: none; }
    .cp-syl-move .cp-icon-btn { flex: none; }
}

/* ── Course Projects: navigation, tasks (edit forms), dashboard, My tasks ── */
.cp-subnav { display: flex; gap: var(--space-1); flex-wrap: wrap; padding: 4px; background: var(--surface); border: 1px solid var(--border-solid); border-radius: var(--radius-md); width: fit-content; max-width: 100%; }
.cp-subnav-link, .cp-subnav-link:visited { padding: 7px 14px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; font-size: 0.85rem; text-decoration: none; white-space: nowrap; }
.cp-subnav-link:hover { color: var(--navy); background: var(--bg); }
.cp-subnav-link.is-active { color: var(--white); background: var(--navy); }
.cp-subnav-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cp-nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--gold); color: var(--navy); font-size: 0.68rem; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.cp-nav-badge[hidden] { display: none; }

.cp-task-main { min-width: 0; }
.cp-task-notes { margin-top: 3px; font-size: 0.8rem; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
.cp-task-link { display: inline-block; margin-top: 3px; font-size: 0.78rem; font-weight: 600; color: var(--navy-mid); }
.cp-task-flag { margin-top: 4px; font-size: 0.68rem; padding: 1px 7px; }
.cp-task-tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding-left: calc(18px + var(--space-3)); }
.cp-task-tools > details[open] { flex: 1 1 100%; }
.cp-task-add { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-task-form { width: min(100%, 760px); }
.cp-task-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4); }
.cp-task-form-grid .field-group { min-width: 0; }
.cp-task-form-grid textarea { resize: vertical; }
.cp-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-solid); }
.cp-panel-head h3 { margin: 0; font-family: "Familjen Grotesk", sans-serif; font-size: 1rem; color: var(--navy); }
.cp-link, .cp-link:visited { font-size: 0.82rem; font-weight: 600; color: var(--navy-mid); }

.cp-of { font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.cp-dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.cp-table-scroll { overflow-x: auto; }
.cp-table { width: 100%; }
.cp-table th, .cp-table td { padding: 10px 10px; vertical-align: middle; }
.cp-row-link, .cp-row-link:visited { font-weight: 600; color: var(--navy); text-decoration: none; overflow-wrap: anywhere; }
.cp-row-link:hover { text-decoration: underline; }
.cp-sub { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.cp-minibar { display: flex; align-items: center; gap: var(--space-2); min-width: 90px; }
.cp-minibar .cp-progress { flex: 1; }
.cp-overdue { list-style: none; margin: 0; padding: 0; }
.cp-overdue li { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-overdue li:first-child { border-top: 0; }
.cp-more { margin: 0; padding: var(--space-2) var(--space-4) var(--space-3); font-size: 0.8rem; }

@media (max-width: 1280px) { .cp-dash-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
    .cp-task-form-grid { grid-template-columns: minmax(0, 1fr); }
    .cp-task-tools { padding-left: 0; }
}

/* ── Course Projects: expenses, edit/launch modals ── */
.cp-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.cp-hero-copy { flex: 1 1 320px; min-width: 0; }
.cp-hero-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.cp-right { text-align: right; }
.cp-exp-summary { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-solid); font-size: 0.85rem; color: var(--muted); }
.cp-exp-summary b { color: var(--text); margin-left: 4px; }
.cp-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.cp-chip { padding: 3px 10px; border: 1px solid var(--border-solid); border-radius: 999px; background: var(--bg); font-size: 0.78rem; color: var(--muted); }
.cp-chip b { color: var(--navy); margin-left: 4px; }
.cp-total-row td { border-top: 2px solid var(--border-solid); background: var(--bg); }
.cp-expense-tools td { padding-top: 0; border-top: 0; }
.cp-expense-tools-inner { padding-left: 0; }
.cp-fixed-note, .cp-info-note { margin: 0 0 var(--space-3); padding: 9px 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border-solid); font-size: 0.82rem; color: var(--muted); }
.cp-fixed-note b { color: var(--text); }
.cp-warn { margin: var(--space-3) 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-text); font-size: 0.85rem; }
.cp-warn ul { margin: 6px 0 0; padding-left: 20px; }
.cp-info-note { margin-top: var(--space-3); }

/* ── Course Projects: lifecycle, history ── */
.cp-lifecycle { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2) var(--space-4); }
.cp-lifecycle form { margin: 0; }
.cp-locked-banner { border: 1px solid var(--warning-border); border-radius: var(--radius-sm); }
.cp-history { padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border-solid); border-radius: var(--radius-md); }
.cp-history-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.cp-history-list li { display: grid; grid-template-columns: 90px minmax(0, 1.2fr) minmax(0, 2fr) auto; gap: var(--space-3); font-size: 0.82rem; align-items: baseline; }
.cp-history-reason { overflow-wrap: anywhere; }
.cp-check-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); font-size: 0.85rem; color: var(--text); }
.cp-check-row input { width: 16px; height: 16px; accent-color: var(--navy); }
@media (max-width: 720px) { .cp-history-list li { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* ── Course Projects: templates and settings pages ── */
.cp-seg { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.cp-seg-btn, .cp-seg-btn:visited { padding: 6px 16px; border: 1px solid var(--border-solid); border-radius: 999px; background: var(--surface); color: var(--navy); font-weight: 600; font-size: 0.85rem; text-decoration: none; }
.cp-seg-btn:hover { border-color: var(--gold); }
.cp-seg-btn.is-active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.cp-seg-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cp-persistent-note { margin: 0; }
.cp-tmpl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border-solid); border-radius: var(--radius-md); }
.cp-inline-form { display: inline; margin: 0; }
.cp-tmpl-task { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.4fr) auto; gap: var(--space-2) var(--space-4); align-items: center; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-tmpl-task:first-child { border-top: 0; }
.cp-tmpl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-size: 0.82rem; }
.cp-tmpl-tools { grid-column: 1 / -1; padding-left: 0; }
.cp-tmpl-empty .cp-tmpl-create { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; justify-content: center; padding: 0 var(--space-4) var(--space-5); }
.cp-copy-form { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.cp-copy-label { display: grid; gap: 4px; font-size: 0.75rem; color: var(--label); }
@media (max-width: 720px) { .cp-tmpl-task { grid-template-columns: minmax(0, 1fr); } }

.cp-tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--navy); font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.cp-set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-4); align-items: center; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-set-row:first-child { border-top: 0; }
.cp-set-row.is-inactive .cp-set-name { color: var(--muted); }
.cp-set-name { font-weight: 600; color: var(--text); margin-right: var(--space-2); overflow-wrap: anywhere; }
.cp-hint { color: var(--warning-text); }
.cp-small-btn { padding: 4px 10px; font-size: 0.75rem; }

/* ── Course Projects: activity ── */
.cp-activity { list-style: none; margin: 0; padding: 0; }
.cp-activity li { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-activity li:first-child { border-top: 0; }
.cp-activity-text { min-width: 0; overflow-wrap: anywhere; font-size: 0.875rem; }
.cp-activity-when { flex: none; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.cp-activity-pager { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
@media (max-width: 720px) { .cp-activity li { flex-direction: column; gap: 2px; } }

.cp-outline-head { margin-top: var(--space-4); }
.cp-outline-head h3 { margin: 0 0 var(--space-2); font-family: "Familjen Grotesk", sans-serif; font-size: 1.1rem; color: var(--navy); }

/* ── Course Projects: Excel import ── */
.cp-import-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); padding: var(--space-3) var(--space-4) 0; }
.cp-import-file { flex: 1 1 280px; min-width: 0; }
.cp-import-file input[type="file"] { min-height: 40px; padding: 6px var(--space-3); }
.cp-import-note { margin: 0; padding: var(--space-2) var(--space-4) var(--space-4); font-size: 0.82rem; }
.cp-issues { margin: 0; padding: var(--space-3) var(--space-4) var(--space-2) calc(var(--space-4) + 20px); display: grid; gap: 6px; color: var(--danger-text); font-size: 0.875rem; }
.cp-import-confirm { display: grid; gap: var(--space-3); padding: var(--space-4); }
.cp-mode { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.cp-mode input { margin-top: 4px; accent-color: var(--navy); }
.cp-mode:has(input:checked) { border-color: var(--navy); background: var(--bg); }

/* ── Course Projects: inline syllabus editing (click the text and type) ── */
.cp-syllabus.cp-inline-on .cp-syl-fallback { display: none; }
.cp-syl-quick-add[hidden] { display: none; }
.cp-inline {
    display: block; width: 100%; min-width: 0; margin: 0; padding: 3px 6px;
    border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
    font: inherit; line-height: 1.4; color: inherit; resize: none; overflow: hidden; box-shadow: none;
}
.cp-inline::placeholder { color: var(--label); opacity: 1; }
.cp-inline:not([readonly]):hover { background: var(--gold-soft); }
.cp-inline:not([readonly]):focus { outline: 2px solid var(--gold); outline-offset: 0; background: var(--surface); border-color: transparent; }
.cp-inline[readonly] { cursor: default; }
.cp-inline-title { font-weight: 500; color: var(--text); }
.cp-inline-module-title { font-family: "Familjen Grotesk", sans-serif; font-weight: 700; font-size: 1rem; color: var(--navy); }
.cp-inline-desc { margin-top: 1px; font-size: 0.82rem; color: var(--muted); }
.cp-inline-module-desc { margin-left: calc(var(--space-3) + 2.4em); width: calc(100% - var(--space-3) - 2.4em); }
/* An empty description takes no room until the row is being edited (the note button or Tab brings it up). */
.cp-inline-desc:placeholder-shown:not(:focus) { height: 0 !important; min-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; margin: 0; }
.cp-syl-topic-row > .cp-syl-num { padding-top: 4px; }
.cp-syl-line { display: flex; align-items: flex-start; gap: var(--space-2); }
.cp-syl-line .cp-inline-title { flex: 1 1 auto; }
.cp-inline-dur-wrap { display: inline-flex; align-items: baseline; flex: none; width: 4.6rem; font-size: 0.78rem; color: var(--muted); }
.cp-inline-dur-wrap:has(.cp-inline-dur:not(:placeholder-shown))::after { content: "min"; margin-left: 2px; }
.cp-inline-dur { width: 2.6rem; padding-left: 4px; padding-right: 4px; text-align: right; font-size: 0.78rem; color: var(--muted); }
.cp-inline-add { border: 1px dashed var(--border-solid); background: transparent; color: var(--text); }
.cp-inline-add:not([readonly]):hover { border-color: var(--gold); }
.cp-syl-quick-add { padding: 6px 0 0 var(--space-5); }
.cp-syl-quick-module { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-field-error { margin: 2px 0 0 6px; font-size: 0.78rem; color: var(--danger-text); }
.cp-field-error[hidden] { display: none; }
.cp-syl-module-title { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.cp-syl-module-title .cp-inline-module-title { flex: 1 1 14rem; width: auto; }
.cp-icon-btn[data-delete]:hover { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.cp-syl-topic.is-saving, .cp-syl-module.is-saving { opacity: 0.7; }
.cp-syl-topic-row > .cp-syl-topic-body { flex: 1 1 14rem; }
/* Row tools stay out of the way on a mouse until the row is hovered or focused; touch screens always show them. */
@media (hover: hover) and (pointer: fine) {
    .cp-syllabus.cp-inline-on .cp-syl-move { opacity: 0; }
    .cp-syllabus.cp-inline-on .cp-syl-topic-row:hover .cp-syl-move,
    .cp-syllabus.cp-inline-on .cp-syl-module-head:hover .cp-syl-move,
    .cp-syllabus.cp-inline-on .cp-syl-move:focus-within,
    .cp-syllabus.cp-inline-on .cp-syl-topic-row:focus-within .cp-syl-move,
    .cp-syllabus.cp-inline-on .cp-syl-module-head:focus-within .cp-syl-move { opacity: 1; }
}

/* ── Course Projects: recording progress (per topic tick, per module and whole-course bars) ── */
.cp-syl-titlebox { display: flex; align-items: flex-start; gap: var(--space-2); flex: 1 1 auto; min-width: 0; }
.cp-syl-titlebox .cp-inline-title { flex: 1 1 auto; }
.cp-rec-check { margin-top: 1px; }
.cp-syl-topic-body > .cp-rec-check { display: inline-block; vertical-align: middle; margin-right: var(--space-2); }
.cp-syl-rec { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.cp-syl-rec[hidden] { display: none; }
.cp-syl-rec .cp-progress { flex: 1 1 120px; max-width: 260px; min-width: 80px; }
.cp-syl-rec-text { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.cp-syl-module-rec { margin: var(--space-2) 0 0 calc(var(--space-3) + 2.4em); }
.cp-syl-rec-total { flex: 1 1 260px; }
.cp-syl-recform { margin: 0; }
.cp-syl-topic:has([data-recorded]:checked) .cp-inline-title,
.cp-syl-topic:has([data-recorded-static]:checked) .cp-syl-topic-title { color: var(--muted); }
@media (max-width: 720px) {
    .cp-syl-titlebox { flex: 1 1 100%; }
    .cp-syl-module-rec { margin-left: 0; }
    .cp-syl-rec { flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
    .cp-syl-rec-total { flex-basis: 100%; }
}

/* ── Course Projects: inline task rows (important controls on the line, the rest in a details panel) ── */
.cp-tasks-inline-on .cp-task-fallback { display: none; }
.cp-task--inline { display: block; padding: 0; }
.cp-task-line {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(8rem, 11rem) minmax(8.5rem, auto) auto;
    align-items: start;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-2) var(--space-4);
}
.cp-task-check { padding-top: 2px; }
.cp-task-title-input { font-weight: 600; color: var(--text); }
.cp-task.is-done .cp-task-title-input { color: var(--muted); text-decoration: line-through; }
.cp-task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-3); padding-left: 6px; }
.cp-task-meta .cp-task-note, .cp-task-meta .cp-task-link { margin-top: 0; }
.cp-task-meta [hidden] { display: none; }
.cp-task-who { padding-top: 1px; min-width: 0; }
.cp-task-due { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0 var(--space-2); text-align: right; }
.cp-inline-select {
    display: block; width: 100%; min-width: 0; padding: 3px 4px; font: inherit; font-size: 0.82rem; color: var(--text);
    border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; cursor: pointer;
}
.cp-inline-select:not(:disabled):hover { background: var(--gold-soft); }
.cp-inline-select:focus-visible { outline: 2px solid var(--gold); outline-offset: 0; background: var(--surface); }
.cp-inline-date { width: auto; font-size: 0.82rem; padding: 3px 4px; }
.cp-task-due-text { font-size: 0.78rem; }
.cp-task-due-text:empty { display: none; }
.cp-task-expand svg { display: block; margin: 0 auto; }
.cp-task.is-open .cp-task-expand svg { transform: rotate(180deg); }
.cp-task--inline.is-open { background: var(--pale, var(--surface)); }
.cp-task--inline.is-saving { opacity: 0.75; }
.cp-task-details { padding: var(--space-1) var(--space-4) var(--space-3) calc(var(--space-4) + 24px + var(--space-3)); }
.cp-task-details[hidden] { display: none; }
.cp-task-details-grid { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 14rem) minmax(0, 1fr); gap: var(--space-2) var(--space-4); }
.cp-detail { display: grid; gap: 2px; min-width: 0; font-size: 0.8rem; }
.cp-detail > span:first-child { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.cp-detail-wide { grid-column: 1 / -1; }
.cp-task-details .cp-inline, .cp-task-details .cp-inline-select { border-color: var(--border-solid); background: var(--surface); }
.cp-task-details-foot { margin-top: var(--space-2); }
.cp-danger-link { color: var(--danger-text); border-color: var(--danger-border); }
.cp-danger-link:hover { background: var(--danger-bg); }
.cp-task-quick { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-task-quick[hidden] { display: none; }
@media (max-width: 720px) {
    .cp-task-line {
        grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
        padding: var(--space-2) var(--space-3);
    }
    .cp-task-main { grid-column: 2 / 4; }
    .cp-task-expand { grid-column: 4; grid-row: 1; }
    .cp-task-who { grid-column: 2; grid-row: 2; }
    .cp-task-due { grid-column: 3 / 5; grid-row: 2; justify-content: flex-start; text-align: left; }
    .cp-task-details { padding: var(--space-1) var(--space-3) var(--space-3); }
    .cp-task-details-grid { grid-template-columns: minmax(0, 1fr); }
    .cp-task-quick { padding: var(--space-3); }
}
@media (pointer: coarse), (max-width: 720px) {
    .cp-inline-select, .cp-inline-date, .cp-task-details .cp-inline { min-height: 40px; }
    .cp-task-expand { width: 40px; height: 40px; }
    .cp-task-title-input { min-height: 40px; padding-top: 9px; }
    .cp-danger-link { min-height: 40px; }
}

/* ── Course Projects: inline expense rows ── */
.cp-contents { display: contents; }
.cp-exp-inline-on .cp-exp-fallback { display: none; }
.cp-exp-head, .cp-exp-line {
    display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 11rem 8.5rem 2.5rem; gap: var(--space-2) var(--space-3);
    padding: 0 var(--space-4);
}
.cp-exp-head { padding-top: var(--space-2); padding-bottom: var(--space-1); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); border-bottom: 1px solid var(--border-solid); }
.cp-exp-head span:nth-child(4) { text-align: right; }
.cp-exp-list { list-style: none; margin: 0; padding: 0; }
.cp-exp { border-top: 1px solid var(--border-solid); padding: var(--space-2) 0; }
.cp-exp:first-child { border-top: 0; }
.cp-exp.is-saving { opacity: 0.75; }
.cp-exp-line { align-items: start; }
.cp-exp-cell { display: block; min-width: 0; margin: 0; }
.cp-exp-label { display: none; }
.cp-exp-sub { display: flex; gap: var(--space-2); margin-top: 2px; }
.cp-exp-sub .cp-inline { flex: 1 1 40%; font-size: 0.8rem; color: var(--muted); }
.cp-exp-sub .cp-inline-select { flex: 1 1 60%; font-size: 0.78rem; color: var(--muted); }
.cp-exp-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cp-exp .cp-field-error, .cp-exp-quick .cp-field-error { padding: 0 var(--space-4); margin-top: 2px; }
.cp-exp-foot { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 2px solid var(--border-solid); font-size: 0.9rem; }
.cp-exp-quick { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-exp-quick[hidden] { display: none; }
.cp-exp-quick-fields { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 11rem 8.5rem auto; gap: var(--space-2) var(--space-3); align-items: center; }
.cp-exp-quick-fields .cp-inline, .cp-exp-quick-fields .cp-inline-select { border: 1px dashed var(--border-solid); }
.cp-exp-quick-fields .cp-inline-select { padding: 4px 6px; }
@media (max-width: 720px) {
    .cp-exp-head { display: none; }
    .cp-exp { padding: var(--space-3) 0; }
    .cp-exp-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; padding: 0 var(--space-3); }
    .cp-exp-text { grid-column: 1 / -1; grid-row: 1; }
    .cp-exp-date { grid-column: 1; grid-row: 2; }
    .cp-exp-cat { grid-column: 2; grid-row: 2; }
    .cp-exp-amt { grid-column: 1 / 3; grid-row: 3; }
    .cp-exp-line > .cp-icon-btn { grid-column: 3; grid-row: 3; align-self: end; }
    .cp-exp-label { display: block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
    .cp-exp-sub { flex-direction: column; }
    .cp-exp-sub .cp-inline, .cp-exp-sub .cp-inline-select { flex: none; }
    .cp-exp-foot { padding: var(--space-3); }
    .cp-exp-quick { padding: var(--space-3); }
    .cp-exp-quick-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .cp-exp-quick-fields > [data-qfield="note"] { grid-column: 1 / -1; }
    .cp-exp-quick-fields > .primary-button { grid-column: 1 / -1; }
    .cp-exp .cp-field-error, .cp-exp-quick .cp-field-error { padding: 0 var(--space-3); }
}
@media (pointer: coarse), (max-width: 720px) {
    .cp-exp .cp-inline, .cp-exp-quick .cp-inline { min-height: 40px; }
}

/* ── Course Projects: shared inline-edit pieces (Templates and Settings pages) ── */
.cp-inline-engine-on .cp-ifallback { display: none; }
.cp-quick-add { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-quick-add[hidden] { display: none; }
.cp-set-row.is-inactive .cp-set-name-input { color: var(--muted); }
.cp-set-line { display: flex; align-items: center; gap: var(--space-2); }
.cp-set-name-input { font-weight: 600; max-width: 28rem; }
.cp-set-usage { padding-left: 6px; }
.cp-set-row.is-saving, .cp-tmpl-task.is-saving, .cp-tmpl-phase.is-saving { opacity: 0.75; }
.cp-set-tools { flex-wrap: nowrap; }
.cp-phase-name-input { flex: 1 1 auto; min-width: 0; font-family: "Familjen Grotesk", sans-serif; font-weight: 700; font-size: 1rem; color: var(--navy); }
.cp-phase-error { padding: 0 var(--space-4); }
.cp-tmpl-phase .cp-panel-head .cp-syl-move { flex-wrap: nowrap; flex: none; }
.cp-tmpl-task--inline { display: block; padding: 0; }
.cp-tmpl-colhead, .cp-tmpl-line {
    display: grid; grid-template-columns: minmax(0, 1fr) 15.5rem 11rem auto; gap: var(--space-2) var(--space-3); padding: 0 var(--space-4);
}
.cp-tmpl-colhead { padding-top: var(--space-2); padding-bottom: var(--space-1); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); border-bottom: 1px solid var(--border-solid); }
.cp-tmpl-line { align-items: start; padding-top: var(--space-2); padding-bottom: var(--space-2); }
.cp-tmpl-titlebox { min-width: 0; }
.cp-tmpl-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); padding-left: 6px; font-size: 0.75rem; color: var(--muted); }
.cp-tmpl-rule { display: flex; align-items: center; gap: var(--space-1); }
.cp-tmpl-rule .cp-inline-select { flex: 1 1 auto; }
.cp-tmpl-offset { width: 4.2rem; flex: none; text-align: right; }
.cp-tmpl-days { font-size: 0.78rem; color: var(--muted); }
.cp-tmpl-tools-inline { flex-wrap: nowrap; }
.cp-tmpl-task--inline .cp-field-error { padding: 0 var(--space-4) var(--space-2); }
.cp-tmpl-details { padding-left: var(--space-4); }
.cp-tmpl-task--inline.is-open { background: var(--pale, var(--surface)); }
.cp-tmpl-task--inline .cp-task-details-grid { grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); }
@media (max-width: 720px) {
    .cp-tmpl-colhead { display: none; }
    .cp-tmpl-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-left: var(--space-3); padding-right: var(--space-3); }
    .cp-tmpl-titlebox { grid-column: 1 / -1; }
    .cp-tmpl-rule { grid-column: 1 / -1; }
    .cp-tmpl-assignee { grid-column: 1; }
    .cp-tmpl-tools-inline { grid-column: 2; justify-content: flex-end; }
    .cp-tmpl-details { padding: var(--space-1) var(--space-3) var(--space-3); }
    .cp-tmpl-task--inline .cp-task-details-grid { grid-template-columns: minmax(0, 1fr); }
    .cp-quick-add { padding: var(--space-3); }
    .cp-phase-error, .cp-tmpl-task--inline .cp-field-error { padding-left: var(--space-3); padding-right: var(--space-3); }
    .cp-set-row { grid-template-columns: minmax(0, 1fr); }
    .cp-set-name-input { max-width: none; }
}
@media (pointer: coarse), (max-width: 720px) {
    .cp-set-name-input, .cp-phase-name-input, .cp-tmpl-offset, .cp-inline-add { min-height: 40px; }
}

/* ── Course Projects: copy-name buttons on the syllabus ── */
.cp-icon-btn[data-copy] { flex: none; color: var(--muted); }
.cp-icon-btn[data-copy] svg { display: block; margin: 0 auto; }
.cp-icon-btn[data-copy].is-copied { color: var(--success-text); border-color: var(--success-border); background: var(--success-bg, var(--surface)); }
.cp-icon-btn[data-copy].is-copy-failed { color: var(--danger-text); border-color: var(--danger-border); }
.cp-syl-topic-body > .cp-icon-btn[data-copy] { vertical-align: middle; margin-left: var(--space-2); }
.cp-syl-module-title > .cp-icon-btn[data-copy] { align-self: center; }

/* ── Course Projects: the course charter ── */
.cp-charter { padding-bottom: var(--space-2); }
.cp-charter-apply { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-solid); background: var(--gold-soft); }
.cp-charter-apply p { margin: 0; }
.cp-charter-block, .cp-charter-section { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-charter > .cp-charter-block:first-child, .cp-charter > .cp-charter-apply + .cp-charter-block { border-top: 0; }
.cp-charter-field + .cp-charter-field { margin-top: var(--space-3); }
.cp-charter-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.cp-charter-head h3 { margin: 0; font-family: "Familjen Grotesk", sans-serif; font-size: 0.95rem; color: var(--navy); }
.cp-charter-head .cp-sub { flex: 1 1 14rem; }
.cp-charter-text { margin-top: 4px; font-size: 0.92rem; border-color: var(--border-solid); background: var(--surface); }
.cp-charter-read { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; font-size: 0.92rem; }
.cp-charter-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.cp-charter-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--space-1) var(--space-2); padding: 2px 0; }
.cp-charter-item.is-saving { opacity: 0.75; }
.cp-charter-item .cp-field-error { grid-column: 1 / -1; padding: 0 6px; }
.cp-charter-item--read { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 4px 0; border-top: 1px dashed var(--border-solid); }
.cp-charter-item--read:first-child { border-top: 0; }
.cp-charter-text, .cp-charter-item .cp-inline { min-width: 0; }
.cp-charter-add { padding: var(--space-2) 0 0; border-top: 0; }
.cp-charter-tools { flex-wrap: nowrap; }
.cp-charter-plainform { display: flex; gap: var(--space-2); margin: 4px 0; }
.cp-charter-plainform input { flex: 1 1 auto; min-width: 0; }
@media (hover: hover) and (pointer: fine) {
    .cp-inline-engine-on .cp-charter-item .cp-charter-tools { opacity: 0; }
    .cp-inline-engine-on .cp-charter-item:hover .cp-charter-tools,
    .cp-inline-engine-on .cp-charter-item:focus-within .cp-charter-tools { opacity: 1; }
}
@media (max-width: 720px) {
    .cp-charter-block, .cp-charter-section { padding: var(--space-3); }
    .cp-charter-apply { padding: var(--space-3); }
    .cp-charter-item { grid-template-columns: minmax(0, 1fr); }
    .cp-charter-tools { justify-content: flex-end; }
}
@media (pointer: coarse), (max-width: 720px) {
    .cp-charter-item .cp-inline, .cp-charter-text { min-height: 40px; }
}

#cp-tab-panel.is-loading { opacity: 0.6; pointer-events: none; }

/* ── Course Projects: Muhurta (Panchang) page ── */
.cp-pn-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.cp-pn-form .field-group { margin: 0; min-width: 11rem; }
.cp-pn-nav { display: flex; gap: var(--space-2); margin-left: auto; flex-wrap: wrap; }
.cp-pn-mr { font-size: 0.85em; color: var(--muted); }
.cp-pn-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-3) var(--space-4); padding: var(--space-3) var(--space-4); }
.cp-pn-label { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.cp-pn-list { list-style: none; margin: 0; padding: 0; }
.cp-pn-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-4); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-pn-list .cp-pn-row:first-child, .cp-pn-avoid .cp-pn-row:first-child { border-top: 0; }
.cp-pn-time { min-width: 11rem; font-weight: 600; color: var(--navy); }
.cp-pn-auspicious .cp-pn-time { color: var(--success-text); }
.cp-pn-inauspicious .cp-pn-time { color: var(--danger-text); }
.cp-pn-note { font-size: 0.78rem; color: var(--warning-text); }
.cp-pn-foot { margin: 0; padding: var(--space-2) var(--space-4); }
.cp-pn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--space-3) var(--space-5); padding: var(--space-3) var(--space-4); }
.cp-pn-grid h4, .cp-pn-fold h4 { margin: 0 0 var(--space-1); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--label); }
.cp-pn-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.cp-pn-fold { padding: var(--space-2) var(--space-4) var(--space-3); }
.cp-pn-selected { background: var(--gold-soft); }
.cp-pn-method { margin-top: var(--space-3); }
.cp-pn-rules { flex: 1 1 100%; }
.cp-pn-rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: var(--space-2) var(--space-4); padding: var(--space-2) 0; }
.cp-pn-check { display: flex; align-items: flex-start; gap: var(--space-2); font-size: 0.88rem; }
.cp-pn-rec { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-solid); }
.cp-pn-list > .cp-pn-rec:first-child, .cp-pn-top > .cp-pn-rec:first-child { border-top: 0; }
.cp-pn-rec.is-best { background: var(--gold-soft); }
.cp-pn-rec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); }
.cp-pn-suggest { font-family: "Familjen Grotesk", sans-serif; font-size: 1.15rem; font-weight: 700; color: var(--navy); }
.cp-pn-rec-window, .cp-pn-score { font-size: 0.82rem; color: var(--muted); }
.cp-pn-best { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.cp-pn-why { margin-top: 2px; font-size: 0.85rem; }
.cp-pn-save { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px dashed var(--border-solid); }
.cp-pn-save .cp-pn-check { flex: 1 1 100%; }
.cp-pn-save select { max-width: 100%; }
.cp-pn-personal { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-1); }
.cp-pn-tag { padding: 1px 8px; border: 1px solid var(--border-solid); border-radius: 999px; font-size: 0.75rem; }
.cp-pn-tag.cp-pn-favourable { color: var(--success-text); border-color: var(--success-border); }
.cp-pn-tag.cp-pn-middling { color: var(--muted); }
.cp-pn-tag.cp-pn-unfavourable { color: var(--danger-text); border-color: var(--danger-border); }
.cp-pn-top { list-style: none; margin: 0; padding: 0; }
.cp-pn-warn { margin: 0; padding: var(--space-2) var(--space-4); color: var(--warning-text); }
.cp-pn-profile-form { margin-top: var(--space-2); }
.cp-pn-delete { margin-top: var(--space-2); }

@media (max-width: 720px) {
    .cp-pn-form { padding: var(--space-3); }
    .cp-pn-nav { margin-left: 0; }
    .cp-pn-facts, .cp-pn-grid { padding: var(--space-3); }
    .cp-pn-row { padding: var(--space-2) var(--space-3); }
    .cp-pn-time { min-width: 0; flex: 1 1 100%; }
    .cp-pn-rec { padding: var(--space-3); }
}

/* ── Course Projects: saved launch time on the go-live tile ── */
.kpi-card .cp-launch { display: block; margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px dashed var(--border-solid); }
.cp-launch b { display: block; color: var(--navy); font-size: 0.95rem; }
.cp-launch-warn { display: block; margin-top: 2px; font-size: 0.75rem; }
.cp-launch-link { display: block; margin-top: 2px; font-size: 0.78rem; }
.cp-pn-saved-body { padding: var(--space-3) var(--space-4); }
.cp-pn-saved-line { margin: 0 0 var(--space-2); font-size: 1rem; }
.cp-launch-reasons { margin: 0 0 var(--space-2); padding-left: var(--space-4); font-size: 0.8rem; color: var(--text); }

/* ── Course Projects: focus states for text links and toggles, and touch-sized controls ── */
.cp-link:focus-visible, .cp-row-link:focus-visible, .cp-task-link:focus-visible, .cp-task-note a:focus-visible,
.cp-fold > summary:focus-visible, .cp-toggle-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }

/* On phones and other touch screens every control gets at least a 40px target. Text links keep their look: they
   grow an invisible padding, offset by a matching negative margin so the layout does not move. Shared components
   (back link, filter selects, page-size select) are enlarged only inside these pages, not app-wide. */
@media (pointer: coarse), (max-width: 720px) {
    .cp-subnav-link, .cp-tab, .cp-seg-btn { min-height: 40px; display: inline-flex; align-items: center; }
    .cp-icon-btn { width: 40px; height: 40px; font-size: 1.1rem; }
    .cp-drag-handle { width: 40px; height: 40px; }
    .cp-move-to { height: 40px; min-width: 96px; }
    .cp-fold > summary { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 40px; padding: 0 var(--space-2); }
    .cp-check { width: 40px; height: 40px; }
    .cp-check::before { inset: 9px; }
    .cp-task-title { display: inline-block; padding: 8px 0; }
    .cp-link, .cp-row-link, .cp-task-link, .cp-task-note a, .kpi-meta a, .cp-history a {
        display: inline-block; padding: 12px 6px; margin: -12px -6px;
    }
    .cp-page .back-link { display: inline-flex; align-items: center; min-height: 40px; }
    .cp-filter-bar .pt-filter-select, .cp-activity-pager .page-size-select, .cp-page .pt-filter-clear { min-height: 40px; }
    .cp-page .pt-filter-clear { display: inline-flex; align-items: center; }
    .cp-toggle-btn, .cp-small-btn { min-height: 40px; }
    .cp-task { grid-template-columns: 40px minmax(0, 1fr); }
    .cp-syl-topic-row { gap: var(--space-2); }
}
