/* ClaimNorth v3 — Enterprise design system (wave 93 #1031)
 *
 * Single canonical stylesheet. Replaces the wave-92 patchwork + the
 * ad-hoc inline styles scattered across templates. This file IS the design.
 *
 * Architecture:
 *   1. Reset
 *   2. Design tokens (CSS custom properties)
 *   3. Base elements
 *   4. Layout primitives (shell, grid, stack, row)
 *   5. Components (btn, card, input, table, badge, alert, modal)
 *   6. App shell (sidebar + topbar + main)
 *   7. Utilities
 *
 * Reference quality bar: Linear, Stripe Dashboard, Notion, QuickBooks Online.
 */

/* ============================================================
 *  1. RESET / NORMALIZE
 * ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cn-text);
  background: var(--cn-page);
}
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
a { color: var(--cn-link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--cn-text); letter-spacing: -0.01em; }
p { margin: 0; }
table { border-collapse: collapse; }

/* ============================================================
 *  2. DESIGN TOKENS
 * ============================================================ */
:root {
  /* Color — semantic */
  --cn-page:        #f7f8fa;   /* App background */
  --cn-surface:     #ffffff;   /* Cards, panels */
  --cn-surface-2:   #f4f5f7;   /* Subtle surface (hover, code) */
  --cn-border:      #e5e7eb;   /* Borders */
  --cn-border-strong: #d1d5db;
  --cn-text:        #111827;   /* Primary text */
  --cn-text-muted:  #6b7280;   /* Secondary text */
  --cn-text-faint:  #9ca3af;   /* Tertiary / placeholder */
  --cn-link:        #1e40af;
  --cn-link-hover:  #1e3a8a;
  --cn-primary:     #1d4ed8;   /* Accent / buttons / focus */
  --cn-primary-hover:#1e40af;
  --cn-primary-soft:#eff6ff;
  --cn-success:     #047857;
  --cn-success-soft:#ecfdf5;
  --cn-warning:     #b45309;
  --cn-warning-soft:#fffbeb;
  --cn-danger:      #b91c1c;
  --cn-danger-soft: #fef2f2;

  /* Type scale */
  --cn-fs-xs: 12px;
  --cn-fs-sm: 13px;
  --cn-fs-md: 14px;   /* body */
  --cn-fs-lg: 16px;
  --cn-fs-xl: 18px;
  --cn-fs-2xl: 22px;
  --cn-fs-3xl: 28px;
  --cn-fs-4xl: 36px;

  /* Spacing — 4px scale */
  --cn-sp-1: 4px;
  --cn-sp-2: 8px;
  --cn-sp-3: 12px;
  --cn-sp-4: 16px;
  --cn-sp-5: 20px;
  --cn-sp-6: 24px;
  --cn-sp-8: 32px;
  --cn-sp-10: 40px;
  --cn-sp-12: 48px;
  --cn-sp-16: 64px;

  /* Radius */
  --cn-r-sm: 4px;
  --cn-r-md: 6px;
  --cn-r-lg: 8px;
  --cn-r-xl: 12px;

  /* Shadow */
  --cn-shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --cn-shadow-md: 0 4px 6px -1px rgba(16,24,40,0.08), 0 2px 4px -2px rgba(16,24,40,0.06);
  --cn-shadow-lg: 0 10px 15px -3px rgba(16,24,40,0.08), 0 4px 6px -4px rgba(16,24,40,0.05);

  /* Layout */
  --cn-sidebar-w: 232px;
  --cn-topbar-h: 56px;
}

/* ============================================================
 *  3. BASE ELEMENTS
 * ============================================================ */
h1 { font-size: var(--cn-fs-3xl); line-height: 1.2; }
h2 { font-size: var(--cn-fs-2xl); line-height: 1.3; }
h3 { font-size: var(--cn-fs-xl); line-height: 1.3; }
h4 { font-size: var(--cn-fs-lg); line-height: 1.4; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px;
       background: var(--cn-surface-2); padding: 2px 6px; border-radius: var(--cn-r-sm); color: var(--cn-text); }
hr { border: 0; border-top: 1px solid var(--cn-border); margin: var(--cn-sp-6) 0; }
::selection { background: var(--cn-primary-soft); color: var(--cn-text); }

/* Focus rings — visible keyboard focus everywhere */
*:focus-visible {
  outline: 2px solid var(--cn-primary);
  outline-offset: 2px;
  border-radius: var(--cn-r-sm);
}

/* ============================================================
 *  4. LAYOUT PRIMITIVES
 * ============================================================ */
.cn-shell { max-width: 1280px; margin: 0 auto; padding: var(--cn-sp-6); }
.cn-stack-xs > * + * { margin-top: var(--cn-sp-2); }
.cn-stack-sm > * + * { margin-top: var(--cn-sp-3); }
.cn-stack    > * + * { margin-top: var(--cn-sp-4); }
.cn-stack-lg > * + * { margin-top: var(--cn-sp-6); }
.cn-row { display: flex; align-items: center; gap: var(--cn-sp-3); flex-wrap: wrap; }
.cn-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--cn-sp-3); flex-wrap: wrap; }
.cn-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--cn-sp-4); }
.cn-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--cn-sp-4); }
.cn-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--cn-sp-4); }
.cn-grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--cn-sp-4); }
@media (max-width: 880px) {
  .cn-grid-2, .cn-grid-3, .cn-grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
 *  5. COMPONENTS
 * ============================================================ */

/* --- Buttons --- */
.cn-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--cn-sp-2);
  padding: var(--cn-sp-2) var(--cn-sp-4);
  min-height: 36px;
  font-size: var(--cn-fs-sm);
  font-weight: 500;
  color: var(--cn-text);
  background: var(--cn-surface);
  border: 1px solid var(--cn-border-strong);
  border-radius: var(--cn-r-md);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.cn-btn:hover { background: var(--cn-surface-2); border-color: var(--cn-text-muted); text-decoration: none; }
.cn-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cn-btn-primary { background: var(--cn-primary); color: #fff; border-color: var(--cn-primary); }
.cn-btn-primary:hover { background: var(--cn-primary-hover); border-color: var(--cn-primary-hover); color: #fff; }
.cn-btn-danger { background: var(--cn-danger); color: #fff; border-color: var(--cn-danger); }
.cn-btn-danger:hover { background: #991b1b; border-color: #991b1b; color: #fff; }
.cn-btn-ghost { background: transparent; border-color: transparent; color: var(--cn-text); }
.cn-btn-ghost:hover { background: var(--cn-surface-2); }
.cn-btn-sm { min-height: 28px; padding: var(--cn-sp-1) var(--cn-sp-3); font-size: var(--cn-fs-xs); }
.cn-btn-lg { min-height: 44px; padding: var(--cn-sp-3) var(--cn-sp-6); font-size: var(--cn-fs-md); }

/* --- Cards --- */
.cn-card {
  background: var(--cn-surface);
  border: 1px solid var(--cn-border);
  border-radius: var(--cn-r-lg);
  padding: var(--cn-sp-5);
  box-shadow: var(--cn-shadow-sm);
}
.cn-card-header { margin-bottom: var(--cn-sp-4); display: flex; align-items: center; justify-content: space-between; gap: var(--cn-sp-3); flex-wrap: wrap; }
.cn-card-title { font-size: var(--cn-fs-lg); font-weight: 600; color: var(--cn-text); margin: 0; }
.cn-card-subtitle { font-size: var(--cn-fs-sm); color: var(--cn-text-muted); margin: 4px 0 0; }

/* --- KPI tiles --- */
.cn-kpi { background: var(--cn-surface); border: 1px solid var(--cn-border); border-radius: var(--cn-r-lg); padding: var(--cn-sp-4) var(--cn-sp-5); }
.cn-kpi-label { font-size: var(--cn-fs-xs); color: var(--cn-text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; margin-bottom: 6px; }
.cn-kpi-value { font-size: var(--cn-fs-3xl); font-weight: 600; color: var(--cn-text); line-height: 1.2; }
.cn-kpi-trend { font-size: var(--cn-fs-xs); color: var(--cn-text-muted); margin-top: 4px; }
.cn-kpi-trend.up { color: var(--cn-success); }
.cn-kpi-trend.down { color: var(--cn-danger); }

/* --- Inputs --- */
.cn-input, .cn-select, .cn-textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: var(--cn-fs-md);
  font-family: inherit;
  line-height: 1.4;
  color: var(--cn-text);
  background: var(--cn-surface);
  border: 1px solid var(--cn-border-strong);
  border-radius: var(--cn-r-md);
  min-height: 36px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cn-input:focus, .cn-select:focus, .cn-textarea:focus {
  outline: none;
  border-color: var(--cn-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}
.cn-input::placeholder { color: var(--cn-text-faint); }
.cn-label { display: block; font-size: var(--cn-fs-sm); font-weight: 500; color: var(--cn-text); margin-bottom: 6px; }
.cn-help { font-size: var(--cn-fs-xs); color: var(--cn-text-muted); margin-top: 4px; }

/* --- Tables --- */
.cn-table { width: 100%; background: var(--cn-surface); border: 1px solid var(--cn-border); border-radius: var(--cn-r-lg); overflow: hidden; box-shadow: var(--cn-shadow-sm); }
.cn-table table { width: 100%; }
.cn-table th, .cn-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--cn-fs-sm);
  border-bottom: 1px solid var(--cn-border);
  vertical-align: middle;
}
.cn-table th {
  font-size: var(--cn-fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  color: var(--cn-text-muted);
  background: var(--cn-surface-2);
  border-bottom-color: var(--cn-border-strong);
}
.cn-table tbody tr:last-child td { border-bottom: 0; }
.cn-table tbody tr:hover { background: var(--cn-surface-2); }
.cn-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cn-table .nowrap { white-space: nowrap; }
.cn-table-empty { padding: var(--cn-sp-12); text-align: center; color: var(--cn-text-muted); }

/* --- Badges --- */
.cn-badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  font-size: var(--cn-fs-xs);
  font-weight: 500;
  background: var(--cn-surface-2);
  color: var(--cn-text);
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
}
.cn-badge-success { background: var(--cn-success-soft); color: var(--cn-success); }
.cn-badge-warning { background: var(--cn-warning-soft); color: var(--cn-warning); }
.cn-badge-danger  { background: var(--cn-danger-soft); color: var(--cn-danger); }
.cn-badge-primary { background: var(--cn-primary-soft); color: var(--cn-primary); }

/* --- Alerts --- */
.cn-alert { padding: var(--cn-sp-3) var(--cn-sp-4); border-radius: var(--cn-r-md); font-size: var(--cn-fs-sm); border: 1px solid; }
.cn-alert-info    { background: var(--cn-primary-soft); border-color: #bfdbfe; color: var(--cn-primary); }
.cn-alert-success { background: var(--cn-success-soft); border-color: #a7f3d0; color: var(--cn-success); }
.cn-alert-warning { background: var(--cn-warning-soft); border-color: #fde68a; color: var(--cn-warning); }
.cn-alert-danger  { background: var(--cn-danger-soft); border-color: #fecaca; color: var(--cn-danger); }

/* --- Empty state --- */
.cn-empty {
  text-align: center;
  padding: var(--cn-sp-12) var(--cn-sp-6);
  color: var(--cn-text-muted);
}
.cn-empty h3 { color: var(--cn-text); margin-bottom: 8px; font-size: var(--cn-fs-lg); }

/* ============================================================
 *  6. APP SHELL (sidebar + topbar + main)
 * ============================================================ */
body.cn-v3-shell {
  margin: 0;
  background: var(--cn-page);
}
body.cn-v3-shell > #cn-shell-v3 {
  display: grid;
  grid-template-columns: var(--cn-sidebar-w) 1fr;
  grid-template-rows: var(--cn-topbar-h) 1fr;
  min-height: 100vh;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
}

/* Sidebar */
#cn-sidebar-v3 {
  grid-area: sidebar;
  background: #0f172a;          /* deep navy */
  color: #cbd5e1;
  padding: var(--cn-sp-5) 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1e293b;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
#cn-sidebar-v3 .brand {
  padding: 0 var(--cn-sp-5) var(--cn-sp-5);
  border-bottom: 1px solid #1e293b;
  margin-bottom: var(--cn-sp-3);
}
#cn-sidebar-v3 .brand-mark {
  font-size: var(--cn-fs-lg);
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}
#cn-sidebar-v3 .brand-tag {
  font-size: var(--cn-fs-xs);
  color: #64748b;
  margin-top: 2px;
}
#cn-sidebar-v3 .section-label {
  padding: var(--cn-sp-3) var(--cn-sp-5) var(--cn-sp-1);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 600;
}
#cn-sidebar-v3 .nav-item {
  display: flex;
  align-items: center;
  gap: var(--cn-sp-3);
  padding: 8px var(--cn-sp-5);
  font-size: var(--cn-fs-sm);
  color: #cbd5e1;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
#cn-sidebar-v3 .nav-item:hover { background: #1e293b; color: #fff; text-decoration: none; }
#cn-sidebar-v3 .nav-item.active { background: #1e293b; color: #fff; border-left-color: var(--cn-primary); font-weight: 500; }
#cn-sidebar-v3 .nav-item .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  color: #94a3b8;
}
#cn-sidebar-v3 .nav-item.active .ico { color: #fff; }
#cn-sidebar-v3 .footer {
  margin-top: auto;
  padding: var(--cn-sp-4) var(--cn-sp-5);
  border-top: 1px solid #1e293b;
  font-size: var(--cn-fs-xs);
  color: #64748b;
}
#cn-sidebar-v3 .footer .user-name { color: #e2e8f0; font-weight: 500; font-size: var(--cn-fs-sm); }
#cn-sidebar-v3 .footer .signout { color: #94a3b8; text-decoration: none; margin-top: 6px; display: inline-block; }
#cn-sidebar-v3 .footer .signout:hover { color: #fff; text-decoration: underline; }

/* Topbar */
#cn-topbar-v3 {
  grid-area: topbar;
  background: var(--cn-surface);
  border-bottom: 1px solid var(--cn-border);
  padding: 0 var(--cn-sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cn-sp-4);
  position: sticky;
  top: 0;
  z-index: 50;
}
#cn-topbar-v3 .crumbs { font-size: var(--cn-fs-sm); color: var(--cn-text-muted); display: flex; align-items: center; gap: 6px; }
#cn-topbar-v3 .crumbs a { color: var(--cn-text-muted); }
#cn-topbar-v3 .crumbs a:hover { color: var(--cn-text); }
#cn-topbar-v3 .crumbs .sep { color: var(--cn-text-faint); }
#cn-topbar-v3 .crumbs .here { color: var(--cn-text); font-weight: 500; }
#cn-topbar-v3 .actions { display: flex; align-items: center; gap: var(--cn-sp-3); }
#cn-topbar-v3 .actions .icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--cn-r-md);
  color: var(--cn-text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}
#cn-topbar-v3 .actions .icon-btn:hover { background: var(--cn-surface-2); color: var(--cn-text); }

/* Main */
#cn-main-v3 {
  grid-area: main;
  padding: var(--cn-sp-6);
  min-width: 0;          /* allow shrinking inside grid */
  overflow-x: auto;
}
#cn-main-v3 > .cn-shell { padding: 0; }   /* shell already padded by main */

.cn-page-header { margin-bottom: var(--cn-sp-6); }
.cn-page-title { font-size: var(--cn-fs-3xl); margin: 0; }
.cn-page-subtitle { font-size: var(--cn-fs-md); color: var(--cn-text-muted); margin-top: 6px; }

/* Mobile: collapse sidebar */
@media (max-width: 880px) {
  body.cn-v3-shell > #cn-shell-v3 {
    grid-template-columns: 1fr;
    grid-template-rows: var(--cn-topbar-h) 1fr;
    grid-template-areas: "topbar" "main";
  }
  #cn-sidebar-v3 {
    position: fixed;
    left: -240px;
    transition: left 0.2s;
    z-index: 100;
    height: 100vh;
    width: var(--cn-sidebar-w);
  }
  body.cn-sidebar-open #cn-sidebar-v3 { left: 0; box-shadow: var(--cn-shadow-lg); }
  body.cn-sidebar-open::before { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
  .cn-mobile-toggle { display: inline-flex !important; }
}
.cn-mobile-toggle { display: none; }

/* ============================================================
 *  7. HIDE / NEUTRALIZE OLD CHROME (so v3 shell takes over cleanly)
 * ============================================================ */
body.cn-v3-shell .v3-header,
body.cn-v3-shell .topnav,
body.cn-v3-shell #cn-topbar-v2,
body.cn-v3-shell .cn-skip-link-v2,
body.cn-v3-shell #cn-gs-floater,
body.cn-v3-shell #cn-org-switcher,
body.cn-v3-shell #cn-trial-banner,
body.cn-v3-shell #cn-demo-banner,
body.cn-v3-shell .v3-page-marker {
  display: none !important;
}

/* Don't let injected brand.css repaint inputs/cards weird */
body.cn-v3-shell input, body.cn-v3-shell select, body.cn-v3-shell textarea {
  color: var(--cn-text) !important;
  background: var(--cn-surface) !important;
}

/* ============================================================
 *  8. UTILITIES
 * ============================================================ */
.cn-muted { color: var(--cn-text-muted); }
.cn-faint { color: var(--cn-text-faint); }
.cn-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.cn-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cn-break { overflow-wrap: anywhere; word-break: break-word; }
.cn-hidden { display: none !important; }
.cn-mt-0 { margin-top: 0 !important; }
.cn-mt-2 { margin-top: var(--cn-sp-2); }
.cn-mt-4 { margin-top: var(--cn-sp-4); }
.cn-mt-6 { margin-top: var(--cn-sp-6); }
.cn-mt-8 { margin-top: var(--cn-sp-8); }
.cn-text-xs { font-size: var(--cn-fs-xs); }
.cn-text-sm { font-size: var(--cn-fs-sm); }
.cn-text-lg { font-size: var(--cn-fs-lg); }
.cn-text-2xl { font-size: var(--cn-fs-2xl); }


/* ============================================================
 *  9. WAVE-95 HARDENING (BURST_1037_HARDEN)
 *  Real visual problems found by inspection:
 *  - Floating "AI JOB COACH" widget overlapping content
 *  - Right-edge clipping on /home-v3 legacy tile rows
 *  - Dark-on-dark text in legacy "Operations" and "Recent Estimates"
 * ============================================================ */

/* Kill every known floater that overlays content */
body.cn-v3-shell #cn-ai-coach,
body.cn-v3-shell .ai-coach,
body.cn-v3-shell .cn-ai-coach,
body.cn-v3-shell #cn-job-coach,
body.cn-v3-shell .job-coach,
body.cn-v3-shell .v3-coach-card,
body.cn-v3-shell .floating-coach,
body.cn-v3-shell [class*="job-coach"],
body.cn-v3-shell [id*="job-coach"],
body.cn-v3-shell [class*="ai-coach"],
body.cn-v3-shell [id*="ai-coach"] {
  display: none !important;
}

/* Force the main area to clip rather than horizontally scroll the whole page */
body.cn-v3-shell { overflow-x: hidden !important; }
body.cn-v3-shell #cn-main-v3 {
  overflow-x: hidden !important;
  min-width: 0;
}

/* Anything inside main with explicit fixed width past viewport: cap it */
body.cn-v3-shell #cn-main-v3 .v3-tile-row,
body.cn-v3-shell #cn-main-v3 .v3-row,
body.cn-v3-shell #cn-main-v3 .v3-grid,
body.cn-v3-shell #cn-main-v3 .ops-row,
body.cn-v3-shell #cn-main-v3 .workflow-outline,
body.cn-v3-shell #cn-main-v3 .recent-estimates,
body.cn-v3-shell #cn-main-v3 [class*="grid"] {
  max-width: 100% !important;
  flex-wrap: wrap !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 12px !important;
}

/* Force readable contrast on dark legacy tiles — text becomes white,
 * subtitle becomes light gray. Cards keep their dark bg. */
body.cn-v3-shell .tile,
body.cn-v3-shell .ops-tile,
body.cn-v3-shell .op-tile,
body.cn-v3-shell .estimate-tile,
body.cn-v3-shell .workflow-step,
body.cn-v3-shell [style*="background:#0e1116"],
body.cn-v3-shell [style*="background:#11151c"],
body.cn-v3-shell [style*="background: #0e1116"],
body.cn-v3-shell [style*="background:#0F172A"],
body.cn-v3-shell [class*="dark-tile"] {
  color: #f1f5f9 !important;
}
body.cn-v3-shell .tile p,
body.cn-v3-shell .tile .sub,
body.cn-v3-shell .ops-tile p,
body.cn-v3-shell .estimate-tile .sub,
body.cn-v3-shell .workflow-step p {
  color: #cbd5e1 !important;
}

/* For dim text WITHOUT a dark backdrop (e.g. "This is the office control surface...") 
 * lift contrast against white page bg */
body.cn-v3-shell #cn-main-v3 .lede,
body.cn-v3-shell #cn-main-v3 .sub,
body.cn-v3-shell #cn-main-v3 p.muted,
body.cn-v3-shell #cn-main-v3 p[style*="color:#"] {
  color: #475569 !important;
}

/* The "operations" eyebrow + subtitle were illegible — force solid */
body.cn-v3-shell #cn-main-v3 .eyebrow,
body.cn-v3-shell #cn-main-v3 [class*="eyebrow"] {
  color: #64748b !important;
  font-weight: 600 !important;
}

/* If the legacy page hardcodes a sticky header at top:0, push it under the topbar */
body.cn-v3-shell #cn-main-v3 .v3-header,
body.cn-v3-shell #cn-main-v3 [class*="sticky"] { top: var(--cn-topbar-h) !important; }


/* ============================================================
 *  10. WAVE-96 VALIDATION PASS  (BURST_1038_HARDEN_PAGES)
 * ============================================================ */

/* (b) Legacy class aliases — /carriers uses .wrap/.crumb/.sub/.card/.badge
 *     map them to v3 components so the page stops looking jumbled */
body.cn-v3-shell .wrap { max-width: 1280px; margin: 0; padding: 0; }
body.cn-v3-shell .crumb { font-size: 13px; color: #6b7280; margin-bottom: 8px; }
body.cn-v3-shell .crumb a { color: #6b7280; }
body.cn-v3-shell .sub { color: #6b7280; font-size: 14px; margin-top: 4px; margin-bottom: 20px; }
body.cn-v3-shell .card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.05);
  overflow: hidden;
}
body.cn-v3-shell .card > table { width: 100%; }
body.cn-v3-shell .card table th { background: #f4f5f7; padding: 10px 14px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; font-weight: 500; border-bottom: 1px solid #e5e7eb; }
body.cn-v3-shell .card table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; font-size: 13px; vertical-align: middle; }
body.cn-v3-shell .card table .num { text-align: right; font-variant-numeric: tabular-nums; }
body.cn-v3-shell .card table .carrier-name { color: #1e40af; font-weight: 500; }
body.cn-v3-shell .badge {
  display: inline-block;
  padding: 2px 10px;
  background: #f4f5f7;
  color: #111827;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
body.cn-v3-shell .badge.internal { background: #fffbeb; color: #b45309; }
body.cn-v3-shell .badge.submitted { background: #eff6ff; color: #1e40af; }
body.cn-v3-shell .badge.approved { background: #ecfdf5; color: #047857; }

/* (c) Project detail page lives inside index.html — force light bg + readable text */
body.cn-v3-shell .page, body.cn-v3-shell .project-page, body.cn-v3-shell main > .container {
  background: var(--cn-page) !important;
  color: var(--cn-text) !important;
}
body.cn-v3-shell .panel {
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  padding: 20px !important;
  margin-bottom: 16px !important;
  box-shadow: 0 1px 2px rgba(16,24,40,0.05) !important;
}
body.cn-v3-shell .panel h2, body.cn-v3-shell .panel h3, body.cn-v3-shell .panel .panel-topline { color: #111827 !important; }
body.cn-v3-shell .panel-topline .eyebrow { color: #6b7280 !important; }
body.cn-v3-shell .room, body.cn-v3-shell .scope-item, body.cn-v3-shell .estimate-row {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
  color: #111827 !important;
}

/* Inputs and selects inside legacy templates */
body.cn-v3-shell input[type="text"],
body.cn-v3-shell input[type="number"],
body.cn-v3-shell input[type="email"],
body.cn-v3-shell input[type="tel"],
body.cn-v3-shell input[type="date"],
body.cn-v3-shell input[type="search"],
body.cn-v3-shell input[type="url"],
body.cn-v3-shell textarea,
body.cn-v3-shell select {
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #d1d5db !important;
  border-radius: 6px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  min-height: 36px !important;
}

/* Page-wide text shouldn't be light-on-light or dark-on-dark anymore */
body.cn-v3-shell #cn-main-v3 * { -webkit-text-fill-color: initial !important; }
body.cn-v3-shell #cn-main-v3 [style*="color:#0a0a"],
body.cn-v3-shell #cn-main-v3 [style*="color:#111"],
body.cn-v3-shell #cn-main-v3 [style*="color: #111"],
body.cn-v3-shell #cn-main-v3 [style*="color:#222"],
body.cn-v3-shell #cn-main-v3 [style*="color: #222"] {
  color: #111827 !important;
}

/* (d) The previous "kill all coaches" rule was too aggressive. Relax: don't hide the
 * AI coach card itself, just take it out of the floating overlay. Let it live in
 * main content flow with normal positioning. */
body.cn-v3-shell #cn-ai-coach,
body.cn-v3-shell .ai-coach,
body.cn-v3-shell .cn-ai-coach,
body.cn-v3-shell #cn-job-coach,
body.cn-v3-shell .job-coach,
body.cn-v3-shell .v3-coach-card,
body.cn-v3-shell .floating-coach,
body.cn-v3-shell [class*="job-coach"],
body.cn-v3-shell [id*="job-coach"],
body.cn-v3-shell [class*="ai-coach"],
body.cn-v3-shell [id*="ai-coach"] {
  display: block !important;
  position: static !important;
  bottom: auto !important; right: auto !important; top: auto !important; left: auto !important;
  margin-top: 12px;
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  padding: 16px !important;
  max-width: 100% !important;
}


/* ============================================================
 *  11. BURST_1038B — FORCE LIGHT BG (kills legacy --cn-color-panel dark bleed)
 * ============================================================ */
html, body, body.cn-v3-shell {
  background: #f7f8fa !important;
}
body.cn-v3-shell #cn-main-v3 {
  background: #f7f8fa !important;
  color: #111827 !important;
}
/* Override legacy CSS variables that were assumed dark */
body.cn-v3-shell {
  --cn-color-panel: #f4f5f7 !important;
  --cn-color-paper: #ffffff !important;
  --cn-color-ink: #111827 !important;
  --cn-color-ink-muted: #6b7280 !important;
  --cn-color-line: #e5e7eb !important;
  --cn-color-line-strong: #d1d5db !important;
}
/* Any element that hardcoded #0e1116/#111/#111827 as background must NOT
 * cover the whole page. We don't try to flip them — just stop them being
 * stuck to top-left absolute origins inside main content. */
body.cn-v3-shell #cn-main-v3 [style*="background:#111"],
body.cn-v3-shell #cn-main-v3 [style*="background: #111"] {
  background: #ffffff !important;
  color: #111827 !important;
}


/* ============================================================
 *  12. WAVE-97 POLISH (BURST_1039_POLISH_CSS)
 * ============================================================ */

/* Module tile component */
.cn-mod {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.08s;
}
.cn-mod:hover {
  border-color: #c7d2fe;
  box-shadow: 0 4px 6px -1px rgba(16,24,40,0.07), 0 2px 4px -2px rgba(16,24,40,0.05);
  text-decoration: none;
  transform: translateY(-1px);
}
.cn-mod-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.cn-mod-title {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  line-height: 1.3;
}
.cn-mod-sub {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
  line-height: 1.45;
}

/* AI coach card */
.cn-ai-coach-v3 {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e0e7ff;
}
.cn-coach-tip {
  font-size: 13px;
  color: #374151;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #1d4ed8;
  border-radius: 4px;
}

/* Workflow stage cards */
.cn-flow-step { position: relative; }
.cn-flow-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
}

/* KPI tiles — tint the value text differently per kind via small variants */
.cn-kpi {
  position: relative;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cn-kpi:hover {
  border-color: #c7d2fe;
  box-shadow: 0 1px 3px rgba(16,24,40,0.06);
}
.cn-kpi-value { letter-spacing: -0.02em; }

/* Status badge color polish — bigger color contrast */
.cn-badge,
body.cn-v3-shell .cn-badge {
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 3px 10px;
}
.cn-badge-success, body.cn-v3-shell .cn-badge-success { background: #d1fae5; color: #065f46; }
.cn-badge-warning, body.cn-v3-shell .cn-badge-warning { background: #fef3c7; color: #92400e; }
.cn-badge-danger,  body.cn-v3-shell .cn-badge-danger  { background: #fee2e2; color: #991b1b; }
.cn-badge-primary, body.cn-v3-shell .cn-badge-primary { background: #dbeafe; color: #1e40af; }

/* Active projects table — hover rows + first column emphasis */
.cn-table tbody tr:hover { background: #f8fafc; cursor: default; }
.cn-table tbody td a { font-weight: 500; color: #1e40af; }
.cn-table tbody td a:hover { color: #1e3a8a; text-decoration: underline; }

/* Page padding — tighten on wide screens */
body.cn-v3-shell #cn-main-v3 { padding: 28px 32px; max-width: 1280px; margin: 0 auto; }

/* Section header rhythm */
body.cn-v3-shell #cn-main-v3 h2 { margin-top: 32px; }
body.cn-v3-shell #cn-main-v3 h2:first-of-type { margin-top: 24px; }

/* Sidebar — clearer active state */
#cn-sidebar-v3 { background: #0f172a; color: #cbd5e1; }
#cn-sidebar-v3 .nav-item { color: #cbd5e1; font-size: 13px; font-weight: 400; }
#cn-sidebar-v3 .nav-item:hover { background: #1e293b; color: #ffffff; }
#cn-sidebar-v3 .nav-item.active {
  background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
  border-left-color: #60a5fa;
  color: #ffffff;
  font-weight: 500;
}
#cn-sidebar-v3 .brand-mark { color: #ffffff; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
#cn-sidebar-v3 .brand-tag { color: #64748b; font-size: 11px; margin-top: 3px; }
#cn-sidebar-v3 .section-label { color: #475569; font-size: 10px; letter-spacing: 0.08em; padding-top: 18px; }

/* On mobile, modules grid becomes one column with AI coach below */
@media (max-width: 880px) {
  body.cn-v3-shell #cn-main-v3 > div.cn-grid { grid-template-columns: 1fr !important; }
}


/* ============================================================
 *  13. WAVE-98 DASHBOARD COMPONENTS  (BURST_1040_DASH_CSS)
 * ============================================================ */

/* -- Hero -- */
.cn-hero {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.cn-hero-left {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  border-radius: 14px;
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
}
.cn-hero-left::after {
  content: "";
  position: absolute;
  right: -50px;
  top: -50px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96,165,250,0.18), transparent 70%);
  pointer-events: none;
}
.cn-hero-eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-weight: 500;
}
.cn-hero-title {
  font-size: 32px;
  color: #ffffff;
  margin: 4px 0 8px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.cn-hero-summary {
  font-size: 15px;
  color: #cbd5e1;
  line-height: 1.5;
  margin: 0 0 22px;
}
.cn-hero-kpis {
  display: flex;
  align-items: stretch;
  gap: 18px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.cn-hk { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.cn-hk-num { font-size: 22px; color: #ffffff; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; }
.cn-hk-lbl { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; }
.cn-hk-sep { width: 1px; background: rgba(148, 163, 184, 0.18); }
.cn-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cn-hero-actions .cn-btn {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  color: #ffffff;
}
.cn-hero-actions .cn-btn:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); }
.cn-hero-actions .cn-btn-primary {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}
.cn-hero-actions .cn-btn-primary:hover { background: #2563eb; border-color: #2563eb; }

/* -- Hero right (AI coach) -- */
.cn-hero-right { display: flex; flex-direction: column; }
.cn-coach-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e0e7ff;
  border-radius: 14px;
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.cn-coach-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cn-coach-ico {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cn-coach-title { font-weight: 600; font-size: 14px; color: #111827; }
.cn-coach-sub { font-size: 12px; color: #6b7280; }
.cn-coach-tips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.cn-coach-tip {
  font-size: 12px;
  color: #475569;
  padding: 8px 10px;
  background: #f1f5f9;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
}
.cn-coach-form { display: flex; gap: 6px; }
.cn-coach-form .cn-input { flex: 1; min-height: 32px; padding: 6px 10px; font-size: 13px; }
.cn-coach-form .cn-btn { padding: 6px 12px; font-size: 13px; min-height: 32px; }
.cn-coach-answer { margin-top: 10px; font-size: 13px; color: #374151; min-height: 18px; }

/* -- Section block -- */
.cn-section {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.cn-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.cn-section-title { font-size: 17px; font-weight: 600; color: #111827; margin: 0; }
.cn-section-sub { font-size: 13px; color: #6b7280; margin: 4px 0 0; }

/* -- Pipeline -- */
.cn-pipeline {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
.cn-pipe-col {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
}
.cn-pipe-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.cn-pipe-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cn-pipe-name { font-size: 11px; color: #475569; font-weight: 500; }
.cn-pipe-num { font-size: 22px; font-weight: 600; color: #111827; line-height: 1.1; margin: 2px 0 6px; }
.cn-pipe-bar { height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.cn-pipe-fill { height: 100%; transition: width 0.3s; }

/* -- Project cards -- */
.cn-proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.cn-proj-card {
  display: block;
  text-decoration: none;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  position: relative;
  transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.cn-proj-card:hover {
  border-color: #c7d2fe;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(16,24,40,0.07);
  text-decoration: none;
}
.cn-proj-status { position: absolute; top: 12px; right: 12px; }
.cn-proj-title {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  line-height: 1.35;
  margin-bottom: 4px;
  padding-right: 80px; /* room for status badge */
}
.cn-proj-client { font-size: 13px; color: #6b7280; margin-bottom: 2px; }
.cn-proj-addr { font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.cn-proj-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #6b7280;
  border-top: 1px solid #f3f4f6;
  padding-top: 10px;
  margin-top: 10px;
}
.cn-proj-claim { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.cn-proj-date { font-variant-numeric: tabular-nums; }

/* -- Two-column section (activity + workflow side by side) -- */
.cn-two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

/* -- Activity feed -- */
.cn-act-list { display: flex; flex-direction: column; gap: 0; }
.cn-act-row {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}
.cn-act-row:last-child { border-bottom: 0; }
.cn-act-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3b82f6;
  margin-top: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
}
.cn-act-event { font-size: 13px; color: #111827; font-weight: 500; }
.cn-act-meta { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* -- Workflow list -- */
.cn-flow { list-style: none; padding: 0; margin: 0; }
.cn-flow li {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  color: #374151;
}
.cn-flow li:last-child { border-bottom: 0; }
.cn-flow-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #eff6ff;
  color: #1e40af;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

/* -- Responsive -- */
@media (max-width: 1100px) {
  .cn-hero { grid-template-columns: 1fr; }
  .cn-two-col { grid-template-columns: 1fr; }
  .cn-pipeline { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 720px) {
  .cn-hero-kpis { flex-direction: column; gap: 12px; }
  .cn-hk-sep { display: none; }
  .cn-pipeline { grid-template-columns: repeat(2, 1fr); }
}


/* ============================================================
 *  14. WAVE-99 — MODERN ENTERPRISE SIDEBAR  (BURST_1041_SIDEBAR_MODERN)
 *  Goals: subtle gradient, icons aligned, hover glow, primary CTA,
 *  search box, organized sections, user card at bottom with avatar.
 * ============================================================ */

#cn-sidebar-v3 {
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 60%, #111827 100%) !important;
  color: #cbd5e1;
  border-right: 1px solid rgba(148, 163, 184, 0.08);
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  width: var(--cn-sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.2) transparent;
}
#cn-sidebar-v3::-webkit-scrollbar { width: 6px; }
#cn-sidebar-v3::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.2); border-radius: 3px; }

/* Top section: brand + CTA + search */
#cn-sidebar-v3 .sb-top {
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(148,163,184,0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#cn-sidebar-v3 .sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
#cn-sidebar-v3 .sb-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}
#cn-sidebar-v3 .sb-brand-name {
  color: #f1f5f9;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
#cn-sidebar-v3 .sb-brand-tag {
  color: #64748b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* CTA button */
#cn-sidebar-v3 .sb-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, box-shadow 0.15s;
}
#cn-sidebar-v3 .sb-cta:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
#cn-sidebar-v3 .sb-cta svg { stroke: #ffffff; }

/* Search box */
#cn-sidebar-v3 .sb-search {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  padding: 0 10px;
  transition: border-color 0.12s, background 0.12s;
}
#cn-sidebar-v3 .sb-search:hover { border-color: rgba(148, 163, 184, 0.2); background: rgba(255, 255, 255, 0.06); }
#cn-sidebar-v3 .sb-search:focus-within {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
#cn-sidebar-v3 .sb-search svg { color: #64748b; flex-shrink: 0; }
#cn-sidebar-v3 .sb-search input {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: #e2e8f0 !important;
  font-size: 13px !important;
  padding: 8px 8px 8px 8px !important;
  width: 100%;
  min-height: auto !important;
  flex: 1;
}
#cn-sidebar-v3 .sb-search input::placeholder { color: #64748b; }

/* Nav groups */
#cn-sidebar-v3 .sb-nav {
  flex: 1;
  padding: 8px 0 20px;
  overflow-y: auto;
}
#cn-sidebar-v3 .sb-group { padding: 8px 0; }
#cn-sidebar-v3 .sb-group-label {
  padding: 6px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  font-weight: 600;
}

/* Nav items */
#cn-sidebar-v3 .nav-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 7px 16px !important;
  margin: 1px 8px;
  font-size: 13px;
  color: #cbd5e1 !important;
  border-left: 0 !important;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.1s, color 0.1s, transform 0.08s;
}
#cn-sidebar-v3 .nav-item:hover {
  background: rgba(148, 163, 184, 0.08) !important;
  color: #ffffff !important;
  text-decoration: none;
  transform: translateX(1px);
}
#cn-sidebar-v3 .nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.06)) !important;
  color: #ffffff !important;
  font-weight: 500;
  position: relative;
}
#cn-sidebar-v3 .nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: #3b82f6;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}
#cn-sidebar-v3 .nav-item .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #64748b;
  flex-shrink: 0;
}
#cn-sidebar-v3 .nav-item:hover .ico { color: #94a3b8; }
#cn-sidebar-v3 .nav-item.active .ico { color: #60a5fa; }

/* User card at bottom */
#cn-sidebar-v3 .sb-user {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
}
#cn-sidebar-v3 .sb-user-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
#cn-sidebar-v3 .sb-user-info { min-width: 0; flex: 1; }
#cn-sidebar-v3 .sb-user-name {
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#cn-sidebar-v3 .sb-user-link {
  color: #64748b;
  font-size: 11px;
  text-decoration: none;
}
#cn-sidebar-v3 .sb-user-link:hover { color: #94a3b8; text-decoration: underline; }

/* Hide old user footer if anything was left over */
#cn-sidebar-v3 .footer { display: none !important; }

/* Top bar adjustments — modernize the breadcrumb area */
#cn-topbar-v3 {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}
#cn-topbar-v3 .crumbs .here { color: #111827; font-weight: 600; }


/* ============================================================
 * BURST_143_RESPONSIVE_OVERRIDE — must come AFTER any duplicate
 * #cn-sidebar-v3 rule. The duplicate at line ~1087 sets
 * position:sticky which beats the @media block above by source
 * order. This block lives at end-of-file and uses !important to
 * decisively win.
 * ============================================================ */
@media (max-width: 880px) {
  body.cn-v3-shell > #cn-shell-v3 {
    display: block !important;
    grid-template-columns: 1fr !important;
    grid-template-areas: none !important;
  }
  #cn-sidebar-v3 {
    position: fixed !important;
    top: 0 !important;
    left: -260px !important;
    width: var(--cn-sidebar-w) !important;
    height: 100vh !important;
    z-index: 9000 !important;
    transition: left 0.22s cubic-bezier(.16,1,.3,1) !important;
    grid-area: unset !important;
  }
  body.cn-sidebar-open #cn-sidebar-v3 {
    left: 0 !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
  }
  body.cn-sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 8999;
    backdrop-filter: blur(2px);
  }
  #cn-topbar-v3 {
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  #cn-main-v3 {
    padding: 12px !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
  }
  /* Show hamburger; hide search button label on tiny widths */
  .cn-mobile-toggle { display: inline-flex !important; }
  #cn-topbar-v3 .cn-btn-sm { padding: 6px 10px !important; font-size: 12px !important; }
  /* Hide floating widgets that overlap on tiny screens */
  #cn-gs-floater, #cn-org-switcher { display: none !important; }
  /* Reduce hero/kpi gaps on tiny screens */
  body.cn-v3-shell .cn-hero { padding: 18px 16px !important; }
  body.cn-v3-shell .cn-pipeline { grid-template-columns: 1fr !important; }
  body.cn-v3-shell .cn-proj-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 881px) {
  /* Ensure mobile-only toggle stays hidden on desktop */
  .cn-mobile-toggle { display: none !important; }
}

/* Hamburger button styling */
.cn-mobile-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--cn-border, rgba(15,23,42,.08));
  color: var(--cn-text, #0f172a);
  cursor: pointer;
  margin-right: 8px;
  -webkit-tap-highlight-color: transparent;
}
.cn-mobile-toggle:active { transform: scale(.96); }
.cn-mobile-toggle svg { width: 18px; height: 18px; }

/* BURST_150_RESPONSIVE_TOOLTIPS */

/* ============================================================
 * BURST_150_RESPONSIVE_TOOLTIPS — mobile tables, chip sizing,
 * tooltip system. Append-only, end of file so it wins by source
 * order over older rules.
 * ============================================================ */

/* --- Responsive tables --- */
@media (max-width: 880px) {
  /* Every table inside main shell auto-wraps in horizontal scroll */
  #cn-main-v3 table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
    white-space: nowrap;
    border-collapse: collapse;
  }
  #cn-main-v3 table thead, #cn-main-v3 table tbody, #cn-main-v3 table tr {
    width: max-content;
    min-width: 100%;
  }
  /* Add a subtle scroll hint */
  #cn-main-v3 .cn-table-wrap, #cn-main-v3 [class*="-table"] {
    position: relative;
  }
  #cn-main-v3 .cn-table-wrap::after,
  #cn-main-v3 [class*="-table"]::after {
    content: "";
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(15,23,42,.05));
    pointer-events: none;
  }

  /* Kanban / pipeline — stack columns vertically on phone */
  body.cn-v3-shell .cn-pipeline,
  body.cn-v3-shell .cn-kanban,
  body.cn-v3-shell .cn-proj-grid,
  body.cn-v3-shell .cn-grid-3,
  body.cn-v3-shell .cn-grid-4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  body.cn-v3-shell .cn-pipe-col,
  body.cn-v3-shell .cn-kanban-col {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Force any deeply-nested fixed-width grids to shrink */
  body.cn-v3-shell #cn-main-v3 > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Inputs and selects should fill width */
  body.cn-v3-shell #cn-main-v3 input[type="text"],
  body.cn-v3-shell #cn-main-v3 input[type="email"],
  body.cn-v3-shell #cn-main-v3 input[type="search"],
  body.cn-v3-shell #cn-main-v3 select,
  body.cn-v3-shell #cn-main-v3 textarea {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* --- Touch-target floor (mobile only) --- */
@media (max-width: 880px) {
  .cn26-chip,
  .cn-chip,
  #cn-main-v3 .cn-btn,
  #cn-main-v3 .cn-btn-sm {
    min-height: 44px;
    padding-left: 14px !important;
    padding-right: 14px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  #cn-topbar-v3 .icon-btn,
  #cn-topbar-v3 .actions a,
  #cn-topbar-v3 .actions button {
    min-width: 44px;
    min-height: 44px;
  }
  #cn-main-v3 table td,
  #cn-main-v3 table th {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }
  /* Catalog category chips — primary touch-target offender */
  .cn26-chip {
    font-size: 14px !important;
    border-radius: 22px;
  }
}

/* --- CSS-only tooltip system ([data-tip]) --- */
[data-tip] {
  position: relative;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 10000;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 7px 11px;
  border-radius: 7px;
  font: 500 11px/1.35 ui-sans-serif,system-ui,sans-serif;
  letter-spacing: -.005em;
  white-space: nowrap;
  max-width: 280px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(15,23,42,.18), 0 2px 6px rgba(15,23,42,.12);
  animation: cn-tip-in .15s cubic-bezier(.16,1,.3,1);
}
[data-tip]:hover::before,
[data-tip]:focus-visible::before {
  content: "";
  position: absolute;
  z-index: 10000;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  border: 5px solid transparent;
  border-top-color: #0f172a;
  pointer-events: none;
}
/* Direction variants */
[data-tip-pos="right"]:hover::after,
[data-tip-pos="right"]:focus-visible::after {
  bottom: auto;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
}
[data-tip-pos="right"]:hover::before,
[data-tip-pos="right"]:focus-visible::before {
  bottom: auto;
  top: 50%;
  left: 100%;
  transform: translateY(-50%) translateX(2px);
  border-color: transparent;
  border-right-color: #0f172a;
}
[data-tip-pos="left"]:hover::after,
[data-tip-pos="left"]:focus-visible::after {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + 8px);
  transform: translateY(-50%);
}
[data-tip-pos="left"]:hover::before,
[data-tip-pos="left"]:focus-visible::before {
  bottom: auto;
  top: 50%;
  left: auto;
  right: 100%;
  transform: translateY(-50%) translateX(-2px);
  border-color: transparent;
  border-left-color: #0f172a;
}
[data-tip-pos="bottom"]:hover::after,
[data-tip-pos="bottom"]:focus-visible::after {
  bottom: auto;
  top: calc(100% + 8px);
}
[data-tip-pos="bottom"]:hover::before,
[data-tip-pos="bottom"]:focus-visible::before {
  bottom: auto;
  top: 100%;
  border-color: transparent;
  border-bottom-color: #0f172a;
  transform: translateX(-50%) translateY(-2px);
}
/* Wide variant for longer descriptions */
[data-tip-wide]:hover::after,
[data-tip-wide]:focus-visible::after {
  white-space: normal;
  width: 240px;
  max-width: 240px;
  text-align: left;
  line-height: 1.45;
}
@keyframes cn-tip-in {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* Disable tooltips on touch devices (no hover anyway, but avoids long-press flash) */
@media (hover: none) {
  [data-tip]:hover::after,
  [data-tip]:hover::before,
  [data-tip]:focus-visible::after,
  [data-tip]:focus-visible::before {
    display: none;
  }
}

/* BURST_152_DRAGDROP — drag-drop overhaul */
.cn-sortable { cursor: grab; transition: opacity .12s ease, transform .12s ease, box-shadow .12s ease; }
.cn-sortable:active { cursor: grabbing; }
.cn-dragging { opacity: 0.4; transform: scale(0.985); }
[data-cn-sort-url] {
  /* Hint that the container holds sortable items */
}
.cn-filedrop { position: relative; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.cn-filedrop-hover {
  background: rgba(124, 107, 255, 0.06) !important;
  outline: 2px dashed rgba(124, 107, 255, 0.55);
  outline-offset: -4px;
  box-shadow: inset 0 0 0 1px rgba(124,107,255,0.18);
}
.cn-filedrop-hover::before {
  content: "Drop to upload";
  position: absolute;
  inset: 50% 0 auto 0;
  transform: translateY(-50%);
  text-align: center;
  font: 600 13px/1.3 ui-sans-serif,system-ui,sans-serif;
  color: #5b4cf0;
  letter-spacing: -.01em;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255,255,255,0.9);
}
.cn-chip-draggable {
  cursor: grab;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
  user-select: none;
}
.cn-chip-draggable:active { cursor: grabbing; }
.cn-chip-target {
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.cn-chip-target-hover {
  background: rgba(124,107,255,0.08) !important;
  outline: 2px dashed rgba(124,107,255,0.55);
  outline-offset: -4px;
}

/* Sort-handle treatment if a child uses .cn-drag-handle */
.cn-drag-handle {
  cursor: grab;
  color: rgba(15,23,42,0.42);
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cn-drag-handle:hover { color: rgba(15,23,42,0.78); }
.cn-drag-handle::before {
  content: "\2261";   /* ≡ glyph as fallback drag handle */
  font-size: 18px; line-height: 1;
}

@media (hover: none) {
  /* On touch devices, fall back to long-press semantics — hide the grab cursor */
  .cn-sortable { cursor: default; }
  .cn-chip-draggable { cursor: default; }
}
