:root {
  --sidebar-w-collapsed: 72px;
  --sidebar-w-expanded: 252px;
  --bg: #080d14;
  --bg-elevated: #0c121c;
  --bg-card: rgba(12, 18, 28, 0.92);
  --bg-card-strong: #0e1522;
  --border: rgba(148, 163, 184, 0.1);
  --border-strong: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --heading: #f1f5f9;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --accent-3: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.22);
  --renewal-chip-bg-top: #8b5cf6;
  --renewal-chip-bg-bottom: #5b21b6;
  /* Lavender / purple-tint waves (replaces pure white on chip) */
  --renewal-chip-fg: #ede9fe;
  --renewal-chip-wave: rgba(196, 181, 253, 0.55);
  --renewal-chip-wave-glow: rgba(167, 139, 250, 0.45);
  --renewal-chip-shadow: -4px 0 22px rgba(124, 58, 237, 0.38), 0 4px 18px rgba(0, 0, 0, 0.28);
  --renewal-chip-shadow-open: -2px 0 14px rgba(124, 58, 237, 0.32), 0 2px 12px rgba(0, 0, 0, 0.22);
  --renewal-chip-text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --space-page: clamp(0.75rem, 2vw, 1.25rem);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Native form controls (especially <select> dropdown lists) follow OS theme unless hinted */
html {
  color-scheme: dark;
  scrollbar-gutter: stable;
}

html:has(body.auth-body) {
  color-scheme: light;
}

body.nav-prefetching {
  cursor: wait;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-strong: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --muted: #64748b;
  --heading: #0f172a;
  --accent: #6d28d9;
  --accent-2: #0891b2;
  --accent-3: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-float: 0 8px 24px rgba(15, 23, 42, 0.08);
  --renewal-chip-bg-top: #7c3aed;
  --renewal-chip-bg-bottom: #5b21b6;
  --renewal-chip-fg: #f5f3ff;
  --renewal-chip-wave: rgba(196, 181, 253, 0.5);
  --renewal-chip-wave-glow: rgba(167, 139, 250, 0.4);
  --renewal-chip-shadow: -4px 0 20px rgba(109, 40, 217, 0.4), 0 4px 16px rgba(15, 23, 42, 0.12);
  --renewal-chip-shadow-open: -2px 0 12px rgba(109, 40, 217, 0.35), 0 2px 10px rgba(15, 23, 42, 0.1);
  --renewal-chip-text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
.is-hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body.app-body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body.app-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code { background: rgba(148, 163, 184, 0.12); padding: 0.15rem 0.35rem; border-radius: 8px; }

.app-shell {
  min-height: 100vh;
}

/* —— Login page: white background, purple motion, split card —— */
body.auth-body {
  min-height: 100vh;
  margin: 0;
  background: #faf8ff;
  color: #0f172a;
  color-scheme: light;
}

.auth-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  overflow: hidden;
}

.auth-page__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #faf8ff;
  overflow: hidden;
}

.auth-page__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
  /* Matches page bg so there is no 1-frame flash before JS paints (2d canvas alpha:false). */
  background: #faf8ff;
}

.auth-page__wrap {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 920px;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.1fr);
  border-radius: 20px;
  overflow: hidden;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 8px 24px rgba(15, 23, 42, 0.08),
    0 24px 56px rgba(15, 23, 42, 0.1),
    0 40px 90px rgba(124, 58, 237, 0.12),
    0 0 0 1px rgba(15, 23, 42, 0.06);
}

.auth-card__brand {
    position: relative;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    background: #000000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: min(42vh, 22rem);
    overflow: hidden;
}

.auth-card__brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.06), transparent 62%);
  pointer-events: none;
}

.auth-card__logo-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 11rem;
  padding: 0.75rem;
  box-sizing: border-box;
}

.auth-card__logo {
  display: block;
  max-width: min(78%, 240px);
  max-height: min(32vh, 220px);
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
}

.auth-card__body {
  padding: clamp(2rem, 5vw, 3rem);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: #0f172a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  border-left: 1px solid rgba(124, 58, 237, 0.12);
}

.auth-card__form-head {
  display: grid;
  gap: 0.35rem;
}

.auth-card__form-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
}

.auth-card__form-lead {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.45;
}

.auth-card__form {
  margin-top: 0.25rem;
}

.auth-card__submit {
  margin-top: 0.15rem;
}

body.auth-body .auth-card__body .field-group label {
  color: #475569;
}

body.auth-body .auth-card__body input,
body.auth-body .auth-card__body select,
body.auth-body .auth-card__body textarea {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}

body.auth-body .auth-card__credentials.credential-box {
  background: rgba(124, 58, 237, 0.06);
  border-color: rgba(124, 58, 237, 0.18);
  color: #334155;
}

@media (max-width: 720px) {
  .auth-card {
    grid-template-columns: 1fr;
    border-radius: 18px;
  }
  .auth-card__body {
    border-left: none;
    border-top: 1px solid rgba(124, 58, 237, 0.12);
  }
}

.glass-card {
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
}

.auth-brand { display: flex; align-items: center; gap: 1rem; }
.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.brand-mark--logo {
  background: transparent;
  padding: 0;
  overflow: hidden;
  display: block;
}
.brand-mark--logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  border-radius: inherit;
}
.brand-mark.large { width: 58px; height: 58px; font-size: 1.2rem; }
.brand-title { font-weight: 700; color: var(--heading); }
.brand-subtitle { color: var(--muted); font-size: 0.92rem; }
.hero-badge,
.eyebrow,
.metric-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
.hero-badge,
.dark,
.eyebrow { color: var(--muted); }
.hero-badge.dark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255,255,255,0.9);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
}
.metric-label { color: var(--muted); }

.stack-form { display: grid; gap: 0.9rem; }
.compact-form { gap: 0.8rem; }
.field-grid { display: grid; gap: 0.8rem; }
.field-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-group { display: grid; gap: 0.42rem; }
.field-group.full-span { grid-column: 1 / -1; }
.field-group label { font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
}
body[data-theme="light"] input,
body[data-theme="light"] select,
body[data-theme="light"] textarea {
  background: rgba(255, 255, 255, 0.78);
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

/* <select> closed state + options: color-scheme fixes white popup on Windows/Chrome; options styled where supported */
select {
  color-scheme: dark;
  background-color: var(--bg-card-strong);
  color: var(--text);
}
body[data-theme="light"] select {
  color-scheme: light;
  background-color: rgba(255, 255, 255, 0.78);
}
select option,
select optgroup {
  background-color: var(--bg-card-strong);
  color: var(--text);
}
body[data-theme="light"] select option,
body[data-theme="light"] select optgroup {
  background-color: #ffffff;
  color: var(--text);
}
.password-field {
  position: relative;
  width: 100%;
}
.password-field input {
  padding-right: 2.75rem;
}
.password-field-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.password-field-toggle:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.12);
}
.password-field-toggle .eye-icon {
  width: 20px;
  height: 20px;
  pointer-events: none;
}
.password-field.password-visible .eye-icon--show {
  display: none;
}
.password-field.password-visible .eye-icon--hide {
  display: block !important;
}
.password-field:not(.password-visible) .eye-icon--hide {
  display: none !important;
}
textarea { resize: vertical; min-height: 110px; }
.inline-field { display: flex; align-items: center; }
.inline-field label { display: inline-flex; align-items: center; gap: 0.6rem; }
.inline-field input[type="checkbox"] { width: auto; }

.button,
.icon-button,
.quick-link,
.sidebar-nav a,
.profile-pill,
.tiny-chip,
.status-pill {
  transition: 0.18s ease;
}

.button {
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 600;
}
.button:hover { opacity: 0.92; }
.button.primary {
  background: var(--accent);
  color: white;
  box-shadow: none;
}
.button.primary:hover { opacity: 0.9; }
.button.secondary {
  background: rgba(148, 163, 184, 0.1);
}
.button.ghost { background: transparent; border: 1px solid var(--border-strong); }
.button.light { background: white; color: #0f172a; }
.button.ghost-on-dark { background: rgba(255,255,255,0.08); color: white; }
.button.wide { width: 100%; }
.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.icon-button:hover { background: rgba(255,255,255,0.08); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.compact-card { padding: 0.85rem; }
.gradient-card {
  background: var(--bg-card-strong);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.gradient-card .hero-copy {
  color: var(--muted);
}
body[data-theme="light"] .gradient-card .hero-badge.dark {
  background: rgba(15, 23, 42, 0.06);
  color: var(--heading);
}
.spotlight-card { display: grid; place-items: center; text-align: center; }
.spotlight-ring {
  width: 112px;
  height: 112px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-3);
  background: transparent;
  border: 2px solid rgba(34, 197, 94, 0.35);
}
.hero-grid,
.metric-grid,
.content-grid,
.page-grid,
.quick-links-grid,
.card-grid {
  display: grid;
  gap: 0.875rem;
}
.hero-grid { grid-template-columns: 2fr 1fr; margin-bottom: 0.875rem; }
.hero-grid > *,
.content-grid > *,
.page-grid > *,
.metric-grid > * {
  min-width: 0;
}
.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  min-height: auto;
  flex-wrap: wrap;
}
.hero-panel h2 { margin: 0.35rem 0; font-size: clamp(1.5rem, 2.5vw, 2.1rem); max-width: 18ch; font-weight: 600; color: var(--heading); }
.hero-copy { max-width: 56ch; color: var(--muted); }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0.875rem; }
.metric-card { display: grid; gap: 0.25rem; min-height: 96px; }
.metric-card strong { font-size: 1.65rem; font-weight: 600; color: var(--heading); }
.metric-card strong.metric-value {
  font-variant-numeric: tabular-nums;
  min-height: 1.35em;
  display: inline-block;
}
a.metric-card {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
a.metric-card:hover {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.05);
}
a.metric-card:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.65);
  outline-offset: 2px;
}
.metric-note { color: var(--muted); font-size: 0.9rem; }

/* Dashboard KPIs — CRM-style cards with icons */
.metric-grid--kpi {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.metric-kpi {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem 0.75rem;
  min-height: 108px;
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}
.metric-kpi:hover {
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  transform: translateY(-1px);
}
.metric-kpi:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.65);
  outline-offset: 2px;
}
.metric-kpi__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.metric-kpi__icon svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
}
.metric-kpi--leads .metric-kpi__icon {
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.28);
}
.metric-kpi--clients .metric-kpi__icon {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.28);
}
.metric-kpi--revenue .metric-kpi__icon {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.28);
}
.metric-kpi--renewals .metric-kpi__icon {
  color: #38bdf8;
  background: rgba(6, 182, 212, 0.14);
  border: 1px solid rgba(6, 182, 212, 0.26);
}
.metric-kpi__body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.metric-kpi .metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.metric-kpi .metric-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.metric-kpi .metric-note {
  font-size: 0.82rem;
}
.metric-kpi__arrow {
  font-size: 1.15rem;
  color: var(--muted);
  opacity: 0.55;
  align-self: center;
}
body[data-theme="light"] .metric-kpi {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.96) 100%);
}
body[data-theme="light"] .metric-kpi:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.dashboard-charts {
  display: grid;
  gap: 0.875rem;
  margin-bottom: 1rem;
}
.dashboard-charts__row--split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.875rem;
}
.chart-card .section-head--chart {
  margin-bottom: 0.35rem;
}
.chart-card__canvas-wrap {
  position: relative;
  height: 260px;
  width: 100%;
  min-height: 200px;
}
.chart-card__canvas-wrap--doughnut {
  max-width: 360px;
  margin: 0 auto;
}
.chart-card__canvas-wrap--bar {
  height: 240px;
}
.chart-card__canvas-wrap canvas {
  max-height: 100%;
}
.chart-card__empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2rem 1rem;
  margin: 0;
}
.chart-card__empty.is-hidden {
  display: none;
}
canvas.is-hidden {
  display: none !important;
}

.content-grid.two-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.page-grid.split-layout { grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.95fr); gap: 1rem; }
.quick-links-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.quick-link {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  font-weight: 600;
}
.quick-link:hover { border-color: var(--border-strong); background: rgba(124, 58, 237, 0.06); }
.card-grid.compact-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.app-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}
.sidebar {
  position: sticky;
  top: 0;
  /* minmax(0,1fr) so the nav row can shrink on short viewports */
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  width: var(--sidebar-w-expanded);
  padding: 0.85rem 0.75rem;
  border-right: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.72);
  backdrop-filter: blur(12px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
  z-index: 30;
  align-self: start;
  min-height: 0;
  overflow: hidden;
}
/* Light theme: dark chrome (sidebar + top bar) for contrast with light main content */
body[data-theme="light"] .sidebar {
  background: #0a0a0a;
  border-right-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: none;
}
body[data-theme="light"] .sidebar .brand-title {
  color: #f8fafc;
}
body[data-theme="light"] .sidebar .brand-subtitle {
  color: rgba(248, 250, 252, 0.62);
}
body[data-theme="light"] .sidebar-nav a,
body[data-theme="light"] .sidebar-nav-group-summary {
  color: rgba(248, 250, 252, 0.78);
  border-color: transparent;
}
body[data-theme="light"] .sidebar-nav a:hover,
body[data-theme="light"] .sidebar-nav-group-summary:hover {
  background: rgba(124, 58, 237, 0.35);
  color: #ffffff;
  border-color: rgba(167, 139, 250, 0.4);
}
body[data-theme="light"] .sidebar-nav a.active,
body[data-theme="light"] .sidebar-nav-group.is-child-active > .sidebar-nav-group-summary {
  background: rgba(124, 58, 237, 0.45);
  color: #ffffff;
  border-color: rgba(167, 139, 250, 0.55);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.3rem 0.2rem;
  min-height: 48px;
  box-sizing: border-box;
}
.brand-text {
  min-width: 0;
  transition: opacity 0.2s ease, max-width 0.25s ease, max-height 0.22s ease, margin 0.2s ease;
  overflow: hidden;
}
.sidebar-nav {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}
.sidebar-nav::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-md);
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 500;
  min-height: 40px;
}
.sidebar-nav .nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.sidebar-nav .nav-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.18s ease, max-width 0.22s ease;
  min-width: 0;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(124, 58, 237, 0.12);
  color: var(--heading);
  border-color: rgba(124, 58, 237, 0.25);
}
.sidebar-nav a.is-hidden { display: none; }

.sidebar-nav-group {
  margin: 0;
  padding: 0;
  border-radius: var(--radius-md);
}
.sidebar-nav-group.is-hidden {
  display: none !important;
}
.sidebar-nav-group-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-md);
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 500;
  min-height: 40px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  box-sizing: border-box;
}
.sidebar-nav-group-summary::-webkit-details-marker {
  display: none;
}
.sidebar-nav-group-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.75;
  transition: transform 0.18s ease;
}
.sidebar-nav-group[open] > .sidebar-nav-group-summary .sidebar-nav-group-chevron {
  transform: rotate(180deg);
}
.sidebar-nav-group-summary:hover {
  background: rgba(124, 58, 237, 0.12);
  color: var(--heading);
  border-color: rgba(124, 58, 237, 0.25);
}
.sidebar-nav-group.is-child-active > .sidebar-nav-group-summary {
  background: rgba(124, 58, 237, 0.12);
  color: var(--heading);
  border-color: rgba(124, 58, 237, 0.25);
}
.sidebar-nav-group-items {
  display: grid;
  gap: 0.2rem;
  padding: 0.15rem 0 0.35rem 0;
}
.sidebar-nav-group-items a {
  padding-left: 2.15rem;
  font-size: 0.92em;
}

@media (hover: hover) and (pointer: fine) and (min-width: 901px) {
  .sidebar {
    width: var(--sidebar-w-collapsed);
    transition: width 0.22s ease;
    overflow: hidden;
    /* Fixed header row height so hover does not resize the logo row (logo jerk). */
    grid-template-rows: 4rem minmax(0, 1fr);
  }
  .sidebar:hover {
    width: var(--sidebar-w-expanded);
    box-shadow: var(--shadow-float);
  }
  .sidebar-brand {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    align-items: center;
    overflow: hidden;
  }
  .sidebar:not(:hover) .brand-text {
    opacity: 0;
    max-width: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    flex: 0 0 0;
    pointer-events: none;
  }
  .sidebar:hover .brand-text {
    opacity: 1;
    max-width: 200px;
    max-height: 3.25rem;
    flex: 1 1 auto;
    min-width: 0;
  }
  .sidebar:not(:hover) .sidebar-nav a,
  .sidebar:not(:hover) .sidebar-nav-group-summary {
    justify-content: center;
  }
  .sidebar:hover .sidebar-nav a,
  .sidebar:hover .sidebar-nav-group-summary {
    justify-content: flex-start;
  }
  .sidebar:not(:hover) .sidebar-nav-group-items {
    display: none !important;
  }
  .sidebar:not(:hover) .sidebar-nav-group-chevron {
    display: none;
  }
  .sidebar:not(:hover) .nav-label {
    opacity: 0;
    max-width: 0;
  }
  .sidebar:hover .nav-label {
    opacity: 1;
    max-width: 220px;
  }
}

@media (hover: none) and (min-width: 901px) {
  .sidebar {
    width: var(--sidebar-w-expanded);
    overflow: visible;
  }
  .brand-text {
    opacity: 1;
    max-width: none;
  }
  .sidebar-nav a {
    justify-content: flex-start;
  }
  .nav-label {
    opacity: 1;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none !important;
  }
  .sidebar-nav .nav-label,
  .brand-text {
    transition: none !important;
  }
  .renewal-radar-edge-chip-waves span {
    animation: none !important;
  }
}
.tiny-chip {
  display: inline-flex;
  width: fit-content;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 0.78rem;
}
.text-link { color: #7dd3fc; }

.main-shell { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  background: rgba(7, 17, 31, 0.72);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1.25rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-top: max(1rem, env(safe-area-inset-top));
  min-width: 0;
}
body[data-theme="light"] .topbar {
  background: #0a0a0a;
  border-bottom-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: none;
}
body[data-theme="light"] .topbar .eyebrow {
  color: rgba(248, 250, 252, 0.55);
}
body[data-theme="light"] .topbar .page-title {
  color: #f8fafc;
}
body[data-theme="light"] .topbar .icon-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #e5e7eb;
}
body[data-theme="light"] .topbar .icon-button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
body[data-theme="light"] .topbar .button.ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f3f4f6;
}
body[data-theme="light"] .topbar .button.ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}
body[data-theme="light"] .topbar .header-identity {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}
body[data-theme="light"] .topbar .header-line-primary strong {
  color: #f8fafc;
}
body[data-theme="light"] .topbar .header-welcome-prefix {
  color: rgba(248, 250, 252, 0.95);
}
body[data-theme="light"] .topbar .header-line-role {
  color: rgba(148, 163, 184, 0.95);
}
body[data-theme="light"] .topbar .status-dot.success {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.45), 0 0 0 5px rgba(255, 255, 255, 0.08);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.topbar-left {
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-actions {
  flex: 0 1 auto;
  min-width: 0;
  justify-content: flex-end;
  margin-left: auto;
}

.topbar-theme-toggle {
  flex-shrink: 0;
}

.header-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.85rem 0.45rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  min-width: 0;
  max-width: min(420px, 50vw);
}

.header-identity-text {
  min-width: 0;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
}

.header-name-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
}

.header-line-primary {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.05rem, 2.1vw, 1.28rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-welcome-prefix {
  color: #f8fafc;
  font-weight: 600;
}

.header-line-primary strong {
  color: #f8fafc;
  font-weight: 700;
}

.header-line-role {
  margin: 0;
  margin-left: auto;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: #9eb0ca;
  line-height: 1.2;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  white-space: nowrap;
}

.topbar .status-dot.success {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-3);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4), 0 0 0 5px rgba(255, 255, 255, 0.05);
}

.header-user-menu {
  position: relative;
  flex-shrink: 0;
}

.header-avatar-btn {
  display: grid;
  place-items: center;
  grid-template: 1fr / 1fr;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  color: var(--text);
  overflow: hidden;
}

.header-avatar-btn > .header-avatar-fallback,
.header-avatar-btn > .header-avatar-img {
  grid-area: 1 / 1;
}

.header-avatar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.header-avatar-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.header-avatar-icon {
  width: 22px;
  height: 22px;
  color: rgba(226, 232, 240, 0.75);
}

.header-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 0.35rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-card-strong);
  box-shadow: var(--shadow-float);
  z-index: 80;
}

.header-dropdown[hidden] {
  display: none !important;
}

.header-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

a.header-dropdown-item:hover {
  background: rgba(124, 58, 237, 0.12);
  color: var(--heading);
}

.header-dropdown-item--danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

body[data-theme="light"] .topbar .header-avatar-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #e5e7eb;
}

body[data-theme="light"] .topbar .header-avatar-icon {
  color: rgba(248, 250, 252, 0.7);
}

body[data-theme="light"] .topbar .header-dropdown {
  background: #111827;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

body[data-theme="light"] .topbar .header-dropdown-item {
  color: #f1f5f9;
}

body[data-theme="light"] .topbar a.header-dropdown-item:hover {
  background: rgba(124, 58, 237, 0.35);
  color: #fff;
}

body[data-theme="light"] .topbar .header-dropdown-item--danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}
.page-title {
  margin: 0.2rem 0 0;
  font-size: clamp(1.2rem, 2.8vw, 1.55rem);
  color: var(--heading);
  line-height: 1.2;
  word-break: break-word;
}
.profile-pill {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 220px;
}
.profile-pill strong { display: block; font-size: 0.92rem; color: var(--heading); }
.profile-pill span:last-child { font-size: 0.8rem; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--muted); box-shadow: 0 0 0 5px rgba(255,255,255,0.04); }
.status-dot.success { background: var(--accent-3); }
.sidebar-toggle { display: none; }

/* Mobile drawer: dim main content when nav is open */
.sidebar-backdrop {
  display: none;
}
@media (max-width: 900px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(2, 8, 23, 0.55);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }
  body.app-body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  body[data-theme="light"] .sidebar-backdrop {
    background: rgba(15, 23, 42, 0.38);
  }
  body.app-body.sidebar-open {
    overflow: hidden;
  }
}
@media (min-width: 901px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

.page-shell {
  padding: var(--space-page);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  padding-left: max(var(--space-page), env(safe-area-inset-left));
  padding-right: max(var(--space-page), env(safe-area-inset-right));
  min-width: 0;
}
.sticky-card { position: sticky; top: 92px; align-self: start; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.section-head h3 { margin: 0.15rem 0 0; font-size: 1.05rem; font-weight: 600; color: var(--heading); }
.section-head--lead-toolbar {
  align-items: center;
  flex-wrap: nowrap;
}
.section-head--lead-toolbar .section-head-titles {
  flex-shrink: 0;
}
.section-head--lead-toolbar .toolbar-lead-row {
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}
.section-head--lead-toolbar .toolbar-lead-row input[type="search"] {
  min-width: 140px;
  max-width: 280px;
  flex: 1 1 160px;
  width: auto;
}
.section-head--lead-toolbar .toolbar-lead-row select {
  min-width: 128px;
  flex: 0 0 auto;
  width: auto;
}
.section-head--lead-toolbar .toolbar-lead-row .button {
  flex-shrink: 0;
  white-space: nowrap;
}
.follow-ups-page {
  padding-top: 0.25rem;
}
.follow-ups-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.follow-ups-tab {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.follow-ups-tab:hover {
  color: var(--heading);
  background: rgba(255, 255, 255, 0.07);
}
.follow-ups-tab.is-active {
  color: #fff;
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.18);
}
body[data-theme="light"] .follow-ups-tab.is-active {
  color: #1e1b4b;
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.12);
}
.follow-ups-toolbar-wrap {
  margin-top: 0.15rem;
}
.follow-ups-panel {
  min-width: 0;
}
.toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.compact-toolbar input,
.compact-toolbar select { min-width: 170px; }

.table-wrap {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  vertical-align: top;
}
.compact-table tbody tr:hover { background: rgba(255,255,255,0.025); }
.cell-title { font-weight: 600; color: var(--heading); }
.cell-subtitle, .muted { color: var(--muted); }
.cell-stack { display: grid; gap: 0.18rem; }
.inline-status-cell {
  min-width: 0;
  vertical-align: middle;
}
.inline-status-select {
  max-width: 11rem;
  width: 100%;
  font-size: 0.8rem;
  padding: 0.32rem 0.45rem;
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(15, 23, 42, 0.65);
  color: var(--heading);
}
body[data-theme="light"] .inline-status-select {
  background: #fff;
}
.inline-status-select:disabled {
  opacity: 0.55;
  cursor: wait;
}
.inline-assign-cell {
  min-width: 0;
  vertical-align: middle;
  max-width: 15rem;
}
.assignee-dropdown {
  position: relative;
  display: block;
  width: 100%;
  max-width: 14rem;
  min-width: 0;
}
.assignee-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  max-width: 14rem;
  min-height: 2.1rem;
  padding: 0.32rem 0.5rem;
  font-size: 0.8rem;
  text-align: left;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(15, 23, 42, 0.65);
  color: var(--heading);
  cursor: pointer;
}
.assignee-dropdown__trigger:disabled {
  opacity: 0.55;
  cursor: wait;
}
.assignee-dropdown__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.assignee-dropdown__chev {
  flex-shrink: 0;
  opacity: 0.75;
}
.assignee-dropdown__panel {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 40;
  box-sizing: border-box;
  width: 100%;
  max-width: 16rem;
  min-width: 0;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.35rem 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated, #1e293b);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
body[data-theme="light"] .assignee-dropdown__trigger {
  background: #fff;
}
body[data-theme="light"] .assignee-dropdown__panel {
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}
.assignee-dropdown__option {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--heading);
}
.assignee-dropdown__option:hover {
  background: rgba(255, 255, 255, 0.06);
}
body[data-theme="light"] .assignee-dropdown__option:hover {
  background: rgba(15, 23, 42, 0.06);
}
.assignee-dropdown__name {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.assignee-dropdown__option input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent, #7c3aed);
}
.assignee-dropdown.open .assignee-dropdown__trigger {
  border-color: var(--accent, #7c3aed);
}
.row-actions {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.45rem;
  justify-content: flex-end;
  align-items: center;
}
.row-actions .button { padding: 0.4rem 0.65rem; border-radius: var(--radius-sm); font-size: 0.8rem; }
.row-actions .button.danger { background: rgba(239, 68, 68, 0.15); color: #fecaca; }
body[data-theme="light"] .row-actions .button.danger { color: #991b1b; }
.data-table thead th.th-actions {
  text-align: right;
  width: 1%;
  white-space: nowrap;
  min-width: 8.5rem;
}
.data-table thead th.th-actions--wide {
  min-width: 11.5rem;
}
.data-table.compact-table tbody td:last-child:has(.row-actions) {
  white-space: nowrap;
  min-width: 8.5rem;
  vertical-align: middle;
}
.field-grid.two-col > .employee-create-only.field-grid {
  grid-column: 1 / -1;
}
.employee-create-only.is-hidden {
  display: none !important;
}
.row-actions .row-action-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  padding: 0;
}
.row-actions .row-action-icon svg {
  width: 18px;
  height: 18px;
}
.icon-button.icon-button--danger {
  border-color: rgba(239, 68, 68, 0.38);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}
.icon-button.icon-button--danger:hover {
  background: rgba(239, 68, 68, 0.24);
}
body[data-theme="light"] .icon-button.icon-button--danger {
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.35);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-new,
.status-pending { background: rgba(245, 158, 11, 0.16); color: #facc15; border-color: rgba(245, 158, 11, 0.25); }
.status-contacted,
.status-qualified,
.status-active,
.status-paid,
.status-completed,
.status-converted { background: rgba(34, 197, 94, 0.16); color: #86efac; border-color: rgba(34, 197, 94, 0.25); }
.status-lost,
.status-cancelled,
.status-expired,
.status-inactive { background: rgba(239, 68, 68, 0.14); color: #fca5a5; border-color: rgba(239, 68, 68, 0.26); }
.status-onhold,
.status-missed { background: rgba(59, 130, 246, 0.14); color: #93c5fd; border-color: rgba(59, 130, 246, 0.24); }
.status-expirysoon { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.status-unknown { background: rgba(148, 163, 184, 0.12); color: var(--muted); }

/* Light theme: dark text on tinted fills so pills stay readable on white cards */
body[data-theme="light"] .status-new,
body[data-theme="light"] .status-pending {
  background: #fef3c7;
  color: #92400e;
  border-color: rgba(146, 64, 14, 0.35);
}
body[data-theme="light"] .status-contacted,
body[data-theme="light"] .status-qualified,
body[data-theme="light"] .status-active,
body[data-theme="light"] .status-paid,
body[data-theme="light"] .status-completed,
body[data-theme="light"] .status-converted {
  background: #dcfce7;
  color: #166534;
  border-color: rgba(22, 101, 52, 0.4);
}
body[data-theme="light"] .status-lost,
body[data-theme="light"] .status-cancelled,
body[data-theme="light"] .status-expired,
body[data-theme="light"] .status-inactive {
  background: #fee2e2;
  color: #991b1b;
  border-color: rgba(153, 27, 27, 0.35);
}
body[data-theme="light"] .status-onhold,
body[data-theme="light"] .status-missed {
  background: #dbeafe;
  color: #1e40af;
  border-color: rgba(30, 64, 175, 0.35);
}
body[data-theme="light"] .status-expirysoon {
  background: #ffedd5;
  color: #c2410c;
  border-color: rgba(194, 65, 12, 0.4);
}
body[data-theme="light"] .status-unknown {
  background: #f1f5f9;
  color: #475569;
  border-color: rgba(71, 85, 105, 0.3);
}

.role-pill,
.permission-pill,
.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.1);
  color: #c4b5fd;
  border: 1px solid rgba(124, 58, 237, 0.2);
  font-size: 0.75rem;
  font-weight: 600;
}
body[data-theme="light"] .role-pill,
body[data-theme="light"] .permission-pill,
body[data-theme="light"] .chip-label {
  color: #5b21b6;
}
.chip-row, .chip-checklist { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip-label {
  cursor: pointer;
  position: relative;
}
/* Visually hide checkbox but keep it in the tab order / label association (display:none breaks label toggling). */
.chip-label input[type='checkbox'] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.chip-label.selected { background: rgba(34, 197, 94, 0.16); border-color: rgba(34, 197, 94, 0.28); color: #86efac; }
body[data-theme="light"] .chip-label.selected {
  background: #dcfce7;
  color: #166534;
  border-color: rgba(22, 101, 52, 0.4);
}
.permission-groups { display: grid; gap: 0.8rem; }
.permission-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  background: rgba(255,255,255,0.03);
}
.permission-group h4 { margin: 0 0 0.7rem; color: var(--heading); }

.activity-list,
.compact-list,
.info-stack {
  display: grid;
  gap: 0.8rem;
}
.activity-item,
.list-item,
.info-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  background: rgba(255,255,255,0.03);
}
a.list-item.list-item--link {
  display: grid;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
a.list-item.list-item--link:hover {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.05);
}
a.list-item.list-item--link:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.65);
  outline-offset: 2px;
}
.activity-item { display: grid; gap: 0.25rem; }
.list-item-head { display: flex; justify-content: space-between; gap: 1rem; }
.loading-state, .empty-state { color: var(--muted); }
.empty-state {
  padding: 1rem;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}
.credential-box {
  padding: 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.08);
  display: grid;
  gap: 0.35rem;
}
.form-actions, .dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; }
.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  color: var(--muted);
}
.saga-dialog {
  width: min(560px, calc(100vw - max(2rem, env(safe-area-inset-left) + env(safe-area-inset-right))));
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  margin: auto;
}
.saga-dialog::backdrop { background: rgba(2, 8, 23, 0.55); backdrop-filter: blur(6px); }
.saga-dialog--lead {
  width: min(720px, calc(100vw - max(2rem, env(safe-area-inset-left) + env(safe-area-inset-right))));
  max-height: min(calc(100vh - 2rem), calc(100dvh - 2rem));
}
.saga-dialog--lead .dialog-card {
  max-height: min(calc(100vh - 2.5rem), calc(100dvh - 2.5rem));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.dialog-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Renewal radar: vertical edge chip (global) + right drawer */
.renewal-radar-shell {
  pointer-events: none;
}
.renewal-radar-shell > * {
  pointer-events: auto;
}
.renewal-radar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: rgba(2, 8, 23, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.renewal-radar-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
body[data-theme="light"] .renewal-radar-backdrop {
  background: rgba(15, 23, 42, 0.4);
}
.renewal-radar-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 89;
  width: min(540px, calc(100vw - 1rem));
  max-width: 100%;
  background: var(--bg-card-strong);
  border-left: 1px solid var(--border-strong);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.35);
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 0;
}
.renewal-radar-drawer.is-open {
  transform: translateX(0);
}
.renewal-radar-drawer-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  padding-top: max(1rem, env(safe-area-inset-top));
}
.renewal-radar-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.renewal-radar-drawer-head h3 {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
}
.renewal-radar-drawer-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}
.renewal-radar-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.renewal-radar-table-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.renewal-radar-table-wrap .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.renewal-radar-table-wrap.loading-state {
  opacity: 0.55;
  pointer-events: none;
}
.renewal-radar-table {
  width: 100%;
  table-layout: fixed;
  font-size: 0.86rem;
}
.renewal-radar-table.data-table thead th:nth-child(1) {
  width: 46%;
  text-align: left;
}
.renewal-radar-table.data-table thead th:nth-child(2) {
  width: 26%;
  text-align: left;
}
/* Enough width for mail + eye in one row (icons stay inline). */
.renewal-radar-table.data-table thead th.th-actions {
  width: 28%;
  min-width: 5.75rem;
  max-width: none;
  text-align: right;
}
.renewal-radar-table .cell-title {
  display: block;
  font-weight: 600;
  color: var(--heading);
}
.renewal-radar-table tbody td.renewal-radar-table__td--name {
  vertical-align: top;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}
.renewal-radar-table tbody td.renewal-radar-table__td--status {
  vertical-align: middle;
  text-align: left;
}
.renewal-radar-table tbody td.renewal-radar-table__td--action {
  vertical-align: middle;
  text-align: right;
  white-space: nowrap;
  width: 28%;
  min-width: 5.75rem;
}
.renewal-radar-table tbody td.renewal-radar-table__td--action .renewal-radar-view-btn {
  display: inline-flex;
  flex-shrink: 0;
}
.renewal-radar-row-actions {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-wrap: nowrap;
}
.renewal-radar-view-btn {
  padding: 0.35rem;
}
.renewal-radar-mail-btn {
  padding: 0.35rem;
}
.renewal-radar-eye-svg,
.renewal-radar-mail-svg {
  width: 18px;
  height: 18px;
  display: block;
}
.renewal-radar-detail-dialog.saga-dialog {
  width: min(920px, calc(100vw - max(2rem, env(safe-area-inset-left) + env(safe-area-inset-right))));
}
.renewal-radar-detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  padding-top: 0.25rem;
  max-height: min(70vh, 32rem);
  overflow-y: auto;
}
@media (min-width: 540px) {
  .renewal-radar-detail-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 860px) {
  .renewal-radar-detail-body {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.renewal-radar-detail-section {
  display: grid;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  min-width: 0;
}
.renewal-radar-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 108px) minmax(0, 1fr);
  gap: 0.5rem;
  font-size: 0.88rem;
  align-items: start;
}
.renewal-radar-detail-label {
  color: var(--muted);
}
.renewal-radar-detail-value {
  min-width: 0;
  word-break: break-word;
}
.renewal-radar-detail-note {
  margin: 0;
  font-size: 0.85rem;
}
.renewal-radar-edge-chip {
  position: fixed;
  right: 0;
  bottom: max(1rem, env(safe-area-inset-bottom));
  top: auto;
  z-index: 90;
  transform: none;
  margin: 0;
  border: none;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--renewal-chip-bg-top), var(--renewal-chip-bg-bottom));
  color: var(--renewal-chip-fg);
  box-shadow: var(--renewal-chip-shadow);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
  max-width: 52px;
  min-height: 46px;
  padding: 0;
  overflow: visible;
  transition: max-width 0.32s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease, filter 0.15s ease;
}
.renewal-radar-edge-chip:hover,
.renewal-radar-edge-chip:focus-visible {
  max-width: min(260px, calc(100vw - 1.5rem));
  filter: brightness(1.06);
}
body.renewal-drawer-open .renewal-radar-edge-chip {
  transform: translateX(calc(-1 * min(420px, calc(100vw - 0.75rem))));
  box-shadow: var(--renewal-chip-shadow-open);
  max-width: min(260px, calc(100vw - 1.5rem));
}
body.renewal-drawer-open .renewal-radar-edge-chip:hover {
  filter: brightness(1.06);
}
.renewal-radar-edge-chip:active {
  filter: brightness(0.96);
}
.renewal-radar-edge-chip:focus-visible {
  outline: 2px solid rgba(167, 139, 250, 0.95);
  outline-offset: 2px;
}
.renewal-radar-edge-chip-waves {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: 12px 0 0 12px;
  overflow: visible;
}
.renewal-radar-edge-chip-waves span {
  position: absolute;
  inset: -6px;
  border-radius: 14px 0 0 14px;
  border: 2px solid var(--renewal-chip-wave);
  transform-origin: right center;
  animation: renewal-radar-wave 2.4s ease-out infinite;
  box-shadow: 0 0 14px var(--renewal-chip-wave-glow);
}
.renewal-radar-edge-chip-waves span:nth-child(2) {
  animation-delay: 0.8s;
}
.renewal-radar-edge-chip-waves span:nth-child(3) {
  animation-delay: 1.6s;
}
@keyframes renewal-radar-wave {
  0% {
    transform: scaleX(1) scaleY(1);
    opacity: 0.55;
  }
  100% {
    transform: scaleX(1.75) scaleY(1.28);
    opacity: 0;
  }
}
.renewal-radar-edge-chip-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 0.45rem 0.4rem 0.45rem 0.55rem;
  overflow: hidden;
  border-radius: 12px 0 0 12px;
}
.renewal-radar-edge-chip-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.renewal-radar-edge-chip-count {
  position: absolute;
  top: -5px;
  right: -7px;
  z-index: 4;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.125rem;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  letter-spacing: -0.02em;
}
.renewal-radar-edge-chip-count.is-zero {
  background: rgba(148, 163, 184, 0.45);
  color: rgba(15, 23, 42, 0.95);
  font-weight: 700;
}
body[data-theme="light"] .renewal-radar-edge-chip-count.is-zero {
  color: #334155;
}
.renewal-radar-edge-chip-count.is-loading {
  background: rgba(148, 163, 184, 0.35);
  color: transparent;
  font-size: 0;
  min-width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  top: -2px;
  right: -2px;
  animation: renewal-chip-count-pulse 1s ease-in-out infinite;
}
@keyframes renewal-chip-count-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}
.renewal-radar-edge-chip-count.is-unavailable {
  background: rgba(148, 163, 184, 0.4);
  color: rgba(226, 232, 240, 0.95);
  font-size: 0.58rem;
  font-weight: 700;
  min-width: 1rem;
  padding: 0 0.15rem;
}
body[data-theme="light"] .renewal-radar-edge-chip-count.is-unavailable {
  color: #475569;
}
.renewal-radar-edge-chip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.renewal-radar-edge-chip-svg {
  width: 24px;
  height: 24px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.renewal-radar-edge-chip-label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: inherit;
  text-shadow: var(--renewal-chip-text-shadow);
  flex-shrink: 0;
  text-transform: none;
  transition: opacity 0.22s ease, max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin 0.22s ease;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
}
.renewal-radar-edge-chip:hover .renewal-radar-edge-chip-label,
.renewal-radar-edge-chip:focus-visible .renewal-radar-edge-chip-label,
body.renewal-drawer-open .renewal-radar-edge-chip .renewal-radar-edge-chip-label {
  opacity: 1;
  max-width: 14rem;
  margin-right: 0.4rem;
}
body.renewal-drawer-open {
  overflow: hidden;
}

.dialog-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}
.info-stack .info-item strong { color: var(--heading); margin-right: 0.35rem; }

.toast-stack {
  position: fixed;
  right: 1rem;
  top: max(1rem, env(safe-area-inset-top));
  bottom: auto;
  display: grid;
  gap: 0.7rem;
  z-index: 999;
}
.toast {
  min-width: 280px;
  max-width: 360px;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: rgba(15, 23, 42, 0.92);
  color: white;
  box-shadow: var(--shadow);
}
body[data-theme="light"] .toast { background: rgba(255,255,255,0.96); color: #0f172a; }
.toast.success { border-color: rgba(34, 197, 94, 0.36); }
.toast.error { border-color: rgba(239, 68, 68, 0.36); }
.toast.info { border-color: rgba(6, 182, 212, 0.36); }

@media (max-width: 1180px) {
  .metric-grid,
  .quick-links-grid,
  .card-grid.compact-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-charts__row--split { grid-template-columns: 1fr; }
  .page-grid.split-layout,
  .hero-grid,
  .content-grid.two-wide { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  body.app-body {
    overflow-x: clip;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    width: min(270px, 88vw);
    transform: translateX(-100%);
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: grid; }

  .hero-panel {
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
  }
  .hero-actions {
    width: 100%;
    justify-content: stretch;
  }
  .hero-actions .button {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.65rem;
    width: 100%;
  }

  .section-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .section-head--lead-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .section-head--lead-toolbar .toolbar-lead-row {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
  }
  .section-head--lead-toolbar .toolbar-lead-row input[type="search"] {
    max-width: none;
    flex: 1 1 200px;
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .page-shell,
  .topbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .metric-grid,
  .quick-links-grid,
  .card-grid.compact-cards,
  .field-grid.two-col { grid-template-columns: 1fr; }
  .topbar { align-items: start; flex-direction: column; }
  .topbar-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
  }
  .header-identity {
    max-width: 100%;
  }
  .header-name-row {
    min-width: 0;
  }
  .profile-pill { min-width: 0; width: 100%; }
  .section-head--lead-toolbar {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: wrap;
  }
  .section-head--lead-toolbar .toolbar-lead-row {
    flex-wrap: wrap;
    justify-content: stretch;
    width: 100%;
  }
  .section-head--lead-toolbar .toolbar-lead-row input[type="search"] {
    max-width: none;
    flex: 1 1 100%;
    min-width: 0;
  }
  .toolbar { width: 100%; }
  .compact-toolbar input,
  .compact-toolbar select,
  .button,
  .form-actions .button { width: 100%; }
  .section-head--lead-toolbar .toolbar-lead-row .button {
    width: auto;
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 120px;
  }
  .row-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .button,
  .hero-actions a.button {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  .auth-page {
    padding: 1rem;
  }
  .auth-card__brand,
  .auth-card__body {
    padding: 1.35rem;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }
  .dialog-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }
  .toast-stack {
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
    top: max(0.75rem, env(safe-area-inset-top));
    bottom: auto;
  }
  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .profile-pill {
    flex-wrap: wrap;
  }
  .topbar-left {
    min-width: 0;
    flex: 1 1 auto;
  }
}
