/* =============================================================================
   FlowDesk Design System — v1
   Style: Soft UI Evolution (professional SaaS admin)
   Themes: light + dark parity via body[data-theme="…"]
   Purpose: sits AFTER each template's inline <style> so tied selectors win.
   ============================================================================= */

/* ------ Fonts ------ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ------ Design tokens: LIGHT (default) ------ */
:root,
body,
body[data-theme="light"] {
  /* Brand */
  --ds-brand: #2563eb;
  --ds-brand-hover: #1d4ed8;
  --ds-brand-active: #1e40af;
  --ds-brand-soft: #eff4ff;
  --ds-brand-fg: #ffffff;
  --ds-accent: #059669;             /* money / positive */
  --ds-accent-soft: #ecfdf5;

  /* Surfaces */
  --ds-canvas: #f6f8fb;             /* page background */
  --ds-surface: #ffffff;            /* cards, panels */
  --ds-surface-2: #f1f5f9;          /* subdued panels */
  --ds-surface-3: #e9eef5;          /* hover / column bg */
  --ds-sidebar: #ffffff;
  --ds-sidebar-hover: #f1f5f9;
  --ds-sidebar-active: #eff4ff;
  --ds-topbar-bg: rgba(255, 255, 255, 0.85);

  /* Text */
  --ds-text: #0f172a;
  --ds-text-muted: #475569;
  --ds-text-subtle: #94a3b8;
  --ds-text-inverse: #ffffff;

  /* Borders */
  --ds-border: #e2e8f0;
  --ds-border-strong: #cbd5e1;
  --ds-divider: #eef1f6;

  /* Status */
  --ds-success: #059669;
  --ds-success-soft: #d1fae5;
  --ds-success-text: #065f46;
  --ds-warning: #d97706;
  --ds-warning-soft: #fef3c7;
  --ds-warning-text: #92400e;
  --ds-danger: #dc2626;
  --ds-danger-soft: #fee2e2;
  --ds-danger-text: #991b1b;
  --ds-info: #2563eb;
  --ds-info-soft: #dbeafe;
  --ds-info-text: #1e40af;

  /* Elevation (soft, layered) */
  --ds-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --ds-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --ds-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  --ds-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.04);
  --ds-shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.25);

  /* Radius */
  --ds-radius-xs: 4px;
  --ds-radius-sm: 6px;
  --ds-radius-md: 10px;
  --ds-radius-lg: 14px;
  --ds-radius-xl: 20px;
  --ds-radius-pill: 999px;

  /* Spacing scale (dense, 4pt base) */
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-space-10: 40px;
  --ds-space-12: 48px;

  /* Motion */
  --ds-dur-fast: 120ms;
  --ds-dur: 180ms;
  --ds-dur-slow: 240ms;
  --ds-ease: cubic-bezier(.2, .0, .0, 1);
  --ds-ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Type */
  --ds-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ds-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ------ Design tokens: DARK ------ */
/* Pre-paint dark shell — set on <html> by the head-boot script so the very
   first frame is already dark. Only paints the outer shell (html) and the
   raw body background — real tokens live under body[data-theme="dark"] and
   take over as soon as the body mark is applied. */
html[data-theme="dark"] { background: #0b1220; color-scheme: dark; }
html[data-theme="dark"] body:not([data-theme="light"]) { background: #0b1120; color: #e5e7eb; }

/* Dark tokens apply ONLY when body's data-theme is 'dark'. The pre-paint
   html[data-theme] mark is a shell hint (background only) — the body value
   is the source of truth for tokens so switching back to light works. */
body[data-theme="dark"] {
  --ds-brand: #60a5fa;              /* lighter for dark surfaces per MD */
  --ds-brand-hover: #93c5fd;
  --ds-brand-active: #bfdbfe;
  --ds-brand-soft: #172554;
  --ds-brand-fg: #0b1120;
  --ds-accent: #10b981;
  --ds-accent-soft: #064e3b;

  --ds-canvas: #0b1120;             /* page canvas — deep navy */
  --ds-surface: #151d2e;            /* cards, panels — clearly lifted from canvas */
  --ds-surface-2: #1c2540;
  --ds-surface-3: #253052;
  --ds-sidebar: #151d2e;            /* matches card surface for clear left/right contrast */
  --ds-sidebar-hover: #1c2540;
  --ds-sidebar-active: rgba(96, 165, 250, 0.16);
  --ds-topbar-bg: rgba(21, 29, 46, 0.85);

  --ds-text: #e6edf7;
  --ds-text-muted: #94a3b8;
  --ds-text-subtle: #64748b;
  --ds-text-inverse: #0b1120;

  --ds-border: #1e293b;
  --ds-border-strong: #334155;
  --ds-divider: #16202f;

  --ds-success: #10b981;
  --ds-success-soft: rgba(16, 185, 129, 0.14);
  --ds-success-text: #6ee7b7;
  --ds-warning: #f59e0b;
  --ds-warning-soft: rgba(245, 158, 11, 0.14);
  --ds-warning-text: #fcd34d;
  --ds-danger: #f87171;
  --ds-danger-soft: rgba(248, 113, 113, 0.14);
  --ds-danger-text: #fca5a5;
  --ds-info: #60a5fa;
  --ds-info-soft: rgba(96, 165, 250, 0.14);
  --ds-info-text: #bfdbfe;

  --ds-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --ds-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);
  --ds-shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
  --ds-shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.55), 0 6px 12px rgba(0, 0, 0, 0.35);
  --ds-shadow-focus: 0 0 0 3px rgba(96, 165, 250, 0.35);
}

/* Fallback to OS pref if user never picked one and theme attribute is absent */
@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]):not([data-theme="dark"]) {
    --ds-brand: #60a5fa; --ds-brand-hover: #93c5fd; --ds-brand-active: #bfdbfe;
    --ds-brand-soft: #172554; --ds-brand-fg: #0b1120;
    --ds-accent: #10b981; --ds-accent-soft: #064e3b;
    --ds-canvas: #0b1120; --ds-surface: #151d2e; --ds-surface-2: #1c2540;
    --ds-surface-3: #253052; --ds-sidebar: #151d2e; --ds-sidebar-hover: #1c2540;
    --ds-sidebar-active: rgba(96, 165, 250, 0.16); --ds-topbar-bg: rgba(21, 29, 46, 0.85);
    --ds-text: #e6edf7; --ds-text-muted: #94a3b8; --ds-text-subtle: #64748b;
    --ds-text-inverse: #0b1120;
    --ds-border: #1e293b; --ds-border-strong: #334155; --ds-divider: #16202f;
    --ds-success: #10b981; --ds-success-soft: rgba(16, 185, 129, 0.14); --ds-success-text: #6ee7b7;
    --ds-warning: #f59e0b; --ds-warning-soft: rgba(245, 158, 11, 0.14); --ds-warning-text: #fcd34d;
    --ds-danger: #f87171; --ds-danger-soft: rgba(248, 113, 113, 0.14); --ds-danger-text: #fca5a5;
    --ds-info: #60a5fa; --ds-info-soft: rgba(96, 165, 250, 0.14); --ds-info-text: #bfdbfe;
    --ds-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ds-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);
    --ds-shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
    --ds-shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.55), 0 6px 12px rgba(0, 0, 0, 0.35);
    --ds-shadow-focus: 0 0 0 3px rgba(96, 165, 250, 0.35);
  }
}

/* =============================================================================
   Base
   ============================================================================= */
html { color-scheme: light dark; }

body {
  font-family: var(--ds-font-sans) !important;
  color: var(--ds-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','cv11'; /* Inter refinements */
}
a {
  text-decoration: none !important;
}
/* Only paint the body background for app shells that have the sidebar layout.
   Auth pages, PDFs, and public forms keep their own body background. */
body:has(> .sidebar),
body:has(> .main-content) {
  background-color: var(--ds-canvas) !important;
}

/* Invoice web page: canvas can be theme-aware, but the invoice paper itself
   stays white with dark text so it always matches the printed PDF version. */
body:has(> .invoice-wrapper) {
  background-color: var(--ds-canvas) !important;
}
body:has(> .invoice-wrapper) .invoice-wrapper {
  background: #ffffff !important;
  color: #0f172a !important;
}
body:has(> .invoice-wrapper) .invoice-container,
body:has(> .invoice-wrapper) .invoice-container * {
  color: #0f172a !important;
}
body:has(> .invoice-wrapper) .invoice-container .company-details h1 { color: var(--ds-brand) !important; }
body:has(> .invoice-wrapper) .invoice-container p,
body:has(> .invoice-wrapper) .invoice-container .invoice-meta,
body:has(> .invoice-wrapper) .invoice-container h4 { color: #475569 !important; }
body:has(> .invoice-wrapper) .invoice-container .detail-box { background: #f8fafc !important; }
body:has(> .invoice-wrapper) .invoice-container thead th { background: #f1f5f9 !important; color: #475569 !important; }
body:has(> .invoice-wrapper) .invoice-container tbody td { border-color: #e2e8f0 !important; }
/* Kill the global row-hover tint on the invoice paper — the paper stays white
   regardless of theme, so the dark ds-surface-2 hover looked broken. */
body:has(> .invoice-wrapper) .invoice-container tr:hover td { background: transparent !important; }
body:has(> .invoice-wrapper) .invoice-container tbody tr:hover { background: transparent !important; }
/* Force any form control on the invoice paper (dates, textareas, etc.) to
   render light — the OS's dark color-scheme was otherwise painting the
   date pickers dark navy with white text. */
body:has(> .invoice-wrapper) .invoice-container input,
body:has(> .invoice-wrapper) .invoice-container textarea,
body:has(> .invoice-wrapper) .invoice-container select {
    color-scheme: light !important;
    background-color: #ffffff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}
body:has(> .invoice-wrapper) .invoice-container .inv-date-input {
    background-color: transparent !important;
    color: #475569 !important;
    border-color: transparent !important;
}
body:has(> .invoice-wrapper) .invoice-container .inv-date-input:hover,
body:has(> .invoice-wrapper) .invoice-container .inv-date-input:focus {
    background-color: #ffffff !important;
    border-color: #dbe3ef !important;
}
body:has(> .invoice-wrapper) .invoice-container input::-webkit-calendar-picker-indicator {
    filter: none !important;
    opacity: 0.6 !important;
}

/* Action bar (top strip of the invoice view) */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 24px !important;
  background: var(--ds-surface) !important;
  border-bottom: 1px solid var(--ds-border) !important;
  border-top-left-radius: var(--ds-radius-lg);
  border-top-right-radius: var(--ds-radius-lg);
}
.action-bar-left { display: inline-flex; align-items: center; gap: 10px; color: var(--ds-text) !important; }
.action-bar-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ds-text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
}
.action-bar-num { font-family: var(--ds-font-mono); font-size: 13px; color: var(--ds-text); }
.action-bar-buttons { display: inline-flex; gap: 8px; align-items: center; }

/* Standalone app topbar (used on the project detail page) */
.ds-app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--ds-topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ds-border);
  min-height: 52px;
}
.ds-app-topbar .ds-topbar-spacer { flex: 1; }
.ds-topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  color: var(--ds-text);
  border: 1px solid var(--ds-border);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  transition: background var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease);
}
.ds-topbar-back:hover { background: var(--ds-surface-2); color: var(--ds-brand); border-color: var(--ds-brand); }
.ds-topbar-back svg { width: 14px !important; height: 14px !important; }

/* Prominent in-page back button (project header) */
.ds-back-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 6px !important;
  padding: 8px 14px !important;
  border-radius: var(--ds-radius-md) !important;
  background: var(--ds-brand-soft) !important;
  color: var(--ds-brand) !important;
  border: 1px solid var(--ds-brand) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  text-decoration: none !important;
}
.ds-back-btn:hover { background: var(--ds-brand) !important; color: var(--ds-brand-fg) !important; }
.ds-back-btn svg { width: 14px !important; height: 14px !important; }

/* Topbar-style icon button (used in the project header) */
.ds-topbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-2);
  color: var(--ds-text-muted);
  border: 1px solid transparent;
  text-decoration: none;
  transition: background var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease);
}
.ds-topbar-icon-btn:hover { background: var(--ds-surface-3); color: var(--ds-text); }
.ds-topbar-icon-btn svg { width: 18px !important; height: 18px !important; }
.ds-topbar-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ds-danger);
  color: #fff;
  font-family: var(--ds-font-mono);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--ds-surface);
}

/* Ds-pill (compact status badges) */
.ds-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px !important; font-weight: 600 !important;
  padding: 4px 10px !important;
  border-radius: 999px !important;
  line-height: 1;
}
.ds-pill-success { background: var(--ds-success-soft) !important; color: var(--ds-success-text) !important; }
.ds-pill-warning { background: var(--ds-warning-soft) !important; color: var(--ds-warning-text) !important; }
.ds-pill-danger  { background: var(--ds-danger-soft)  !important; color: var(--ds-danger-text)  !important; }
.ds-pill-info    { background: var(--ds-info-soft)    !important; color: var(--ds-info-text)    !important; }

/* Auth pages: replace the AI purple with a soft brand background. */
body:has(> .auth-container) {
  background: linear-gradient(135deg, var(--ds-brand) 0%, var(--ds-brand-active) 100%) !important;
}
body:has(> .auth-container) .auth-container {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
  box-shadow: var(--ds-shadow-lg) !important;
  border-radius: var(--ds-radius-lg) !important;
}
body:has(> .auth-container) .auth-header h1 { color: var(--ds-text) !important; font-weight: 600 !important; }
body:has(> .auth-container) .auth-header p,
body:has(> .auth-container) .auth-footer { color: var(--ds-text-muted) !important; }
body:has(> .auth-container) .auth-footer a { color: var(--ds-brand) !important; }
body:has(> .auth-container) .form-group label { color: var(--ds-text-muted) !important; }
body:has(> .auth-container) .form-group input {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
}
body:has(> .auth-container) .btn-primary {
  background: var(--ds-brand) !important;
  background-image: none !important;
  color: var(--ds-brand-fg) !important;
  box-shadow: var(--ds-shadow-sm) !important;
}
body:has(> .auth-container) .btn-primary:hover {
  background: var(--ds-brand-hover) !important;
  transform: none !important;
}

* { transition-property: background-color, border-color, color, box-shadow; transition-duration: var(--ds-dur-fast); transition-timing-function: var(--ds-ease); }

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

::selection { background: rgba(37, 99, 235, 0.25); color: var(--ds-text); }
body[data-theme="dark"] ::selection { background: rgba(96, 165, 250, 0.32); }

/* Focus ring — visible, brand-tinted, respects keyboard nav */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none !important;
  box-shadow: var(--ds-shadow-focus) !important;
  border-radius: var(--ds-radius-sm);
}

/* Tabular figures for numbers/prices */
.ds-num, .invoice-total, .stat-value, .kanban-column-count,
.kpi-value, .money, .amount {
  font-variant-numeric: tabular-nums;
  font-family: var(--ds-font-mono);
  letter-spacing: -0.01em;
}

/* =============================================================================
   Sidebar — replaces the purple gradient with a clean neutral surface
   ============================================================================= */
.sidebar {
  background: var(--ds-sidebar) !important;
  color: var(--ds-text) !important;
  border-right: 1px solid var(--ds-border) !important;
  box-shadow: var(--ds-shadow-xs) !important;
}

.sidebar-header {
  padding: 20px 20px 16px !important;
  border-bottom: 1px solid var(--ds-divider) !important;
}
.sidebar-header img {
  background: transparent !important;
  padding: 0 !important;
  width: 148px !important;
  height: auto !important;
}
.sidebar-header p { color: var(--ds-text-subtle) !important; font-size: 11px !important; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }

.sidebar-nav { padding: 12px 10px !important; gap: 2px !important; display: flex; flex-direction: column; overflow: hidden; }

.nav-item {
  color: var(--ds-text-muted) !important;
  padding: 10px 12px !important;
  border-radius: var(--ds-radius-md) !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: var(--ds-sidebar-hover) !important;
  color: var(--ds-text) !important;
}
.nav-item.active {
  background: var(--ds-sidebar-active) !important;
  color: var(--ds-brand) !important;
  font-weight: 600 !important;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--ds-brand);
}

.nav-item-icon {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  color: currentColor;
  flex-shrink: 0;
}
.nav-item-icon svg { width: 20px; height: 20px; stroke: currentColor; }

/* User profile block at bottom of sidebar */
.user-profile { border-top: 1px solid var(--ds-divider) !important; padding: 12px !important; }
.user-profile-header { border-radius: var(--ds-radius-md) !important; padding: 8px !important; }
.user-profile-header:hover { background: var(--ds-sidebar-hover) !important; }
.user-avatar {
  background: linear-gradient(135deg, var(--ds-brand) 0%, var(--ds-brand-active) 100%) !important;
  box-shadow: var(--ds-shadow-sm) !important;
  width: 40px !important; height: 40px !important;
  font-size: 14px !important;
}
.user-name { color: var(--ds-text) !important; font-weight: 600 !important; }
.user-email, .user-company { color: var(--ds-text-subtle) !important; }

/* =============================================================================
   Top bar / Header — SCOPED to app shells only so it never touches
   .header inside standalone pages (invoice, PDF, form).
   ============================================================================= */
body:has(> .sidebar) .header,
body:has(> .sidebar) .topbar,
body:has(> .main-content) .topbar {
  background: var(--ds-topbar-bg) !important;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ds-border) !important;
  color: var(--ds-text) !important;
}
/* Push the app topbar right of the sidebar so the page title isn't hidden */
body:has(> .sidebar) .topbar {
  left: 240px !important;
  justify-content: space-between !important;
  padding-left: 20px !important;
}
body:has(> .sidebar.ds-collapsed) .topbar {
  left: 68px !important;
}
/* Reserve space below the fixed topbar so page content is never hidden under it.
   The topbar is 60px tall in admin.php; add top padding to .content-area. */
body:has(> .sidebar) .main-content > .content-area {
  padding-top: 84px !important;
}
/* Same offset on the standalone project detail page */
body:has(> .ds-app-topbar) { padding-top: 0; }
body:has(> .sidebar) .header h2,
body:has(> .main-content) .header h2 {
  color: var(--ds-text) !important; font-weight: 600 !important; letter-spacing: -0.01em;
}
/* Topbar page title (replaces the old .header row) */
.topbar-title {
  display: flex; align-items: center; gap: 12px;
  padding-left: 6px;
}
.topbar-title h2 {
  font-size: 18px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
  color: var(--ds-text) !important;
  margin: 0 !important;
}

/* =============================================================================
   Main content area
   ============================================================================= */
.main-content { background: var(--ds-canvas) !important; color: var(--ds-text) !important; }
.content-area { background: var(--ds-canvas) !important; color: var(--ds-text) !important; }

/* =============================================================================
   Cards & panels
   ============================================================================= */
.card,
.table-card,
.settings-card,
.stat-card,
.project-card,
.project-deal-card,
.kanban-card,
.notification-dropdown,
.user-dropdown,
.modal-content,
.invoice-builder-card {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius-lg) !important;
  box-shadow: var(--ds-shadow-sm) !important;
}

.project-card:hover, .kanban-card:hover, .stat-card:hover {
  box-shadow: var(--ds-shadow-md) !important;
  border-color: var(--ds-border-strong) !important;
  transform: translateY(-1px);
  transition: transform var(--ds-dur) var(--ds-ease-out), box-shadow var(--ds-dur) var(--ds-ease-out), border-color var(--ds-dur) var(--ds-ease-out);
}

.project-card-title, .kanban-card-title { color: var(--ds-text) !important; font-weight: 600 !important; }
.project-card-info-row, .kanban-card-meta { color: var(--ds-text-muted) !important; }
.project-card-status, .kanban-column-count { color: var(--ds-text-subtle) !important; }

/* Section titles inside cards */
.table-header, .card-header { border-bottom: 1px solid var(--ds-divider) !important; }
.table-header h3, .card-header h3, .invoice-builder-card h3 { color: var(--ds-text) !important; font-weight: 600 !important; }

/* =============================================================================
   Buttons
   ============================================================================= */
.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger,
.action-btn, .primary-btn, .save-btn, .submit-btn, .btn-save, .add-btn,
.project-card-btn, .kanban-card-btn, .settings-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--ds-font-sans) !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  padding: 8px 14px !important;
  border-radius: var(--ds-radius-md) !important;
  border: 1px solid transparent !important;
  cursor: pointer;
  min-height: 36px;
  line-height: 1.2;
  transition: background-color var(--ds-dur) var(--ds-ease), box-shadow var(--ds-dur) var(--ds-ease), transform var(--ds-dur-fast) var(--ds-ease), border-color var(--ds-dur) var(--ds-ease);
}
.btn-primary, .action-btn, .primary-btn, .save-btn, .submit-btn {
  background: var(--ds-brand) !important;
  color: var(--ds-brand-fg) !important;
  box-shadow: var(--ds-shadow-xs);
}
.btn-primary:hover, .action-btn:hover, .primary-btn:hover, .save-btn:hover, .submit-btn:hover {
  background: var(--ds-brand-hover) !important;
  box-shadow: var(--ds-shadow-sm);
}
.btn-primary:active { transform: translateY(1px); background: var(--ds-brand-active) !important; }

.btn-secondary, .project-card-btn, .kanban-card-btn {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
}
.btn-secondary:hover, .project-card-btn:hover, .kanban-card-btn:hover {
  background: var(--ds-surface-2) !important;
  border-color: var(--ds-border-strong) !important;
}

.btn-ghost {
  background: transparent !important;
  color: var(--ds-text-muted) !important;
  border: 1px solid transparent !important;
}
.btn-ghost:hover { background: var(--ds-surface-2) !important; color: var(--ds-text) !important; }

.btn-danger {
  background: var(--ds-danger) !important;
  color: #fff !important;
  border-color: var(--ds-danger) !important;
}
.btn-danger:hover { background: color-mix(in srgb, var(--ds-danger) 88%, black) !important; filter: none; }

button:disabled, .btn:disabled { opacity: 0.5 !important; cursor: not-allowed !important; }

/* =============================================================================
   Forms
   ============================================================================= */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="url"], input[type="search"], input[type="date"],
input[type="time"], input[type="datetime-local"], select, textarea {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius-md) !important;
  padding: 10px 12px !important;
  font-family: var(--ds-font-sans) !important;
  font-size: 14px !important;
  min-height: 40px;
  transition: border-color var(--ds-dur) var(--ds-ease), box-shadow var(--ds-dur) var(--ds-ease), background-color var(--ds-dur) var(--ds-ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--ds-border-strong) !important; }
input:focus, select:focus, textarea:focus {
  outline: none !important;
  border-color: var(--ds-brand) !important;
  box-shadow: var(--ds-shadow-focus) !important;
}
::placeholder { color: var(--ds-text-subtle) !important; opacity: 1; }

label { color: var(--ds-text-muted) !important; font-size: 13px; font-weight: 500; }

/* =============================================================================
   Tables
   ============================================================================= */
table { border-collapse: separate !important; border-spacing: 0; }
th {
  background: var(--ds-surface-2) !important;
  color: var(--ds-text-muted) !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  font-size: 11px !important;
  letter-spacing: 0.04em;
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--ds-border) !important;
  text-align: left;
}
td {
  color: var(--ds-text) !important;
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--ds-divider) !important;
  font-size: 14px !important;
}
tr:hover td { background: var(--ds-surface-2) !important; }

/* =============================================================================
   Badges / status pills
   ============================================================================= */
.badge, .status-badge, .tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px !important; font-weight: 600 !important;
  padding: 3px 10px !important;
  border-radius: var(--ds-radius-pill) !important;
  line-height: 1.4;
}
.badge-success, .status-approved, .status-paid, .status-completed { background: var(--ds-success-soft) !important; color: var(--ds-success-text) !important; }
.badge-warning, .status-pending, .status-review { background: var(--ds-warning-soft) !important; color: var(--ds-warning-text) !important; }
.badge-danger, .status-rejected, .status-overdue { background: var(--ds-danger-soft) !important; color: var(--ds-danger-text) !important; }
.badge-info, .status-draft, .status-active { background: var(--ds-info-soft) !important; color: var(--ds-info-text) !important; }

/* =============================================================================
   Kanban
   ============================================================================= */
.kanban-column, .projects-kanban-board {
  background: var(--ds-surface-2) !important;
  border: 1px solid var(--ds-divider) !important;
  border-radius: var(--ds-radius-lg) !important;
}
.kanban-column-header { color: var(--ds-text-muted) !important; font-weight: 600 !important; text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
.kanban-card { border-radius: var(--ds-radius-md) !important; }

/* =============================================================================
   Notifications dropdown, user dropdown, modals
   ============================================================================= */
.notification-dropdown, .user-dropdown {
  border: 1px solid var(--ds-border) !important;
  box-shadow: var(--ds-shadow-lg) !important;
  border-radius: var(--ds-radius-lg) !important;
}
.notification-dropdown-header { border-bottom: 1px solid var(--ds-divider) !important; color: var(--ds-text) !important; }
.notification-item { border-bottom: 1px solid var(--ds-divider) !important; }
.notification-item:hover { background: var(--ds-surface-2) !important; }
.notification-item-title { color: var(--ds-text) !important; }
.notification-item-time { color: var(--ds-text-subtle) !important; }

.notification-bell {
  background: var(--ds-surface-2) !important;
  color: var(--ds-text-muted) !important;
  border-radius: var(--ds-radius-md) !important;
  border: 1px solid transparent !important;
  padding: 8px !important;
}
.notification-bell:hover { background: var(--ds-surface-3) !important; color: var(--ds-text) !important; }

.modal-content { border-radius: var(--ds-radius-lg) !important; box-shadow: var(--ds-shadow-lg) !important; border: 1px solid var(--ds-border) !important; }
.modal-overlay, .modal-backdrop { background: rgba(15, 23, 42, 0.55) !important; backdrop-filter: blur(4px); }

/* =============================================================================
   Theme switch (existing select) — restyle cleanly
   ============================================================================= */
.theme-switch, .status-select {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius-md) !important;
  padding: 6px 10px !important;
}
.theme-switch select { color: inherit !important; background: transparent !important; }

/* =============================================================================
   Settings tabs
   ============================================================================= */
.settings-topbar {
  background: var(--ds-surface) !important;
  border-bottom: 1px solid var(--ds-border) !important;
}
.settings-tab {
  color: var(--ds-text-muted) !important;
  border-bottom: 2px solid transparent !important;
  padding: 12px 14px !important;
  font-weight: 500 !important;
}
.settings-tab:hover { color: var(--ds-text) !important; background: var(--ds-surface-2) !important; }
.settings-tab.active { color: var(--ds-brand) !important; border-bottom-color: var(--ds-brand) !important; background: transparent !important; }

.settings-card p, .settings-card small { color: var(--ds-text-muted) !important; }

/* =============================================================================
   View toggles / segmented controls
   ============================================================================= */
.view-toggle-btn {
  background: var(--ds-surface) !important;
  color: var(--ds-text-muted) !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius-md) !important;
  padding: 6px 10px !important;
}
.view-toggle-btn.active, .view-toggle-btn[aria-pressed="true"] {
  background: var(--ds-brand-soft) !important;
  color: var(--ds-brand) !important;
  border-color: var(--ds-brand) !important;
}

/* =============================================================================
   User dropdown (Settings / Profile / Download / Logout)
   ============================================================================= */
.user-dropdown {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
  box-shadow: var(--ds-shadow-lg) !important;
  border-radius: var(--ds-radius-lg) !important;
  padding: 6px !important;
  /* Give the menu room for all items — the original 200px cap clipped 4-item lists. */
  max-height: none !important;
}
.user-profile.open .user-dropdown { max-height: none !important; }

/* When sidebar is collapsed, float the dropdown out to the right instead of
   letting it collapse to the sidebar's narrow width. */
.sidebar.ds-collapsed .user-dropdown {
  left: calc(100% + 8px) !important;
  right: auto !important;
  bottom: 0 !important;
  width: 240px !important;
  margin-bottom: 0 !important;
}
.sidebar.ds-collapsed .user-profile.open .user-dropdown { margin-bottom: 0 !important; }
.user-dropdown-item {
  color: var(--ds-text) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: var(--ds-radius-md) !important;
  padding: 10px 12px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  text-decoration: none !important;
  transition: background-color var(--ds-dur-fast) var(--ds-ease);
}
.user-dropdown-item:hover {
  background: var(--ds-surface-2) !important;
  color: var(--ds-text) !important;
}
.user-dropdown-item .icon,
.user-dropdown-item svg.ds-icon {
  color: var(--ds-text-muted) !important;
  width: 18px !important;
  height: 18px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.user-dropdown-item:hover .icon,
.user-dropdown-item:hover svg.ds-icon {
  color: var(--ds-brand) !important;
}
/* Kill any inline border-top divider styling; use tokenized divider instead */
.user-dropdown-item[style*="border-top"] {
  border-top: 1px solid var(--ds-divider) !important;
  margin-top: 6px !important;
  padding-top: 12px !important;
}
.user-dropdown-icon { color: var(--ds-text-subtle) !important; }

/* =============================================================================
   Sidebar collapse
   ============================================================================= */
.sidebar {
  --ds-sidebar-w: 240px;
  --ds-sidebar-w-collapsed: 68px;
  width: var(--ds-sidebar-w) !important;
  transition: width var(--ds-dur) var(--ds-ease-out);
  position: relative;
}
.sidebar.ds-collapsed { width: var(--ds-sidebar-w-collapsed) !important; }

/* Toggle button pinned to the sidebar's right edge */
.ds-sidebar-toggle {
  position: absolute;
  top: 22px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ds-surface);
  color: var(--ds-text-muted);
  border: 1px solid var(--ds-border);
  box-shadow: var(--ds-shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: background var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease), transform var(--ds-dur) var(--ds-ease-out);
}
.ds-sidebar-toggle:hover { color: var(--ds-brand); background: var(--ds-surface-2); }
.ds-sidebar-toggle svg { width: 14px !important; height: 14px !important; }
.sidebar.ds-collapsed .ds-sidebar-toggle svg { transform: rotate(180deg); }

/* Collapsed state: hide labels, center icons, tidy header/profile */
.sidebar.ds-collapsed .sidebar-header p,
.sidebar.ds-collapsed .nav-item > span:not(.nav-item-icon),
.sidebar.ds-collapsed .user-info,
.sidebar.ds-collapsed .user-dropdown-icon { display: none !important; }

.sidebar.ds-collapsed .sidebar-header {
  padding: 16px 8px !important;
  text-align: center;
}
.sidebar.ds-collapsed .sidebar-header img {
  width: 40px !important; height: 40px !important;
  object-fit: contain;
  margin: 0 auto !important;
}

.sidebar.ds-collapsed .nav-item {
  justify-content: center;
  padding: 12px 0 !important;
}
.sidebar.ds-collapsed .nav-item.active::before {
  left: 0;
  top: 6px; bottom: 6px;
}
.sidebar.ds-collapsed .user-profile-header { justify-content: center; padding: 8px 4px !important; }
.sidebar.ds-collapsed .user-avatar { margin: 0 auto; }

/* Tooltip label when collapsed */
.sidebar.ds-collapsed .nav-item[data-label]:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 12px;
  background: var(--ds-text);
  color: var(--ds-surface);
  padding: 6px 10px;
  border-radius: var(--ds-radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--ds-shadow-md);
  z-index: 1000;
  pointer-events: none;
}
.sidebar.ds-collapsed .nav-item { position: relative; }

/* Hide any nav-item badge (unread count) inside collapsed sidebar */
.sidebar.ds-collapsed .nav-item > span[style*="background"] { display: none !important; }

/* =============================================================================
   Theme segmented control (Sun / Moon / Monitor)
   ============================================================================= */
.ds-theme-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  border-radius: 999px;
  gap: 2px;
}
.ds-theme-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ds-text-muted);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease);
}
.ds-theme-toggle button:hover { color: var(--ds-text); }
.ds-theme-toggle button.is-active {
  background: var(--ds-surface);
  color: var(--ds-brand);
  box-shadow: var(--ds-shadow-xs);
}
.ds-theme-toggle svg { width: 16px !important; height: 16px !important; }

/* =============================================================================
   Dashboard hero banner — its gradient is always light, so pin text dark in both themes
   ============================================================================= */
.dashboard-hero {
  background: linear-gradient(120deg, #eef4ff 0%, #f8fafc 100%) !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius-lg) !important;
}
.dashboard-hero h3 { color: #0f172a !important; font-weight: 600 !important; letter-spacing: -0.01em; }
.dashboard-hero p { color: #475569 !important; }
body[data-theme="dark"] .dashboard-hero {
  background: linear-gradient(120deg, #1c2540 0%, #151d2e 100%) !important;
  border-color: var(--ds-border) !important;
}
body[data-theme="dark"] .dashboard-hero h3 { color: var(--ds-text) !important; }
body[data-theme="dark"] .dashboard-hero p { color: var(--ds-text-muted) !important; }

/* =============================================================================
   Empty state
   ============================================================================= */
.ds-empty {
  text-align: center;
  padding: 72px 24px;
  background: var(--ds-surface);
  border: 1px dashed var(--ds-border) !important;
  border-radius: var(--ds-radius-lg);
  color: var(--ds-text-muted);
}
.ds-empty h3 { color: var(--ds-text) !important; font-weight: 600 !important; margin: 8px 0 4px; font-size: 16px; }
.ds-empty p { color: var(--ds-text-muted) !important; font-size: 14px; margin: 0 auto; max-width: 380px; }
.ds-empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  border-radius: 999px;
  background: var(--ds-surface-2);
  color: var(--ds-text-subtle);
  margin-bottom: 16px;
}
.ds-empty-icon svg { width: 28px !important; height: 28px !important; stroke-width: 1.5; }

/* Also normalize the older .empty-state markup that other templates use */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  background: var(--ds-surface);
  border: 1px dashed var(--ds-border) !important;
  border-radius: var(--ds-radius-lg);
  color: var(--ds-text-muted) !important;
}
.empty-state p { color: var(--ds-text-muted) !important; }
.empty-state-icon {
  display: inline-flex !important; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  border-radius: 999px;
  background: var(--ds-surface-2);
  color: var(--ds-text-subtle) !important;
  margin: 0 auto 16px;
  font-size: 24px !important;
}
.empty-state-icon svg { width: 28px !important; height: 28px !important; }

/* =============================================================================
   Info banner (replaces the AI-purple hero banner)
   ============================================================================= */
.ds-info-banner {
  background: linear-gradient(120deg, var(--ds-brand-soft) 0%, var(--ds-surface) 100%);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.ds-info-banner-body { display: flex; align-items: center; gap: 16px; }
.ds-info-banner-icon {
  width: 44px; height: 44px;
  border-radius: 999px;
  background: var(--ds-surface);
  color: var(--ds-brand);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--ds-border);
}
.ds-info-banner-icon svg { width: 20px !important; height: 20px !important; }
.ds-info-banner-text { flex: 1; }
.ds-info-banner-text h3 { color: var(--ds-text) !important; margin: 0 0 2px !important; font-size: 15px !important; font-weight: 600 !important; }
.ds-info-banner-text p { color: var(--ds-text-muted) !important; margin: 0 !important; font-size: 13px !important; }
.ds-info-banner-cta { flex-shrink: 0; }

/* =============================================================================
   Purge legacy purple gradient from inline styles across the app
   These attribute selectors catch every `style="…#667eea…"` /  `…#764ba2…"`
   that still lives in the templates and re-tints it to the brand blue,
   so we don't have to hand-edit dozens of inline styles.
   ============================================================================= */
[style*="#667eea"],
[style*="#764ba2"],
[style*="667eea"],
[style*="764ba2"] {
  background-image: none !important;
  background: var(--ds-brand) !important;
  color: var(--ds-brand-fg) !important;
  border-color: var(--ds-brand) !important;
  box-shadow: none !important;
}
/* Special-case: light-tinted comment/task highlights use the color as a border-left
   accent — recolor the accent but preserve the light background. */
[style*="border-left: 3px solid #667eea"],
[style*="border-left:3px solid #667eea"] {
  background: var(--ds-surface-2) !important;
  color: var(--ds-text) !important;
  border-left-color: var(--ds-brand) !important;
}
/* When the purple was used on inputs/textareas as a focus border */
input[style*="#667eea"],
textarea[style*="#667eea"] {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border-color: var(--ds-brand) !important;
}
/* Avatar circles built from the gradient: keep them clean brand circles */
[style*="linear-gradient(135deg, #667eea"] {
  background: linear-gradient(135deg, var(--ds-brand) 0%, var(--ds-brand-active) 100%) !important;
  color: #fff !important;
}

/* =============================================================================
   Modal helpers (form-style modals)
   ============================================================================= */
.ds-form-modal { max-width: 640px !important; border-radius: var(--ds-radius-lg) !important; }
.ds-modal-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px !important; font-weight: 600 !important;
  color: var(--ds-text) !important;
  margin: 0 0 4px !important;
  letter-spacing: -0.01em;
}
.ds-modal-title svg { color: var(--ds-brand) !important; width: 22px !important; height: 22px !important; }
.ds-modal-sub { color: var(--ds-text-muted) !important; font-size: 13px !important; margin: 0 0 20px !important; }
.ds-field-group { margin-bottom: 20px; }
.ds-field-group > label {
  display: block !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-text-muted) !important;
  margin-bottom: 8px !important;
}
.ds-input-row { display: flex; gap: 8px; align-items: stretch; }
.ds-input-row > .btn-primary,
.ds-input-row > .btn-secondary { min-height: 44px; }
.ds-code-input {
  flex: 1;
  font-family: var(--ds-font-mono) !important;
  font-size: 12px !important;
  background: var(--ds-surface-2) !important;
  color: var(--ds-text) !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius-md) !important;
  padding: 12px !important;
}
.ds-help { display: block; margin-top: 8px; color: var(--ds-text-subtle) !important; font-size: 12px !important; }

/* =============================================================================
   Status icon picker (Settings › Statuses modal)
   ============================================================================= */
.ds-mini-label {
  display: block !important;
  margin: 8px 0 6px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--ds-text-muted) !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ds-icon-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  margin-bottom: 16px;
}
.ds-icon-choice {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ds-text-muted);
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background var(--ds-dur-fast) var(--ds-ease), color var(--ds-dur-fast) var(--ds-ease), border-color var(--ds-dur-fast) var(--ds-ease);
}
.ds-icon-choice:hover { background: var(--ds-surface); color: var(--ds-text); border-color: var(--ds-border); }
.ds-icon-choice.is-active {
  background: var(--ds-brand-soft);
  color: var(--ds-brand);
  border-color: var(--ds-brand);
}
.ds-icon-choice svg { width: 16px !important; height: 16px !important; }

/* Status tag rendering — center the SVG in the icon slot */
.status-tag .status-icon,
.status-tag .drag-handle,
.status-tag .marker-icon {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: var(--ds-text-muted);
}
.status-tag .status-icon svg,
.status-tag .drag-handle svg { width: 16px !important; height: 16px !important; }
.status-tag .marker-icon svg { width: 14px !important; height: 14px !important; }
.status-tag .status-icon { color: var(--ds-brand); }

/* Kanban column large status icon */
.status-icon-lg { display: inline-flex; align-items: center; justify-content: center; color: var(--ds-brand); }
.status-icon-lg svg { width: 20px !important; height: 20px !important; }

/* =============================================================================
   Invoice payment-details inline editor
   ============================================================================= */
body:has(> .invoice-wrapper) .payment-details {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 12px;
}
body:has(> .invoice-wrapper) .payment-details-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
body:has(> .invoice-wrapper) .payment-details h4 {
  margin: 0 !important;
  color: #475569 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
body:has(> .invoice-wrapper) .payment-details-actions button {
  appearance: none;
  background: #ffffff;
  color: #2563eb !important;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 120ms, border-color 120ms;
  margin-left: 6px;
}
body:has(> .invoice-wrapper) .payment-details-actions button:hover { background: #dbeafe; border-color: #93c5fd; }
body:has(> .invoice-wrapper) .payment-details-status {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
  font-family: var(--ds-font-mono, monospace);
}
body:has(> .invoice-wrapper) .payment-details-body {
  color: #0f172a !important;
  font-size: 13px;
  line-height: 1.65;
  min-height: 22px;
}
body:has(> .invoice-wrapper) .payment-details-empty {
  color: #94a3b8 !important;
  font-style: italic;
}
body:has(> .invoice-wrapper) .payment-details-textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px !important;
  border: 1px solid #93c5fd !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: #0f172a !important;
  font-family: inherit !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
body:has(> .invoice-wrapper) .payment-details-textarea:focus { border-color: #2563eb !important; box-shadow: 0 0 0 3px rgba(37,99,235,0.15) !important; }
body:has(> .invoice-wrapper) .payment-details-textarea::placeholder { color: #94a3b8 !important; }

/* Invoice line item name + description */
body:has(> .invoice-wrapper) .inv-item-name {
  color: #0f172a !important;
  font-weight: 500;
  line-height: 1.35;
}
body:has(> .invoice-wrapper) .inv-item-desc {
  color: #64748b !important;
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.4;
  white-space: pre-wrap;
}
body:has(> .invoice-wrapper) .inv-item-desc-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px !important;
  border: 1px dashed #cbd5e1 !important;
  border-radius: 6px !important;
  background: #f8fafc !important;
  color: #334155 !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
  font-family: inherit !important;
  resize: none;
  overflow: hidden;
  outline: none;
  box-sizing: border-box;
  transition: border-color 120ms, background 120ms;
}
body:has(> .invoice-wrapper) .inv-item-desc-input:focus {
  border-color: #2563eb !important;
  background: #ffffff !important;
}
body:has(> .invoice-wrapper) .inv-item-desc-input::placeholder { color: #94a3b8; font-style: italic; }
body:has(> .invoice-wrapper) .inv-item-desc-input.saved { border-color: #10b981 !important; }
body:has(> .invoice-wrapper) .inv-item-desc-input.save-failed { border-color: #ef4444 !important; }
@media print {
  body:has(> .invoice-wrapper) .inv-item-desc-input {
    border: none !important; background: transparent !important; padding: 0 !important; margin-top: 4px;
    color: #64748b !important; font-size: 12px !important;
  }
}
.no-print {}
@media print { .no-print { display: none !important; } }

/* =============================================================================
   Settings › any tab — dark-mode legibility for the hardcoded light styles
   ============================================================================= */
body[data-theme="dark"] #settings label,
body[data-theme="dark"] #settings h3,
body[data-theme="dark"] #settings .settings-title,
body[data-theme="dark"] #settings .form-group > label,
body[data-theme="dark"] #settings-section label,
body[data-theme="dark"] #settings .field-group label,
body[data-theme="dark"] #settings [style*="color: #1e293b"],
body[data-theme="dark"] #settings [style*="color:#1e293b"],
body[data-theme="dark"] #settings [style*="color: #334155"],
body[data-theme="dark"] #settings [style*="color:#334155"] {
  color: var(--ds-text) !important;
}
body[data-theme="dark"] #settings [style*="color: #64748b"],
body[data-theme="dark"] #settings [style*="color:#64748b"],
body[data-theme="dark"] #settings [style*="color: #666"],
body[data-theme="dark"] #settings [style*="color: #999"],
body[data-theme="dark"] #settings small,
body[data-theme="dark"] #settings p {
  color: var(--ds-text-muted) !important;
}
body[data-theme="dark"] #settings [style*="background: #f8fafc"],
body[data-theme="dark"] #settings [style*="background:#f8fafc"],
body[data-theme="dark"] #settings [style*="linear-gradient(135deg, #f8fafc"] {
  background: var(--ds-surface-2) !important;
  background-image: none !important;
}
body[data-theme="dark"] #settings [style*="border: 2px dashed"] {
  border-color: var(--ds-border-strong) !important;
}
body[data-theme="dark"] #settings [style*="border: 1px solid #e2e8f0"],
body[data-theme="dark"] #settings [style*="border:1px solid #e2e8f0"] {
  border-color: var(--ds-border) !important;
}
body[data-theme="dark"] #settings code {
  color: var(--ds-text) !important;
  background: var(--ds-surface-2) !important;
}
body[data-theme="dark"] #settings .status-tag {
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
  border-color: var(--ds-border) !important;
}
body[data-theme="dark"] #settings .status-tag .status-name { color: var(--ds-text) !important; }
body[data-theme="dark"] #settings .status-tag .status-icon svg { color: var(--ds-brand); }
body[data-theme="dark"] #settings .section-icon svg { color: var(--ds-brand); }

/* =============================================================================
   Toasts (replaces the inline error/success banners)
   ============================================================================= */
.ds-toast-host {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100% - 40px));
}
.ds-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  color: var(--ds-text);
  border: 1px solid var(--ds-border);
  box-shadow: var(--ds-shadow-lg);
  min-width: 260px;
  transform: translateX(20px);
  opacity: 0;
  animation: ds-toast-in 200ms cubic-bezier(.16,1,.3,1) forwards;
}
.ds-toast.leaving { animation: ds-toast-out 180ms ease-in forwards; }
@keyframes ds-toast-in  { to { transform: translateX(0); opacity: 1; } }
@keyframes ds-toast-out { to { transform: translateX(20px); opacity: 0; } }
.ds-toast-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
}
.ds-toast-body { flex: 1; font-size: 13px; line-height: 1.45; }
.ds-toast-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ds-text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
}
.ds-toast-close:hover { background: var(--ds-surface-2); color: var(--ds-text); }
.ds-toast-success .ds-toast-icon { background: var(--ds-success); }
.ds-toast-error   .ds-toast-icon { background: var(--ds-danger); }
.ds-toast-info    .ds-toast-icon { background: var(--ds-info); }
@media (prefers-reduced-motion: reduce) {
  .ds-toast, .ds-toast.leaving { animation-duration: 1ms !important; }
}

/* Overdue project styling */
.project-card.is-overdue,
.project-deal-card.is-overdue,
.kanban-card.is-overdue,
.project-list-row.is-overdue {
  border-color: var(--ds-danger) !important;
  box-shadow: 0 0 0 1px var(--ds-danger) inset, var(--ds-shadow-sm);
}
.project-due-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ds-text-muted);
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ds-surface-2);
}
.project-due-date.overdue {
  background: var(--ds-danger-soft);
  color: var(--ds-danger-text);
  font-weight: 600;
}
.project-due-date svg { width: 14px !important; height: 14px !important; }

/* List view for projects */
.projects-list-view {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
}
.project-list-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 3fr) minmax(120px, 1fr) 140px 140px 140px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  transition: border-color var(--ds-dur) var(--ds-ease), transform var(--ds-dur) var(--ds-ease);
}
.project-list-row:hover { border-color: var(--ds-border-strong); transform: translateX(2px); }
.project-list-row-status { color: var(--ds-brand); display: inline-flex; }
.project-list-row-title { font-weight: 600; color: var(--ds-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list-row-client { color: var(--ds-text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list-row-status-label { font-size: 12px; color: var(--ds-text-muted); text-transform: capitalize; }
.project-list-row .project-due-date { justify-self: end; }
.project-list-row-open { justify-self: end; }
.projects-list-header {
  display: grid;
  grid-template-columns: 24px minmax(0, 3fr) minmax(120px, 1fr) 140px 140px 140px;
  gap: 12px;
  padding: 8px 14px;
  color: var(--ds-text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Contact details modal — info grid */
.ds-detail-section { margin-bottom: 24px; }
.ds-detail-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px !important; font-weight: 600 !important;
  color: var(--ds-text-muted) !important;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0 0 12px !important;
}
.ds-detail-title svg { color: var(--ds-brand); }
.ds-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 24px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  padding: 14px 16px;
}
.ds-info-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ds-info-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-text-subtle);
}
.ds-info-value {
  font-size: 13px;
  color: var(--ds-text);
  word-break: break-word;
}

/* Project deal card actions (Kanban card footer) */
.project-deal-card {
  max-width: 340px;
}
.ds-deal-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ds-deal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px !important;
  border-radius: var(--ds-radius-sm) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  min-height: 30px !important;
  border: 1px solid transparent !important;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ds-dur-fast) var(--ds-ease), transform var(--ds-dur-fast) var(--ds-ease);
}
.ds-deal-btn:hover { transform: translateY(-1px); }
.ds-deal-btn svg { width: 14px !important; height: 14px !important; }
.ds-deal-btn-timer {
  background: var(--ds-success) !important;
  color: #fff !important;
  padding: 6px 8px !important;
  min-width: 30px;
}
.ds-deal-btn-timer:hover { background: color-mix(in srgb, var(--ds-success) 88%, black) !important; }
.ds-deal-btn-open {
  background: var(--ds-brand) !important;
  color: var(--ds-brand-fg) !important;
}
.ds-deal-btn-open:hover { background: var(--ds-brand-hover) !important; }

/* Notification dropdown item — normalize sizes so long messages stay compact */
.notification-item {
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--ds-divider) !important;
}
.notification-item-title {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--ds-text) !important;
  line-height: 1.35 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.notification-item-message {
  font-size: 12px !important;
  color: var(--ds-text-muted) !important;
  line-height: 1.4 !important;
  margin-top: 4px !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden !important;
}
.notification-item-time {
  font-size: 11px !important;
  color: var(--ds-text-subtle) !important;
  margin-top: 4px !important;
}
.notification-item-icon svg { width: 16px !important; height: 16px !important; color: var(--ds-brand); }
.notification-dropdown { max-width: 360px !important; }

/* Clickable count pill (used in Companies table) */
.ds-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 10px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  color: var(--ds-text);
  border-radius: 999px;
  font-family: var(--ds-font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease), border-color var(--ds-dur) var(--ds-ease);
}
.ds-count-pill:hover { background: var(--ds-brand-soft); color: var(--ds-brand); border-color: var(--ds-brand); }
.ds-count-inline {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  background: var(--ds-surface);
  color: var(--ds-text-muted);
  border-radius: 999px;
  font-family: var(--ds-font-mono);
  font-size: 11px;
  font-weight: 600;
}
.ds-sub-nav-btn.active .ds-count-inline { background: var(--ds-brand-soft); color: var(--ds-brand); }

/* Company detail modal panels */
.ds-detail-panel { min-height: 120px; }
.ds-detail-panel table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-text-muted);
  border-bottom: 1px solid var(--ds-border);
}
.ds-detail-panel table tbody tr { border-bottom: 1px solid var(--ds-divider); }
.ds-detail-panel table tbody tr:last-child { border-bottom: 0; }

/* Sub-navigation strip (used at the top of Quotes/Services) */
.ds-sub-nav {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  border-radius: 999px;
  margin-bottom: 20px;
}
.ds-sub-nav-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ds-text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  transition: background var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease);
}
.ds-sub-nav-btn:hover { color: var(--ds-text); }
.ds-sub-nav-btn.active {
  background: var(--ds-surface);
  color: var(--ds-brand);
  box-shadow: var(--ds-shadow-xs);
}

/* Grouped list (ClickUp-style status groups) */
.ds-list-group { border-bottom: 1px solid var(--ds-divider); padding: 4px 0; }
.ds-list-group[open] { padding-bottom: 8px; }
.ds-list-group-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--ds-radius-md);
  user-select: none;
}
.ds-list-group-summary::-webkit-details-marker { display: none; }
.ds-list-group-summary:hover { background: var(--ds-surface-2); }
.ds-list-group-caret {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ds-text-muted);
  transition: transform var(--ds-dur) var(--ds-ease-out);
}
.ds-list-group[open] .ds-list-group-caret { transform: rotate(90deg); }
.ds-list-group-icon { color: var(--ds-brand); display: inline-flex; }
.ds-list-group-name { font-weight: 600; color: var(--ds-text); }
.ds-list-group-count {
  font-family: var(--ds-font-mono);
  font-size: 11px;
  color: var(--ds-text-muted);
  padding: 2px 8px;
  background: var(--ds-surface-2);
  border-radius: 999px;
}
.ds-list-group-body { padding: 4px 0; }
.ds-list-empty { padding: 20px; color: var(--ds-text-subtle); text-align: center; font-size: 13px; font-style: italic; }

/* Field-icon that acts as a "manage settings" shortcut */
.field-icon-link {
  color: var(--ds-text-muted);
  cursor: help;
  text-decoration: none;
  transition: color 120ms, transform 120ms;
  display: inline-flex; align-items: center; justify-content: center;
}
.field-icon-link:hover { color: var(--ds-brand); transform: translateY(-1px); }

/* =============================================================================
   Utility helpers
   ============================================================================= */
svg.ds-icon {
  width: 20px !important;
  height: 20px !important;
  display: inline-block !important;
  vertical-align: middle;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
svg.ds-icon.ds-icon-sm { width: 16px !important; height: 16px !important; }
svg.ds-icon.ds-icon-lg { width: 28px !important; height: 28px !important; }
.ds-divider { height: 1px; background: var(--ds-divider); margin: var(--ds-space-4) 0; border: 0; }

/* Print-friendly */
@media print {
  .sidebar, .topbar, .header, .theme-switch, .notification-bell, .user-profile { display: none !important; }
  .main-content { margin: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
}
