/*
================================================================================
  FILE: sites/crm/assets/style.css
  DESCRIPTION: ArdinGate CRM — full dark-theme stylesheet for all pages
================================================================================
  VERSION: 1.33
  LAST UPDATED: 2026-05-01

  PROJECT: ArdinGate CRM (project v4.117)
  PART OF: sites/crm/ — internal client and project tracker (subdomain crm.ardingate.com)

  ARCHITECTURE:
    - Design tokens are defined in sibling assets/tokens.css (loaded BEFORE
      this file). That file declares `@layer base, components, utilities;`
      and supplies all custom properties (surfaces, text, state, spacing,
      radius, shadow, motion, type) plus light/dark theme switching via
      [data-theme] attribute on :root.
    - Cascade layers used in this file:
        @layer base       → reset, typography, every existing component rule
        @layer utilities  → .u-* utility classes
      Anything outside a layer wins over both, but new rules should target
      a layer so theme + density overrides cascade predictably.
    - Mobile-first with breakpoints at 768px and 480px.
    - No external fonts or CDN dependencies — system font stack only.
    - All tables scroll horizontally on small screens via .table-wrap.

  CHANGE LOG:
  v1.33   2026-05-01  Claude  Phase G — .crm-messages thread + .badge--info/neutral in
                            @layer utilities (project files + client message sections).
  v1.32.1 2026-04-30  Claude  Convert remaining scattered rgba() in component rules to 8-digit hex
  v1.32   2026-04-30  Claude  Inline style sweep — token pass on style.css:
                              - queue-badge--warn/danger colors → tokens
                              - filter-count color: #fff → var(--accent-text)
                              - login-body gradients + card shadow → tokens
                              - stepper rainbow values → var(--step-c*) tokens
                              - pdf-preview-body/row/full + pdfv-page → tokens
                              - .u-dim → var(--text-dim)
                              - badge/callout--warning → var(--callout-warn-*)
                              - forecast-stat-label → var(--text-muted)
                              - total-row--pending → var(--pending-row-bg)
                              - select-sm-dark → var(--select-dark-*)
                              - add .chart-canvas-wrap + .form-control--sm classes
  v1.31.4 2026-04-30  Claude  .form-input added as alias of .form-control so webhook URL/name
                              inputs and other admin fields using that class get full styling
  v1.31.3 2026-04-30  Claude  .filter-bar .form-control: width: auto so filter dropdowns/inputs
                              don't stretch full-width in the flex filter bar (form-control base
                              rule sets width:100% which causes stacking)
  v1.31.2 2026-04-30  Claude  .action-cell: drop display:flex (empty flex td doesn't receive
                              hover background paint, causing card bg to bleed through as a
                              dark square on row hover); use vertical-align + text-align instead
  v1.31.1 2026-04-30  Claude  .card overflow: hidden → clip so sticky thead and table-wrap
                              scrollbars aren't clipped by the card's border-radius
  v1.31   2026-04-30  Claude  Phase C.2 — add .modal-search-item--action variant
                              (tinted left edge) so palette action items visually
                              separate from plain search results.
  v1.30   2026-04-30  Claude  Hardcoded hex/rgba sweep — flow through tokens
                              - All .badge-* domain variants now use
                                --state-{ok,warn,danger,info}-text and --text-purple
                                so AA holds in both themes (was broken on light)
                              - All .billing-status-* backgrounds + borders now use
                                --{green,amber,red,blue,purple,gray}-dim and
                                --state-*-border tokens
                              - .badge--approved/declined/sent unified on tokens
                              - .alert-inline-error → state-danger tokens (drops
                                --alert-error-* fallback that was never defined)
                              - .event-dot-* + .balance-progress-fill gradients →
                                state tokens
                              - .timer-running-banner + .risk-banner-* text →
                                state tokens
                              - .aging-bucket-61-90 → new --orange / --orange-dim
                                tokens (per theme)
                              - .aging-bucket-over-90 box-shadow → state-danger-border
                              - var(--danger, #e55) → var(--state-danger);
                                var(--green, #34d399) → var(--state-ok)
  v1.29   2026-04-30  Claude  Phase B.2 — relocated theme-toggle CSS to components.css;
                              added .u-c-muted / .u-c-secondary / .u-list-reset
                              utilities used by the new /styleguide page.
  v1.28   2026-04-30  Claude  Phase B.1 — cascade layers + tokens extraction
                              - Removed inline :root token block; tokens now in tokens.css
                              - Wrapped existing rules in @layer base
                              - Wrapped utility classes in @layer utilities
                              - Bumped project version reference to v4.105 (Phase B.1)
  v1.27.1 2026-04-30  Claude  Add text-align:center to .login-submit — justify-content alone
                              doesn't reliably center text in inline-flex at full width.
  v1.27   2026-04-29  Claude  Add u-c-aaa color utility for dynamic inline style removal (#7)
  v1.26   2026-04-29  Claude  Extended utility layer to cover all remaining inline styles (#7)
                              - Added color utilities: u-c-6e6, u-c-b45
                              - Added font-size utilities: u-text-65, u-text-10
                              - Added sizing utilities: u-mw-120
                              - Added layout utilities: u-span-full, u-m-0
                              - Added component classes: .badge--warning, .total-row--pending,
                                .input-date-sm, .select-sm-dark, .response-preview
                              - Added padding to .pagination rule
  v1.25   2026-04-29  Claude  Utility class layer — remove style-src-attr 'unsafe-inline'
                              from CSP. Added .u-* utilities (display, flex, spacing, sizing,
                              text), .badge--approved/declined/sent, .callout--warning,
                              .forecast-stat-*, .form-grid--2col / --1-2 / --alerts
                              modifiers, .color-swatch-auto via CSS custom property (#7)
  v1.24.1 2026-04-28  Claude  Rename "Invoice Ninja billing panel" CSS section comment
                              to "Billing panel" — IN was decommissioned at v4.66; the
                              .billing-* classes outlived IN and are used by the new
                              billing engine. Comment-only; no rule changes.
  v1.24   2026-04-28  Claude  Phase 8 — .queue-badge variants (ok/warn/danger) for the
                              job queue status indicator in the nav bar.
  v1.23.4 2026-04-27  Claude  Center button labels on full-width buttons (project v4.73.15) —
                              .btn uses display:inline-flex which defaults to flex-start, so
                              .btn--block and .login-submit had left-aligned text. Added
                              justify-content:center to both. Affects estimator action buttons
                              (Save as new project, Save & generate contract draft, Copy
                              summary to clipboard) and the login + 2FA submit buttons.
  v1.23.3 2026-04-27  Claude  PDF preview thead background reset (project v4.73.4)
                              .pdfv-table th was inheriting background: var(--bg-surface)
                              from the global "thead th" rule, painting the header row
                              dark navy on the PDF preview's white paper — turning it into
                              dark text (--pdfv-body, ~#1a1a1a) on dark navy at 1.1
                              contrast. Added background: transparent to the .pdfv-table th
                              override so the header row stays on the paper.
  v1.23.2 2026-04-27  Claude  Table-header contrast fixes (project v4.73.3)
                              - thead th color: --text-muted → --text-secondary
                                (3.4 → 5.7 contrast on --bg-surface, passes WCAG AA)
                              - .line-items-table th color: same swap
                                (2.4 → 4.1 contrast on --bg-raised — invoice view, project view)
                              - .pdfv-table th: dropped opacity:.75 that was crushing the
                                header text contrast in the settings PDF preview (the
                                "unreadable top line of the items table" the user flagged
                                earlier — the opacity stacked on top of an already-muted
                                color)
  v1.23.1 2026-04-27  Claude  Padding for .form-body / trailing .form-actions — when a form
                              wraps fields in <div class="form-body"> inside a bare .card
                              (e.g. /time/log.php, /time/edit.php, /invoices/credit.php),
                              both sat flush against the card edges because .form-body had
                              no rule and .form-actions only had top padding. Added
                              .form-body { padding: 1.25rem } and a scoped
                              .form-body + .form-actions override that supplies the
                              side+bottom padding without affecting .form-card layouts
                              (project v4.73 → v4.73.2)
  v1.23   2026-04-27  Claude  Live previews on settings pages (project v4.73)
                              - .portal-preview + .ppv-* children: dashboard mockup
                                styled via CSS custom props (--ppv-accent, --ppv-bg, etc.)
                              - .pdf-preview-full + .pdfv-* children: full invoice mockup
                                with header bar, Bill-To grid, line-item table, totals,
                                notes; aspect-ratio honors --pdfv-paper
  v1.22   2026-04-27  Claude  Settings page CSS — all missing classes (project v4.71)
                              - .card-body alias for .card__body padding
                              - .card-grid / .card-grid--2col: settings hub grid
                              - .card--link: clickable card with hover
                              - .card-text / .card-meta: card content typography
                              - .tab-bar / .tab-link / .tab-link--active: tab nav
                              - .form-label / .form-control / .form-hint: named
                                class aliases for existing element selectors
                              - .form-grid / .form-group--full: settings form grid
                              - .checkbox-label: inline checkbox row
                              - .color-picker-wrap / .color-swatch /
                                .form-control--hex: color picker row
                              - input[type="color"] base styles
                              - .preset-list / .preset-btn / .preset-dot /
                                .preset-name / .preset-meta: one-click presets
                              - .color-grid: 200px-min auto-fill color field grid
                              - .radius-wrap / .radius-preview / .radius-val:
                                border-radius slider row
                              - .font-preview-wrap: font preview box
                              - .pdf-preview and children: mini PDF preview card
  v1.21.1 2026-04-26  Claude  Add padding to .filter-bar so content doesn't touch card border (project v4.70)
  v1.21   2026-04-26  Claude  Time tracking styles (project v4.65)
                              - .timer-running-banner: top-of-card running timer strip with pulsing dot
                              - .timer-running-dot: green pulse animation
                              - .timer-start-form: inline flex start-timer row
                              - .timer-desc-input: stretchy text field in start form
                              - .row-billed: dimmed/strikethrough style for billed rows
  v1.20   2026-04-26  Claude  Table totals bar + invoice billing dashboard card styles (project v4.64)
                              - .table-totals-bar / -item / --owed for invoice list
  v1.19   2026-04-26  Claude  Invoice billing status badge variants (project v4.58)
                              - .billing-status-viewed, -void, -settled, -pending,
                                -failed, -refunded added for native billing system
  v1.18   2026-04-24  Claude  Invoice Ninja billing panel styles (project v4.56)
                              - .billing-status-badge + per-status color variants
                                (draft, sent, partial, paid, overdue, recurring,
                                cancelled)
                              - .billing-panel / .billing-panel--unsynced: inner
                                content area for the billing card
                              - .billing-detail-grid / -item / -label / -value:
                                same 2-col grid pattern as .detail-grid
                              - .billing-actions: flex row for action buttons
                              - .billing-id-mono: monospace truncated ID display
  v1.17   2026-04-24  Claude  Full mobile/tablet responsive pass (project v4.55)
                              - Fixed hamburger never showing: base .nav-hamburger
                                { display:none } in the v4.24 section was placed
                                AFTER the media query, so it always won. Fixed by
                                using .nav-inner .nav-hamburger (higher specificity)
                                in the ≤768px block.
                              - Nav hamburger now triggers at ≤768px (was 540px) so
                                tablets no longer see 5 cramped inline nav links
                              - nav-link min-height/flex moved into the ≤768px block
                              - activity-table stacking breakpoint bumped to ≤640px
                                (was 560px); added data-label::before labels for
                                cells that carry the data-label attribute
                              - .leads-filter-tabs wraps on ≤640px; source-group
                                drops to its own row with a top divider
                              - .card-header .brand-tabs wraps on ≤640px (contracts)
                              - ≤400px: search trigger hidden, main padding tightened
  v1.16   2026-04-22  Claude  Actual Kraken palette — full :root color token overhaul (project v4.52)
                              - --bg-base: #001628 (Deep Sea Blue), surface/raised/hover step up in teal-navy
                              - --accent/#E9072B (Red Alert), --accent-dim updated rgba
                              - --text-secondary: #68A2B9 (Shadow Blue), --text-muted: #4a7896
                              - --border/border-strong: Shadow Blue tint replaces white overlays
                              - --red/#E9072B + --red-dim updated rgba (error states stay red)
  v1.15   2026-04-22  Claude  Auth-log page utility classes (project v4.49 → v4.49.1)
                              - .card-header--flex: space-between card header for filter controls
                              - .filter-row / .filter-select: inline event-type dropdown
                              - .row--warn: left danger-accent on failure rows
                              - .cell-nowrap / .cell-mono / .cell-ua: table cell helpers
  v1.14   2026-04-22  Claude  Strip-inline-styles cleanup utilities batch 2 (project v4.48 → v4.49)
                              - Extended the SHARED UTILITIES block with additional
                                helpers surfaced while converting the remaining 16
                                CRM pages: brand-tab--compact, leads-filter-tabs,
                                leads-source-group / -label, table-link-bold,
                                cell-email, cell-details / -lead / -ellipsis,
                                notes-form-body / -actions, notes-textarea,
                                notes-block--spaced, alert-row, lead-meta-caption,
                                lead-meta-hint, event-log-actor, event-log-empty,
                                label-optional, card-title__hint, summary-hint,
                                col-num-right, btn-group-wrap, card--stack-sm,
                                form-group--snug, label-block
                              - No existing rules changed; all new rules are
                                additive and don't collide with component styles.
  v1.13   2026-04-22  Claude  .donut-grid expanded to 3 columns for the new
                              Clients by Brand chart (project v4.47 → v4.48).
                              Added intermediate 2-column breakpoint ≤1100px
                              so three cards don't squish; still collapses to
                              a single column ≤700px.
  v1.0    2026-04-20  Claude  Initial build — full component library: nav, cards,
                              tables, badges, forms, buttons, alerts, timeline,
                              phase stepper, split indicator, pagination, login page
  v1.0.1  2026-04-20  Claude  Subdomain migration — no functional changes (project v4.9 → v4.10)
  v1.1    2026-04-20  Claude  Line-item repeater styles for the multi-service
                              project form, plus the services breakdown table and
                              invoice summary on the project view (project v4.10 → v4.11)
  v1.2    2026-04-20  Claude  v4.12 UI overhaul — big addition at the bottom
                              - Nav tools (search trigger, "+" quick-add, user
                                menu avatar) + reshuffled .nav-inner layout
                              - Dropdowns, modals (search + confirm), overflow
                                row menus
                              - Activity feed, aging buckets, upcoming list
                              - Balance progress bar, risk banner
                              - Clickable phase stepper (.phase-step-btn)
                              - Sortable column headers
                              - Client avatar, empty state polish, alert close
                              - Fade/slide animations
                              (project v4.11 → v4.12)
  v1.3    2026-04-20  Claude  Collapsible line-item rows — collapsed/expanded toggle
                              - .line-item .line-item-summary hidden by default;
                                .line-item:not(.line-item-is-open) shows summary +
                                hides editor (simplified from prior attempt that had
                                redundant explicit rules causing specificity conflicts)
                              - .line-item-summary-name/cycle/price/actions layout
                              - .line-items-actions now flex so + Add Service and
                                Save sit side by side
                              (project v4.12 → v4.13)
  v1.12   2026-04-21  Claude  Login page redesign + TOTP code input style (project v4.30 → v4.31)
                              - .login-body: subtle radial gradients (red + blue) for depth
                              - .login-card: tightened padding, drop shadow, 420px max
                              - .login-brand: logo mark + name + sub on one row (was stacked)
                              - .login-submit: full-width primary button, heavier font weight
                              - .login-code-input: monospace, letter-spaced, centered — TOTP form
                              - .login-foot: subtle border-top footer for links/copyright
  v1.11   2026-04-21  Claude  Snapshot grid + on_hold dashboard logic (project v4.29.2 → v4.30)
                              - .dashboard-snapshot: 2-col grid for Receivables + Pipeline
                                Health (stacks ≤960px); solo child spans full width
                              - .aging-footnote: dashed divider + parked money line
                              - .row-on-hold: muted opacity + amber left border for
                                on_hold project rows on the active projects table
  v1.10.1 2026-04-21  Claude  Aging + health grids now have 1rem top padding so tiles don't butt up against the card title (project v4.29.1 → v4.29.2)
  v1.10   2026-04-21  Claude  Filter popover styles for clients page (project v4.29 → v4.29.1)
                              - .filter-bar-single: search + filter stay on one row at
                                all widths (no column flip at ≤768px)
                              - .filter-trigger / .filter-count: icon-and-label button
                                with active filter count pill badge
                              - .filter-panel: styles for the popover body — labels,
                                full-width selects, actions row with top border
  v1.9    2026-04-21  Claude  Dashboard design pass (project v4.28.1 → v4.29)
                              - .nav-badge: swapped red for green — a new-lead count is a
                                positive signal, red made it read as an error
                              - .stat-card-arrow: hover translate + accent color so the
                                drill-through affordance is clear; .stat-card-static mutes
                                the non-clickable Total Revenue card
                              - Aging bucket color escalation: 0-30 green, 31-60 amber,
                                61-90 orange, 90+ bright red with glow + larger number
                              - .health-grid / .health-tile: Pipeline Health tiles for
                                the dashboard (overdue / at-risk / on-track / on-hold)
                                with zero-count fade so empty states don't shout
  v1.8    2026-04-21  Claude  Leads feature — badge + nav-badge styles (project v4.27 → v4.28)
                              - .badge-lead-new/contacted/qualified/converted/closed
                              - .nav-badge: red pill counter on nav links
  v1.7    2026-04-21  Claude  Phase rainbow colors + status exception layout (project v4.24 → v4.25)
                              - form.steps-phase button:nth-of-type(1-7): pink-first rainbow
                                (discovery=pink #e91e63, then red→orange→yellow→green→blue→violet)
                              - form.steps-status { flex-wrap: wrap } so exceptions break to row 2
                              - .stepper-exception-marker: full-width flex divider with italic label
                              - .status-exception::before: no connector line into exception buttons
                              - .status-exception .phase-dot: dashed border for visual distinction
  v1.6    2026-04-20  Claude  Full mobile-responsive pass (project v4.23 → v4.24)
                              - .nav-hamburger: hidden on desktop, shown ≤540px;
                                opens nav-links as absolute dropdown below nav bar
                              - .clients-table: card layout ≤640px with data-label
                                grid columns (label | value per row)
                              - .activity-table: stacked layout ≤560px; hides
                                thead, blocks each td, normalises white-space
                              - Line item summary-actions: opacity:1 at ≤860px
                                (no hover on touch)
                              - Touch targets: .btn min-height 40px, .btn-sm 36px,
                                .row-menu-toggle 36px at ≤640px
                              - General polish: form-card padding 1rem, page-actions
                                and card-header wrap, filter inputs min-height 40px,
                                nav-link min-height 44px in mobile dropdown
  v1.5    2026-04-20  Claude  Rainbow steppers + dashboard donut charts (project v4.18 → v4.19)
                              - .phase-active .phase-dot + hover now use --step-color/--step-dim
                              - form.phase-stepper button:nth-of-type(1-7) define per-step
                                rainbow colors (red→orange→yellow→green→blue→indigo→violet)
                              - .donut-grid, .donut-card, .donut-canvas-wrap (2.5D perspective
                                + drop-shadow), .donut-legend for dashboard charts
  v1.4    2026-04-20  Claude  Activity timeline table (project v4.16 → v4.17)
                              - .event-dot + per-type variants (payment, refund,
                                service triangle, interaction circle)
                              - .activity-filters container rule
  v1.3.3  2026-04-20  Claude  Status stepper helpers — .stepper-section-label and
                              .stepper-section-divider for the two-row Phase & Status
                              card (project v4.15 → v4.16)
  v1.3.2  2026-04-20  Claude  Fix detail-grid email clipping — minmax 160→200px,
                              overflow-wrap + min-width:0 on .detail-value
                              (project v4.14 → v4.15)
  v1.3.1  2026-04-20  Claude  Hide Edit/× actions on collapsed rows until hover
                              (project v4.13 → v4.14)
================================================================================
*/

/* Design tokens are defined in sibling assets/tokens.css (Phase B.1).
   That file declares `@layer base, components, utilities;` and supplies every
   custom property below this point. Theme overrides hang off [data-theme]. */

@layer base {

/* ── Reset & Base ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Navigation ─────────────────────────────────────────────────────────────── */

.nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-strong);
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-inner .nav-brand { margin-right: 0.5rem; }
.nav-inner .nav-links { margin-right: auto; }
.nav-tools {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.nav-app-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--text-primary); text-decoration: none; }
.nav-link-active {
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
}

/* ── Main Content ───────────────────────────────────────────────────────────── */

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Page Header ────────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  line-height: 1.3;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.page-breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.page-breadcrumb a { color: var(--text-secondary); }
.page-breadcrumb a:hover { color: var(--text-primary); }

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.count-badge {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-raised);
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  vertical-align: middle;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover {
  background: var(--red-dim);
  color: var(--red);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: clip;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-card { padding: 1.5rem; }

/* ── Stats Grid ─────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.stat-value-lg {
  font-size: 1.25rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-surface);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tfoot td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-strong);
  background: var(--bg-raised);
  font-size: 0.875rem;
}

.totals-row td { background: var(--bg-raised); }

.action-cell {
  vertical-align: middle;
  white-space: nowrap;
  text-align: right;
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: var(--gray-dim);
  color: var(--text-secondary);
}

/* Brand badges */
.badge-web     { background: var(--accent-dim);  color: var(--state-danger-text); }
.badge-studios { background: var(--blue-dim);    color: var(--state-info-text); }
.badge-both    { background: var(--purple-dim);  color: var(--text-purple); }

/* Client status badges */
.badge-lead     { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-active   { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-inactive { background: var(--gray-dim);   color: var(--text-secondary); }
.badge-archived { background: var(--gray-dim);   color: var(--text-muted); }

/* Project status badges */
.badge-in_progress { background: var(--blue-dim);   color: var(--state-info-text); }
.badge-review      { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-complete    { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-cancelled   { background: var(--red-dim);    color: var(--state-danger-text); }
.badge-on_hold     { background: var(--gray-dim);   color: var(--text-secondary); }

/* Interaction type badges */
.badge-interaction-call             { background: var(--blue-dim);   color: var(--state-info-text); }
.badge-interaction-email            { background: var(--purple-dim); color: var(--text-purple); }
.badge-interaction-meeting          { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-interaction-note             { background: var(--gray-dim);   color: var(--text-secondary); }
.badge-interaction-quote_sent       { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-interaction-quote_approved   { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-interaction-invoice_sent     { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-interaction-payment_reminder { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-interaction-contract_sent    { background: var(--accent-dim); color: var(--state-danger-text); }
.badge-interaction-contract_signed  { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-interaction-kickoff          { background: var(--purple-dim); color: var(--text-purple); }
.badge-interaction-scope_change     { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-interaction-delivery         { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-interaction-follow_up        { background: var(--blue-dim);   color: var(--state-info-text); }

/* Lead status badges */
.badge-lead-new        { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-lead-contacted  { background: var(--amber-dim);  color: var(--state-warn-text); }
.badge-lead-qualified  { background: var(--blue-dim);   color: var(--state-info-text); }
.badge-lead-converted  { background: var(--green-dim);  color: var(--state-ok-text); }
.badge-lead-closed     { background: var(--gray-dim);   color: var(--text-secondary); }

/* Nav notification badge (new lead count — positive signal, not an alert) */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 99px;
  background: var(--green);
  color: #062e12;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 0.3rem;
  vertical-align: middle;
}

/* ── Queue Badge ────────────────────────────────────────────────────────────── */

.queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}
.queue-badge--ok   { background: var(--green);          color: #062e12; }
.queue-badge--warn { background: var(--amber);          color: var(--queue-warn-text); }
.queue-badge--danger { background: var(--queue-danger); color: var(--queue-danger-text); }

/* ── Balance Colors ─────────────────────────────────────────────────────────── */

.balance-clear    { color: var(--green); }
.balance-owed     { color: var(--text-primary); }
.balance-overdue  { color: var(--red); }
.balance-attention{ color: var(--amber); }

/* ── Filter Bar ─────────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
}
.filter-bar .form-control {
  width: auto;
}

/* Single-line variant — search + filter button stay on one row, no column flip */
.filter-bar-single {
  flex-wrap: nowrap;
}
.filter-bar-single .search-input {
  min-width: 0;
}

/* Filter popover trigger — icon + label + active-count badge */
.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.filter-trigger svg { flex-shrink: 0; }
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

/* Filter panel — sits inside .dropdown-menu so inherits popover positioning */
.filter-panel {
  min-width: 280px;
  padding: 1rem;
}
.filter-panel-row {
  margin-bottom: 0.85rem;
}
.filter-panel-row:last-of-type {
  margin-bottom: 0;
}
.filter-panel-row label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.filter-panel-row select {
  width: 100%;
}
.filter-panel-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.filter-clear-link { white-space: nowrap; }

@media (max-width: 540px) {
  .filter-panel { min-width: 240px; }
  .filter-bar-single .filter-trigger { padding-left: 0.75rem; padding-right: 0.75rem; }
}

/* ── Brand Filter Tabs ──────────────────────────────────────────────────────── */

.brand-tabs {
  display: flex;
  gap: 0.375rem;
}

/* Stack modifier — adds the margin-bottom previously applied inline
   (index.php dashboard row, projects/index.php filter row). */
.brand-tabs--stack { margin-bottom: 1.5rem; }

/* ── Dashboard two-column grid (index.php) ──────────────────────────────────── */
/* Previously rendered via inline style="" + a sibling <style> @media block;
   consolidated here per the "no inline styles" rule (project v4.49). */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 860px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.brand-tab {
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}
.brand-tab:hover { background: var(--bg-raised); color: var(--text-primary); }
.brand-tab-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0;
}
.form-row .form-group { margin-bottom: 1.25rem; }

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.required { color: var(--accent); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.55rem 0.75rem;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
input:disabled, select:disabled, textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%239999a8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}
textarea { resize: vertical; min-height: 80px; }

optgroup { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; }
option   { background: var(--bg-raised); color: var(--text-primary); }

.form-error input,
.form-error select,
.form-error textarea {
  border-color: var(--red);
}

.field-error {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* When a form uses .form-body inside a bare .card (no .form-card wrapper),
   the body and trailing actions need their own padding — otherwise the
   form fields and the buttons sit flush against the card edges. */
.form-body { padding: 1.25rem; }
.form-body + .form-actions {
  margin-top: 0;
  padding: 1rem 1.25rem 1.25rem;
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  border: 1px solid;
}

.alert-success {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.alert-error {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

/* ── Overdue List ───────────────────────────────────────────────────────────── */

.overdue-list {
  list-style: none;
  padding: 0.25rem 1.25rem 1rem;
}

.overdue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  font-size: 0.875rem;
}
.overdue-item:last-child { border-bottom: none; }

.overdue-client { color: var(--text-secondary); }
.overdue-project { font-weight: 500; }
.overdue-date, .overdue-balance { font-size: 0.8rem; }

/* ── Client/Project Detail ──────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
}

.detail-grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.detail-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
  overflow-wrap: break-word;
  min-width: 0;
}

.notes-block {
  padding: 0 1.25rem 1.25rem;
}

.notes-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 0.35rem;
  white-space: pre-wrap;
}

/* ── Interaction Timeline ───────────────────────────────────────────────────── */

.timeline { padding: 0.5rem 0; }

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.75rem;
  row-gap: 0.2rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-hidden { display: none; }

.timeline-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-summary {
  grid-column: 1 / 3;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 0.35rem;
}

.timeline-delete {
  grid-row: 1;
  grid-column: 3;
}

/* ── Phase Stepper ──────────────────────────────────────────────────────────── */

.phase-stepper {
  display: flex;
  align-items: flex-start;
  padding: 1.25rem;
  gap: 0;
  overflow-x: auto;
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  min-width: 70px;
}

/* Connector line between steps */
.phase-step::before {
  content: '';
  position: absolute;
  top: 8px;
  left: calc(-50% + 8px);
  right: calc(50% + 8px);
  height: 2px;
  background: var(--border-strong);
}
.phase-step:first-child::before,
button.phase-step:first-of-type::before { display: none; }

.phase-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 2px solid var(--border-strong);
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.phase-active .phase-dot {
  background: var(--step-color, var(--accent));
  border-color: var(--step-color, var(--accent));
  box-shadow: 0 0 0 3px var(--step-dim, var(--accent-dim));
}

.phase-label {
  font-size: 0.72rem;
  text-align: center;
  color: var(--text-muted);
  white-space: nowrap;
}
.phase-active .phase-label {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── 50/50 Split Indicator ──────────────────────────────────────────────────── */

.split-indicator {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.25rem;
}

.split-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
}

.split-paid {
  border-color: var(--green);
  background: var(--green-dim);
}

.split-unpaid {
  border-color: var(--border-strong);
  background: var(--bg-raised);
}

.split-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  font-weight: 600;
}

.split-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.split-status {
  font-size: 0.8rem;
  font-weight: 600;
}
.split-paid .split-status  { color: var(--green); }
.split-unpaid .split-status{ color: var(--text-muted); }

/* ── Pagination ─────────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem 1.5rem;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Summary totals bar displayed below filtered invoice/table lists */
.table-totals-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.table-totals-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-right: auto;
}
.table-totals-item {
  color: var(--text-secondary);
}
.table-totals-item strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.table-totals-item--owed strong {
  color: var(--amber);
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */

.site-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 2rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ── Login / 2FA pages ──────────────────────────────────────────────────────── */

.login-body {
  background:
    radial-gradient(ellipse 900px 500px at 20% -10%, var(--login-glow-red), transparent 60%),
    radial-gradient(ellipse 700px 400px at 110% 110%, var(--login-glow-blue), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--login-card-shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.login-logo-mark {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
  box-shadow: 0 4px 12px #cc1f1f59;
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.login-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.login-brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.login-alert {
  margin-bottom: 1rem;
}

.login-form .form-group {
  margin-bottom: 1rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 1rem;
  font-weight: 600;
  justify-content: center;
  text-align: center;
}

.login-code-input {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.45em;
  text-align: center;
  padding: 0.7rem 0.85rem;
}

.login-foot {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.login-foot a {
  color: var(--text-secondary);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .split-indicator {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .search-input { min-width: unset; }

  /* .filter-bar-single keeps search + filter on one row even on mobile */
  .filter-bar-single {
    flex-direction: row;
    align-items: center;
  }

  .timeline-item {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
  }
  .timeline-date { grid-column: 1; }
  .timeline-delete { grid-row: 1; grid-column: 2; }
  .timeline-summary { grid-column: 1 / 3; }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .nav-app-name {
    display: none;
  }

  .main-content {
    padding: 1.25rem 1rem;
  }

  .brand-tabs { flex-wrap: wrap; }
}

/* ── Line Item Repeater (project add/edit) ────────────────────────────────── */

.line-items-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.line-items-header label { margin-bottom: 0; }
.line-items-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.line-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.line-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 0.875rem 0.625rem;
}

.line-item-main {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) 80px minmax(0, 1fr) minmax(0, 1fr) 40px;
  gap: 0.75rem;
  align-items: end;
}

.line-item-field { min-width: 0; }
.line-item-field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.line-item-field-qty.line-item-qty-hidden { visibility: hidden; }

.line-item-total {
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.line-item-field-remove { align-self: end; }
.line-item-remove {
  width: 100%;
  padding: 0.55rem 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-muted);
}
.line-item-remove:hover {
  color: var(--red);
  border-color: var(--red);
}

.line-item-desc {
  margin-top: 0.625rem;
}
.line-item-description {
  background: var(--bg-base) !important;
  font-size: 0.82rem;
  padding: 0.45rem 0.65rem !important;
}

/* ── Line item collapsed / expanded toggle ──────────────────────────────── */
/* Summary hidden by default; editor (a plain div) is block by default */
.line-item .line-item-summary { display: none; }

/* Collapsed (no .line-item-is-open): flip — show summary, hide editor */
.line-item:not(.line-item-is-open) .line-item-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.line-item:not(.line-item-is-open) .line-item-editor { display: none; }

.line-item-summary-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line-item-summary-cycle {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.line-item-summary-price {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 6rem;
  text-align: right;
  white-space: nowrap;
}
.line-item-summary-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.line-item:not(.line-item-is-open):hover .line-item-summary-actions {
  opacity: 1;
}

.line-items-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.line-items-summary {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.line-items-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.line-items-summary-value { font-variant-numeric: tabular-nums; }
.line-items-summary-total {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}
.line-items-summary-total .line-items-summary-label { color: var(--text-primary); }

/* ── Services Breakdown (project view) ────────────────────────────────────── */

.line-items-table th {
  background: var(--bg-raised);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}
.line-items-table td,
.line-items-table th {
  padding: 0.65rem 0.875rem;
}

.invoice-summary {
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.invoice-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
}
.invoice-summary-label { color: var(--text-secondary); }
.invoice-summary-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.invoice-summary-total {
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 600;
}
.invoice-summary-total .invoice-summary-label { color: var(--text-primary); }

/* ── Line item repeater — responsive ──────────────────────────────────────── */

@media (max-width: 860px) {
  .line-item-main {
    grid-template-columns: 1fr 1fr;
  }
  .line-item-field-service { grid-column: 1 / -1; }
  .line-item-field-remove {
    grid-column: 2 / 3;
    justify-self: end;
    width: 40px;
  }
  .line-item-field-remove .line-item-remove { width: 40px; }
}

@media (max-width: 480px) {
  .line-item-main {
    grid-template-columns: 1fr;
  }
  .line-item-field-remove {
    grid-column: 1 / -1;
    justify-self: end;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   v4.12 UI OVERHAUL — additions below this line
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Nav: search trigger, quick-add, avatar ───────────────────────────────── */

.nav-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  width: 240px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.nav-search-trigger:hover {
  border-color: var(--accent-dim);
  color: var(--text-secondary);
}
.nav-search-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.nav-search-trigger svg { flex-shrink: 0; }
.nav-search-placeholder {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-search-kbd, .modal-search-kbd, kbd {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
}

.nav-user-trigger {
  width: 34px;
  height: 34px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.nav-user-trigger:hover { border-color: var(--accent-dim); background: var(--bg-hover); }
.nav-avatar {
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (max-width: 860px) {
  .nav-search-trigger { width: 44px; padding: 0.4rem; justify-content: center; }
  .nav-search-placeholder, .nav-search-kbd { display: none; }
}
@media (max-width: 768px) {
  /* Use .nav-inner prefix to beat the base .nav-hamburger { display:none }
     rule that's defined later in the v4.24 section — same specificity,
     later declaration would otherwise always win. */
  .nav-inner .nav-hamburger { display: flex; margin-right: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0.125rem;
    background: var(--bg-surface);
    border-bottom: 2px solid var(--border-strong);
    padding: 0.5rem;
    z-index: 99;
    box-shadow: 0 8px 24px #00000066;
  }
  .nav-links.nav-mobile-open { display: flex; }
  .nav-link {
    padding: 0.7rem 0.875rem;
    font-size: 0.9rem;
    border-radius: var(--radius);
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .nav-link-active { border-bottom: none; background: var(--accent-dim); }
}

/* ── Dropdowns ────────────────────────────────────────────────────────────── */

.dropdown { position: relative; display: inline-block; }

.dropdown-toggle[aria-expanded="true"] {
  background: var(--bg-hover);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px #00000059;
  padding: 0.4rem;
  z-index: 200;
  display: none;
  animation: dropdownIn 0.12s ease-out;
}
.dropdown-menu-right { left: auto; right: 0; }
.dropdown[data-open="true"] .dropdown-menu { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-primary);
  text-decoration: none;
  text-align: left;
  font-family: var(--font);
  font-size: 0.875rem;
  cursor: pointer;
}
.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.dropdown-item-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 0.7rem;
  flex-shrink: 0;
}
.dropdown-item-title { font-weight: 500; }
.dropdown-item-sub { font-size: 0.78rem; color: var(--text-muted); }

.dropdown-header { padding: 0.55rem 0.65rem; }
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.15rem;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal (search + confirm) ─────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #0000008c;
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem 1rem;
  z-index: 500;
  animation: modalFadeIn 0.15s ease-out;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 50px #00000080;
  animation: modalSlideIn 0.15s ease-out;
}

.modal-search { padding: 0; overflow: hidden; }

.modal-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.modal-search-input-wrap svg { flex-shrink: 0; }
.modal-search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0;
  outline: none;
}
.modal-search-input-wrap input:focus { box-shadow: none; }

.modal-search-results {
  max-height: 56vh;
  overflow-y: auto;
  padding: 0.4rem;
}

.modal-search-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.modal-search-group {
  padding: 0.5rem 0.6rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
}
.modal-search-item:hover,
.modal-search-item.is-active {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.modal-search-item-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Phase C.2 — palette action items: tinted left edge so actions visually pop
   above plain search results. */
.modal-search-item--action {
  border-left: 3px solid var(--accent);
  padding-left: calc(0.65rem - 3px);
}
.modal-search-item--action span:first-child {
  font-weight: 500;
}

.modal-confirm {
  padding: 1.25rem 1.5rem 1rem;
  max-width: 420px;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}
.modal-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Row overflow (⋯) menu ────────────────────────────────────────────────── */

.row-menu {
  position: relative;
  display: inline-block;
}
.row-menu-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.row-menu-toggle:hover,
.row-menu-toggle[aria-expanded="true"] {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.row-menu-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px #00000059;
  padding: 0.3rem;
  z-index: 50;
  display: none;
  animation: dropdownIn 0.12s ease-out;
}
.row-menu[data-open="true"] .row-menu-menu { display: block; }

.row-menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.84rem;
  text-align: left;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
}
.row-menu-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}
.row-menu-item-danger { color: var(--red); }
.row-menu-item-danger:hover { background: var(--red-dim); }

/* ── Clickable stat cards ─────────────────────────────────────────────────── */

a.stat-card,
button.stat-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
a.stat-card:hover,
button.stat-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-surface);
  transform: translateY(-1px);
  text-decoration: none;
}
.stat-card-arrow {
  float: right;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
  transition: transform 0.15s, color 0.15s;
}
a.stat-card:hover .stat-card-arrow,
button.stat-card:hover .stat-card-arrow {
  color: var(--accent);
  transform: translateX(2px);
}
/* Static (non-clickable) stat card — informational only */
.stat-card-static {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: default;
  opacity: 0.85;
}
.stat-card-static .stat-label {
  color: var(--text-muted);
}

/* ── Aging buckets ────────────────────────────────────────────────────────── */

.aging-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 1rem 1.25rem 1.25rem;
}
.aging-bucket {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
}
.aging-bucket-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.aging-bucket-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.aging-bucket-0-30     { border-color: var(--green); background: var(--green-dim); }
.aging-bucket-0-30 .aging-bucket-value    { color: var(--green); }
.aging-bucket-31-60    { border-color: var(--amber); background: var(--amber-dim); }
.aging-bucket-31-60 .aging-bucket-value   { color: var(--amber); }
/* Aging-bucket 61-90 uses the dedicated orange token to keep it visually
   distinct from 31-60 (amber) and 90+ (red) — see --orange / --orange-dim
   in tokens.css. */
.aging-bucket-61-90    { border-color: var(--orange); background: var(--orange-dim); }
.aging-bucket-61-90 .aging-bucket-value   { color: var(--orange); }
.aging-bucket-over-90  {
  border-color: var(--red);
  background: var(--red-dim);
  box-shadow: 0 0 0 1px var(--red), 0 2px 8px var(--state-danger-border);
}
.aging-bucket-over-90 .aging-bucket-label { color: var(--red); }
.aging-bucket-over-90 .aging-bucket-value { color: var(--red); font-size: 1.1rem; }

@media (max-width: 640px) {
  .aging-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Footnote under aging grid — shows parked (on-hold) money so it's visible
   without being counted as aging receivables. */
.aging-footnote {
  padding: 0 1.25rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-top: 1px dashed var(--border);
  padding-top: 0.85rem;
  margin: 0 1.25rem;
}

/* Active Projects table — muted styling for rows that are on_hold so they're
   visible without shouting. Subtle left border hints that the row is special. */
.row-on-hold {
  opacity: 0.75;
  border-left: 2px solid var(--amber);
}
.row-on-hold td:first-child {
  padding-left: calc(1rem - 2px);
}

/* ── Dashboard snapshot row — Receivables + Pipeline Health side-by-side ─── */

.dashboard-snapshot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
/* If only one card is present, it takes the full row width so it doesn't
   float awkwardly in the left column with an empty right half. */
.dashboard-snapshot > .card:only-child {
  grid-column: 1 / -1;
}
@media (max-width: 960px) {
  .dashboard-snapshot { grid-template-columns: 1fr; }
}

/* ── Pipeline Health tiles ────────────────────────────────────────────────── */

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 1rem 1.25rem 1.25rem;
}
.health-tile {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.85rem;
  text-align: center;
  transition: transform 0.15s;
}
.health-tile-value {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.health-tile-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Active (count > 0) colors — colored tile grabs attention when it matters */
.health-tile-overdue {
  border-color: var(--red);
  background: var(--red-dim);
  box-shadow: 0 0 0 1px var(--red), 0 2px 10px var(--state-danger-border);
}
.health-tile-overdue .health-tile-value { color: var(--red); }
.health-tile-overdue .health-tile-label { color: var(--red); }

.health-tile-at_risk  { border-color: var(--amber); background: var(--amber-dim); }
.health-tile-at_risk .health-tile-value  { color: var(--amber); }

.health-tile-on_track { border-color: var(--green); background: var(--green-dim); }
.health-tile-on_track .health-tile-value { color: var(--green); }

.health-tile-on_hold  { border-color: var(--border); }
.health-tile-on_hold .health-tile-value  { color: var(--text-secondary); }

/* Zero-count tiles fade into the background — no false alarms */
.health-tile.is-zero {
  background: var(--bg-raised);
  border-color: var(--border);
  box-shadow: none;
  opacity: 0.45;
}
.health-tile.is-zero .health-tile-value,
.health-tile.is-zero .health-tile-label {
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .health-grid { grid-template-columns: repeat(2, 1fr); }
  .health-tile-value { font-size: 1.75rem; }
}

/* ── Activity feed ────────────────────────────────────────────────────────── */

.activity-feed {
  padding: 0.5rem 0;
}
.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
}
.activity-row:hover {
  background: var(--bg-hover);
  text-decoration: none;
  color: var(--text-primary);
}
.activity-row:last-child { border-bottom: none; }

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.activity-icon-payment     { background: var(--green-dim); color: var(--green); }
.activity-icon-refund      { background: var(--red-dim); color: var(--red); }
.activity-icon-interaction { background: var(--blue-dim); color: var(--state-info-text); }

.activity-body { flex: 1; min-width: 0; }
.activity-title {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-when {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Upcoming list (dashboard) ────────────────────────────────────────────── */

.upcoming-list {
  list-style: none;
  padding: 0.25rem 1.25rem 1rem;
}
.upcoming-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-when {
  font-weight: 600;
  color: var(--amber);
  font-size: 0.82rem;
  min-width: 6rem;
}

/* ── Client avatar (detail + list) ────────────────────────────────────────── */

.client-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--accent-dim);
  border: 1px solid var(--accent-dim);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.client-avatar-web     { background: var(--accent-dim); color: var(--state-danger-text); }
.client-avatar-studios { background: var(--blue-dim);   color: var(--state-info-text); }
.client-avatar-both    { background: var(--purple-dim); color: var(--text-purple); }

.client-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}
.client-header .client-avatar { width: 56px; height: 56px; font-size: 1.15rem; }

/* ── Balance progress bar (project view) ──────────────────────────────────── */

.balance-progress {
  padding: 0.875rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.balance-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}
.balance-progress-head strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.balance-progress-bar {
  background: var(--bg-raised);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.balance-progress-fill {
  background: linear-gradient(90deg, var(--green), var(--state-ok-text));
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease-out;
}
.balance-progress-fill.is-overdue { background: linear-gradient(90deg, var(--red), var(--state-danger-text)); }
.balance-progress-fill.is-at-risk { background: linear-gradient(90deg, var(--amber), var(--state-warn-text)); }

/* ── Risk banner (project view) ───────────────────────────────────────────── */

.risk-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid;
}
.risk-banner-overdue {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--state-danger-text);
}
.risk-banner-at_risk {
  background: var(--amber-dim);
  border-color: var(--amber);
  color: var(--state-warn-text);
}
.risk-banner-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff14;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Clickable phase stepper ─────────────────────────────────────────────── */

.phase-step-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font);
  color: inherit;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.phase-step-btn:hover .phase-dot {
  border-color: var(--step-color, var(--accent));
  background: var(--step-dim, var(--accent-dim));
}
.phase-step-btn:hover .phase-label { color: var(--text-primary); }
.phase-stepper-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 1.25rem 0.75rem;
  font-style: italic;
}
.stepper-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.85rem 1.25rem 0;
}
.stepper-section-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 1.25rem;
}

/* Rainbow color per step position — status stepper (ROYGBIV). Values live in tokens.css. */
form.phase-stepper button:nth-of-type(1) { --step-color: var(--step-c1); --step-dim: var(--step-c1-dim); }
form.phase-stepper button:nth-of-type(2) { --step-color: var(--step-c2); --step-dim: var(--step-c2-dim); }
form.phase-stepper button:nth-of-type(3) { --step-color: var(--step-c3); --step-dim: var(--step-c3-dim); }
form.phase-stepper button:nth-of-type(4) { --step-color: var(--step-c4); --step-dim: var(--step-c4-dim); }
form.phase-stepper button:nth-of-type(5) { --step-color: var(--step-c5); --step-dim: var(--step-c5-dim); }
form.phase-stepper button:nth-of-type(6) { --step-color: var(--step-c6); --step-dim: var(--step-c6-dim); }
form.phase-stepper button:nth-of-type(7) { --step-color: var(--step-c7); --step-dim: var(--step-c7-dim); }

/* Phase stepper: pink-first rainbow (discovery=pink, then ROYGBV). Values live in tokens.css. */
form.steps-phase button:nth-of-type(1) { --step-color: var(--step-cp); --step-dim: var(--step-cp-dim); }
form.steps-phase button:nth-of-type(2) { --step-color: var(--step-c1); --step-dim: var(--step-c1-dim); }
form.steps-phase button:nth-of-type(3) { --step-color: var(--step-c2); --step-dim: var(--step-c2-dim); }
form.steps-phase button:nth-of-type(4) { --step-color: var(--step-c3); --step-dim: var(--step-c3-dim); }
form.steps-phase button:nth-of-type(5) { --step-color: var(--step-c4); --step-dim: var(--step-c4-dim); }
form.steps-phase button:nth-of-type(6) { --step-color: var(--step-c5); --step-dim: var(--step-c5-dim); }
form.steps-phase button:nth-of-type(7) { --step-color: var(--step-c7); --step-dim: var(--step-c7-dim); }

/* Status stepper: exception states wrap below the main progression */
form.steps-status { flex-wrap: wrap; }
.stepper-exception-marker {
  flex-basis: 100%;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem 1.25rem 0.15rem;
  font-style: italic;
}
.status-exception::before { display: none; }
.status-exception .phase-dot { border-style: dashed; }

/* ── Dashboard Donut Charts ──────────────────────────────────────────────── */

.donut-grid {
  display: grid;
  /* Three columns as of v4.48 (added Clients by Brand). Collapses below
     1100px via the media query further down. */
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.donut-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.donut-card-header {
  padding: 1rem 1.25rem 0;
}
.donut-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.donut-canvas-wrap {
  padding: 1.25rem;
  display: flex;
  justify-content: center;
  filter: drop-shadow(0 6px 18px #00000080);
  transform: perspective(500px) rotateX(8deg);
  transform-origin: center bottom;
}
.donut-canvas-wrap canvas {
  max-width: 220px;
  max-height: 220px;
}
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0 1.25rem 1.25rem;
  justify-content: center;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
@media (max-width: 1100px) {
  .donut-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .donut-grid { grid-template-columns: 1fr; }
}

/* ── Activity Timeline Table ─────────────────────────────────────────────── */

.activity-filters {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.event-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: 0.35rem;
}
.event-dot-payment     { background: var(--state-ok);     border-radius: 2px; }
.event-dot-refund      { background: var(--state-danger); border-radius: 2px; }
.event-dot-interaction { background: var(--state-info);   border-radius: 50%; }
.event-dot-service {
  width: 0;
  height: 0;
  background: transparent;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--state-warn);
  border-radius: 0;
  vertical-align: middle;
}

.phase-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem 0;
  flex-wrap: wrap;
}
.phase-status-row-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Sortable table headers ──────────────────────────────────────────────── */

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}
th.sortable::after {
  content: '↕';
  color: var(--text-muted);
  margin-left: 0.35rem;
  opacity: 0.5;
  font-size: 0.75rem;
}
th.sortable:hover::after { opacity: 1; }
th.sortable[data-sort-dir="asc"]::after  { content: '↑'; color: var(--accent); opacity: 1; }
th.sortable[data-sort-dir="desc"]::after { content: '↓'; color: var(--accent); opacity: 1; }

/* ── Empty state polish ──────────────────────────────────────────────────── */

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.25rem;
}
.empty-state-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.empty-state-sub {
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ── Alert close button ─────────────────────────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: fadeInDown 0.25s ease-out;
}
.alert > span { flex: 1; }
.alert-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
}
.alert-close:hover { opacity: 1; background: #ffffff14; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Recent-contact mark ─────────────────────────────────────────────────── */

.time-ago {
  color: var(--text-secondary);
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}

/* ── Archived client banner ─────────────────────────────────────────────── */

.archived-banner {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 0.55rem 0.875rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.84rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Filter bar extras ──────────────────────────────────────────────────── */

.filter-bar .balance-filter { min-width: 160px; }
.filter-bar label {
  margin-bottom: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.filter-bar .search-input {
  padding: 0.5rem 0.75rem;
}

/* ── Responsive: projects table on client view ──────────────────────────── */

@media (max-width: 860px) {
  .client-projects-table thead { display: none; }
  .client-projects-table,
  .client-projects-table tbody,
  .client-projects-table tr,
  .client-projects-table td {
    display: block;
    width: 100%;
  }
  .client-projects-table tr {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .client-projects-table tr:last-child { border-bottom: none; }
  .client-projects-table tr:hover td { background: transparent; }
  .client-projects-table td {
    padding: 0.2rem 0;
    border: none;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0.5rem;
    font-size: 0.85rem;
  }
  .client-projects-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    align-self: center;
  }
  .client-projects-table .action-cell { justify-content: flex-end; padding-top: 0.4rem; }
  .client-projects-table tfoot { display: none; }
}

/* ── Page fade-in ───────────────────────────────────────────────────────── */

.main-content { animation: pageFadeIn 0.2s ease-out; }
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   v4.24 MOBILE POLISH
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Mobile nav hamburger (hidden on desktop) ─────────────────────────────── */

.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.nav-hamburger:hover { background: var(--bg-raised); }
.nav-hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
}
.nav-hamburger[aria-expanded="true"] span { background: var(--text-primary); }

/* ── Clients list: responsive card layout at ≤640px ──────────────────────── */

@media (max-width: 640px) {
  .clients-table thead { display: none; }
  .clients-table,
  .clients-table tbody,
  .clients-table tr { display: block; width: 100%; }
  .clients-table tr {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .clients-table tr:last-child { border-bottom: none; }
  .clients-table tr:hover td { background: transparent; }
  .clients-table td[data-label] {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.4rem;
    align-items: start;
    padding: 0.2rem 0;
    border: none;
    font-size: 0.875rem;
  }
  .clients-table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding-top: 0.15rem;
  }
  .clients-table td.action-cell {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0 0.15rem;
    border-top: 1px solid var(--border);
    margin-top: 0.35rem;
  }
}

/* ── Activity / unified event table: stacked at ≤640px ───────────────────── */

@media (max-width: 640px) {
  .activity-table thead { display: none; }
  .activity-table,
  .activity-table tbody,
  .activity-table tr { display: block; width: 100%; }
  .activity-table tr {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .activity-table tr:last-child { border-bottom: none; }
  .activity-table tr:hover td { background: transparent; }
  .activity-table td {
    display: block;
    padding: 0.15rem 0;
    border: none;
    font-size: 0.875rem;
    white-space: normal !important;
  }
  .activity-table td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.15rem;
  }
  .activity-table td.action-cell {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
  }
  /* Totals row: collapse colspan cell, show summary full-width */
  .activity-table .totals-row { background: var(--bg-raised); }
  .activity-table .totals-row td[colspan] { display: none; }
}

/* ── Line item summary: actions always visible on touch ─────────────────── */

@media (max-width: 860px) {
  .line-item-summary-actions { opacity: 1; }
}

/* ── Touch targets and phone polish ──────────────────────────────────────── */

@media (max-width: 640px) {
  /* Minimum tap targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; padding: 0.35rem 0.7rem; }
  .row-menu-toggle { width: 36px; height: 36px; }

  /* Tighten form padding on phone */
  .form-card { padding: 1rem; }

  /* Wrapping helpers */
  .page-actions { flex-wrap: wrap; }
  .card-header  { flex-wrap: wrap; gap: 0.5rem; }
  .card-header .brand-tabs { flex-wrap: wrap; }

  /* Filter inputs — taller tap area */
  .filter-bar select,
  .filter-bar input[type="text"] { min-height: 40px; }

  /* Leads filter tabs: wrap status tabs, drop source group to its own row */
  .leads-filter-tabs { flex-wrap: wrap; gap: 0.3rem; }
  .leads-source-group {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    margin-top: 0.15rem;
  }
}


/* ── Very small phones (≤400px): trim nav-tools further ──────────────────── */

@media (max-width: 400px) {
  .nav-search-trigger { display: none; }
  .main-content { padding: 1rem 0.75rem; }
}

/* =============================================================================
 * SHARED UTILITIES — strip-inline-style cleanup (project v4.49)
 *
 * Every rule below replaces a specific inline style="" pattern that was in use
 * across CRM pages. Names follow a loose BEM modifier convention:
 *   .thing--modifier   one-off variant of an existing block
 *   .thing             standalone utility block
 *
 * Keep these near the bottom of the file so component-level rules still win
 * on specificity ties.
 * ============================================================================= */

/* --- Text + spacing utilities ---------------------------------------------- */
.text-muted      { color: var(--text-muted); }
.text-muted-sm   { color: var(--text-muted); font-size: 0.8rem; }
.text-secondary  { color: var(--text-secondary); }
.help-text       { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.field-help      { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.lead-text       { color: var(--text-secondary); margin-bottom: 1rem; }
.empty-dash      { color: var(--text-muted); }
.cell-meta       { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.cell-subtext    { font-size: 0.8rem; color: var(--text-muted); }
.section-heading-sm { font-size: 0.95rem; margin-bottom: 0.5rem; }

.is-hidden       { display: none !important; }

/* --- Card modifiers -------------------------------------------------------- */
.card--narrow    { max-width: 720px; }
.card--stack     { margin-bottom: 1.5rem; }
.card--stack-sm  { margin-bottom: 1rem; }
.card--warning   { border-color: var(--amber); margin-bottom: 1.5rem; }
.card-title--warning { color: var(--amber); }
.card__body      { padding: 1.25rem; }

/* --- Form modifiers -------------------------------------------------------- */
.form--inline           { margin: 0; }
.form--inline-block     { display: inline-block; margin: 0; }
.form--spaced           { margin-top: 1.25rem; }
.form--inline-row       { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.form-group--compact    { margin-bottom: 0.5rem; }
.form-group--tight      { margin-bottom: 0.5rem; }
.form-group--snug       { margin-bottom: 0.75rem; }
.form-group--flush      { margin: 0; }
.form-group--narrow     { max-width: 200px; }

/* Label wrapping a radio/checkbox that needs to be on its own line */
.label-block            { display: block; }

/* Inputs with distinct use cases --------------------------------------------- */
.input--otp {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: 0.4em;
    font-size: 1.15rem;
    text-align: center;
}
.input--token {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: 0.15em;
    min-width: 220px;
}
.input--mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.85rem;
}
.textarea--mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}
.textarea--notes {
    min-height: 120px;
    resize: vertical;
}

/* --- Button rows ----------------------------------------------------------- */
.btn-row         { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.action-row      { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.btn--block      { width: 100%; justify-content: center; }
.btn--spaced     { margin-top: 0.4rem; }

/* --- Column width helpers (for tables) ------------------------------------- */
.col-num         { text-align: right; }
.col-date        { width: 110px; white-space: nowrap; }
.col-actions     { width: 40px; }
.col-source      { width: 140px; }
.col-status      { width: 110px; }
.num-cell        { text-align: right; }
.event-date-cell { white-space: nowrap; color: var(--text-muted); font-size: 0.85rem; }
.event-type-cell { white-space: nowrap; }
.event-meta      { color: var(--text-muted); font-size: 0.8rem; }

/* --- Detail labels & items ------------------------------------------------- */
.detail-label--tight  { margin-bottom: 0.35rem; }
.detail-label--nudged { margin-top: 0.8rem; margin-bottom: 0.35rem; }
.detail-label__meta {
    color: var(--text-muted);
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.7rem;
}
.detail-item--full    { grid-column: 1 / -1; }

/* --- Code / monospace display ---------------------------------------------- */
.code-block {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: 0.05em;
    word-break: break-all;
}
.code-block--wide {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0;
}
.hash-display {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    word-break: break-all;
}

/* --- Divider (replaces inline-styled <hr>) --------------------------------- */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* --- Alerts + inline variants ---------------------------------------------- */
.alert--spaced { margin-bottom: 1.25rem; }
.alert--split  { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.alert-inline-error {
    padding: 1rem;
    color: var(--state-danger-text);
    background: var(--state-danger-bg);
    border-radius: 6px;
    max-width: 220px;
    font-size: 0.8rem;
}
.empty-message { color: var(--text-muted); font-style: italic; }

/* --- Brand tab + filter bar bits ------------------------------------------- */
.brand-tab__count {
    margin-left: 0.3rem;
    opacity: 0.65;
    font-size: 0.8rem;
}
.brand-tab--compact {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
}

/* --- Leads page filter bar (status tabs + source toggle on one row) -------- */
.leads-filter-tabs { margin-bottom: 1rem; }
.leads-source-group {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.leads-source-label { color: var(--text-muted); font-size: 0.85rem; }

/* --- Name + subtitle stack in a table cell --------------------------------- */
.table-link-bold { font-weight: 600; }
.cell-email      { font-size: 0.9rem; }
.cell-details    { font-size: 0.85rem; color: var(--text-muted); max-width: 260px; }
.cell-details-lead  { margin-bottom: 0.2rem; }
.cell-details-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Notes textarea block in a card body ----------------------------------- */
.notes-form-body    { padding: 1rem 1.25rem; }
.notes-form-actions { padding: 0 1.25rem 1.25rem; }
.notes-textarea     { width: 100%; resize: vertical; }

/* --- Message block (lead view) --------------------------------------------- */
.notes-block--spaced { margin-top: 1rem; }

/* --- Alert split row (install-library nudge) ------------------------------- */
.alert-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* --- Signing link sidebar tweaks ------------------------------------------- */
.lead-meta-caption { color: var(--text-muted); margin-top: 0; }
.lead-meta-hint    { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0; }
.event-log-actor   { color: var(--text-muted); }
.event-log-empty   { color: var(--text-muted); }

/* --- "(optional)" hint next to a label ------------------------------------- */
.label-optional { color: var(--text-muted); font-weight: normal; }

/* --- Card-title subnote (e.g., legacy-view parenthetical) ------------------ */
.card-title__hint { color: var(--text-muted); font-size: 0.8rem; font-weight: 400; }

/* --- Invoice summary inline "(per yr)" style hint -------------------------- */
.summary-hint     { color: var(--text-muted); font-size: 0.8rem; }

/* --- Table col-align right helpers in a <th> or <td> ----------------------- */
.col-num-right    { text-align: right; }

/* --- Button row helpers ---------------------------------------------------- */
.btn-group-wrap   { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* --- Inline badge next to a heading ---------------------------------------- */
.badge--inline { margin-left: 0.5rem; }

/* --- 2FA / security-page specifics ----------------------------------------- */
.twofa-setup-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
    margin: 1rem 0;
}
@media (max-width: 640px) {
    .twofa-setup-grid { grid-template-columns: 1fr; }
}
.qr-frame {
    /* Always white — the QR bitmap itself is white-on-black so the
       background must stay white in dark mode for scan reliability. */
    background: #ffffff;
    padding: 0.75rem;
    border-radius: var(--radius);
    display: inline-block;
}
.recovery-codes {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.25rem;
}
.recovery-codes__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.95rem;
}
.recovery-codes__code {
    padding: 0.3rem 0.5rem;
    background: var(--bg-surface);
    border-radius: 4px;
    letter-spacing: 0.05em;
}

/* ── Auth-log page utilities ─────────────────────────────────────────────── */
.card-header--flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-select {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
}
.filter-select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Failure/block rows get a subtle left accent so they pop at a glance */
.row--warn td:first-child {
    border-left: 3px solid var(--state-danger);
}
.cell-nowrap {
    white-space: nowrap;
}
.cell-mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.875rem;
}
.cell-ua {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ── Billing panel ────────────────────────────────────────────────────────── */

.billing-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}
.billing-status-draft     { background: var(--bg-raised);  color: var(--text-secondary); border-color: var(--border); }
.billing-status-sent      { background: var(--blue-dim); color: var(--state-info-text); border-color: var(--state-info-border); }
.billing-status-viewed    { background: var(--purple-dim);color: var(--text-purple); border-color: var(--purple-border); }
.billing-status-partial   { background: var(--amber-dim); color: var(--state-warn-text); border-color: var(--state-warn-border); }
.billing-status-paid      { background: var(--green-dim); color: var(--state-ok-text); border-color: var(--state-ok-border); }
.billing-status-overdue   { background: var(--red-dim);   color: var(--state-danger-text); border-color: var(--state-danger-border); }
.billing-status-void      { background: var(--gray-dim);color: var(--text-muted); border-color: var(--border); }
.billing-status-recurring { background: var(--purple-dim);color: var(--text-purple); border-color: var(--purple-border); }
.billing-status-cancelled { background: var(--gray-dim);color: var(--text-muted); border-color: var(--border); }
.billing-status-settled   { background: var(--green-dim);  color: var(--state-ok-text); border-color: var(--state-ok-border); }
.billing-status-pending   { background: var(--amber-dim);  color: var(--state-warn-text); border-color: var(--state-warn-border); }
.billing-status-failed    { background: var(--red-dim);    color: var(--state-danger-text); border-color: var(--state-danger-border); }
.billing-status-refunded  { background: var(--gray-dim); color: var(--text-muted); border-color: var(--border); }

.billing-panel {
    padding: 1rem 1.25rem 1.25rem;
}
.billing-panel--unsynced {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.billing-panel--unsynced .billing-panel-desc {
    flex: 1;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.billing-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
}
.billing-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.billing-detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.billing-detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
}
.billing-id-mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.billing-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .billing-panel--unsynced {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Time tracking ────────────────────────────────────────────────────────── */

.timer-running-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1.25rem;
    background: var(--state-ok-bg);
    border-bottom: 1px solid var(--state-ok-border);
    font-size: 0.875rem;
    flex-wrap: wrap;
}
.timer-running-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--state-ok);
    flex-shrink: 0;
    animation: timer-pulse 1.4s ease-in-out infinite;
}
@keyframes timer-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.8); }
}

.timer-start-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.timer-desc-input {
    flex: 1;
    min-width: 180px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}
.timer-desc-input:focus {
    outline: none;
    border-color: var(--accent);
}

.row-billed td {
    opacity: 0.5;
}

/* ── Settings Pages ─────────────────────────────────────────────────────────── */

/* card-body: padding alias matching card__body */
.card-body { padding: 1.25rem; }

/* settings hub — 2-column grid of link cards */
.card-grid        { display: grid; gap: 1rem; }
.card-grid--2col  { grid-template-columns: repeat(2, 1fr); }

.card--link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.card--link:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px #0000004d;
}
.card--link .card-title { color: var(--text-primary); font-size: 1rem; font-weight: 600; }
.card--link:hover .card-title { color: var(--accent); }

.card-text { color: var(--text-secondary); font-size: .875rem; margin-top: .35rem; }
.card-meta { color: var(--text-muted); font-size: .75rem; margin-top: .6rem; }

/* tab bar */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-link {
  padding: .6rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-link:hover { color: var(--text-primary); }
.tab-link--active { color: var(--accent); border-bottom-color: var(--accent); }

/* named-class aliases for existing element-selector form styles */
.form-label {
  display: block;
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: .35rem;
  font-weight: 500;
}
.form-control,
.form-input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .875rem;
  padding: .55rem .75rem;
  transition: border-color .15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus,
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .35rem; }

/* 2-col auto-fill form grid */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.form-group--full { grid-column: 1 / -1; }

/* checkbox with inline label */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-primary);
}
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* color picker row */
.color-picker-wrap { display: flex; align-items: center; gap: .5rem; }
input[type="color"] {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
.color-swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.form-control--hex { font-family: monospace; max-width: 7.5rem; }

/* one-click preset buttons */
.preset-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.preset-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: .5rem .65rem;
  transition: border-color .15s, background .15s;
}
.preset-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.preset-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  box-shadow: 0 1px 4px #00000073;
  flex-shrink: 0;
}
.preset-name {
  font-size: .65rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 4.5rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-meta { font-size: .6rem; color: var(--text-muted); opacity: .7; text-align: center; }

/* color picker grid */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }

/* border-radius slider row */
.radius-wrap { display: flex; align-items: center; gap: .75rem; }
.radius-wrap input[type="range"] { flex: 1; accent-color: var(--accent); }
.radius-preview {
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  flex-shrink: 0;
  transition: border-radius .1s;
}
.radius-val { min-width: 2.5rem; text-align: right; font-size: .85rem; color: var(--text-secondary); }

/* font preview box */
.font-preview-wrap {
  margin-top: .5rem;
  padding: .6rem .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--text-secondary);
}

/* mini PDF preview (legacy / fallback) */
.pdf-preview {
  margin-top: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .7rem;
}
.pdf-preview-header {
  padding: .4rem .65rem;
  font-weight: 700;
  font-size: .75rem;
  transition: background .2s, color .2s;
}
.pdf-preview-body { padding: .5rem .65rem; background: var(--pdf-page-bg); color: var(--pdf-page-text); }
.pdf-preview-row {
  display: flex;
  justify-content: space-between;
  padding: .15rem 0;
  border-bottom: 1px solid var(--pdf-row-border);
}
.pdf-preview-total {
  display: flex;
  justify-content: space-between;
  padding: .25rem 0;
  font-weight: 700;
  border-top: 2px solid;
  margin-top: .25rem;
}

/* ── Live full PDF invoice preview ─────────────────────────────────────────── */
.pdf-preview-full {
  background: var(--pdf-canvas-bg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  font-size: 11px;
  font-family: var(--pdfv-font, Helvetica, Arial, sans-serif);
}
.pdfv-page {
  background: var(--pdf-page-bg);
  color: var(--pdf-page-text);
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: var(--pdfv-paper, 8.5/11);
  box-shadow: 0 4px 16px #00000059;
  display: flex;
  flex-direction: column;
}
.pdfv-header {
  background: var(--pdfv-accent);
  color: var(--pdfv-htext);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.pdfv-from .pdfv-co {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.pdfv-from .pdfv-co-meta {
  font-size: .75rem;
  opacity: .85;
  margin-top: .15rem;
}
.pdfv-doc {
  text-align: right;
}
.pdfv-doc-label {
  font-size: .7rem;
  letter-spacing: .15em;
  opacity: .85;
}
.pdfv-doc-num {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: .1rem;
}
.pdfv-body {
  padding: 1.25rem 1.5rem;
  flex: 1;
  color: var(--pdfv-body);
}
.pdfv-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.pdfv-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--pdfv-body);
  opacity: .55;
  margin-bottom: .25rem;
}
.pdfv-value {
  font-size: .8rem;
  line-height: 1.5;
  color: var(--pdfv-body);
}
.pdfv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: .8rem;
  color: var(--pdfv-body);
}
.pdfv-table th {
  text-align: left;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: .5rem .4rem;
  border-bottom: 1.5px solid var(--pdfv-border);
  font-weight: 700;
  color: var(--pdfv-body);
  /* Undo the global thead th rule that paints the cell --bg-surface (CRM dark
     navy) — the PDF preview lives on a white paper background, so the global
     rule turned the header row into dark text on dark navy = unreadable. */
  background: transparent;
}
.pdfv-table td {
  padding: .55rem .4rem;
  border-bottom: 1px solid var(--pdfv-border);
}
.pdfv-table .pdfv-num {
  text-align: right;
  white-space: nowrap;
}
.pdfv-totals {
  margin-left: auto;
  width: 240px;
  font-size: .8rem;
  color: var(--pdfv-body);
}
.pdfv-tot-row {
  display: flex;
  justify-content: space-between;
  padding: .35rem 0;
}
.pdfv-tot-row + .pdfv-tot-row { border-top: 1px solid var(--pdfv-border); }
.pdfv-tot-grand {
  border-top: 2px solid var(--pdfv-accent) !important;
  margin-top: .25rem;
  padding-top: .55rem;
  color: var(--pdfv-accent);
  font-weight: 700;
  font-size: .9rem;
}
.pdfv-notes {
  margin-top: 1.5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--pdfv-border);
}

/* ── Live portal preview ──────────────────────────────────────────────────── */
.portal-preview {
  --ppv-accent: #c0392b;
  --ppv-accent-text: #ffffff;
  --ppv-bg: #f4f5f7;
  --ppv-surface: #ffffff;
  --ppv-border: #e5e7eb;
  --ppv-text: #1a1a1a;
  --ppv-muted: #6b7280;
  --ppv-radius: 10px;
  --ppv-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --ppv-max: 900px;
  background: var(--ppv-bg);
  color: var(--ppv-text);
  font-family: var(--ppv-font);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.portal-preview .ppv-bar {
  background: var(--ppv-surface);
  border-bottom: 1px solid var(--ppv-border);
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.portal-preview .ppv-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.portal-preview .ppv-mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--ppv-radius);
  background: var(--ppv-accent);
  color: var(--ppv-accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
}
.portal-preview .ppv-co {
  font-weight: 700;
  font-size: .95rem;
  color: var(--ppv-text);
}
.portal-preview .ppv-tagline {
  font-size: .7rem;
  color: var(--ppv-muted);
}
.portal-preview .ppv-btn-ghost {
  background: transparent;
  border: 1px solid var(--ppv-border);
  color: var(--ppv-text);
  padding: .35rem .7rem;
  border-radius: var(--ppv-radius);
  font-size: .8rem;
  cursor: default;
}
.portal-preview .ppv-page {
  padding: 1.5rem 1.25rem;
}
.portal-preview .ppv-inner {
  max-width: var(--ppv-max);
  margin: 0 auto;
}
.portal-preview .ppv-h {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 .25rem 0;
  color: var(--ppv-text);
}
.portal-preview .ppv-sub {
  color: var(--ppv-muted);
  margin: 0 0 1.25rem 0;
  font-size: .85rem;
}
.portal-preview .ppv-card {
  background: var(--ppv-surface);
  border: 1px solid var(--ppv-border);
  border-radius: var(--ppv-radius);
  margin-bottom: .85rem;
  overflow: hidden;
}
.portal-preview .ppv-card-h {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--ppv-border);
  font-weight: 600;
  font-size: .85rem;
  color: var(--ppv-text);
}
.portal-preview .ppv-card-b {
  padding: .25rem 1rem;
}
.portal-preview .ppv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem 0;
  border-bottom: 1px solid var(--ppv-border);
  gap: 1rem;
}
.portal-preview .ppv-row.ppv-row-last { border-bottom: none; }
.portal-preview .ppv-row-title {
  font-weight: 500;
  color: var(--ppv-text);
  font-size: .85rem;
}
.portal-preview .ppv-row-sub {
  font-size: .72rem;
  color: var(--ppv-muted);
  margin-top: .1rem;
}
.portal-preview .ppv-btn {
  background: var(--ppv-accent);
  color: var(--ppv-accent-text);
  text-decoration: none;
  padding: .35rem .8rem;
  border-radius: var(--ppv-radius);
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}
.portal-preview .ppv-badge {
  background: var(--ppv-bg);
  color: var(--ppv-muted);
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 600;
  border: 1px solid var(--ppv-border);
  white-space: nowrap;
}
.portal-preview .ppv-badge-accent {
  background: var(--ppv-accent);
  color: var(--ppv-accent-text);
  border-color: var(--ppv-accent);
}
.portal-preview .ppv-foot {
  text-align: center;
  color: var(--ppv-muted);
  font-size: .72rem;
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--ppv-border);
}

} /* end @layer base */

@layer utilities {

/* ============================================================
   UTILITY CLASSES — do not add inline styles; use these
   ============================================================ */

/* --- Display --- */
.u-dn       { display: none }
.u-inline   { display: inline }
.u-contents { display: contents }
.u-flex     { display: flex }
.u-iflex    { display: inline-flex }
.u-grid     { display: grid }

/* --- Flex helpers --- */
.u-ai-center  { align-items: center }
.u-ai-start   { align-items: flex-start }
.u-jc-between { justify-content: space-between }
.u-flex-wrap  { flex-wrap: wrap }
.u-gap-4      { gap: 4px }
.u-gap-xs     { gap: .25rem }
.u-gap-sm     { gap: .5rem }
.u-gap-md     { gap: 1rem }
.u-gap-lg     { gap: 2rem }

/* --- Text --- */
.u-text-right  { text-align: right }
.u-text-center { text-align: center }
.u-nowrap      { white-space: nowrap }
.u-word-break  { word-break: break-all }
.u-mono        { font-family: monospace }
.u-uppercase   { text-transform: uppercase }
.u-tracking-1  { letter-spacing: 1px }
.u-link-plain  { text-decoration: none; color: inherit }
.u-fw-600      { font-weight: 600 }
.u-fw-700      { font-weight: 700 }
.u-overflow-x  { overflow-x: auto }
.u-pre-wrap    { white-space: pre-wrap }
.u-cursor-pointer { cursor: pointer }

/* --- Font sizes --- */
.u-text-65  { font-size: .65rem }
.u-text-70  { font-size: .7rem }
.u-text-75  { font-size: .75rem }
.u-text-78  { font-size: .78rem }
.u-text-80  { font-size: .8rem }
.u-text-82  { font-size: .82rem }
.u-text-sm  { font-size: .875rem }
.u-text-85  { font-size: .85rem }
.u-text-10  { font-size: 10px }
.u-text-11  { font-size: 11px }
.u-text-12  { font-size: 12px }
.u-text-lg  { font-size: 1.5rem }

/* --- Colors --- */
.u-muted        { color: var(--text-muted) }
.u-dim          { color: var(--text-dim) }
.u-c-888        { color: #888 }
.u-c-aaa        { color: #aaa }
.u-c-6e6        { color: #6e6e73 }
.u-c-b45        { color: #b45309 }
.u-text-green   { color: var(--green) }
.u-text-success { color: var(--green) }
.u-text-danger  { color: var(--red) }
.u-text-border  { border-top: 1px solid var(--border) }

/* --- Margin top --- */
.u-mt-xs  { margin-top: .25rem }
.u-mt-sm  { margin-top: .5rem }
.u-mt-md  { margin-top: 1rem }
.u-mt-lg  { margin-top: 1.25rem }
.u-mt-xl  { margin-top: 1.5rem }
.u-mt-2xl { margin-top: 2rem }

/* --- Margin bottom --- */
.u-mb-xs  { margin-bottom: .25rem }
.u-mb-sm  { margin-bottom: .5rem }
.u-mb-sm2 { margin-bottom: .75rem }
.u-mb-md  { margin-bottom: 1rem }
.u-mb-lg  { margin-bottom: 1.25rem }
.u-mb-xl  { margin-bottom: 1.5rem }
.u-mb-2xl { margin-bottom: 2rem }

/* --- Margin all --- */
.u-m-0 { margin: 0 }

/* --- Margin left / right --- */
.u-ml-4    { margin-left: 4px }
.u-ml-35   { margin-left: .35rem }
.u-ml-auto { margin-left: auto }

/* --- Padding --- */
.u-p-0    { padding: 0 }
.u-p-card { padding: 1rem 1.25rem }
.u-pt-0   { padding-top: 0 }
.u-pt-sm  { padding-top: .75rem }
.u-pb-sm  { padding-bottom: .5rem }
.u-px-4   { padding-left: 4px; padding-right: 4px }

/* --- Sizing --- */
.u-w-auto  { width: auto }
.u-w-full  { width: 100% }
.u-w-50    { width: 50% }
.u-w-55    { width: 55% }
.u-w-15    { width: 15% }
.u-w-20    { width: 20% }
.u-mw-120  { max-width: 120px }
.u-mw-160  { max-width: 160px }
.u-mw-180  { max-width: 180px }
.u-mw-420  { max-width: 420px }
.u-mw-560  { max-width: 560px }
.u-mw-600  { max-width: 600px }

/* --- Table column widths (for <th>) --- */
.u-col-55  { width: 55px }
.u-col-60  { width: 60px }
.u-col-80  { width: 80px }
.u-col-100 { width: 100px }
.u-col-110 { width: 110px }
.u-col-120 { width: 120px }
.u-col-130 { width: 130px }
.u-col-140 { width: 140px }
.u-col-160 { width: 160px }
.u-col-200 { width: 200px }
.u-col-260 { width: 260px }

/* --- Grid helpers --- */
.u-grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem }
.u-span-full { grid-column: 1 / -1 }

/* form-grid override modifiers */
.form-grid--2col   { grid-template-columns: 1fr 1fr }
.form-grid--1-2    { grid-template-columns: 1fr 2fr }
.form-grid--alerts { grid-template-columns: 2fr 1fr 1fr 1fr }
.form-grid--3col   { grid-template-columns: 2fr 1fr 1fr }

/* --- Quote status badge variants --- */
.badge--approved { background: var(--green-dim); color: var(--state-ok-text);     border: 1px solid var(--state-ok-border) }
.badge--declined { background: var(--red-dim);   color: var(--state-danger-text); border: 1px solid var(--state-danger-border) }
.badge--sent     { background: var(--amber-dim); color: var(--state-warn-text);   border: 1px solid var(--state-warn-border) }
.badge--warning  { background: var(--callout-warn-bg); color: var(--callout-warn-text); border: 1px solid var(--callout-warn-border) }

/* --- Warning callout banner --- */
.callout--warning { background: var(--callout-warn-bg); color: var(--callout-warn-text); border: 1px solid var(--callout-warn-border) }

/* --- Forecast stat row / labels / values --- */
.forecast-stats       { display: flex; gap: 2rem; flex-wrap: wrap; padding: .25rem 0 }
.forecast-stat-label  { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted) }
.forecast-stat-val    { font-size: 1.5rem; font-weight: 700 }

/* --- Color swatch — background set via CSS custom property --swatch-bg --- */
.color-swatch-auto { background: var(--swatch-bg) }

/* --- Pending split-payment row in quote/invoice tables --- */
.total-row--pending { background: var(--pending-row-bg) }

/* --- Small date input in recurring invoice list --- */
.input-date-sm { font-size: .75rem; padding: 2px 6px; height: 28px }

/* --- Chart canvas container (fixed height for Chart.js aspect-ratio override) --- */
.chart-canvas-wrap { height: 180px; position: relative; }

/* --- Compact form control (inline status selects, etc.) --- */
.form-control--sm { font-size: .75rem; padding: 2px 6px; width: auto; }

/* --- Dark compact select (payment link on client view) --- */
.select-sm-dark {
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--select-dark-border);
  background: var(--select-dark-bg);
  color: var(--select-dark-text);
  margin-right: 4px;
}

/* --- Compact response-body preview in webhook delivery log --- */
.response-preview { font-size: .7rem; margin-top: .25rem; white-space: pre-wrap; overflow: auto; max-height: 120px }

/* --- Phase B.2 additions ---------------------------------------------- */
.u-c-muted     { color: var(--text-muted) }
.u-c-secondary { color: var(--text-secondary) }
.u-list-reset  { list-style: none; padding: 0; margin: 0 }

/* --- Phase G additions — project files + messages --------------------- */
.crm-messages {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.crm-msg { display: flex; }
.crm-msg--admin  { justify-content: flex-end; }
.crm-msg--client { justify-content: flex-start; }
.crm-msg-bubble {
  max-width: 75%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
}
.crm-msg--admin .crm-msg-bubble  { background: var(--surface-3); color: var(--text-primary); }
.crm-msg--client .crm-msg-bubble { background: var(--surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary); }
.crm-msg-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: flex;
  gap: 0.3rem;
}
.badge--info    { background: var(--state-info-bg); color: var(--state-info-text); border: 1px solid var(--state-info-border); }
.badge--neutral { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

} /* end @layer utilities */
