/* Frozen SaaS V2 tokens, integrated without prototype controllers. */
:root {
  /* Brand Palette - Deep Navy, Vibrant Enterprise Blue & Cyan Accents */
  --asfit-navy-950: #0a0f1d;
  --asfit-navy-900: #0f172a;
  --asfit-navy-850: #162036;
  --asfit-navy-800: #1e293b;
  --asfit-navy-700: #334155;
  --asfit-navy-600: #475569;

  /* Primary Accent - Tuned for WCAG AA Contrast (>5.2:1 with white) */
  --asfit-primary: #2563eb;
  --asfit-primary-hover: #1d4ed8;
  --asfit-primary-active: #1e40af;
  --asfit-primary-light: #eff6ff;
  --asfit-primary-border: #bfdbfe;
  --asfit-primary-glow: rgba(37, 99, 235, 0.18);

  /* Secondary Accent - Enterprise Cyan / Teal */
  --asfit-cyan: #0891b2;
  --asfit-cyan-hover: #0e7490;
  --asfit-cyan-light: #ecfeff;
  --asfit-cyan-border: #a5f3fc;

  /* Neutral Backgrounds & Surfaces */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;
  --bg-input: #ffffff;

  /* Text & Content Tokens */
  --text-heading: #0f172a;
  --text-body: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;

  /* Border & Divider Tokens */
  --border-light: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #2563eb;

  /* Semantic Feedback & Status Tokens */
  --status-active-text: #15803d;
  --status-active-bg: #f0fdf4;
  --status-active-border: #bbf7d0;

  --status-review-text: #b45309;
  --status-review-bg: #fffbeb;
  --status-review-border: #fde68a;

  --status-danger-text: #b91c1c;
  --status-danger-bg: #fef2f2;
  --status-danger-border: #fecaca;

  --status-info-text: #1d4ed8;
  --status-info-bg: #eff6ff;
  --status-info-border: #bfdbfe;

  --status-neutral-text: #475569;
  --status-neutral-bg: #f1f5f9;
  --status-neutral-border: #cbd5e1;

  /* Spacing Scale */
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  --space-4xl: 40px;

  /* Radii Scale (Bounded to <=8px for repeated controls per Codex audit) */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
  --shadow-drawer: -4px 0 32px rgba(15, 23, 42, 0.18);
  --shadow-modal: 0 24px 48px rgba(15, 23, 42, 0.22);

  /* Typography System */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  --font-size-2xs: 0.6875rem; /* 11px */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.8125rem;  /* 13px */
  --font-size-base: 0.875rem; /* 14px */
  --font-size-md: 0.9375rem;  /* 15px */
  --font-size-lg: 1rem;       /* 16px */
  --font-size-xl: 1.125rem;   /* 18px */
  --font-size-2xl: 1.25rem;   /* 20px */
  --font-size-3xl: 1.5rem;    /* 24px */
  --font-size-4xl: 1.75rem;   /* 28px */

  /* Layout Constants */
  --sidebar-width: 256px;
  --header-height: 60px;
  --context-panel-width: 380px;
  --drawer-width: 520px;
}

/* P1 compatibility adapter: presentation only; never reset feature layout or form contracts. */
html.asfit-v2 {
  --blue: var(--asfit-primary); --blue-dark: var(--asfit-primary-hover);
  --navy: var(--asfit-navy-900); --line: var(--border-subtle);
  --surface: var(--bg-surface); --soft: var(--bg-app);
  --asfit-font-sans: var(--font-sans); --asfit-font-mono: var(--font-mono);
  --asfit-color-primary: var(--asfit-primary); --asfit-color-primary-hover: var(--asfit-primary-hover);
  --asfit-color-text: var(--text-heading); --asfit-color-text-secondary: var(--text-secondary);
  --asfit-color-text-muted: var(--text-muted); --asfit-color-surface: var(--bg-surface);
  --asfit-color-surface-subtle: var(--bg-subtle); --asfit-color-border: var(--border-subtle);
  --asfit-color-sidebar: var(--asfit-navy-900); --asfit-color-sidebar-border: var(--asfit-navy-800);
  --asfit-color-sidebar-hover: var(--asfit-navy-850); --asfit-color-sidebar-text: #cbd5e1;
  --color-bg-body: var(--bg-app); --color-bg-surface: var(--bg-surface);
  --color-text-main: var(--text-heading); --color-text-muted: var(--text-muted);
  --color-border: var(--border-subtle); --font-family: var(--font-sans);
}
.asfit-v2 body { margin:0; padding:0; background:var(--bg-app); color:var(--text-body); font-family:var(--font-sans); }
.asfit-v2 :where(button,input,select,textarea) { font-family:inherit; }
.asfit-v2 :where(a,button,input,select,textarea,summary,[tabindex]):focus-visible { outline:2px solid var(--border-focus); outline-offset:3px; }
.asfit-v2 :is(.button,.asfit-button,.btn) { border-radius:var(--radius-md); font-size:var(--font-size-sm); font-weight:700; line-height:1.4; min-height:40px; transition:background-color .15s,border-color .15s; }
.asfit-v2 :is(.button-primary,.asfit-button--primary,.btn-primary) { background:var(--asfit-primary); border-color:var(--asfit-primary); color:#fff; }
.asfit-v2 :is(.button-primary,.asfit-button--primary,.btn-primary):hover:not(:disabled) { background:var(--asfit-primary-hover); border-color:var(--asfit-primary-hover); color:#fff; }
.asfit-v2 :is(.button-secondary,.asfit-button--secondary,.btn-secondary) { background:var(--bg-surface); border-color:var(--border-medium); color:var(--text-secondary); }
.asfit-v2 :is(.button-secondary,.asfit-button--secondary,.btn-secondary):hover:not(:disabled) { background:var(--bg-subtle); color:var(--text-heading); }
.asfit-v2 :is(.button,.asfit-button,.btn):disabled { cursor:not-allowed; box-shadow:none; }
.asfit-v2 :where(input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]),select,textarea) { border-color:var(--border-medium); border-radius:var(--radius-md); background-color:var(--bg-input); color:var(--text-heading); }
.asfit-v2 :where(input,select,textarea):focus-visible { border-color:var(--border-focus); }
.asfit-v2 :where(.panel,.card) { border-color:var(--border-subtle); box-shadow:var(--shadow-xs); }
.asfit-v2 :where(table) { border-color:var(--border-subtle); }
.asfit-v2 :where(th) { background:var(--bg-subtle); color:var(--text-secondary); }
.asfit-v2 :where(td,th) { border-color:var(--border-subtle); }
.asfit-v2 :where(td) { font-variant-numeric:tabular-nums; }
.asfit-v2 :where(.badge,.asfit-status,.asfit-badge) { font-size:var(--font-size-xs); font-weight:700; }
.asfit-v2 :is(.badge-active,.badge-approved,.badge-completed) { color:var(--status-active-text); background:var(--status-active-bg); border-color:var(--status-active-border); }
.asfit-v2 :is(.badge-pending,.badge-in_review,.badge-on_hold) { color:var(--status-review-text); background:var(--status-review-bg); border-color:var(--status-review-border); }
.asfit-v2 :is(.badge-rejected,.badge-cancelled) { color:var(--status-danger-text); background:var(--status-danger-bg); border-color:var(--status-danger-border); }
.asfit-v2 :where(.crm-contact-edit-dialog,.crm-deal-dialog,.auth-card) { border-color:var(--border-subtle); }
.asfit-v2 :where(.admin-toast,.portal-toast) { border-radius:var(--radius-md); box-shadow:var(--shadow-md); }
@media(max-width:768px) { .asfit-v2 :is(.button,.asfit-button,.btn) { min-height:44px; } }
@media(prefers-reduced-motion:reduce) { .asfit-v2 :is(.button,.asfit-button,.btn,.admin-sidebar,.app-sidebar) { transition:none; } }

/* CRM shell. Existing routes, permission visibility and feature markup are retained. */
.asfit-v2 .admin-sidebar { position:fixed; inset:0 auto 0 0; width:var(--sidebar-width); height:100dvh; display:flex; flex-direction:column; padding:0; margin:0; background:var(--asfit-navy-900); color:#cbd5e1; border-right:1px solid var(--asfit-navy-800); border-radius:0; box-shadow:none; overflow:hidden; z-index:70; }
.asfit-v2 .admin-sidebar .topbar-left { position:relative; flex:0 0 var(--header-height); height:var(--header-height); border-bottom:1px solid var(--asfit-navy-800); }
.asfit-v2 .admin-sidebar .brand { height:var(--header-height); padding:0 16px; gap:10px; border:0; }
.asfit-v2 .admin-sidebar .brand-mark { flex:0 0 32px; width:32px; height:32px; border-radius:8px; display:grid;place-items:center; background:linear-gradient(135deg,var(--asfit-primary),var(--asfit-cyan)); color:#fff; font-size:13px; font-weight:800; }
.asfit-v2 .admin-sidebar .brand-copy strong { font-size:13px; color:#fff; }
.asfit-v2 .admin-sidebar .brand-copy small { font-size:10px; color:#22d3ee; }
.asfit-v2 .admin-sidebar .admin-brand-chevron { display:none; }
.asfit-v2 .admin-drawer-workspace { display:flex; margin:12px 12px 4px; padding:8px 10px; border:1px solid var(--asfit-navy-800); background:var(--asfit-navy-850); border-radius:8px; }
.asfit-v2 .admin-sidebar .primary-nav { flex:1 1 auto; min-height:0; overflow-y:auto; overflow-x:hidden; padding:8px 10px 16px; margin:0; width:100%; display:flex; flex-direction:column; gap:14px; position:static; transform:none; visibility:visible; opacity:1; max-height:none; }
.asfit-v2 .admin-sidebar .nav-section { width:100%; }
.asfit-v2 .admin-sidebar .nav-section-links { display:flex; flex-direction:column; gap:3px; }
.asfit-v2 .admin-sidebar .nav-section-label { padding:8px 10px; font-size:10px; color:#94a3b8; letter-spacing:0; }
.asfit-v2 .admin-sidebar .primary-nav a { min-height:40px; width:100%; padding:10px 12px; display:flex; align-items:center; gap:10px; border:1px solid transparent; border-radius:8px; color:#cbd5e1; font-size:12px; line-height:1.4; }
.asfit-v2 .admin-sidebar .primary-nav a:hover { color:#fff; background:var(--asfit-navy-850); }
.asfit-v2 .admin-sidebar .primary-nav a:is(.is-active,[aria-current=page]) { color:#fff; background:var(--asfit-primary); border-color:var(--asfit-primary); }
.asfit-v2 .admin-sidebar .admin-nav-icon { width:18px; height:18px; flex:0 0 18px; }
.asfit-v2 .admin-sidebar .topbar-utilities { flex:0 0 auto; margin:0; padding:12px; border-top:1px solid var(--asfit-navy-800); background:var(--asfit-navy-950); }
.asfit-v2 .admin-sidebar .account-area { margin:0; min-width:0; }
.asfit-v2 .admin-sidebar .account-name { color:#fff; }
.asfit-v2 .admin-sidebar .account-details small { color:#94a3b8; }
.asfit-v2 .admin-mobile-header { position:fixed; top:0; left:var(--sidebar-width); right:0; height:var(--header-height); min-height:var(--header-height); padding:0 24px; display:flex; align-items:center; gap:12px; background:var(--bg-surface); border-bottom:1px solid var(--border-subtle); z-index:45; }
.asfit-v2 .admin-mobile-context { display:flex; align-items:center; gap:8px; min-width:0; }
.asfit-v2 .admin-mobile-context span { color:var(--text-muted); font-size:12px; }
.asfit-v2 .admin-mobile-context strong { color:var(--text-heading); font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.asfit-v2 .nav-toggle,.asfit-v2 .v2-drawer-close { display:none; }
.asfit-v2 .shell { width:calc(100% - var(--sidebar-width)); max-width:none; min-width:0; margin:var(--header-height) 0 0 var(--sidebar-width); padding:24px; }
.asfit-v2 .admin-nav-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.5); z-index:60; }
.asfit-v2 .v2-skip-link { position:fixed; top:8px; left:280px; transform:translateY(-160%); z-index:1000; padding:10px 14px; background:#fff; color:var(--asfit-primary-hover); border:2px solid var(--border-focus); border-radius:8px; }
.asfit-v2 .v2-skip-link:focus { transform:none; }
@media(max-width:1024px) {
 .asfit-v2 .admin-sidebar { transform:translateX(-100%); transition:transform .2s ease; }
 .asfit-v2 .admin-sidebar:has(.primary-nav.is-open) { transform:translateX(0); }
 .asfit-v2 .admin-sidebar .primary-nav { visibility:visible; position:static; transform:none; max-height:none; opacity:1; }
 .asfit-v2 .admin-mobile-header { left:0; padding:0 16px; }
 .asfit-v2 .shell { width:100%; margin-left:0; padding:16px; }
 .asfit-v2 .nav-toggle,.asfit-v2 .v2-drawer-close { display:grid; place-items:center; width:44px; height:44px; flex:0 0 44px; padding:0; border:1px solid var(--border-subtle); border-radius:8px; background:var(--bg-surface); color:var(--text-heading); }
 .asfit-v2 .v2-drawer-close { position:absolute; right:8px; top:8px; width:40px; height:44px; background:transparent; color:#cbd5e1; border:0; }
 .asfit-v2 .admin-sidebar .brand { padding-right:46px; }
 .asfit-v2 .admin-mobile-context span,.asfit-v2 .admin-mobile-context>svg { display:none; }
 .asfit-v2 .admin-sidebar .primary-nav a { min-height:44px; }
 .asfit-v2 .v2-skip-link { left:12px; }
 .asfit-v2 body.v2-nav-open { overflow:hidden; }
}

