/*
  Leadwise CRM demo styles

  How this file is organised:
  1. Fonts and design tokens (colors, type scale, spacing) for light and dark
  2. Base and accessibility helpers
  3. Layout (sidebar, top bar, page grid)
  4. Components (buttons, cards, charts, table, toasts)
  5. Motion and responsive rules

  Colors never appear outside the token block, so a theme change only
  ever touches one place. Every text and background pair was checked
  against WCAG AA contrast (4.5:1 for text, 3:1 for graphics).
*/

/* 1. Fonts and tokens ---------------------------------------------------- */

/* Inter is self hosted so the page makes no third party requests. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* A metric matched fallback keeps text from jumping when Inter finishes loading. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.4%;
  ascent-override: 90.2%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light;

  --font: "Inter", "Inter Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Type scale. Nothing on the page is smaller than 13px. */
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-h1: clamp(1.75rem, 1.35rem + 1.6vw, 2.5rem);
  --fs-stat: clamp(2rem, 1.7rem + 0.9vw, 2.5rem);

  --sidebar-w: 17rem;
  --radius-sm: 0.625rem;
  --radius: 0.875rem;
  --radius-lg: 1.125rem;

  /* Light theme */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --border: #e3e7ef;
  --border-strong: #cfd6e4;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #546178;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #4338ca;
  --accent-soft: #eef0ff;
  --focus: #4f46e5;
  --danger-dot: #e11d48;
  --scrim: rgb(15 23 42 / 0.45);

  --c-blue: #2563eb;
  --c-violet: #7c3aed;
  --c-green: #059669;
  --c-amber: #d97706;
  --grid-line: #e9edf4;

  --chip-blue-fg: #1d4ed8;   --chip-blue-bg: #e0e9ff;
  --chip-violet-fg: #6d28d9; --chip-violet-bg: #ede7fe;
  --chip-green-fg: #047857;  --chip-green-bg: #d8f5e8;
  --chip-amber-fg: #9a4a04;  --chip-amber-bg: #fdeccf;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow: 0 1px 3px rgb(15 23 42 / 0.06), 0 8px 24px -12px rgb(15 23 42 / 0.12);
  --shadow-lg: 0 2px 6px rgb(15 23 42 / 0.06), 0 18px 36px -14px rgb(15 23 42 / 0.2);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1120;
  --surface: #121a2e;
  --surface-2: #18223a;
  --border: #243049;
  --border-strong: #34425f;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #9aa8c0;
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-text: #a5b4fc;
  --accent-soft: #1e2547;
  --focus: #a5b4fc;
  --danger-dot: #fb7185;
  --scrim: rgb(2 6 23 / 0.7);

  --c-blue: #60a5fa;
  --c-violet: #a78bfa;
  --c-green: #34d399;
  --c-amber: #fbbf24;
  --grid-line: #212c45;

  --chip-blue-fg: #93c5fd;   --chip-blue-bg: #16294f;
  --chip-violet-fg: #c4b5fd; --chip-violet-bg: #2b2158;
  --chip-green-fg: #6ee7b7;  --chip-green-bg: #10352b;
  --chip-amber-fg: #fcd34d;  --chip-amber-bg: #3a2d0c;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow: 0 1px 3px rgb(0 0 0 / 0.35), 0 8px 24px -12px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.4), 0 18px 36px -14px rgb(0 0 0 / 0.65);
}

/* 2. Base and accessibility helpers ------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base) / 1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 3. Layout -------------------------------------------------------------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 0.75rem; padding: 0 0.5rem; text-decoration: none; }
.brand-mark { width: 2.5rem; height: 2.5rem; flex: none; filter: drop-shadow(0 6px 10px rgb(79 70 229 / 0.28)); }
.brand-name { display: block; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.brand-name span { color: var(--accent-text); }
.brand-tag { display: block; margin-top: 0.125rem; font-size: var(--fs-xs); color: var(--muted); }

.nav-label { padding: 0 0.75rem; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.side-nav { display: grid; gap: 0.25rem; margin-top: 0.5rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-base);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.18s, color 0.18s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-count { margin-left: auto; padding: 0.125rem 0.5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-xs); font-weight: 600; }
.nav-item[aria-current="page"] .nav-count { background: var(--surface); }

.sidebar-bottom { margin-top: auto; display: grid; gap: 0.75rem; }

.help-card { padding: 1.125rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.help-card .chip-icon { margin-bottom: 0.75rem; }
.help-title { font-size: var(--fs-base); font-weight: 600; }
.help-text { margin: 0.25rem 0 0.75rem; font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; }

.profile { display: flex; align-items: center; gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.profile-name { display: block; font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; }
.profile-role { display: block; font-size: var(--fs-xs); color: var(--muted); }
.profile .icon-btn { margin-left: auto; }

.avatar { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-sm); font-weight: 700; }

.main-area { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-start, .top-actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn.mobile-menu { display: none; }

.breadcrumbs ol { display: flex; align-items: center; gap: 0.5rem; font-size: var(--fs-sm); color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 0.5rem; color: var(--border-strong); }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 600; }

main { flex: 1; width: 100%; max-width: 96rem; margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.5rem); }
main:focus { outline: none; }

.page-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem; margin-bottom: 2rem; }
.eyebrow { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.live-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--c-green); }
h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.lede { margin-top: 0.5rem; font-size: var(--fs-md); color: var(--muted); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.5rem; }

.page-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; padding: 1.5rem clamp(1rem, 3vw, 2.5rem); font-size: var(--fs-sm); color: var(--muted); border-top: 1px solid var(--border); }

/* 4. Components ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s, transform 0.12s, box-shadow 0.18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 14px -6px rgb(79 70 229 / 0.6); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { background: var(--surface-2); color: var(--text); }
.btn-link { min-height: 2.5rem; padding: 0; color: var(--accent-text); }
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.18s, color 0.18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .icon { width: 1.375rem; height: 1.375rem; }
.badge-dot { position: absolute; top: 0.625rem; right: 0.7rem; width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--danger-dot); border: 2px solid var(--surface); }

/* Show the sun in dark mode (click for light) and the moon in light mode. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.chip-icon { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); }
.chip-icon.blue { background: var(--chip-blue-bg); color: var(--chip-blue-fg); }
.chip-icon.violet { background: var(--chip-violet-bg); color: var(--chip-violet-fg); }
.chip-icon.green { background: var(--chip-green-bg); color: var(--chip-green-fg); }
.chip-icon.amber { background: var(--chip-amber-bg); color: var(--chip-amber-fg); }

.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }

/* Stat cards */
.metric-card { padding: 1.5rem; transition: transform 0.22s ease, box-shadow 0.22s ease; }
.metric-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.metric-label { font-size: var(--fs-base); font-weight: 600; color: var(--text-2); }
.metric-value { margin: 1rem 0 0.5rem; font-size: var(--fs-stat); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-unit { margin-left: 0.125rem; font-size: 0.6em; font-weight: 600; color: var(--muted); }
.metric-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: var(--fs-sm); color: var(--muted); }
.trend { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem; border-radius: 999px; background: var(--chip-green-bg); color: var(--chip-green-fg); font-weight: 600; }
.trend .icon { width: 0.9375rem; height: 0.9375rem; stroke-width: 2.5; }

.spark { width: 100%; height: 2.75rem; margin-top: 1rem; overflow: visible; }
.spark-area { stroke: none; opacity: 0.14; }
.spark-line { fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.spark.blue { color: var(--c-blue); } .spark.green { color: var(--c-green); } .spark.violet { color: var(--c-violet); } .spark.amber { color: var(--c-amber); }
.spark-area { fill: currentColor; } .spark-line { stroke: currentColor; }

/* Panels */
.panel { padding: 1.5rem; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.panel-heading h2 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; }
.panel-heading p { margin-top: 0.125rem; font-size: var(--fs-sm); color: var(--muted); }

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap select {
  appearance: none;
  min-height: 2.75rem;
  padding: 0 2.5rem 0 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s;
}
.select-wrap select:hover { background: var(--surface-2); }
.select-wrap .icon { position: absolute; right: 0.75rem; width: 1.125rem; height: 1.125rem; pointer-events: none; color: var(--muted); }
.select-wrap .btn { padding-right: 0.875rem; }

/* Pipeline chart */
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 1.5rem; font-size: var(--fs-sm); color: var(--muted); }
.legend div { display: flex; align-items: center; gap: 0.5rem; }
.legend strong { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.dot { width: 0.625rem; height: 0.625rem; border-radius: 3px; flex: none; }
.dot.blue { background: var(--c-blue); } .dot.violet { background: var(--c-violet); } .dot.green { background: var(--c-green); } .dot.amber { background: var(--c-amber); }

.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.75rem; height: 17.5rem; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 2rem; font-size: var(--fs-xs); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.chart-plot { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.5rem; padding-bottom: 2rem; }
.grid-lines { position: absolute; inset: 0 0 2rem; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.grid-lines i { height: 1px; background: var(--grid-line); }

.bar-group { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: center; gap: 0.25rem; }
.bar-group > span { position: absolute; bottom: -2rem; left: 0; right: 0; text-align: center; font-size: var(--fs-sm); color: var(--muted); }
.bar { flex: 0 1 1.125rem; height: calc(var(--v) / 400 * 100%); border-radius: 0.375rem 0.375rem 0.125rem 0.125rem; transform-origin: bottom; transition: filter 0.18s; }
.bar.blue { background: var(--c-blue); } .bar.violet { background: var(--c-violet); } .bar.green { background: var(--c-green); }
.bar-group:hover .bar { filter: brightness(1.12); }
.bar-group::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0;
  z-index: 3;
  width: max-content;
  max-width: 12.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.5rem;
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
/* Tooltips on the right half open leftwards so they never push the page wider. */
.bar-group:nth-child(n + 4)::after { left: auto; right: 0; }
.bar-group:hover::after { opacity: 1; transform: none; }

/* Lead source donut */
.donut-wrap { position: relative; width: min(11.5rem, 100%); aspect-ratio: 1; margin: 0.25rem auto 1.5rem; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 4; }
.donut .track { stroke: var(--surface-2); }
.seg-blue { stroke: var(--c-blue); } .seg-violet { stroke: var(--c-violet); } .seg-green { stroke: var(--c-green); } .seg-amber { stroke: var(--c-amber); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: var(--fs-xs); color: var(--muted); }

.source-list { display: grid; gap: 0.25rem; }
.source-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; font-size: var(--fs-base); color: var(--text-2); border-bottom: 1px solid var(--border); }
.source-list li:last-child { border-bottom: 0; }
.source-list li span { display: flex; align-items: center; gap: 0.625rem; }
.source-list strong { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Leads table */
.leads-panel { padding-bottom: 0; overflow: hidden; }
.leads-heading { flex-wrap: wrap; align-items: center; }
.table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 0.875rem; width: 1.125rem; height: 1.125rem; color: var(--muted); pointer-events: none; }
.search-box input {
  width: clamp(12rem, 22vw, 16rem);
  min-height: 2.75rem;
  padding: 0 2.5rem 0 2.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.search-box input::placeholder { color: var(--muted); opacity: 1; }
.search-box input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.search-box kbd { position: absolute; right: 0.625rem; display: grid; place-items: center; min-width: 1.5rem; height: 1.5rem; border: 1px solid var(--border-strong); border-radius: 0.375rem; background: var(--surface-2); color: var(--muted); font: 600 var(--fs-xs) var(--font); }

.table-scroll { margin: 0 -1.5rem; overflow-x: auto; }
table { width: 100%; min-width: 46rem; border-collapse: collapse; text-align: left; }
th { padding: 0.75rem 1.5rem; background: var(--surface-2); border-block: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); font-size: var(--fs-base); color: var(--text-2); white-space: nowrap; }
tbody tr { transition: background-color 0.15s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td:last-child, th:last-child { text-align: right; }

.contact { display: flex; align-items: center; gap: 0.75rem; }
.contact-avatar { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 700; }
.contact-avatar.violet { background: var(--chip-violet-bg); color: var(--chip-violet-fg); }
.contact-avatar.green { background: var(--chip-green-bg); color: var(--chip-green-fg); }
.contact-avatar.amber { background: var(--chip-amber-bg); color: var(--chip-amber-fg); }
.contact-avatar.blue { background: var(--chip-blue-bg); color: var(--chip-blue-fg); }
.contact-name { display: block; font-weight: 600; color: var(--text); line-height: 1.3; }
.contact-mail { display: block; font-size: var(--fs-sm); color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.status::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; }
.status-qualified { background: var(--chip-green-bg); color: var(--chip-green-fg); }
.status-progress { background: var(--chip-violet-bg); color: var(--chip-violet-fg); }
.status-new { background: var(--chip-amber-bg); color: var(--chip-amber-fg); }

.empty-row td { padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); white-space: normal; }

.table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0 1.25rem; border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }
.table-footer strong { color: var(--text); font-variant-numeric: tabular-nums; }
.pagination { display: flex; align-items: center; gap: 0.25rem; }
.page-btn { display: inline-grid; place-items: center; min-width: 2.5rem; height: 2.5rem; padding: 0 0.5rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; transition: background-color 0.18s; }
.page-btn:hover { background: var(--surface-2); }
.page-btn[aria-current="page"] { background: var(--accent); color: #fff; }
.page-gap { padding: 0 0.25rem; }

/* Toasts */
.toast-region { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60; display: grid; gap: 0.75rem; width: min(24rem, calc(100vw - 2.5rem)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); pointer-events: auto; animation: toast-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.toast.leaving { animation: toast-out 0.2s ease-in both; }
.toast-icon { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: 50%; background: var(--chip-green-bg); color: var(--chip-green-fg); }
.toast-icon .icon { width: 1.0625rem; height: 1.0625rem; stroke-width: 2.5; }
.toast-title { font-size: var(--fs-base); font-weight: 600; line-height: 1.4; }
.toast-text { margin-top: 0.125rem; font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; }
.toast-close { display: grid; place-items: center; width: 2rem; height: 2rem; margin: -0.25rem -0.25rem 0 auto; flex: none; border: 0; border-radius: 0.5rem; background: transparent; color: var(--muted); }
.toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-close .icon { width: 1.125rem; height: 1.125rem; }

.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0s 0.25s; }

/* 5. Motion and responsive rules ---------------------------------------- */

/* Cards and panels glide in. Only opacity and transform change, so nothing reflows. */
.reveal { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--d, 0) * 60ms); }

.live-dot { animation: pulse 2.4s ease-out infinite; }

/* Charts start collapsed and play once when they scroll into view (see demo.js). */
.js [data-animate]:not(.is-visible) .bar { transform: scaleY(0); }
.js [data-animate]:not(.is-visible) .seg { stroke-dasharray: 0 100; }
.js [data-animate]:not(.is-visible) .spark-line { stroke-dashoffset: 1; }
.js [data-animate]:not(.is-visible) .spark-area { opacity: 0; }

.spark-line { stroke-dasharray: 1; }
.is-visible .bar { animation: grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--g) * 90ms + var(--b) * 45ms); }
.is-visible .seg { animation: sweep 1.1s cubic-bezier(0.3, 0.7, 0.2, 1) both; animation-delay: calc(var(--s) * 140ms); }
.is-visible .spark-line { animation: draw 1.2s ease-out both; }
.is-visible .spark-area { animation: fade-area 1.2s ease-out both; }

/* Brief color fade while switching themes. JS adds the class and removes it again. */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after { transition: background-color 0.25s, color 0.25s, border-color 0.25s, fill 0.25s, stroke 0.25s !important; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes sweep { from { stroke-dasharray: 0 100; } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes fade-area { from { opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(5 150 105 / 0.45); } 70%, 100% { box-shadow: 0 0 0 0.5rem rgb(5 150 105 / 0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

@media (max-width: 68.75rem) {
  .content-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 64rem) {
  .app { display: block; }
  .icon-btn.mobile-menu { display: inline-grid; }

  /* On small screens the sidebar becomes a drawer. Hidden means unfocusable too. */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(20rem, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0.28s;
  }
  .sidebar.open { transform: none; visibility: visible; transition-delay: 0s; box-shadow: var(--shadow-lg); }
  .scrim.open { opacity: 1; visibility: visible; transition-delay: 0s; }
}

@media (max-width: 40rem) {
  .panel, .metric-card { padding: 1.25rem; }
  .table-scroll { margin: 0 -1.25rem; }
  th, td { padding-inline: 1.25rem; }
  .breadcrumbs { display: none; }
  .page-heading .btn { width: 100%; }
  .toast-region { right: 1rem; bottom: 1rem; left: 1rem; width: auto; }
  .search-box, .search-box input { width: 100%; }
  .table-actions { width: 100%; }
  .chart { height: 15rem; }
  .bar { flex-basis: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}

/* Chart data hooks. Strict CSP blocks inline style attributes, so values live in data attributes. */
[data-v="146"] { --v: 146; }
[data-v="152"] { --v: 152; }
[data-v="168"] { --v: 168; }
[data-v="186"] { --v: 186; }
[data-v="192"] { --v: 192; }
[data-v="196"] { --v: 196; }
[data-v="208"] { --v: 208; }
[data-v="218"] { --v: 218; }
[data-v="224"] { --v: 224; }
[data-v="244"] { --v: 244; }
[data-v="248"] { --v: 248; }
[data-v="254"] { --v: 254; }
[data-v="268"] { --v: 268; }
[data-v="286"] { --v: 286; }
[data-v="296"] { --v: 296; }
[data-v="306"] { --v: 306; }
[data-v="318"] { --v: 318; }
[data-v="342"] { --v: 342; }
.bar-group:nth-child(1) { --g: 0; }
.bar-group:nth-child(2) { --g: 1; }
.bar-group:nth-child(3) { --g: 2; }
.bar-group:nth-child(4) { --g: 3; }
.bar-group:nth-child(5) { --g: 4; }
.bar-group:nth-child(6) { --g: 5; }
.bar:nth-child(1) { --b: 0; }
.bar:nth-child(2) { --b: 1; }
.bar:nth-child(3) { --b: 2; }
.seg-blue { --s: 0; } .seg-violet { --s: 1; } .seg-green { --s: 2; } .seg-amber { --s: 3; }
[data-d="1"] { --d: 1; }
[data-d="2"] { --d: 2; }
[data-d="3"] { --d: 3; }
[data-d="4"] { --d: 4; }
[data-d="5"] { --d: 5; }
[data-d="6"] { --d: 6; }
[data-d="7"] { --d: 7; }
[data-d="8"] { --d: 8; }

/* Windows high contrast mode: keep borders and focus rings visible. */
@media (forced-colors: active) {
  .btn-primary, .page-btn[aria-current="page"] { border-color: ButtonText; }
  .bar, .seg-blue, .seg-violet, .seg-green, .seg-amber { forced-color-adjust: none; }
}

/* Anchored sections stop just below the sticky top bar. */
#overview, #leads { scroll-margin-top: 5.5rem; }
#leads:focus { outline: none; }
.chart-y span { line-height: 1; }

/* Friendly page for unknown addresses (404.html). */
.notfound { display: grid; place-content: center; justify-items: center; gap: 1rem; min-height: 100vh; padding: 2rem; text-align: center; }
.notfound img { width: 4rem; height: 4rem; }
.notfound .code { font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.notfound p { max-width: 28rem; color: var(--muted); font-size: var(--fs-md); }
