:root {
  /* ═══════════════════════════════════════════════════════════
     SAFITRACK DESIGN SYSTEM v2 — Attio-grade cohesion
     Every token below is implementation-ready.
     ═══════════════════════════════════════════════════════════ */

  /* ── Colors ── */
  --color-primary: #2f5fd0;
  --color-primary-rgb: 47, 95, 208;
  --color-primary-dark: #2550b5;
  --color-primary-light: #6b93e8;
  --color-primary-bg: rgba(47, 95, 208, 0.08);
  --color-primary-bg-hover: rgba(47, 95, 208, 0.12);

  --color-success: #16a34a;
  --color-success-rgb: 22, 163, 74;
  --color-success-bg: rgba(22, 163, 74, 0.08);
  --color-warning: #ca8a04;
  --color-warning-rgb: 202, 138, 4;
  --color-warning-bg: rgba(202, 138, 4, 0.08);
  --color-danger: #dc2626;
  --color-danger-rgb: 220, 38, 38;
  --color-danger-bg: rgba(220, 38, 38, 0.08);

  /* ── Backgrounds — very subtle layering like Attio ── */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f3f5;
  --bg-elevated: #ffffff;
  --bg-gray: #e9ecef;
  --bg-hover: rgba(0, 0, 0, 0.03);
  --bg-active: rgba(0, 0, 0, 0.05);

  /* ── Text — clear 3-level hierarchy ── */
  --text-primary: #0d0f11;
  --text-secondary: #3d4249;
  --text-muted: #6e7681;
  --text-inverse: #ffffff;

  /* ── Borders — subtle, low-contrast ── */
  --border-color: #dee2e6;
  --border-color-light: #f1f3f5;

  /* ── Shadows — extremely subtle, Attio-style ── */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.10);

  /* ── Layout ── */
  --header-height: 52px;
  --sidebar-width: 220px;
  --bottom-nav-height: 64px;
  --content-max-width: 1200px;

  /* ── Border Radius — tight, consistent like Attio ── */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* ── Spacing — strict 4px grid ── */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;

  /* ── Control heights — THE unifying constant ── */
  --control-height-xs: 24px;
  --control-height-sm: 28px;
  --control-height-md: 30px;
  --control-height-lg: 36px;
  --icon-xs: 12px;
  --icon-sm: 14px;
  --icon-md: 16px;
  --icon-lg: 18px;

  /* ── Button tokens ── */
  --btn-radius: 8px;
  --btn-font-size: 0.875rem;
  --btn-font-weight: 550;

  /* ── Transitions — fast, professional ── */
  --transition-fast: 100ms ease;
  --transition-base: 150ms ease;
  --transition-slow: 250ms ease;
  --motion-ease-standard: cubic-bezier(0.25, 0.1, 0.25, 1);
  --motion-ease-emphasized: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-distance-press: 1px;
  --motion-distance-hover: 0px;

  /* ── Z-index layers ── */
  --z-dropdown: 1000;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 1000;
  --z-modal: 1100;
  --z-toast: 100000;
  --z-loading: 1300;
  --z-header: 800;
}

/* =========================
   Settings module — Redesigned (Senior v2)
   Purpose: stronger hierarchy, clearer affordances, 8px spacing system
   ========================= */

/* Spacing and type tokens (unified with design system) */
:root {
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 32px;
  --s-5: 40px;
  --s-6: 56px;

  /* ── Typography scale — compact, professional ── */
  --type-xxs: 0.6875rem;   /* 11px */
  --type-xs: 0.75rem;      /* 12px */
  --type-sm: 0.8125rem;    /* 13px */
  --type-md: 0.875rem;     /* 14px */
  --type-lg: 1rem;         /* 16px */
  --type-xl: 1.125rem;     /* 18px */
  --type-xxl: 1.25rem;     /* 20px */

  --card-radius: var(--radius-md);
  --card-border: 1px solid var(--border-color);
  --card-elevation: var(--shadow-xs);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-1);
  border-bottom: 1px solid var(--border-color-light);
}

.settings-header>div:first-child {
  max-width: 68%;
}

.settings-title {
  font-size: var(--type-xxl);
  margin: 0;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.settings-sub {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--type-sm);
  line-height: 1.4;
}

.settings-header-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center
}

/* Actions — make primary prominent, cancel subtle */
.settings-header-actions .btn {
  border-radius: var(--btn-radius);
  padding: 0 var(--space-3);
  font-weight: 550;
}

.settings-header-actions .btn.btn-primary {
  transform: translateY(0);
  transition: background var(--transition-fast);
}

.settings-header-actions .btn.btn-primary:active {
  transform: translateY(1px);
}

.settings-header-actions .btn.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.settings-layout {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
  max-width: var(--content-max-width);
  margin: 0 auto
}

/* Navigation — compact vertical rail with clear active affordance */
.settings-nav {
  width: 220px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.settings-nav .nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 6px;
  background: transparent;
  transition: background 180ms ease
}

.settings-nav .nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: none;
}

.settings-nav .nav-item.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.settings-nav .nav-item.active::before {
  background: var(--color-primary);
}

.settings-nav .nav-item.danger {
  color: var(--color-danger);
  font-weight: 600;
}

.settings-content {
  flex: 1;
  min-width: 380px
}

/* Card — more breathing room, clearer header */
.section-card {
  background: var(--bg-secondary);
  border-radius: var(--card-radius);
  border: var(--card-border);
  overflow: hidden;
}

.section-card+.section-card {
  margin-top: var(--s-3)
}

.section-card-header {
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-color-light);
  display: flex;
  align-items: center;
  justify-content: space-between
}

.section-title {
  margin: 0;
  font-size: var(--type-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.section-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: var(--type-sm)
}

.section-card-body {
  padding: var(--s-3)
}

/* Form grid tuned to 8px system */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2)
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.form-field label {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: var(--type-sm)
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field select {
  height: calc(var(--control-height-lg) + 2px);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: none;
  font-size: var(--type-md)
}

/* Small input variant */
.input-small,
select.input-small {
  box-sizing: border-box;
  height: var(--control-height-md);
  padding: 0 var(--space-3);
  line-height: 1.2;
  font-size: var(--type-md);
  border-radius: var(--btn-radius);
}

/* Override for select inputs that need explicit height */
select.input-small {
  height: var(--control-height-md) !important;
  min-height: var(--control-height-md);
  line-height: var(--control-height-md) !important;
  padding: 0 var(--space-3) !important;
  font-size: var(--type-md) !important;
  box-sizing: border-box !important;
  vertical-align: middle;
}

/* Main app header brand logo - theme-aware colors */
.header-brand img,
.app-header .header-brand img {
  width: 130px;
  height: auto;
  transition: filter 180ms var(--motion-ease-standard), -webkit-filter 180ms var(--motion-ease-standard);
}

/* Dark mode: render logo white */
html[data-theme="dark"] .header-brand img {
  /* Use grayscale + brightness so the logo becomes neutral (avoid color inversion artifacts)
     Adjust brightness to sit closer to the text tone */
  filter: grayscale(1) brightness(2) contrast(0.95);
  -webkit-filter: grayscale(1) brightness(2) contrast(0.95);
  opacity: 0.95;
}

/* Light mode: render logo darker but not fully saturated black */
html[data-theme="light"] .header-brand img {
  /* Slightly reduce brightness to soften the logo in light mode */
  filter: grayscale(1) brightness(0.75) contrast(0.95);
  -webkit-filter: grayscale(1) brightness(0.75) contrast(0.95);
  opacity: 0.95;
}

.form-field input[disabled] {
  opacity: 0.8
}

.radio-row {
  display: flex;
  gap: 12px;
  align-items: center
}

.radio-row label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--type-sm)
}

/* Segmented control — pill track with inner knob feel, keyboard accessible */
.segmented-control {
  display: inline-flex;
  background: transparent;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-light)
}

.segmented-control .seg-btn {
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  font-weight: 550;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--type-sm);
}

.segmented-control .seg-btn.seg-active {
  background: var(--color-primary);
  color: var(--text-inverse);
}

.seg-hint {
  display: block;
  font-size: var(--type-xxs);
  opacity: 0.9
}

/* Control row — descriptions get more room and better contrast */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2)
}

.control-desc {
  color: var(--text-muted);
  max-width: 62%;
  font-size: var(--type-sm)
}

/* Toggle — larger, tactile */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none
}

.toggle-switch .switch {
  width: 40px;
  height: 24px;
  background: var(--bg-gray);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  position: relative;
  transition: all var(--transition-fast);
}

.toggle-switch .switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked+.switch {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.toggle-switch input:checked+.switch::after {
  transform: translateX(16px);
}

.toggle-switch .switch:focus {
  outline: 3px solid rgba(var(--color-primary-rgb), 0.10);
  outline-offset: 2px
}

.form-actions {
  display: flex;
  gap: var(--s-1);
  justify-content: flex-end;
  padding-top: var(--s-1)
}

.empty-state {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2);
  color: var(--text-muted)
}

.empty-illustration {
  font-size: 26px
}

.danger-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 12px 0
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger-bg);
  padding: 0 var(--space-3);
  border-radius: var(--btn-radius);
  font-weight: 600;
}

@media (max-width: 920px) {
  .settings-layout {
    flex-direction: column
  }

  .settings-nav {
    width: 100%;
    display: flex;
    gap: 8px;
    overflow: auto;
    padding: 8px
  }

  .form-grid {
    grid-template-columns: 1fr
  }

  .settings-header {
    align-items: flex-start
  }

  .settings-header>div:first-child {
    max-width: 100%
  }
}

[data-theme="dark"] {
  /* Backgrounds — refined dark surface hierarchy */
  --bg-primary: #111318;
  --bg-secondary: #16181d;
  --bg-tertiary: #1c1f26;
  --bg-elevated: #1c1f26;
  --bg-gray: #23262e;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.06);

  /* Text — clear hierarchy, bright on dark */
  --text-primary: #f0f2f4;
  --text-secondary: #b8c0cc;
  --text-muted: #737d8c;

  /* Borders — subtle */
  --border-color: #2a2e36;
  --border-color-light: #1f2229;

  /* Shadows — darker ambient */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.32);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.40);

  /* Semantic color backgrounds stay the same */
  --color-primary-bg: rgba(47, 95, 208, 0.12);
  --color-primary-bg-hover: rgba(47, 95, 208, 0.18);
  --color-success-bg: rgba(22, 163, 74, 0.12);
  --color-warning-bg: rgba(202, 138, 4, 0.12);
  --color-danger-bg: rgba(220, 38, 38, 0.12);
}

/* ===== MENTION SYSTEM ===== */
.mention-container {
  position: relative;
}

.mention-input {
  width: 100%;
  min-height: 100px;
  padding: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition-fast);
  resize: vertical;
}

.mention-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.mention-suggestions {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
}

.mention-suggestion {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.mention-suggestion:hover {
  background: var(--bg-tertiary);
}

.mention-suggestion.active {
  background: var(--color-primary-bg);
}

.mention-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

/* Company view summary styles */
.company-summary {
  padding: 8px 0;
}

.company-summary-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.company-summary-avatar img.company-summary-logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.company-summary-initials {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
}

.company-summary-main {
  min-width: 0;
}

.company-summary-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-summary-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.company-summary-domain {
  font-size: 0.9rem;
}

.company-summary-domain-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  font-size: 0.85rem;
}

.company-summary-domain-link svg {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

.company-summary-domain-link:hover {
  background: var(--bg-primary);
  transform: translateY(-1px);
  transition: var(--transition-fast);
}

/* Dark theme tweak */
[data-theme="dark"] .company-summary-domain-link {
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-primary-light);
}

/* Style company link inside person/company summary meta to look like plain muted metadata */
.company-summary-meta .person-view-company-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--color-primary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 160ms ease, transform 160ms ease;
}

.company-summary-meta .person-view-company-link svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  stroke: currentColor;
  opacity: 0.95;
}

.company-summary-meta .person-view-company-link .person-company-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  display: inline-block;
  vertical-align: middle;
}

.company-summary-meta .person-view-company-link:hover {
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

[data-theme="dark"] .company-summary-meta .person-view-company-link {
  color: var(--color-primary-light);
}

.mention-info {
  flex: 1;
}

.mention-name {
  font-weight: 550;
  color: var(--text-primary);
}

.mention-details {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.mentioned-person {
  display: inline-block;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-weight: 550;
  margin: 0 0.125rem;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scrollbar-gutter: stable;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* ===== LOADING SCREEN ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-loading);
  transition: opacity 180ms ease, visibility 180ms ease;
  overflow: hidden;
}

/* dark theme no longer needs a separate color; the variable --bg-primary
   is already dark when theme is set to dark, so the base rule handles both modes. */
/*[data-theme="dark"] .loading-overlay {
  background: #0f1117;
}*/

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes gradient-shift-dark {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Animated background blobs */
.loading-overlay::before {
  content: none;
}

.loading-overlay::after {
  content: none;
}

@keyframes blob-animation {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -30px) scale(1.1);
  }

  66% {
    transform: translate(-20px, 20px) scale(0.95);
  }
}

.loading-content {
  /* default card-style layout for older versions; kept for backwards compatibility */
  text-align: center;
  padding: 2rem 1.75rem;
  position: relative;
  z-index: 10;
  width: min(420px, calc(100% - 2rem));
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .loading-content {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-lg);
}

/* --- simple inline loading layout used by crm loading screen --- */
.loading-content.simple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  box-shadow: none;
  width: auto;
  padding: 0.5rem 1rem;
}

@keyframes content-appear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.loading-logo {
  margin-bottom: 1rem;
  position: relative;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-logo img {
  height: 46px;
  width: auto;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  margin: 0.5rem auto 1rem;
  position: relative;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary);
  animation: loading-spin 0.9s linear infinite;
}

/* inline adjustments when inside simple container */
.loading-content.simple .loading-spinner {
  margin: 0;
  /* no automatic centering */
  width: 24px;
  height: 24px;
  border-width: 2px;
  /* reapply animation in case cascade dropped it */
  animation: loading-spin 0.9s linear infinite;
  animation-play-state: running;
}

/* hide legacy extras when using simple layout */
.loading-content.simple .loading-logo,
.loading-content.simple .loading-progress {
  display: none;
}

.loading-spinner::before,
.loading-spinner::after {
  content: none;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner::before {
  content: none;
}

.loading-spinner::after {
  content: none;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 550;
  margin-bottom: 1rem;
  letter-spacing: 0.2px;
  position: relative;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* smaller font when inside simple layout */
.loading-content.simple .loading-text {
  font-size: 0.8rem;
  margin-bottom: 0;
}

.loading-progress {
  width: 100%;
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  margin: 0 auto;
}

[data-theme="dark"] .loading-progress {
  background: var(--bg-tertiary);
}

.loading-progress-bar {
  height: 100%;
  width: 38%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  animation: loading-bar 1.1s ease-in-out infinite;
}

.loading-progress-bar::after {
  content: none;
}

@keyframes loading-bar {
  0% {
    transform: translateX(-65%);
  }

  100% {
    transform: translateX(225%);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Inline spinner for busy buttons and status lines ("Saving…") */
.btn-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.125em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.8;
  animation: spin 0.7s linear infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

@keyframes loading-progress {
  0% {
    width: 0;
  }

  50% {
    width: 70%;
  }

  100% {
    width: 100%;
  }
}

/* ===== WELCOME SCREEN ===== */
/* Full-screen login welcome — Apple-style, zero extra load time. */
.wlc-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  opacity: 0;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.wlc-overlay.wlc-visible {
  opacity: 1;
  pointer-events: auto;
}

.wlc-overlay.wlc-fade-out {
  opacity: 0;
}

.wlc-content {
  text-align: center;
  user-select: none;
  padding: 0 2rem;
}

.wlc-greeting {
  margin: 0 0 0.15em;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 300;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  opacity: 0;
  transform: translateY(10px);
}

.wlc-name {
  margin: 0;
  font-size: clamp(2.5rem, 7.5vw, 5.5rem);
  font-weight: 200;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  opacity: 0;
  transform: translateY(14px);
}

.wlc-overlay.wlc-visible .wlc-greeting {
  animation: wlc-rise 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}

.wlc-overlay.wlc-visible .wlc-name {
  animation: wlc-rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

@keyframes wlc-rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shared form layout, also used by modals and log-visit */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-field label {
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--text-primary);
  padding-left: 2px;
}

.input-wrapper.modern-input {
  position: relative;
}

.input-wrapper.modern-input i:first-child,
.input-wrapper.modern-input svg.left-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  /* For i tags */
  width: 18px;
  /* For SVGs */
  height: 18px;
  /* For SVGs */
  pointer-events: none;
  z-index: 10;
}

.input-wrapper.modern-input input {
  width: 100%;
  height: 48px;
  /* Increased slightly for better breathability */
  padding: 0 45px 0 42px !important;
  /* Extra padding on right to avoid eye icon overlap */
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: all 0.2s ease-in-out;
}

[data-theme="dark"] .input-wrapper.modern-input input {
  background: rgba(255, 255, 255, 0.03);
  /* Slight contrast against bg */
  border-color: rgba(255, 255, 255, 0.1);
}

.input-wrapper.modern-input input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
  background: var(--bg-primary);
  outline: none;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS — Unified system. Every button shares the same
   DNA: height, radius, font, spacing. Variants only change
   color/fill. This is the #1 cohesion lever.
   ═══════════════════════════════════════════════════════════ */

/* Base Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height-md);
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  font-size: var(--btn-font-size);
  font-weight: var(--btn-font-weight);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn i,
.btn svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex-shrink: 0;
}

.btn::before {
  display: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Shared font styling for all button-like controls */
.toolbar-btn,
.toolbar-btn-primary,
.toggle-btn,
.action-btn {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--type-md);
  font-weight: 550;
}

/* Primary — solid fill, the main CTA */
.btn-primary {
  background: var(--color-primary);
  color: var(--text-inverse);
  border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn-primary:active:not(:disabled) {
  background: var(--color-primary-dark);
}

/* Secondary — bordered, used alongside primary */
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:active:not(:disabled) {
  background: var(--bg-active);
}

[data-theme="dark"] .btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
}

/* Danger — destructive actions */
.btn-danger {
  background: var(--color-danger);
  color: var(--text-inverse);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-danger:active:not(:disabled) {
  background: #991b1b;
}

/* Ghost — minimal, blends with content */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-ghost:active:not(:disabled) {
  background: var(--bg-active);
}

[data-theme="dark"] .btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Focus ring — accessible but subtle */
.btn:focus-visible,
.toolbar-btn:focus-visible,
.toolbar-btn-primary:focus-visible,
.action-btn:focus-visible,
.toggle-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* Size Variants */
.btn-lg {
  height: var(--control-height-lg);
  padding: 0 var(--space-4);
  font-size: var(--btn-font-size);
}

.btn-sm {
  height: var(--control-height-sm);
  padding: 0 var(--space-2);
  font-size: var(--type-xs);
}

.btn-xs {
  height: var(--control-height-xs);
  padding: 0 var(--space-2);
  font-size: var(--type-xxs);
}

.btn-block {
  width: 100%;
}

/* Success */
.btn-success {
  background: var(--color-success);
  color: var(--text-inverse);
  border-color: transparent;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

/* Warning */
.btn-warning {
  background: var(--color-warning);
  color: var(--text-inverse);
  border-color: transparent;
}

.btn-warning:hover:not(:disabled) {
  background: #a16207;
}

/* Icon-only button */
.btn-icon {
  width: var(--control-height-md);
  height: var(--control-height-md);
  padding: 0;
  border-radius: var(--btn-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.btn-primary {
  background: var(--color-primary);
  color: var(--text-inverse);
}

.btn-icon.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-icon.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-icon:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .btn-icon:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Outline Button - Professional Alternative */
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  box-shadow: none;
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-primary-bg);
  box-shadow: 0 2px 4px rgba(47, 95, 208, 0.1);
}

.btn-outline:active:not(:disabled) {
  transform: scale(0.98);
}

[data-theme="dark"] .btn-outline {
  color: var(--color-primary-light);
  border-color: var(--color-primary-light);
}

[data-theme="dark"] .btn-outline:hover:not(:disabled) {
  background: rgba(125, 162, 248, 0.15);
}

/* ===== DARK MODE BUTTON ENHANCEMENTS ===== */

/* Dark mode secondary buttons */
[data-theme="dark"] .btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
  box-shadow: none;
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--color-primary-light);
  box-shadow: 0 2px 6px rgba(125, 162, 248, 0.1);
}

/* Dark mode success button */
[data-theme="dark"] .btn-success {
  box-shadow: 0 2px 8px rgba(31, 157, 110, 0.2);
}

[data-theme="dark"] .btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(31, 157, 110, 0.3);
}

/* Dark mode warning button */
[data-theme="dark"] .btn-warning {
  box-shadow: 0 2px 8px rgba(198, 132, 26, 0.2);
}

[data-theme="dark"] .btn-warning:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(198, 132, 26, 0.3);
}

/* Dark mode danger button */
[data-theme="dark"] .btn-danger {
  box-shadow: 0 2px 8px rgba(200, 58, 58, 0.2);
}

[data-theme="dark"] .btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(200, 58, 58, 0.3);
}

/* Dark mode ghost button */
[data-theme="dark"] .btn-ghost {
  color: var(--text-secondary);
}

[data-theme="dark"] .btn-ghost:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Dark mode icon buttons */
[data-theme="dark"] .btn-icon.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-icon.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--color-primary-light);
}

[data-theme="dark"] .btn-icon.btn-ghost {
  color: var(--text-secondary);
}

[data-theme="dark"] .btn-icon.btn-ghost:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--color-primary-light);
}

/* ===== APP LAYOUT ===== */
.main-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-secondary);
}

/* ===== APP HEADER ===== */
.app-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3) 0 var(--space-2);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
}

body.modal-active {
  overflow: hidden !important;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0;
  padding-left: 0;
  min-width: 0;
  overflow: hidden;
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-md);
  height: var(--control-height-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--btn-radius);
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--bg-hover);
}

.mobile-menu-btn:active {
  background: var(--bg-active);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

/* The page name in the header is for phones (phone.css); wider screens
   show it beside the sidebar instead (.page-label) */
@media (min-width: 769px) {
  .header-page-title {
    display: none !important;
  }
}

.header-org-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-1);
  min-width: 0;
  flex-wrap: nowrap;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--btn-radius);
  transition: background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 1;
}

.header-org-btn:hover {
  background: var(--bg-hover);
}

.header-org-name {
  font-size: var(--type-lg);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.header-org-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.header-org-btn.open .header-org-chevron {
  transform: rotate(180deg);
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--btn-radius);
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  transition: all var(--transition-fast);
}

/* Bare icons in the header: no outline, a soft background on hover.
   Only Ask Safi (.header-ai-btn) keeps its outline. */
.header-icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.header-icon-btn:active {
  background: var(--bg-active);
}

.header-right button,
.header-right .header-icon-btn,
.header-right .header-ai-btn,
.header-right .user-avatar-btn {
  transform: none !important;
}

.header-right button:hover,
.header-right .header-icon-btn:hover,
.header-right .header-ai-btn:hover,
.header-right .user-avatar-btn:hover,
.header-right button:active,
.header-right .header-icon-btn:active,
.header-right .header-ai-btn:active,
.header-right .user-avatar-btn:active {
  transform: none !important;
}

.header-icon-btn svg {
  width: 18px;
  height: 18px;
  color: currentColor;
  display: block;
  flex-shrink: 0;
}

/* Header vertical divider before profile avatar */
.header-divider {
  width: 1px;
  height: 16px;
  background: var(--border-color);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────────────────
   NOTIFICATIONS — redesigned
   ────────────────────────────────────────────────────────────────────── */

#notifications-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* ══════════════════════════════════════════════════════════════════════════════
   NOTIFICATIONS / INBOX SYSTEM (Attio & Linear Inspired)
   ══════════════════════════════════════════════════════════════════════════════ */

.notifications-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notification-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: var(--btn-radius);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  transition: all var(--transition-fast);
}

.notification-bell-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.notification-bell-btn svg {
  width: 18px;
  height: 18px;
  color: currentColor;
  transition: color var(--transition-fast);
  display: block;
  flex-shrink: 0;
}

.notification-bell-btn:hover svg,
.notification-bell-btn.has-unread svg {
  color: var(--text-primary);
}

.notification-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3.5px;
  border-radius: 9999px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  z-index: 2;
}

.notification-badge[style*="display: none"],
.notification-badge[style*="display:none"] {
  display: none !important;
}

/* Popover panel */
.notifications-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(94vw, 390px);
  max-height: min(76vh, 560px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.99);
  transition: opacity 130ms cubic-bezier(0.16, 1, 0.3, 1),
              visibility 130ms,
              transform 130ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#notifications-wrapper.active .notifications-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* The Inbox: a full-height panel sliding out beside the sidebar.
   ui.js sets --inbox-left to the sidebar's edge when it opens. */
#notifications-wrapper .inbox-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--inbox-left, var(--sidebar-width));
  right: auto;
  width: min(400px, calc(100vw - var(--inbox-left, 0px)));
  max-height: none;
  border: 0;
  border-right: 1px solid var(--border-color);
  border-radius: 0;
  box-shadow: 16px 0 40px -12px rgba(0, 0, 0, 0.16);
  transform: translateX(-12px);
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1),
              visibility 160ms,
              transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  /* Over the header's page title (which sits just under dialogs); comes
     after it in the page, so the same level draws on top */
  z-index: calc(var(--z-modal) - 1);
  padding-bottom: 0;
}

#notifications-wrapper.inbox-drawer.active .inbox-panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

#notifications-wrapper .inbox-panel .sn-header {
  height: var(--header-height, 52px);
}

#notifications-wrapper .inbox-panel .sn-list-container {
  flex: 1;
  max-height: none;
}

/* The Inbox button in the sidebar, next to Search */
.sidebar-inbox-btn {
  position: relative;
  width: 32px;
  justify-content: center;
  padding: 0;
}

.sidebar-inbox-btn svg {
  width: 17px;
  height: 17px;
}

.sidebar-inbox-btn.has-unread,
.sidebar-inbox-btn[aria-expanded="true"] {
  color: var(--text-primary);
}

.sidebar-inbox-btn[aria-expanded="true"] {
  background: var(--bg-tertiary);
}

.sidebar-inbox-btn .notification-badge {
  top: -6px;
  right: -6px;
  box-shadow: 0 0 0 2px var(--bg-secondary);
}

/* Phones: a dot on the menu button when the Inbox has something new */
.mobile-menu-btn {
  position: relative;
}

.mobile-menu-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
  pointer-events: none;
}

.mobile-menu-dot[hidden] {
  display: none;
}

/* Header */
.sn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sn-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sn-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: 0;
}

.sn-unread-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sn-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sn-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--btn-radius);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sn-icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sn-icon-btn.active {
  background: var(--bg-tertiary);
  color: var(--color-primary);
}

.sn-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Quick Settings Tray */
.sn-settings-tray {
  max-height: 0;
  overflow: hidden;
  background: var(--bg-tertiary);
  border-bottom: 1px solid transparent;
  transition: max-height 180ms ease, border-color 180ms ease;
  flex-shrink: 0;
}

.sn-settings-tray.open {
  max-height: 140px;
  border-bottom-color: var(--border-color);
}

.sn-settings-tray-inner {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sn-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.sn-settings-meta {
  display: flex;
  flex-direction: column;
}

.sn-settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sn-settings-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.sn-btn-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sn-btn-toggle.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* Segmented Filter Control (Linear / Attio style) */
.sn-filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.sn-filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 var(--space-2);
  border-radius: var(--btn-radius);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sn-filter-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sn-filter-tab.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  font-weight: 600;
}

.sn-tab-count {
  font-size: 0.6875rem;
  font-weight: 500;
  opacity: 0.7;
}

/* Scrollable List Container */
.sn-list-container {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Empty State */
.sn-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  flex: 1;
}

.sn-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.sn-empty-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sn-empty-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  max-width: 240px;
  line-height: 1.4;
}

/* Group headers: Today, Overdue, Earlier */
.sn-group-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 14px var(--space-4) 4px;
  background: var(--bg-secondary);
}

.sn-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sn-group-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sn-group-items {
  display: flex;
  flex-direction: column;
}

/* One row per item: unread dot, icon, name and what it's about, due date */
.sn-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 7px var(--space-4) 7px 8px;
  background: var(--bg-secondary);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: background var(--transition-fast);
}

.sn-item:hover,
.sn-item:focus-visible {
  background: var(--bg-hover);
}

.sn-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.sn-unread-indicator {
  flex: 0 0 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  visibility: hidden;
}

.sn-item.unread .sn-unread-indicator {
  visibility: visible;
}

.sn-item-icon-wrap {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  height: 26px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.sn-item-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.sn-item-title,
.sn-item-message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sn-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-secondary);
}

.sn-item.unread .sn-item-title {
  font-weight: 600;
  color: var(--text-primary);
}

.sn-item-message {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.sn-item-side {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  min-width: 24px;
}

.sn-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Overdue says so through its date; nothing else turns red */
.sn-item.is-overdue .sn-item-time {
  font-weight: 550;
  color: var(--color-danger);
}

/* Mark read / unread: takes the date's place on hover or keyboard focus */
.sn-action-btn {
  position: absolute;
  top: 50%;
  right: -4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.sn-item:hover .sn-action-btn,
.sn-item:focus-within .sn-action-btn {
  opacity: 1;
}

.sn-item:hover .sn-item-time,
.sn-item:focus-within .sn-item-time {
  visibility: hidden;
}

.sn-action-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

/* Footer */
.sn-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: var(--space-2) var(--space-4);
  flex-shrink: 0;
}

.sn-permission-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-1) 0;
}

.sn-permission-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sn-permission-action {
  height: 24px;
  padding: 0 var(--space-3);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(47, 95, 208, 0.08);
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sn-permission-action:hover {
  background: rgba(47, 95, 208, 0.16);
}

.sn-footer-status {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) 0;
}

.sn-kbd-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.sn-kbd-hint kbd {
  display: inline-block;
  padding: 1px 4px;
  font-size: 0.625rem;
  font-family: inherit;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════════════════════════
   IN-APP NOTIFICATION TOASTS (Linear / Attio Stack)
   ══════════════════════════════════════════════════════════════════════════════ */

.safitrack-notif-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: min(92vw, 360px);
  z-index: calc(var(--z-toast) + 10);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.safitrack-notif-toast-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.12), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  outline: none;
}

.safitrack-notif-toast-card.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.safitrack-notif-toast-card.dismissing {
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
}

.notif-toast-icon-wrap {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-top: 2px;
}

.safitrack-notif-toast-card.urgent .notif-toast-icon-wrap {
  color: var(--color-danger);
  background: rgba(220, 38, 38, 0.08);
}

.notif-toast-body {
  flex: 1;
  min-width: 0;
  padding-right: 18px; /* space for close button */
}

.notif-toast-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.notif-toast-category {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.notif-toast-badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
}

.notif-toast-badge.overdue {
  color: var(--color-danger);
  background: rgba(220, 38, 38, 0.08);
}

.notif-toast-badge.due-today {
  color: var(--color-primary);
  background: rgba(47, 95, 208, 0.08);
}

.notif-toast-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 2px;
}

.notif-toast-msg {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: var(--space-2);
}

.notif-toast-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.notif-toast-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--btn-radius);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.notif-toast-btn-action {
  background: var(--color-primary);
  border: 1px solid var(--color-primary);
  color: #fff;
}

.notif-toast-btn-action:hover {
  background: #254db0;
}

.notif-toast-btn-dismiss {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.notif-toast-btn-dismiss:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.notif-toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.notif-toast-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ----- Disable hover transform for key CRM action buttons -----
   The user requested removing the subtle hover 'move/scale' effect
   for new-company / new-person style buttons in CRM. This override
   clears transform on hover for common action button selectors.
*/
.settings-header-actions .btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.company-summary-domain-link,
.company-summary-meta .person-view-company-link,
.toolbar-btn-primary,
#add-company-btn,
#add-person-btn {
  transition-property: background, color, box-shadow !important;
  /* keep color/box-shadow trasitions but drop transform */
}

.settings-header-actions .btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-ghost:hover,
.company-summary-domain-link:hover,
.company-summary-meta .person-view-company-link:hover,
.toolbar-btn-primary:hover,
#add-company-btn:hover,
#add-person-btn:hover {
  transform: none !important;
  /* remove any hover translation/scale */
}

/* Legacy In-App Due Popup aliases (backward-compat) */
.notif-popup-container {
  display: none !important;
}

/* ==========================
   TECHNICIAN FORMS - PREMIUM
   Focused styles to modernize and unify
   Survey / Installation / Maintenance forms
   Non-functional visual improvements only
   ========================== */
.card.max-w-md {
  max-width: 520px;
}

.card.max-w-3xl {
  max-width: 980px;
}

.card .card-body {
  padding: 28px;
}

.section-container {
  background: transparent;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--border-color);
}

.section-container h3.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px 0;
  font-size: 1.02rem;
}

.section-container h3.card-title i {
  width: 20px;
  height: 20px;
  opacity: 0.9
}

.form-field {
  display: block;
  margin-bottom: 12px;
}

.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .12s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: rgba(47, 95, 208, 0.9);
  box-shadow: 0 8px 24px rgba(47, 95, 208, 0.06);
}

.field-helper {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.grid>.form-field.md\:col-span-2 {
  grid-column: span 2;
}

/* radio group for better settings layout */
.form-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: var(--space-3);
}

.tile-option {
  width: 100%;
}

/* tile-based options */
.tile-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.tile-option .indicator {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: 9999px;
  position: relative;
}

.tile-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tile-option input[type="radio"]:checked+.indicator {
  border-color: var(--color-primary);
}

/* highlight entire tile when its radio is checked (modern :has support) */
.tile-option:has(input[type="radio"]:checked) {
  background: var(--bg-secondary);
  border-color: var(--color-primary);
}

.tile-option:has(input[type="radio"]:checked) .tile-title {
  color: var(--color-primary);
}

[data-theme="dark"] .tile-option:has(input[type="radio"]:checked) {
  background: var(--bg-tertiary);
}

.tile-option input[type="radio"]:checked+.indicator::before {
  content: '';
  position: absolute;
  inset: 0.3rem;
  background: var(--color-primary);
  border-radius: 50%;
}

.tile-body {
  display: flex;
  flex-direction: column;
}

.tile-title {
  font-weight: 550;
  color: var(--text-primary);
}

.tile-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

[data-theme="dark"] .tile-option {
  border-color: var(--border-color-light);
  background: var(--bg-secondary);
}

[data-theme="dark"] .tile-option .indicator {
  border-color: var(--border-color-light);
}

[data-theme="dark"] .tile-title {
  color: var(--text-primary);
}

[data-theme="dark"] .tile-sub {
  color: var(--text-secondary);
}

/* alignment helper for action buttons in forms */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: var(--space-6);
}

.photo-upload-multiple {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.05);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
}

.photo-upload-multiple:hover {
  border-color: rgba(47, 95, 208, 0.35);
  box-shadow: 0 8px 24px rgba(47, 95, 208, 0.05);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-grid .relative,
.photo-grid img,
.photo-grid .photo-item {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 8px;
  overflow: hidden;
}

.signature-container {
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.5);
}

.signature-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.signature-placeholder {
  color: var(--text-secondary);
  font-weight: 600;
}

.card .form-field .btn {
  border-radius: 10px;
}

/* Better spacing for submit area */
.card .form-field.mt-8 {
  margin-top: 20px;
}

.btn-primary.w-full {
  width: 100%;
}

/* Responsive tweaks */
@media (max-width: 900px) {
  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card.max-w-3xl {
    padding-left: 12px;
    padding-right: 12px;
  }

  .signature-container {
    height: 220px !important;
  }
}

/* Additional polish for technician forms */
/* Form grid: make two-column layout for wider screens inside technician cards */
.card.max-w-3xl .section-container .grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.card.max-w-3xl .section-container .grid .form-field {
  margin-bottom: 0;
}

/* Accent header stripe and subtle icon background */
.section-container h3.card-title {
  position: relative;
  padding-left: 8px;
}

.section-container h3.card-title::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 4px;
  background: none;
  opacity: 0.14;
}

/* Checklist cards - pill hover and active state */
.section-container label.group {
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.section-container label.group:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.12);
}

.section-container label.group input[type="checkbox"]:checked+span,
.section-container label.group input[type="checkbox"]:checked~span {
  color: var(--color-primary);
  font-weight: 700;
}

/* Submit button prominence inside forms */
.card.max-w-3xl .btn-primary {
  padding: 14px 18px;
  font-size: 1.03rem;
  border-radius: 12px;
  letter-spacing: 0.2px;
}

/* Signature improvements */
.signature-placeholder {
  font-size: 0.98rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.signature-container {
  min-height: 160px;
}

/* Photo grid hover / focus */
.photo-grid .photo-item img {
  transition: transform .18s ease, box-shadow .18s ease;
}

.photo-grid .photo-item img:hover {
  transform: scale(1.03);
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.18);
}

/* Compact mobile layout for technician forms */
/* Accessibility: ensure contrast for helpers on small screens */
/* End of technician form polish */

/* ==========================
   Back button (pill) design
   Used for "Change Location" and "Back to Dashboard"
   ========================== */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.btn-back:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(2, 6, 23, 0.09);
}

.btn-back:active {
  transform: translateY(0);
}

.btn-back-icon i {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.btn-back-text {
  font-size: 0.95rem;
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-avatar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  outline: none;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
}

.user-avatar-btn:hover {
  opacity: 0.88;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--color-primary);
  color: white;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px var(--border-color), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Photo inside the header avatar circle */
.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
  display: block;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast);
  z-index: var(--z-dropdown);
  padding: var(--space-1) 0;
}

.user-menu.active .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-header {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-1);
}

.user-name {
  display: block;
  font-weight: 600;
  font-size: var(--type-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.user-email {
  display: block;
  font-size: var(--type-xs);
  color: var(--text-muted);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-1) 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 9px var(--space-3);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--type-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-radius: 0;
}

.user-dropdown-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.user-dropdown-item-danger {
  color: var(--color-danger);
}

.user-dropdown-item-danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ===== SIDEBAR ===== */
/* sidebar sits beneath modals which share --z-modal, avoid overlap */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: var(--z-sticky);
  pointer-events: none;
}

.sidebar.active {
  pointer-events: auto;
}

.sidebar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.sidebar.active .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-nav {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  overflow: hidden;
}

.sidebar.active .sidebar-nav {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.5rem;
  border-bottom: none;
  font-weight: 550;
  font-size: 1rem;
  flex-shrink: 0;
  min-width: 0;
}

.sidebar-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Small floating page label (icon + text) placed just to the right of the sidebar */
.page-label {
  position: fixed;
  top: 16px;
  left: calc(var(--sidebar-width) + 12px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: transparent;
  pointer-events: none;
  z-index: calc(var(--z-modal) - 1);
}

.page-label .page-label-icon svg,
.page-label .page-label-icon img,
.page-label .page-label-icon i {
  width: 18px;
  height: 18px;
  display: block;
  opacity: 0.95;
}

/* A record page's coloured tile, at the header's icon size */
.page-label .page-label-icon .icon-bg {
  --tile: 18px;
  margin: 0;
}

.page-label .page-label-icon .icon-bg svg {
  width: calc(var(--tile) * 0.69);
  height: calc(var(--tile) * 0.69);
}

.page-label .page-label-text {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1;
}

.sidebar-close:hover {
  background: var(--bg-tertiary);
}

/* Scrollable nav sections container */
.sidebar-nav-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 0.5rem;
}

.sidebar-nav-content::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.sidebar-nav-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Sections: a plain group at the top, then titled groups 16px apart.
   Titles are small, title case and muted; the collapse chevron shows on
   hover (or while collapsed). */
.nav-section {
  padding: 0 var(--space-2) !important;
}

.nav-section + .nav-section {
  margin-top: 16px;
}

.nav-section--top {
  padding-top: 2px !important;
}

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
  padding: 0 var(--space-2);
  margin: 0 0 2px;
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  width: 100%;
  font-family: inherit;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.nav-section-title:hover { color: var(--text-secondary); }

.nav-section-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.15s ease;
  opacity: 0;
}

.nav-section-title:hover .nav-section-chevron,
.nav-section.collapsed .nav-section-chevron {
  opacity: 0.7;
}
.nav-section.collapsed .nav-section-chevron {
  transform: rotate(-90deg);
}

/* Grid-row animation for smooth collapse */
.nav-section-items {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  transition: grid-template-rows 0.2s ease;
}
.nav-section.collapsed .nav-section-items {
  grid-template-rows: 0fr;
}
/* single inner child must have min-height:0 for the 0fr row to fully collapse */
.nav-section-items > div { min-height: 0; overflow: hidden; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 30px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  background: transparent;
  /* Near-black and semibold, as dark as Attio's: Manrope draws lighter
     than Inter at the same weight, so 600 here reads like Inter's 500 */
  color: color-mix(in srgb, var(--text-primary) 88%, var(--bg-secondary));
  font-family: inherit;
  font-size: var(--type-md);
  font-weight: 600;
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--text-primary);
}

/* ===== SIDEBAR ICONS ===== */

/* Hugeicons draw inside a padded 24px box, so 18px reads like a 16px glyph */
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
  opacity: 1;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item .nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  border-radius: 9999px;
  background: rgba(47, 95, 208, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(47, 95, 208, 0.18);
  margin-left: auto;
  margin-right: 4px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  transition: all var(--transition-fast);
}

.nav-item:hover .nav-badge {
  background: rgba(47, 95, 208, 0.16);
  border-color: rgba(47, 95, 208, 0.28);
}

.nav-item.active .nav-badge {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

[data-theme="dark"] .nav-item .nav-badge {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.25);
}

[data-theme="dark"] .nav-item:hover .nav-badge {
  background: rgba(96, 165, 250, 0.22);
  border-color: rgba(96, 165, 250, 0.35);
}

[data-theme="dark"] .nav-item.active .nav-badge {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-version {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.55;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
}

.sidebar-version:hover {
  opacity: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar.collapsed .sidebar-version { display: none; }

.sidebar-footer-logo {
  height: 24px;
  width: auto;
  opacity: 0.8;
  display: block;
  /* Light mode: grayish black */
  filter: grayscale(100%) brightness(20%) contrast(120%);
  transition: all var(--transition-base);
}

[data-theme="dark"] .sidebar-footer-logo {
  /* Dark mode: grayish white */
  filter: grayscale(100%) brightness(200%) contrast(80%);
  opacity: 0.9;
}

/* ── Workspace button (sidebar header) ── */
.ws-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--btn-radius);
  color: var(--text-primary);
  text-align: left;
  transition: background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.ws-btn:hover {
  background: var(--bg-hover);
}

.ws-btn-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: var(--btn-radius);
  background: var(--accent, #6366f1);
  color: #fff;
  font-size: var(--type-xs);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
}

/* Org logo image inside the sidebar workspace button */
.ws-btn-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--btn-radius);
  display: block;
}

.ws-btn-name {
  flex: 1;
  min-width: 0;
  font-size: var(--type-lg);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.ws-btn-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.ws-btn.open .ws-btn-chevron {
  transform: rotate(180deg);
}

/* ── Workspace dropdown menu ── */
.ws-menu {
  position: fixed;
  z-index: 10050;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  min-width: 220px;
}

.ws-menu-org-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}

.ws-menu-org-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--btn-radius);
  background: var(--accent, #6366f1);
  color: #fff;
  font-size: var(--type-sm);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
}

.ws-menu-org-name {
  font-size: var(--type-md);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-1) 0;
}

.ws-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: var(--control-height-sm);
  padding: 0 var(--space-3);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--type-md);
  font-weight: 550;
  border-radius: var(--btn-radius);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.ws-menu-item:hover {
  background: var(--bg-hover);
}

.ws-menu-item svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.ws-menu-item--danger {
  color: var(--color-danger);
}

.ws-menu-item--danger svg {
  color: var(--color-danger);
}

.ws-menu-item--danger:hover {
  background: var(--color-danger-bg);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-top: var(--header-height);
  margin-bottom: var(--bottom-nav-height);
  padding: 1.25rem 0.875rem;
  overflow-x: hidden;
  transition: margin-left 0.3s ease, max-width 0.3s ease;
  background: var(--bg-secondary);
}

/* ===== BOTTOM NAVIGATION (Mobile) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.5rem 1rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: var(--z-fixed);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-base);
  border-radius: 8px;
}

.bottom-nav-item i {
  font-size: 1.25rem;
}

.bottom-nav-item.active {
  color: var(--color-primary);
  background: var(--color-primary-bg);
}

.bottom-nav-item:hover {
  color: var(--text-primary);
  border-color: var(--border-color-light);
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

/* dark theme override for cards */
[data-theme="dark"] .card {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

/* muted copy inside cards uses secondary text in dark mode for legibility */
[data-theme="dark"] .card .text-muted {
  color: var(--text-secondary);
}

/* ensure page headers have a softer divider in dark mode */
[data-theme="dark"] .page-header {
  border-bottom-color: var(--border-color-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: var(--type-md);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-subtitle {
  font-size: var(--type-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.page-header.flex {
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--type-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  display: none;
}

.view-header-minimal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.view-breadcrumb {
  display: flex;
  align-items: center;
}

.view-breadcrumb span {
  font-size: var(--type-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Shared page shell helpers for consistent module structure */
.crm-page-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* List pages (Tasks, Calls, Workflows, Submissions) run edge to edge: the main
   area drops its side and top padding and the page lines its toolbar and rows
   up on --page-gutter. The workflow editor fills the area the same way. */
.main-content:has(> .tl-page),
.main-content:has(> .calls-page),
.main-content:has(> .wf-page),
.main-content:has(> .wf-builder),
.main-content:has(> .ups-reports-section),
.main-content:has(> .visits-hub),
.main-content:has(> .rpt-page) {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

.tl-page,
.calls-page,
.wf-page,
.ups-reports-section,
.visits-hub,
.rpt-page {
  --page-gutter: 2rem;
}

@media (max-width: 1023px) {
  .tl-page,
  .calls-page,
  .wf-page,
  .ups-reports-section,
  .visits-hub,
  .rpt-page {
    --page-gutter: var(--space-5);
  }
}

@media (max-width: 768px) {
  .tl-page,
  .calls-page,
  .wf-page,
  .ups-reports-section,
  .visits-hub,
  .rpt-page {
    --page-gutter: var(--mobile-padding, 0.875rem);
  }
}

/* Visits: the filter bar is a band across the page with a rule under it,
   and the list and activity sidebar line up on the gutter below it */
.main-content > .visits-hub {
  max-width: none;
  margin: 0;
}

.main-content > .visits-hub .visits-command-bar {
  padding: var(--space-3) var(--page-gutter);
}

.main-content > .visits-hub .visits-main-content {
  padding: 0 var(--page-gutter);
}

.crm-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.crm-page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ===== FORM ELEMENTS ===== */
button {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

input,
select,
textarea {
  width: 100%;
  height: var(--control-height-md);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  font-size: var(--type-md);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

textarea {
  height: auto;
  min-height: 80px;
  padding: var(--space-3);
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: var(--icon-md);
  padding-right: var(--space-8);
}

/* ===== VISIT CARD ===== */
.visit-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: border-color var(--transition-fast);
}

.visit-card:hover {
  border-color: var(--color-primary);
}

.visit-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.visit-company {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.visit-date {
  font-size: 0.9rem;
  color: white
}

.visit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.visit-meta-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 1rem;
  color: var(--text-secondary);
}

.visit-meta-item i {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.visit-notes {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-tertiary);
  padding: 0.875rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}

.visit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ===== TAGS ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--control-height-xs);
  padding: 0 var(--space-2);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-size: var(--type-xs);
  font-weight: 550;
  border-radius: var(--radius-xs);
  line-height: 1;
}

.tag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
}

.tag-remove:hover {
  opacity: 1;
}

/* ===== AI INSIGHT ===== */
.ai-insight {
  background: rgba(47, 95, 208, 0.07);
  border: 1px solid rgba(120, 120, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.75rem;
}

[data-theme="dark"] .ai-insight {
  background: rgba(47, 95, 208, 0.12);
  border-color: rgba(120, 120, 255, 0.3);
}

.ai-insight-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: #00035f;
}

[data-theme="dark"] .ai-insight-header {
  color: rgb(226, 239, 255);
}

.ai-insight-content {
  font-size: 1rem;
  color: #00035f;
  line-height: 1.5;
}

[data-theme="dark"] .ai-insight-content {
  color: rgb(226, 239, 255);
}

/* ===== LEAD SCORE BADGE ===== */
.lead-score-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--control-height-xs);
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--type-sm);
  font-weight: 600;
  line-height: 1;
}

.lead-score-badge.high {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.lead-score-badge.medium {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.lead-score-badge.low {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ===== SECTION TITLES ===== */

/* ===== RESPONSIVE ===== */

/* ===== SIDEBAR QUICK ACTIONS BUTTONS ===== */
.sidebar-quick-actions {
  /* A little room between Search / Inbox and Home */
  padding: var(--space-1) var(--space-2) 12px;
  display: flex;
  flex-direction: row;
  gap: var(--space-1);
  flex-shrink: 0;
  border-bottom: none;
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  height: 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  /* Same size, weight and colour as the sidebar's items, as in Attio */
  color: color-mix(in srgb, var(--text-primary) 88%, var(--bg-secondary));
  font-size: var(--type-md);
  font-weight: 600;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  line-height: 1;
  white-space: nowrap;
}

/* Search takes the room; the Inbox is a square */
.sidebar-action-btn:first-child {
  flex: 1;
  min-width: 0;
}

.sidebar-action-btn:last-child {
  flex: 0 0 auto;
}

.sidebar-action-btn:hover {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--border-color) 70%, var(--text-muted));
  color: var(--text-primary);
}

.sidebar-action-btn svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.sidebar-action-btn > span:not(.notification-badge) {
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
}

/* ⌘ K as two small keys */
.sidebar-kbd-group {
  display: inline-flex;
  gap: 3px;
  flex-shrink: 0;
}

.sidebar-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  line-height: 1;
}

/* ===== QUICK ACTIONS MODAL (⌘K) ===== */
.qa-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}

.qa-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.qa-container {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: qa-in 0.15s var(--motion-ease-emphasized);
}

@keyframes qa-in {
  from { opacity: 0; transform: scale(0.97) translateY(-6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.qa-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.qa-header input {
  flex: 1;
  border: none !important;
  background: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none !important;
  box-shadow: none !important;
  height: 28px;
  line-height: 28px;
  padding: 0;
  margin: 0;
  border-radius: 0;
}

.qa-header input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.qa-header-kbd {
  font-family: inherit;
  font-size: 11px;
  font-weight: 550;
  padding: 3px 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--text-muted);
  flex-shrink: 0;
  line-height: 1;
}

.qa-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 16px 4px;
  opacity: 0.7;
}

.qa-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 4px 6px 6px;
}

.qa-results::-webkit-scrollbar { width: 4px; }
.qa-results::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.qa-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.qa-item:hover,
.qa-item.active {
  background: var(--bg-hover);
}

.qa-item-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.qa-item-icon.is-record,
.qa-item.active .qa-item-icon.is-record {
  background: none;
  border-color: transparent;
}

.qa-item.active .qa-item-icon:not(.is-record) {
  background: var(--color-primary-bg);
  border-color: rgba(var(--color-primary-rgb), 0.2);
  color: var(--color-primary);
}

.qa-item-title {
  flex: 1;
  font-size: 14px;
  font-weight: 550;
  color: var(--text-primary);
}

.qa-item-shortcut {
  font-family: inherit;
  font-size: 11px;
  font-weight: 550;
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
}

.qa-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.qa-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.qa-footer-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.qa-footer-hint kbd, .qa-footer-action kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 0 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  line-height: 1.5;
}

.qa-footer-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-secondary);
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
}

.qa-footer-action kbd {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}

/* ===== SEARCH RECORDS MODAL (/) ===== */
.sr-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.sr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.sr-container {
  position: relative;
  width: 100%;
  max-width: 740px;
  margin: 0 var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 520px;
  animation: qa-in 0.15s var(--motion-ease-emphasized);
}

.sr-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sr-header input {
  flex: 1;
  border: none !important;
  background: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none !important;
  box-shadow: none !important;
  height: 28px;
  line-height: 28px;
  padding: 0;
  margin: 0;
  border-radius: 0;
}

.sr-header input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.sr-header-kbd {
  font-family: inherit;
  font-size: 11px;
  font-weight: 550;
  padding: 3px 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--text-muted);
  flex-shrink: 0;
  line-height: 1;
}

.sr-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sr-results-pane {
  width: 50%;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sr-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 14px 4px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sr-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 6px;
}

.sr-results::-webkit-scrollbar { width: 4px; }
.sr-results::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.sr-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sr-item:hover,
.sr-item.active {
  background: var(--bg-hover);
}

.sr-item-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
}

.sr-item-info {
  flex: 1;
  min-width: 0;
}

.sr-item-name {
  display: block;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-item-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.sr-badge-company {
  background: #e8edff;
  color: #3b5bdb;
}

[data-theme="dark"] .sr-badge-company {
  background: rgba(59, 91, 219, 0.18);
  color: #7b9cff;
}

.sr-badge-person {
  background: #e8edff;
  color: #3b5bdb;
}

[data-theme="dark"] .sr-badge-person {
  background: rgba(59, 91, 219, 0.18);
  color: #7b9cff;
}

.sr-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Preview Pane */
.sr-preview-pane {
  width: 50%;
  padding: 16px;
  overflow-y: auto;
}

.sr-preview-pane::-webkit-scrollbar { width: 4px; }
.sr-preview-pane::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.sr-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

.sr-preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.sr-preview-favicon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  object-fit: contain;
  background: #fff;
}

.sr-preview-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sr-preview-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.sr-preview-meta-badge {
  font-size: 11px;
  font-weight: 550;
  color: var(--text-muted);
  margin-top: 1px;
}

.sr-preview-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  opacity: 0.7;
}

.sr-preview-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.sr-preview-icon.is-record {
  opacity: 1;
}

.sr-preview-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: 1px;
}

.sr-preview-val {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.sr-preview-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.sr-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sr-tag {
  font-size: 11px;
  font-weight: 550;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--text-secondary);
}

.sr-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.sr-footer-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.sr-footer-hint kbd, .sr-footer-action kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 0 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  line-height: 1.5;
}

.sr-footer-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
}

.sr-footer-action kbd {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}

/* Search Records - responsive: hide preview pane on small screens */
/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  animation: backdrop-fade-in var(--transition-slow) ease;
}

@keyframes backdrop-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-container {
  position: relative;
  width: 100%;
  margin-bottom: 0;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  animation: modal-slide-up 0.3s var(--motion-ease-emphasized);
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-color);
}

@keyframes modal-slide-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.modal-header h3 {
  font-size: var(--type-md);
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-primary);
}

.modal-header h3 svg,
.modal-header h3 i {
  color: var(--color-primary);
  font-size: var(--type-md);
}

.modal-close {
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--btn-radius);
  cursor: pointer;
}

/* Company view summary enhancements */
.company-summary {
  padding: 12px 0;
}

.company-summary-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.company-summary-avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.company-summary-avatar img.company-summary-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.company-summary-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-inverse);
  background: var(--color-primary);
}

.company-summary-main {
  flex: 1 1 auto;
  min-width: 0;
}

.company-summary-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-summary-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.company-summary-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.company-summary-stats {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.company-summary-stats .stat {
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  min-width: 84px;
}

.stat-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.company-summary-desc {
  margin-top: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  max-height: 72px;
  overflow: hidden;
}

.company-summary-tags {
  margin-top: 8px;
}

.company-summary-tags .tag {
  display: inline-block;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 0 var(--space-2);
  height: var(--control-height-xs);
  line-height: var(--control-height-xs);
  border-radius: var(--radius-xs);
  font-size: var(--type-xs);
  margin-right: var(--space-1);
}

@media (max-width: 880px) {
  .modal-container.modal-size-xl {
    width: 100%;
    border-radius: 12px;
  }

  .company-view-sidebar {
    display: none;
  }
}

/* Company tabs: lists and items */
.company-opps-list,
.company-call-list,
.company-visits-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0.25rem 1rem 1rem 1rem;
}

.company-opp,
.visit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.company-opp-main,
.visit-main {
  flex: 1 1 auto;
  min-width: 0;
}

.visit-title {
  font-weight: 600;
}

.company-opp-title,
.visit-title {
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-opp-meta,
.visit-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.company-opp-actions,
.visit-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Smaller screens: compact spacing */
.modal-close:hover {
  background: var(--bg-tertiary);
}

.modal-close:active {
  background: var(--bg-tertiary);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  max-height: calc(87vh - 140px);
  background: var(--bg-secondary);
}

/* Form Sections */
.form-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color-light);
}

.form-section-icon {
  width: var(--icon-md);
  height: var(--icon-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-radius: var(--radius-xs);
  font-size: var(--type-md);
}

.form-section-title {
  font-size: var(--type-md);
  font-weight: 550;
  color: var(--text-primary);
}

.form-section-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Enhanced Form Fields */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field label {
  font-size: var(--type-md);
  font-weight: 550;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-field label .required-indicator {
  color: var(--color-danger);
  font-weight: 700;
}

.form-field label .field-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

.form-field label .probability-reset-btn {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
}

.form-field label .probability-reset-btn:hover {
  text-decoration: underline;
}

.probability-slider:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-field label .optional-badge {
  font-size: 0.65rem;
  font-weight: 550;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
}

.field-helper {
  font-size: 0.9125rem;
  color: var(--text-muted);
  margin-top: -0.25rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.field-helper i {
  font-size: 0.85rem;
}

/* Enhanced Input Styling */
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  height: var(--control-height-md);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  font-size: var(--type-md);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-field textarea {
  height: auto;
  min-height: 80px;
  padding: var(--space-3);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--text-muted);
}

.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Improve contrast for input borders in light mode (non-dark theme) */
:where(html, body):not([data-theme="dark"]) .form-field input,
:where(html, body):not([data-theme="dark"]) .form-field select,
:where(html, body):not([data-theme="dark"]) .form-field textarea,
:where(html, body):not([data-theme="dark"]) .categories-input,
:where(html, body):not([data-theme="dark"]) .competitors-input,
:where(html, body):not([data-theme="dark"]) .phone-number {
  border-color: rgba(15, 20, 25, 0.12);
}

/* Dark-mode: increase input border visibility */
[data-theme="dark"] .form-field input,
[data-theme="dark"] .form-field select,
[data-theme="dark"] .form-field textarea,
[data-theme="dark"] .categories-input,
[data-theme="dark"] .competitors-input,
[data-theme="dark"] .phone-number {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Input with Icon */
.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.input-with-icon input {
  padding-left: 2.75rem;
}

/* Field Groups */
.field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-group-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

/* Progressive Disclosure */
.advanced-options {
  margin-top: 1rem;
}

.advanced-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--text-secondary);
  width: 100%;
  justify-content: center;
}

.advanced-toggle:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.advanced-toggle i {
  transition: transform var(--transition-fast);
}

.advanced-toggle.active i {
  transform: rotate(180deg);
}

.advanced-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.advanced-content.show {
  max-height: 1000px;
  margin-top: 1rem;
}

.modal-footer {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  justify-content: flex-end;
}

.modal-footer .btn {
  flex: 0 0 auto;
  min-width: 80px;
}

.modal-footer .btn-primary {
  background: var(--color-primary);
  color: var(--text-inverse);
  border-color: transparent;
}

.modal-footer .btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.modal-footer .btn-primary:active:not(:disabled) {
  background: var(--color-primary-dark);
}

.modal-footer .btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.modal-footer .btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
}

.modal-footer .btn-danger {
  background: var(--color-danger);
  color: var(--text-inverse);
  border-color: transparent;
}

.modal-footer .btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.modal-footer-with-option {
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.modal-footer-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.add-more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.add-more-label {
  line-height: 1;
}

.ios-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ios-toggle input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.ios-toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-color);
  transition: background-color 0.2s ease;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-muted) 30%, transparent);
}

.ios-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 20, 25, 0.22);
  transition: transform 0.2s ease;
}

.ios-toggle input[type="checkbox"]:checked+.ios-toggle-slider {
  background: var(--color-primary);
}

.ios-toggle input[type="checkbox"]:checked+.ios-toggle-slider::after {
  transform: translateX(18px);
}

.ios-toggle input[type="checkbox"]:focus-visible+.ios-toggle-slider {
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.duplicate-warning {
  font-size: 0.78rem;
  line-height: 1.2;
  color: var(--color-danger);
  font-weight: 600;
}

/* ==========================================================
   CRM Add-Entity Modals — Attio-inspired minimal design
   (Company, Person, Opportunity, Task, Reminder, Call-Log)
   ========================================================== */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-container {
  max-width: min(560px, 94vw) !important;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] :is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-container {
  box-shadow: 0 28px 70px -12px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-header {
  padding: 0.875rem 1.25rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  gap: 0;
}

/* Hide icons inside modal header titles */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-header h3 svg,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-header h3 i {
  display: none;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-body {
  padding: 1rem 1.25rem 1.25rem;
  background: var(--bg-primary);
  max-height: calc(85vh - 130px);
}

/* Flatten form sections */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-section {
  border-radius: 0;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  background: transparent;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-section + .form-section {
  margin-top: 0.25rem;
  padding-top: 0;
  border-top: none;
}

/* Hide section headers entirely (icons + titles) */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-section-header {
  display: none;
}

/* Compact field spacing */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field {
  margin-bottom: 0.75rem;
  gap: 0.3rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field:last-child {
  margin-bottom: 0;
}

/* Labels: small, normal case, muted color */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field {
  gap: 0.1rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field label {
  font-size: var(--type-md);
  font-weight: 550;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-secondary);
}

/* Required indicator: "(required)" text style */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field label .required-indicator {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}

/* Optional badge: minimal */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field label .optional-badge {
  display: none;
}

/* Compact inputs */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field input,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field select,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field textarea,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .categories-input,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .competitors-input,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .phone-number {
  border-radius: var(--btn-radius);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  font-size: var(--type-md);
  font-weight: 550;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field input:focus,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field select:focus,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field textarea:focus,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .categories-input:focus,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .competitors-input:focus,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .phone-number:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field input::placeholder,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .form-field textarea::placeholder {
  font-style: normal;
  color: var(--text-muted);
}

/* Hide field helpers for cleaner look */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .field-helper {
  display: none;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .field-group {
  gap: 0.75rem;
}

/* Compact footer */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 0.75rem 1.25rem;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .modal-footer .btn {
  padding: 0.4rem 0.875rem;
  font-size: var(--type-md);
  border-radius: var(--btn-radius);
}

/* Category suggestions: compact */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal) .category-suggestions {
  margin-top: 0.375rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal) .tag-suggestion {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}

/* Search dropdowns inside modals: compact, unified */
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-container {
  margin-bottom: 0;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-container i,
:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-container svg {
  display: none;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-container input {
  padding-left: 0.75rem !important;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-results {
  top: calc(100% + 0.25rem);
  border-radius: 8px;
  max-height: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-results .search-result-item {
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-results .search-result-avatar {
  width: 26px;
  height: 26px;
  font-size: 0.6875rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-results .opp-suggest-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .search-results .search-result-name {
  font-size: 0.8125rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .live-search-results {
  top: calc(100% + 0.25rem);
  border-radius: 8px;
  max-height: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .live-search-results .search-result-item {
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .live-search-results .search-result-item .title {
  font-size: 0.8125rem;
  font-weight: 550;
}

:is(#company-modal, #person-modal, #opportunity-modal, #task-modal, #call-log-modal) .live-search-results .search-result-item .subtitle {
  font-size: 0.6875rem;
}

/* =========================================================
   Note / Companies Transfer modals (unchanged layout)
   ========================================================= */
:is(#note-modal, #companies-transfer-modal) .modal-container {
  border-radius: 24px;
  border: 1px solid var(--border-color);
  box-shadow: 0 18px 48px rgba(10, 22, 45, 0.2);
}

#note-modal .modal-container {
  max-width: min(760px, 94vw) !important;
}

#companies-transfer-modal .modal-container {
  max-width: min(820px, 95vw) !important;
}

:is(#note-modal, #companies-transfer-modal) .modal-header {
  padding: 0.8rem 1.2rem;
  background: var(--bg-primary);
}

:is(#note-modal, #companies-transfer-modal) .modal-header h3 {
  font-size: 1.1rem;
  font-weight: 550;
}

:is(#note-modal, #companies-transfer-modal) .modal-body {
  padding: 1.5rem 1.5rem 1.4rem;
  background: var(--bg-primary);
  max-height: calc(88vh - 148px);
}

:is(#note-modal, #companies-transfer-modal) .form-section {
  border-radius: 16px;
  border: 1px solid var(--border-color-light);
  box-shadow: 0 1px 2px rgba(10, 22, 45, 0.04), 0 8px 22px rgba(10, 22, 45, 0.06);
  padding: 1.1rem;
  margin-bottom: 0.9rem;
}

:is(#note-modal, #companies-transfer-modal) .form-section-header {
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
}

:is(#note-modal, #companies-transfer-modal) .form-section-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

:is(#note-modal, #companies-transfer-modal) .form-field {
  margin-bottom: 0.95rem;
}

:is(#note-modal, #companies-transfer-modal) .form-field label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--text-secondary);
}

:is(#note-modal, #companies-transfer-modal) .form-field input,
:is(#note-modal, #companies-transfer-modal) .form-field select,
:is(#note-modal, #companies-transfer-modal) .form-field textarea,
#note-modal .note-content-editable {
  border-radius: 12px;
  border-width: 1px;
  padding: 0.75rem 0.9rem;
  background: var(--bg-primary);
}

:is(#note-modal, #companies-transfer-modal) .form-field input:focus,
:is(#note-modal, #companies-transfer-modal) .form-field select:focus,
:is(#note-modal, #companies-transfer-modal) .form-field textarea:focus,
#note-modal .note-content-editable:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

:is(#note-modal, #companies-transfer-modal) .field-helper {
  font-size: 0.76rem;
}

:is(#note-modal, #companies-transfer-modal) .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 0.9rem 1.5rem;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

/* Remaining CRM Modals (Unified) */
:is(#change-password-modal, #location-modal, #visit-details-modal, #photo-modal) .modal-container {
  border-radius: 24px;
  border: 1px solid var(--border-color);
  box-shadow: 0 18px 48px rgba(10, 22, 45, 0.2);
}

:is(#change-password-modal, #location-modal, #visit-details-modal, #photo-modal) .modal-header {
  padding: 0.8rem 1.2rem;
  background: var(--bg-primary);
}

:is(#change-password-modal, #location-modal, #visit-details-modal, #photo-modal) .modal-header h3 {
  font-size: 1.1rem;
  font-weight: 550;
}

:is(#change-password-modal, #location-modal, #visit-details-modal, #photo-modal) .modal-body {
  padding: 1.25rem 1.5rem 1.4rem;
  background: var(--bg-primary);
  max-height: calc(88vh - 148px);
}

:is(#change-password-modal, #location-modal, #visit-details-modal, #photo-modal) .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 0.9rem 1.5rem;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

:is(#change-password-modal, #visit-details-modal) .modal-body h4 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

 #visit-details-modal) .modal-body p {
  color: var(--text-secondary);
}

/* Confirm Dialog Specific Styles */
.confirm-dialog-container {
  max-width: min(480px, 92vw);
  margin: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modal-fade-in 0.15s ease;
}

.confirm-dialog-container::before {
  display: none;
}

.confirm-dialog-content {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-5);
}

.confirm-dialog-icon {
  width: var(--control-height-md);
  height: var(--control-height-md);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-bg);
  border: 1px solid var(--border-color);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--type-md);
  flex-shrink: 0;
}

.confirm-dialog-icon::before {
  content: '?';
}

.confirm-dialog-copy {
  min-width: 0;
}

.confirm-dialog-copy h3 {
  margin: 0;
  font-size: var(--type-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.confirm-dialog-copy #confirm-message {
  margin: var(--space-2) 0 0;
  font-size: var(--type-md);
  line-height: 1.5;
  color: var(--text-secondary);
}

.confirm-helper-text {
  margin: var(--space-2) 0 0;
  font-size: var(--type-sm);
  line-height: 1.4;
  font-weight: 550;
  color: var(--text-secondary);
  display: none;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-color);
}

.confirm-dialog-actions .btn {
  min-width: 100px;
  height: var(--control-height-md);
  border-radius: var(--btn-radius);
  font-size: var(--btn-font-size);
  font-weight: var(--btn-font-weight);
  padding: 0 var(--space-4);
  line-height: normal;
}

.confirm-dialog-actions .btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.confirm-dialog-actions .btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
}

.confirm-dialog-actions .btn-primary {
  /* no special shadow */
}

.confirm-dialog-container.confirm-dialog-danger::before {
  display: none;
}

.confirm-dialog-container.confirm-dialog-danger .confirm-dialog-icon {
  background: var(--color-danger-bg);
  border-color: var(--border-color);
  color: var(--color-danger);
}

.confirm-dialog-container.confirm-dialog-danger .confirm-dialog-icon::before {
  content: '!';
}

.confirm-dialog-container.confirm-dialog-danger .confirm-helper-text {
  display: block;
  color: var(--text-secondary);
}

.confirm-dialog-container.confirm-dialog-danger .confirm-dialog-copy #confirm-message {
  color: var(--text-secondary);
}

.confirm-dialog-container.confirm-dialog-danger .confirm-dialog-actions .btn-danger {
  /* clean, no dramatic shadow */
}

/* Export format UI removed (export modal deleted) */

.export-format-option input:checked+.export-format-card i {
  color: var(--color-primary);
}

.export-format-card span {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
}

.date-range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.date-range-btn {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-base);
  letter-spacing: 0.2px;
}

.date-range-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 2px 4px rgba(47, 95, 208, 0.1);
}

.date-range-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  box-shadow: 0 2px 6px rgba(47, 95, 208, 0.15);
}

.date-range-btn.active:hover {
  box-shadow: 0 4px 12px rgba(47, 95, 208, 0.25);
}

.date-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Companies import/export transfer modal */
.companies-transfer-switch {
  display: flex;
  gap: 0.5rem;
}

.companies-transfer-switch .date-range-btn {
  flex: 1;
  justify-content: center;
}

#companies-import-feedback code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.companies-import-errors-card {
  margin-top: 0.85rem;
  border: 1px solid var(--color-warning);
  background: var(--color-warning-bg);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
}

.companies-import-errors-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.companies-import-errors-list {
  margin: 0;
  padding-left: 1rem;
  max-height: 170px;
  overflow-y: auto;
}

.companies-import-errors-list li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--space-4));
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease, toast-out 0.2s ease var(--toast-timeout, 2700ms) forwards;
  pointer-events: auto;
}

.toast.subtle {
  border-color: var(--border-color-light);
  box-shadow: var(--shadow-xs);
}

.toast-icon {
  flex-shrink: 0;
  font-size: 1.125rem;
}

.toast.success .toast-icon {
  color: var(--color-success);
}

.toast.error .toast-icon {
  color: var(--color-danger);
}

.toast.info .toast-icon {
  color: var(--color-primary);
}

.toast-message {
  flex: 1;
  font-size: var(--type-md);
  color: var(--text-primary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  margin: -4px -8px -4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}

.toast-close:hover {
  opacity: 1;
  color: var(--text-primary);
}

.ui-success-flash {
  animation: ui-success-flash 850ms ease;
}

@keyframes ui-success-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 157, 110, 0);
  }

  20% {
    box-shadow: 0 0 0 3px rgba(31, 157, 110, 0.2);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(31, 157, 110, 0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(1rem);
  }
}

/* ===== LOCATION MAP ===== */
.location-map {
  height: 200px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-top: 0.75rem;
}

.location-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
}

.location-status.success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.location-status.error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ===== PHOTO UPLOAD ===== */
.photo-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.photo-upload-area:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.photo-upload-area i {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.photo-upload-area span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.photo-preview {
  margin-top: 1rem;
}

.photo-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-md);
}

/* ===== SALES REP LOG VISIT REDESIGN ===== */

/* ===== CHART CONTAINER ===== */
.chart-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin: 1.5rem 0;
  height: 300px;
}

/* ===== SEARCH ===== */
.search-container {
  position: relative;
  margin-bottom: var(--space-3);
}

.search-container i,
.search-container svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: var(--icon-md);
  height: var(--icon-md);
  pointer-events: none;
  z-index: 1;
}

.search-container input {
  width: 100%;
  height: var(--control-height-md);
  padding: 0 var(--space-3) 0 var(--space-8) !important;
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--type-md);
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-container input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

.search-container input::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.search-result-item:hover {
  background: var(--bg-tertiary);
}

.search-result-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.search-result-name {
  font-weight: 550;
  color: var(--text-primary);
}

/* Company suggestion avatar in opportunity modal */
.opp-suggest-avatar {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

[data-theme="dark"] .opp-suggest-avatar {
  background: #2d343e;
  border-color: #3d4754;
}

.opp-suggest-initials {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  letter-spacing: 0.02em;
}

.opp-suggest-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.opp-suggest-avatar--custom {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
}

.opp-suggest-avatar--custom span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
  line-height: 1;
}

.opp-suggest-avatar span {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.opp-suggest-avatar--person {
  background: rgba(100, 120, 220, 0.1);
  border-color: rgba(100, 120, 220, 0.22);
  border-radius: 50%;
}

.opp-suggest-avatar--person span {
  color: #6478dc;
}

[data-theme="dark"] .opp-suggest-avatar--person {
  background: rgba(100, 120, 220, 0.15);
  border-color: rgba(100, 120, 220, 0.3);
}

[data-theme="dark"] .opp-suggest-avatar--person span {
  color: #8090e8;
}

.search-result-role {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--type-xl);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: var(--type-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.empty-state-description {
  font-size: var(--type-sm);
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  max-width: 44ch;
}

.empty-state.empty-state-alert {
  border-color: color-mix(in srgb, var(--color-danger) 35%, var(--border-color));
  background: color-mix(in srgb, var(--color-danger-bg) 25%, var(--bg-primary));
}

.empty-state.empty-state-alert .empty-state-icon {
  color: var(--color-danger);
  border-color: color-mix(in srgb, var(--color-danger) 40%, var(--border-color));
  background: color-mix(in srgb, var(--color-danger-bg) 60%, var(--bg-tertiary));
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg,
      var(--bg-tertiary) 18%,
      color-mix(in srgb, var(--bg-tertiary) 55%, var(--bg-primary)) 50%,
      var(--bg-tertiary) 82%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s infinite;
  border-radius: var(--radius-md);
}

.skeleton-card {
  height: 110px;
  margin-bottom: 0.9rem;
}

.skeleton-title {
  height: 20px;
  width: 58%;
  margin-bottom: 0.6rem;
}

.skeleton-text {
  height: 14px;
  width: 100%;
  margin-bottom: 0.45rem;
}

.skeleton-text.short {
  width: 40%;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===== TAGS INPUT ===== */
.tags-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  min-height: 48px;
  align-items: center;
}

.tags-input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: none;
  padding: 0.25rem;
  font-size: 0.9375rem;
}

.tags-input:focus {
  outline: none;
  box-shadow: none;
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tag-suggestion {
  padding: 0 var(--space-3);
  height: var(--control-height-xs);
  display: inline-flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  font-size: var(--type-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.tag-suggestion:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--text-inverse);
}

/* ===== RESPONSIVE - Tablet and Up ===== */
@media (min-width: 768px) {

  .mobile-menu-btn {
    display: none;
  }

  .sidebar {
    pointer-events: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-nav {
    transform: translateX(0);
    position: fixed;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    pointer-events: auto;
    border-right: 1px solid var(--border-color);
    z-index: calc(var(--z-header) + 1);
  }

  .sidebar-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    padding: 0 0.75rem;
    align-items: center;
  }

  .sidebar-close {
    display: none;
  }

  .sidebar-toggle-btn {
    display: flex;
    margin-left: auto;
  }

  .header-org-btn {
    display: none;
  }

  .app-header {
    left: var(--sidebar-width);
  }

  .header-left {
    display: flex;
    flex-shrink: 0;
  }

  .main-content {
    margin-left: var(--sidebar-width);
    margin-bottom: 0;
    padding: var(--space-5);
    max-width: calc(100vw - var(--sidebar-width));
  }

  .bottom-nav {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .modal {
    align-items: center;
    padding: var(--space-4);
  }

  .modal-container {
    max-width: 520px;
    border-radius: var(--radius-xl);
    animation: modal-fade-in 0.15s ease;
  }

  @keyframes modal-fade-in {
    from {
      opacity: 0;
      transform: scale(0.95);
    }

    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  #toast-container {
    bottom: 2rem;
    left: auto;
    right: 2rem;
    width: 360px;
  }

  .chart-container {
    height: 350px;
  }

  /* ========================================= */
  /* FIX: Handle COLLAPSED state on Tablets */
  /* ========================================= */

  .main-content {
    transition: margin-left var(--transition-base), max-width var(--transition-base);
  }

  .sidebar.collapsed~.main-content,
  .sidebar.collapsed~.notes-view-root {
    margin-left: 60px;
    /* OVERRIDE: Update max-width to match collapsed sidebar (60px) */
    max-width: calc(100vw - 60px);
  }
}

/* ===== RESPONSIVE - Desktop ===== */
@media (min-width: 1024px) {
  .main-content {
    padding: 1rem 2rem;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .card {
    padding: 1rem;
  }
}

/* ===== RESPONSIVE - Large Desktop ===== */
/* ===== RESPONSIVE - Large Desktop ===== */
@media (min-width: 1280px) {

  /* UPDATE: Full width logic */
  .main-content {
    /* 1. Calculate exact remaining width after sidebar */
    width: calc(100vw - var(--sidebar-width));

    /* 2. Keep the margin for sidebar, but REMOVE 'auto' (which was centering it) */
    margin-left: var(--sidebar-width);
    margin-right: 0;

    /* 3. Sleek padding (reduced from 3rem to 2rem) */
    padding: 1rem;

    /* 4. Remove max-width constraint to allow full stretch */
    max-width: none;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .card {
    padding: 1rem;
  }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-prim {
  color: var(--color-primary-light);
}

.text-success {
  color: var(--color-success);
}

.text-warning {
  color: var(--color-warning);
}

.text-danger {
  color: var(--color-danger);
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.gap-3 {
  gap: 1.5rem;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

/* Base Utilities */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gap-x-2 {
  column-gap: 0.5rem;
}

.gap-x-6 {
  column-gap: 1.5rem;
}

.gap-y-2 {
  row-gap: 0.5rem;
}

.gap-y-3 {
  row-gap: 0.75rem;
}

@media (min-width: 640px) {
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .md\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.tag-sm {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.col-span-2 {
  grid-column: span 2 / span 2;
}

/* ===== ROUTE PLANNING ===== */
.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.location-card {
  display: flex;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.location-card:hover {
  border-color: var(--color-primary);
}

.location-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.location-card.recommended {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.location-checkbox {
  margin-right: 0.75rem;
  margin-top: 0.25rem;
}

.location-checkbox input[type="checkbox"] {
  display: none;
}

.location-checkbox label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.location-checkbox input[type="checkbox"]:checked+label {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.location-checkbox input[type="checkbox"]:checked+label::after {
  content: '✓';
  color: white;
  font-size: 0.75rem;
}

.location-info h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.location-info p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.location-recommendation {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--color-success-bg);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sortable-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sortable-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.sortable-handle {
  margin-right: 0.75rem;
  color: var(--text-muted);
  cursor: grab;
}

.sortable-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.75rem;
}

.sortable-content h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.sortable-content p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== MULTI-SELECT FOR REPS ===== */
.multi-select-container {
  position: relative;
}

.multi-select-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  min-height: 48px;
}

.multi-select-display.empty {
  color: var(--text-muted);
  align-items: center;
}

.multi-select-tag {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 550;
  border-radius: var(--radius-full);
}

.multi-select-tag .remove {
  cursor: pointer;
  font-size: 0.875rem;
}

.multi-select-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  display: none;
}

.multi-select-dropdown.show {
  display: block;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.multi-select-option:hover {
  background: var(--bg-tertiary);
}

.multi-select-option.selected {
  background: var(--color-primary-bg);
}

.multi-select-option input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ===== LOCATION SEARCH ===== */
.location-search-container {
  margin-bottom: 1rem;
}

.location-search-container input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition-fast);
}

.location-search-container input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.location-search-container input::placeholder {
  color: var(--text-muted);
}

/* ===== AI RECOMMENDATION ===== */
.ai-recommendation {
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  margin-top: 1rem;
  padding: 1.2rem;
  margin-bottom: 20px;
}

.ai-recommendation-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-success);
}

.ai-recommendation button {
  margin-top: 12px;
  background-color: var(--color-success);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(31, 157, 110, 0.15);
  border: 1px solid transparent;
}

.ai-recommendation button:hover:not(:disabled) {
  background-color: #178659;
  box-shadow: 0 4px 12px rgba(31, 157, 110, 0.25);
}

.ai-recommendation-content {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== OPPORTUNITY PIPELINE ===== */
.opportunity-pipeline-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}

.deals-page-header {
  margin-bottom: 0.35rem;
}

.pipeline-view-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pipeline-view-left,
.pipeline-view-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pipeline-view-btn {
  height: 34px;
  padding: 0 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 550;
}

.pipeline-view-btn.is-active {
  border-color: var(--color-primary);
  color: var(--text-primary);
}

.pipeline-header,
.pipeline-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.pipeline-filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pipeline-filter {
  height: 34px;
  padding: 0 0.72rem;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition-fast);
}

.pipeline-filter:hover {
  border-color: var(--border-color-light);
  color: var(--text-primary);
}

.pipeline-filter.active {
  background: var(--bg-primary);
  border-color: var(--border-color-light);
  color: var(--text-primary);
}

.pipeline-quick-filter {
  min-width: 170px;
  width: 170px;
  flex: 0 0 170px;
}

.pipeline-add-btn {
  margin-left: auto;
}

.pipeline-stages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.875rem;
  padding-bottom: 1rem;
  align-items: stretch;
}

.pipeline-stage {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: auto;
  box-shadow: none;
  transition: border-color 150ms ease;
}

[data-theme="dark"] .pipeline-stage {
  background: #161b22;
  border-color: #2d343e;
}

.pipeline-stage:hover {
  border-color: var(--border-color-light);
}

[data-theme="dark"] .pipeline-stage:hover {
  border-color: #3d4754;
}

.pipeline-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .pipeline-stage-header {
  border-bottom-color: #2d343e;
}

.pipeline-stage-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.pipeline-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.pipeline-stage-count {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  min-width: 22px;
  text-align: center;
}

[data-theme="dark"] .pipeline-stage-count {
  background: #1e2329;
  border-color: #2d343e;
  color: #8b949e;
}

.pipeline-stage-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 550;
  color: var(--text-muted);
  padding-bottom: 0.2rem;
}

.pipeline-stage-total {
  font-weight: 650;
  color: var(--text-secondary);
}

.pipeline-stage-note {
  margin-top: -0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pipeline-stage.is-empty .opportunity-list::before {
  content: 'No deals';
  display: block;
  padding: 1.25rem 0.5rem;
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.opportunity-list {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.pipeline-load-more-wrap {
  margin-top: 0.35rem;
}

.pipeline-load-more {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: 10px;
  color: var(--text-secondary);
  padding: 0.55rem 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.pipeline-load-more-main {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.pipeline-load-more-main svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

.pipeline-load-more-label {
  letter-spacing: 0.01em;
}

.pipeline-load-more-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  color: var(--color-primary);
  border: 1px solid color-mix(in srgb, var(--color-primary) 26%, transparent);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  line-height: 1;
}

.pipeline-load-more-count,
.pipeline-load-more-remaining {
  font-weight: 700;
}

.pipeline-load-more-sep {
  opacity: 0.7;
  font-weight: 600;
}

.pipeline-load-more:hover {
  border-color: var(--color-primary);
  color: var(--text-primary);
  background: color-mix(in srgb, var(--color-primary-bg) 35%, var(--bg-primary));
}

.pipeline-load-more:active {
  transform: translateY(1px);
}

[data-theme="dark"] .pipeline-load-more {
  background: #1a222b;
  border-color: #2d3945;
  color: #b6c2cf;
}

[data-theme="dark"] .pipeline-load-more:hover {
  border-color: color-mix(in srgb, var(--color-primary) 75%, #4f6782 25%);
  color: #e2ebf5;
}

[data-theme="dark"] .pipeline-load-more-meta {
  background: color-mix(in srgb, var(--color-primary) 22%, transparent);
  border-color: color-mix(in srgb, var(--color-primary) 36%, transparent);
}

.pipeline-inline-add {
  width: 100%;
  border: 1px dashed var(--border-color);
  background: transparent;
  color: var(--text-muted);
  height: 32px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  margin-top: 0.1rem;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.pipeline-inline-add:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-bg);
}

/* ===== OPPORTUNITY CARDS ===== */

.opportunity-card {
  --card-bg: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem 0.8rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Columns scroll on mobile; cards must keep their height */
  flex-shrink: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

[data-theme="dark"] .opportunity-card {
  --card-bg: #1c2027;
  border-color: #2d333c;
  box-shadow: none;
}

.opportunity-card:hover {
  border-color: #c3cad3;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
}

[data-theme="dark"] .opportunity-card:hover {
  border-color: #3d4552;
}

/* Filtered-out cards stay in the DOM so sorting and drag-and-drop keep working */
.opportunity-card.is-filtered-out {
  display: none !important;
}

/* Logo, deal name, company and days in stage */
.opp-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.opp-avatar {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

[data-theme="dark"] .opp-avatar {
  background: #2a303a;
}

.opp-avatar-initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.opp-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.opp-card-titles {
  flex: 1;
  min-width: 0;
}

.opp-name {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.opp-company {
  margin-top: 0.1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-dot {
  margin: 0 0.3rem;
}

.opp-stage-age {
  flex-shrink: 0;
  margin-top: 0.1rem;
  font-size: 0.72rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.opportunity-card.is-stale .opp-stage-age {
  color: var(--color-warning);
  font-weight: 600;
}

/* Value, win chance and team */
.opp-value-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 24px;
}

.opp-value {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-primary);
}

.opp-value.is-empty {
  font-weight: 500;
  color: var(--text-muted);
}

.opp-prob-label {
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* Next step */
.opp-next-step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-color-light);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

[data-theme="dark"] .opp-next-step {
  border-top-color: #2a2f37;
}

.opp-step-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.opp-step-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-step-date {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.opp-next-step.is-due-today .opp-step-date {
  color: var(--color-warning);
  font-weight: 600;
}

.opp-next-step.is-overdue .opp-step-date {
  color: var(--color-danger);
  font-weight: 600;
}

/* ===== SORTABLE DRAG STATES ===== */

/* Probability Slider */
.probability-slider-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.probability-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  outline: none;
}

.probability-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.probability-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: none;
}

.probability-value {
  min-width: 40px;
  text-align: center;
  font-weight: 600;
  color: var(--color-primary);
}

/* Competitors Input */
.competitors-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  min-height: 48px;
  align-items: center;
}

.competitors-input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: none;
  padding: 0.25rem;
  font-size: 0.9375rem;
}

.competitors-input:focus {
  outline: none;
  box-shadow: none;
}

.competitor-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: var(--color-danger-bg);
  color: var(--color-danger);
  font-size: 0.75rem;
  font-weight: 550;
  border-radius: var(--radius-full);
}

.competitor-tag .remove {
  cursor: pointer;
  font-size: 0.875rem;
}

/* Pipeline Summary */
/* Responsive adjustments for pipeline */
@media (max-width: 1400px) {
  .pipeline-stages {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .pipeline-view-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pipeline-view-right {
    justify-content: flex-start;
  }

  .pipeline-stages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .pipeline-stage {
    min-height: auto;
  }
}

.pipeline-stage.drag-over {
  background: var(--color-primary-bg);
  border: 2px dashed var(--color-primary);
}

[data-theme="dark"] .pipeline-stage.drag-over {
  background: rgba(47, 95, 208, 0.08);
}

.pipeline-stage.is-drop-origin {
  border-color: var(--border-color-light);
  opacity: 0.7;
}

.pipeline-stage.is-drop-target {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

[data-theme="dark"] .pipeline-stage.is-drop-target {
  background: rgba(47, 95, 208, 0.08);
}

.opportunity-list.valid-drop {
  min-height: 100px;
  background: transparent;
  border-radius: var(--radius-md);
}

/* already defined above in card redesign block - keep this one canonical */
.opportunity-card.dragging {
  opacity: 0.35;
  transform: rotate(1deg) scale(0.98) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2) !important;
  z-index: 1000;
}

.opportunity-card.dragging-active {
  opacity: 0.75;
}

.sortable-ghost {
  opacity: 0 !important;
  background: transparent !important;
  border: 2px dashed var(--color-primary) !important;
  box-shadow: none !important;
}

[data-theme="dark"] .sortable-ghost {
  border-color: var(--color-primary) !important;
  background: rgba(var(--color-primary-rgb, 47, 95, 208), 0.06) !important;
}

.sortable-chosen {
  cursor: grabbing !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18) !important;
  transform: scale(1.02) !important;
  border-color: var(--color-primary) !important;
  transition: none !important;
}

[data-theme="dark"] .sortable-chosen {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45) !important;
}

.sortable-drag {
  opacity: 1 !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

@media (min-width: 768px) {
  .opportunity-list {
    min-height: 100px;
    transition: none;
  }

  .opportunity-list:hover {
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
  }
}

.sidebar-attribution {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.sidebar-attribution p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  /* Better than random red */
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
}

.task-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.task-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 550;
}

.task-status.pending {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.task-status.in_progress {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.task-status.completed {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.task-description {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.task-priority {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 550;
}

.task-priority.low {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.task-priority.medium {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.task-priority.high {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* Responsive adjustments for tasks */
/* ===== AI CHAT ASSISTANT - SAFI AI ===== */

/* header AI button with generative-style animated gradient border */
.header-ai-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 30px;
  box-sizing: border-box;
  padding: 0 var(--space-3) 0 var(--space-2);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  font-size: var(--type-sm);
  cursor: pointer;
  letter-spacing: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

/* Remove gradient border pseudo-elements */
.header-ai-btn::before {
  display: none;
}

.header-ai-btn::after {
  display: none;
}

.header-ai-btn svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  color: var(--color-primary);
  flex-shrink: 0;
}

.header-ai-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--color-primary);
  color: var(--text-primary);
}

.header-ai-btn:hover svg {
  color: var(--color-primary);
}

.header-ai-btn:active {
  background: var(--bg-active);
}

/* ---- Chat panel ---- */
/* ===== AI CHAT PANEL — Attio-inspired clean design ===== */
.ai-chat-window {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color-light);
  display: flex;
  flex-direction: column;
  z-index: 1010;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Shadow only while open — closed, it bled a faint strip onto the right edge */
.ai-chat-window.active {
  transform: translateX(0);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
}

/* ---- Header ---- */
.ai-chat-header {
  padding: 0 12px 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border-color-light);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.ai-chat-header-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

/* ---- Live status dot (pulsing green indicator) ---- */
.ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
  position: relative;
}
.ai-status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--color-success);
  opacity: 0;
  animation: statusPulse 3s ease-in-out infinite;
}
@keyframes statusPulse {
  0%   { transform: scale(0.9); opacity: 0.5; }
  60%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(0.9); opacity: 0; }
}

.ai-chat-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.ai-chat-header-btn {
  background: transparent;
  border: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  padding: 0;
  flex-shrink: 0;
}

.ai-chat-header-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ---- Messages ---- */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 3px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: msgIn 0.15s ease forwards;
}

.ai-chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.ai-chat-message.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.ai-chat-message + .ai-chat-message {
  margin-top: 6px;
}

.ai-chat-message.user + .ai-chat-message.ai,
.ai-chat-message.ai + .ai-chat-message.user {
  margin-top: 16px;
}

/* ---- Bubbles ---- */
.ai-chat-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.6;
}

.ai-chat-message.user .ai-chat-bubble {
  padding: 8px 13px;
  border: 0;
  border-radius: 14px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.ai-chat-message.ai .ai-chat-bubble {
  background: transparent;
  color: var(--text-primary);
  padding: 4px 0;
}

/* ---- Rich text inside AI bubbles ----
   One look in the Safi panel and the Home chat (dashboard.css only sets
   the bigger size there). Headings step up in size and weight over the
   text, sections get room, sub-points sit indented and quieter under
   their item, and dividers are visible in light and dark. */
.ai-chat-bubble {
  --chat-heading: calc(1em + 1.5px);
  --chat-rule: color-mix(in srgb, var(--text-primary) 14%, transparent);
}

.ai-chat-bubble p {
  margin: 0 0 10px 0;
  line-height: 1.6;
}

.ai-chat-bubble > :last-child,
.ai-chat-bubble p:last-child {
  margin-bottom: 0;
}

.ai-chat-bubble h1,
.ai-chat-bubble h2,
.ai-chat-bubble h3,
.ai-chat-bubble h4 {
  margin: 20px 0 8px 0;
  font-size: var(--chat-heading);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.ai-chat-bubble h1 { font-size: calc(var(--chat-heading) + 2px); }

.ai-chat-bubble > h1:first-child,
.ai-chat-bubble > h2:first-child,
.ai-chat-bubble > h3:first-child,
.ai-chat-bubble > h4:first-child,
.ai-chat-bubble hr + h1,
.ai-chat-bubble hr + h2,
.ai-chat-bubble hr + h3,
.ai-chat-bubble hr + h4 {
  margin-top: 0;
}

.ai-chat-bubble ul,
.ai-chat-bubble ol {
  margin: 6px 0 12px 0;
  padding-left: 20px;
}

.ai-chat-bubble li {
  margin-bottom: 6px;
  padding-left: 2px;
  line-height: 1.55;
}

.ai-chat-bubble li:last-child {
  margin-bottom: 0;
}

.ai-chat-bubble li::marker {
  color: var(--text-muted);
}

/* Sub-points: under their item, a step quieter */
.ai-chat-bubble li > ul,
.ai-chat-bubble li > ol {
  margin: 4px 0 2px 0;
  padding-left: 16px;
}

.ai-chat-bubble li > ul > li,
.ai-chat-bubble li > ol > li {
  margin-bottom: 3px;
  color: var(--text-secondary);
}

.ai-chat-bubble li > ul {
  list-style-type: circle;
}

/* Body text is already 550, so bold has to be clearly heavier to show */
.ai-chat-bubble strong {
  font-weight: 750;
  color: var(--text-primary);
}

.ai-chat-bubble em {
  font-style: italic;
}

.ai-chat-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.88em;
  background: var(--bg-tertiary);
  padding: 1.5px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.ai-chat-bubble blockquote {
  border-left: 2px solid var(--chat-rule);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.ai-chat-bubble hr {
  height: 0;
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--chat-rule);
}

/* ---- Message action buttons (copy / helpful / not-helpful / retry) ---- */
.ai-chat-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}

.ai-chat-message.ai:hover .ai-chat-actions,
.ai-chat-message.ai:focus-within .ai-chat-actions {
  opacity: 1;
}

.ai-chat-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.ai-chat-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.ai-chat-action-btn:active {
  transform: scale(0.92);
}

.ai-chat-action-btn.ai-action-active {
  color: var(--color-primary);
}

.ai-chat-action-btn.ai-action-copied {
  color: var(--color-success, #16a34a);
}

.ai-chat-action-btn svg {
  pointer-events: none;
  display: block;
}

/* ---- Footer ---- */
.ai-chat-footer {
  border-top: 1px solid var(--border-color);
  padding: 10px 12px 12px;
  background: var(--bg-primary);
  flex-shrink: 0;
  position: relative;
}

/* ---- Prompts menu ("/"): grouped, keyboard-first ---- */
.ai-prompts-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  max-height: min(400px, 60vh);
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  box-shadow: 0 12px 32px rgba(15, 17, 23, 0.14), 0 2px 6px rgba(15, 17, 23, 0.06);
}

.ai-prompts-menu[hidden] {
  display: none;
}

[data-theme="dark"] .ai-prompts-menu {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.ai-prompts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--border-color);
}

.ai-prompts-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
}

.ai-prompts-keys {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ai-prompts-keys kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-right: 2px;
  padding: 0 4px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  font: inherit;
  font-size: 10.5px;
  color: var(--text-secondary);
}

.ai-prompts-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 6px 6px;
}

.ai-prompts-group[hidden] {
  display: none;
}

.ai-prompts-group-title {
  padding: 8px 8px 4px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
}

.ai-prompt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
}

.ai-prompt-item[hidden] {
  display: none;
}

.ai-prompt-item.is-active {
  background: var(--bg-tertiary);
}

.ai-prompt-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--bg-primary);
  fill: none;
  stroke: var(--text-secondary);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  box-sizing: border-box;
}

.ai-prompt-item.is-active .ai-prompt-icon {
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--border-color));
  stroke: var(--color-primary);
}

.ai-prompt-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ai-prompt-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
}

.ai-prompt-question {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-prompts-empty {
  margin: 0;
  padding: 16px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  color: var(--text-muted);
}

/* ---- Prompts toggle button ---- */
.ai-chat-prompts-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  margin-right: 4px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
  line-height: 1;
}

.ai-chat-prompts-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.ai-chat-prompts-btn.active {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ---- Input composer ---- */
.ai-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.15s;
}

.ai-chat-input-wrap:focus-within {
  border-color: var(--color-primary);
}

.ai-chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.45;
  padding: 5px 8px 5px 0;
  min-width: 0;
  resize: none;
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
}

.ai-chat-textarea:focus,
.ai-chat-textarea:focus-visible {
  outline: none;
  box-shadow: none;
}

.ai-chat-textarea::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

.ai-chat-input-actions {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}

/* ---- Send button ---- */
.ai-chat-send-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.ai-chat-send-btn:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.ai-chat-send-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.ai-chat-send-btn:disabled {
  background: var(--border-color);
  cursor: default;
  opacity: 0.5;
}

/* ---- "Thinking" while an answer is on its way ---- */
.ai-thinking {
  display: inline-block;
  color: var(--text-muted);
  background: linear-gradient(90deg,
    var(--text-muted) 0%, var(--text-muted) 35%,
    var(--text-primary) 50%,
    var(--text-muted) 65%, var(--text-muted) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ai-thinking 2s linear infinite;
}

@keyframes ai-thinking {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-thinking {
    animation: none;
    -webkit-text-fill-color: currentColor;
  }
}

/* ---- Dark mode overrides ---- */
[data-theme="dark"] .ai-chat-bubble code {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ---- Empty state ---- */
.ai-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 4px 48px;
  gap: 20px;
}
.ai-chat-empty.hidden {
  display: none;
}
.ai-chat-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}
.ai-chip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}
.ai-chip {
  padding: 9px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-chip:hover {
  background: var(--color-primary-bg);
  border-color: rgba(var(--color-primary-rgb), 0.3);
  color: var(--color-primary);
}
[data-theme="dark"] .ai-chip {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}
[data-theme="dark"] .ai-chip:hover {
  background: var(--color-primary-bg);
}

[data-theme="dark"] .ai-chat-input-wrap {
  background: var(--bg-tertiary);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== FORCE CONFIRM DIALOG TO TOP ===== */
#confirm-dialog {
  z-index: 99999 !important;
}

#confirm-dialog .modal-container {
  z-index: 99999 !important;
}

#confirm-dialog .modal-backdrop {
  z-index: 99998 !important;
}

/* Ensure toast is visible above everything */
#toast-container {
  z-index: var(--z-toast) !important;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color-light);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-base);
}

.action-btn:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn svg {
  stroke-width: 1.5;
}

.company-description,
.person-details {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.company-location,
.person-company {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.company-location i,
.person-company i {
  color: var(--text-muted);
}

.company-categories,
.person-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.company-category {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 550;
  border-radius: var(--radius-full);
}

.person-contact-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.person-contact-item i {
  color: var(--text-muted);
}

.person-opportunity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-success);
}

.person-opportunity i {
  color: var(--color-success);
}

/* Color-Coded Categories System & Searchable Dropdown */
.categories-field-wrapper {
  position: relative;
}

.categories-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: var(--radius-md, 6px);
  background: var(--bg-primary, #ffffff);
  min-height: 42px;
  align-items: center;
  cursor: text;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.categories-input-container:focus-within {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.categories-input {
  flex: 1;
  min-width: 100px;
  border: none !important;
  background: none !important;
  padding: 2px 4px !important;
  font-size: 0.875rem !important;
  color: var(--text-primary, #0f172a) !important;
  outline: none !important;
  box-shadow: none !important;
  height: 28px !important;
}

.categories-chevron {
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease, transform 0.2s ease;
  user-select: none;
}

.categories-chevron:hover {
  color: var(--text-primary, #0f172a);
  background: var(--bg-secondary, #f1f5f9);
}

.categories-chevron.is-open {
  transform: rotate(180deg);
}

/* 16 Harmonious Category Color Schemes */
.cat-color-0  { --cat-bg: #eff6ff; --cat-color: #1d4ed8; --cat-border: #bfdbfe; --cat-dot: #2563eb; } /* Blue */
.cat-color-1  { --cat-bg: #ecfdf5; --cat-color: #047857; --cat-border: #a7f3d0; --cat-dot: #059669; } /* Emerald */
.cat-color-2  { --cat-bg: #f5f3ff; --cat-color: #6d28d9; --cat-border: #ddd6fe; --cat-dot: #7c3aed; } /* Violet */
.cat-color-3  { --cat-bg: #fffbeb; --cat-color: #b45309; --cat-border: #fde68a; --cat-dot: #d97706; } /* Amber */
.cat-color-4  { --cat-bg: #fff1f2; --cat-color: #be123c; --cat-border: #fecdd3; --cat-dot: #e11d48; } /* Rose */
.cat-color-5  { --cat-bg: #ecfeff; --cat-color: #0e7490; --cat-border: #a5f3fc; --cat-dot: #0891b2; } /* Cyan */
.cat-color-6  { --cat-bg: #eef2ff; --cat-color: #4338ca; --cat-border: #c7d2fe; --cat-dot: #4f46e5; } /* Indigo */
.cat-color-7  { --cat-bg: #f0fdfa; --cat-color: #0f766e; --cat-border: #99f6e4; --cat-dot: #0d9488; } /* Teal */
.cat-color-8  { --cat-bg: #fff7ed; --cat-color: #c2410c; --cat-border: #fed7aa; --cat-dot: #ea580c; } /* Orange */
.cat-color-9  { --cat-bg: #faf5ff; --cat-color: #7e22ce; --cat-border: #e9d5ff; --cat-dot: #9333ea; } /* Purple */
.cat-color-10 { --cat-bg: #fdf2f8; --cat-color: #be185d; --cat-border: #fbcfe8; --cat-dot: #db2777; } /* Pink */
.cat-color-11 { --cat-bg: #f0fdf4; --cat-color: #15803d; --cat-border: #bbf7d0; --cat-dot: #16a34a; } /* Green */
.cat-color-12 { --cat-bg: #fdf4ff; --cat-color: #a21caf; --cat-border: #f5d0fe; --cat-dot: #c026d3; } /* Fuchsia */
.cat-color-13 { --cat-bg: #f7fee7; --cat-color: #4d7c0f; --cat-border: #d9f99d; --cat-dot: #65a30d; } /* Lime */
.cat-color-14 { --cat-bg: #f0f9ff; --cat-color: #0369a1; --cat-border: #bae6fd; --cat-dot: #0284c7; } /* Sky */
.cat-color-15 { --cat-bg: #f1f5f9; --cat-color: #334155; --cat-border: #cbd5e1; --cat-dot: #475569; } /* Slate */

/* Dark Mode Palette */
[data-theme="dark"] .cat-color-0  { --cat-bg: rgba(37, 99, 235, 0.15); --cat-color: #93c5fd; --cat-border: rgba(37, 99, 235, 0.35); --cat-dot: #60a5fa; }
[data-theme="dark"] .cat-color-1  { --cat-bg: rgba(5, 150, 105, 0.15); --cat-color: #6ee7b7; --cat-border: rgba(5, 150, 105, 0.35); --cat-dot: #34d399; }
[data-theme="dark"] .cat-color-2  { --cat-bg: rgba(124, 58, 237, 0.15); --cat-color: #c4b5fd; --cat-border: rgba(124, 58, 237, 0.35); --cat-dot: #a78bfa; }
[data-theme="dark"] .cat-color-3  { --cat-bg: rgba(217, 119, 6, 0.15); --cat-color: #fcd34d; --cat-border: rgba(217, 119, 6, 0.35); --cat-dot: #fbbf24; }
[data-theme="dark"] .cat-color-4  { --cat-bg: rgba(225, 29, 72, 0.15); --cat-color: #fda4af; --cat-border: rgba(225, 29, 72, 0.35); --cat-dot: #fb7185; }
[data-theme="dark"] .cat-color-5  { --cat-bg: rgba(8, 145, 178, 0.15); --cat-color: #67e8f9; --cat-border: rgba(8, 145, 178, 0.35); --cat-dot: #22d3ee; }
[data-theme="dark"] .cat-color-6  { --cat-bg: rgba(79, 70, 229, 0.15); --cat-color: #a5b4fc; --cat-border: rgba(79, 70, 229, 0.35); --cat-dot: #818cf8; }
[data-theme="dark"] .cat-color-7  { --cat-bg: rgba(13, 148, 136, 0.15); --cat-color: #5eead4; --cat-border: rgba(13, 148, 136, 0.35); --cat-dot: #2dd4bf; }
[data-theme="dark"] .cat-color-8  { --cat-bg: rgba(234, 88, 12, 0.15); --cat-color: #fdba74; --cat-border: rgba(234, 88, 12, 0.35); --cat-dot: #fb923c; }
[data-theme="dark"] .cat-color-9  { --cat-bg: rgba(147, 51, 234, 0.15); --cat-color: #d8b4fe; --cat-border: rgba(147, 51, 234, 0.35); --cat-dot: #c084fc; }
[data-theme="dark"] .cat-color-10 { --cat-bg: rgba(219, 39, 119, 0.15); --cat-color: #f9a8d4; --cat-border: rgba(219, 39, 119, 0.35); --cat-dot: #f472b6; }
[data-theme="dark"] .cat-color-11 { --cat-bg: rgba(22, 163, 74, 0.15); --cat-color: #86efac; --cat-border: rgba(22, 163, 74, 0.35); --cat-dot: #4ade80; }
[data-theme="dark"] .cat-color-12 { --cat-bg: rgba(192, 38, 211, 0.15); --cat-color: #f0abfc; --cat-border: rgba(192, 38, 211, 0.35); --cat-dot: #e879f9; }
[data-theme="dark"] .cat-color-13 { --cat-bg: rgba(101, 163, 13, 0.15); --cat-color: #bef264; --cat-border: rgba(101, 163, 13, 0.35); --cat-dot: #a3e635; }
[data-theme="dark"] .cat-color-14 { --cat-bg: rgba(2, 132, 199, 0.15); --cat-color: #7dd3fc; --cat-border: rgba(2, 132, 199, 0.35); --cat-dot: #38bdf8; }
[data-theme="dark"] .cat-color-15 { --cat-bg: rgba(71, 85, 105, 0.15); --cat-color: #cbd5e1; --cat-border: rgba(71, 85, 105, 0.35); --cat-dot: #94a3b8; }

.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 2.5px 8px;
  background: var(--cat-bg, #eff6ff);
  color: var(--cat-color, #1d4ed8);
  border: 1px solid var(--cat-border, #bfdbfe);
  font-size: 0.8125rem;
  font-weight: 550;
  border-radius: 6px;
  line-height: 1.35;
  transition: all 0.15s ease;
}

.category-tag .category-color-dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--cat-dot, #2563eb);
}

.category-tag .tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  font-size: 13px;
  line-height: 1;
  color: inherit;
  opacity: 0.65;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.category-tag .tag-remove:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.12);
}

.categories-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.14), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  max-height: 260px;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

[data-theme="dark"] .categories-dropdown {
  background: #1e2227;
  border-color: #334155;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.category-dropdown-list {
  max-height: 215px;
  overflow-y: auto;
  padding: 4px;
  flex: 1;
}

.category-dropdown-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-secondary, #f8fafc);
  border-radius: 0 0 7px 7px;
}

[data-theme="dark"] .category-dropdown-footer {
  background: #181b1f;
  border-color: #334155;
}

.category-dropdown-meta {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  font-weight: 500;
}

.category-dropdown-close-btn {
  background: var(--primary-color, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.category-dropdown-close-btn:hover {
  background: var(--primary-hover, #1d4ed8);
  opacity: 0.95;
}

.category-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-primary, #0f172a);
  transition: background 0.12s ease;
  user-select: none;
}

.category-dropdown-item:hover {
  background: var(--bg-secondary, #f1f5f9);
}

[data-theme="dark"] .category-dropdown-item:hover {
  background: #283039;
}

.category-dropdown-item.is-selected {
  background: var(--cat-bg, #eff6ff);
  color: var(--cat-color, #1d4ed8);
  font-weight: 600;
}

.category-dropdown-item .category-color-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--cat-dot, #2563eb);
}

.category-dropdown-item .category-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-dropdown-item .category-check {
  margin-left: auto;
  font-size: 13px;
  color: var(--cat-color, #1d4ed8);
  font-weight: 700;
}

.category-dropdown-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted, #64748b);
}

.phone-numbers-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.phone-number-input {
  display: flex;
  gap: 0.5rem;
}

.phone-number {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition-fast);
}

.phone-number:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

/* Manual coordinates section */
.manual-coords-section {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.manual-coords-section.hidden {
  display: block;
}

.coord-inputs {
  display: flex;
  gap: 1rem;
}

.coord-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.coord-inputs input[type="number"] {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.coord-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.coord-buttons button {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-base);
  letter-spacing: 0.2px;
}

.coord-buttons button:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 2px 6px rgba(47, 95, 208, 0.15);
}

.coord-buttons button:active {
  transform: scale(0.98);
}

.coord-buttons button i {
  margin-right: 0.25rem;
}

/* Geocoding button loading state */
.geocode-btn.loading {
  pointer-events: none;
  opacity: 0.6;
}

.geocode-btn.loading i {
  animation: spin 1s linear infinite;
}

/* Force hide the native scrollbar so we can use our custom one */
html,
body {
  scrollbar-width: none !important;
}

/* ----- CUSTOM SCROLLBAR STYLES ----- */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  /* Thin track looks more modern */
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  /* Matches your app's background perfectly */
  border-radius: 100px;
  /* Fully rounded track ends */
  border: none;
  /* Clean look */
}

::-webkit-scrollbar-thumb {
  background-color: #4e6374;
  /* Dark grey thumb - nice contrast */
  border-radius: 4px;
  /* Sleek rounded corners */
  border: 2px solid var(--bg-primary);
  /* Optional border for extra definition */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  /* Subtle lift effect */
  transition: background-color 0.2s, box-shadow 0.2s;
  /* Smooth transition on hover */
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-primary);
  /* Your brand color on hover */
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
  /* Stronger lift on hover */
}

/* Fallback for Firefox */
* {
  scrollbar-width: 10px;
  scrollbar-color: #333333;
}

/* ===== TECHNICIAN SPECIFIC STYLES ===== */

/* Step-based form */
.form-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  position: relative;
}

.form-steps::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  transition: var(--transition-fast);
}

.step.active .step-number {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.step.completed .step-number {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.step-title {
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--text-secondary);
  text-align: center;
}

.step.active .step-title {
  color: var(--color-primary);
  font-weight: 600;
}

.step.completed .step-title {
  color: var(--color-success);
}

/* Step container */
.step-container {
  display: none;
}

.step-container.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Signature Canvas */
.signature-container {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  position: relative;
  margin-bottom: 1rem;
}

.signature-canvas {
  width: 100%;
  height: 200px;
  cursor: crosshair;
  background: white;
  border-radius: var(--radius-md);
}

.signature-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.signature-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.signature-preview {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: none;
}

.signature-preview.show {
  display: block;
}

.signature-preview img {
  max-width: 100%;
  max-height: 100px;
}

/* Photo Grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.photo-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  background: var(--color-danger);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-upload-multiple {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--bg-tertiary);
}

.photo-upload-multiple:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.photo-upload-multiple i {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Technician Visit Card */
.technician-visit-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition-fast);
}

.technician-visit-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.technician-visit-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.technician-visit-company {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.technician-visit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.technician-visit-meta-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.technician-visit-meta-item i {
  color: var(--text-muted);
}

.work-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.work-status-badge.completed {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.work-status-badge.partially-completed {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.work-status-badge.pending {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.work-status-badge.follow-up {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

/* Technician Dashboard Map */
.technician-map-container {
  height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

/* PDF Button */
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  background: var(--color-danger);
  color: white;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 2px 6px rgba(200, 58, 58, 0.15);
  letter-spacing: 0.3px;
}

.pdf-btn:hover {
  background: #b02d2d;
  box-shadow: 0 4px 12px rgba(200, 58, 58, 0.25);
}

.pdf-btn:active {
  box-shadow: 0 1px 3px rgba(200, 58, 58, 0.2);
  transform: scale(0.98);
}

/* Responsive adjustments */
/* Signature Canvas Styles */
.signature-canvas {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  touch-action: none;
}

[data-theme="dark"] .signature-canvas {
  background: #2a2a2a;
  border-color: #444;
}

.signature-placeholder {
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.signature-preview {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: none;
}

.signature-preview.show {
  display: block;
}

.signature-preview img {
  max-height: 100px;
  border-radius: var(--radius-sm);
}

/* Photo Item Styles */
.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-fast);
}

.photo-item:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  background: var(--color-danger);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: var(--transition-fast);
}

.photo-remove:hover {
  opacity: 1;
}

button svg {
  width: 18px;
}

/* Icon background */
/* Record-type tile (company, person, deal): window.recordTile() in icons.js.
   --tile sets its size; the glyph scales with it. */
.icon-bg {
  width: var(--tile, 16px);
  height: var(--tile, 16px);
  border-radius: calc(var(--tile, 16px) / 4);
  /* key detail */
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Icon itself */
.icon-bg svg {
  width: calc(var(--tile, 16px) * 0.69);
  height: calc(var(--tile, 16px) * 0.69);
  fill: white;
}

/* In the sidebar the tile sits in the 18px slot the line icons use */
.nav-item .icon-bg {
  margin: 0 1px;
}

/* Colors (from screenshot) */
.icon-bg.companies {
  background: #2563eb;
}

.icon-bg.people {
  background: #2563eb;
}

.icon-bg.deals {
  background: #c95809;
}

.icon-bg.users {
  background: #0c99bd;
}

.icon-bg.workspaces {
  background: #7c3aed;
}

/* Collapsed sidebar state */
.sidebar.collapsed .sidebar-nav {
  width: 60px;
}

.sidebar.collapsed .sidebar-header {
  padding: 0 0.5rem;
  height: var(--header-height);
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
  padding: 1rem 0.75rem;
}

/* Collapsed sidebar - Quick Actions buttons */
.sidebar.collapsed .sidebar-quick-actions {
  padding: 6px 6px 12px;
  flex-direction: column;
  gap: 4px;
}

.sidebar.collapsed .sidebar-action-btn > span:not(.notification-badge),
.sidebar.collapsed .sidebar-action-btn .sidebar-kbd-group {
  display: none;
}

.sidebar.collapsed .sidebar-quick-actions {
  align-items: center;
}

.sidebar.collapsed .sidebar-action-btn {
  justify-content: center;
  width: 32px;
  padding: 0;
  flex: 0 0 auto;
}

/* Collapsed sidebar state - Fix for Icons */
.sidebar.collapsed .nav-item>span:not(.icon-bg),
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .ws-btn {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-btn {
  margin-left: auto;
  margin-right: auto;
}

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer-logo {
  display: none;
}

/* Ensure icon containers stay visible */
.sidebar.collapsed .icon-bg {
  display: grid;
  /* Keep grid layout for centering */
}

/* Adjust nav items when collapsed */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.65rem;
}

.sidebar.collapsed .nav-item i {
  margin: 0;
  font-size: 1.25rem;
}

/* Adjust main content when sidebar is collapsed */
@media (min-width: 768px) {
  .main-content {
    transition: margin-left var(--transition-base);
  }
}

/* Update icon when sidebar is collapsed — handled by JS */

/* Show tooltips for collapsed sidebar */
.sidebar.collapsed .nav-item {
  position: relative;
}

.sidebar.collapsed .nav-item:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ===== TABLE VIEW STYLES ===== */
.view-options {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.table-container {
  overflow-x: auto;
  margin-top: 1rem;
  min-height: 200px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  text-align: left;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  letter-spacing: 0.3px;
  z-index: 2;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color-light);
  vertical-align: middle;
}

.data-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-secondary) 72%, transparent);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: color-mix(in srgb, var(--color-primary-bg) 35%, var(--bg-tertiary));
}

.data-table th:last-child,
.data-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--bg-primary);
  box-shadow: -8px 0 12px -10px rgba(15, 23, 42, 0.25);
}

.data-table th:last-child {
  z-index: 3;
  background: var(--bg-secondary);
}

.company-name-cell {
  font-weight: 550;
  color: var(--text-primary);
}

.company-description {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.person-name-cell {
  font-weight: 550;
  color: var(--text-primary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 550;
}

.status-active {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-inactive {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.table-actions .action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.table-actions .action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Responsive adjustments for table */
/* Add these styles to your CSS file */

/* Pagination Styles */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 550;
  cursor: pointer;
  transition: var(--transition-fast);
}

.pagination-btn:hover:not(.disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--color-primary);
}

.pagination-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.pagination-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn svg {
  width: 16px;
  height: 16px;
}

.pagination-ellipsis {
  padding: 0 0.5rem;
  color: var(--text-muted);
}

/* Responsive adjustments */
.photo-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: white;
  padding: 8px 4px 4px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-align: center;
}

.photo-item:hover .photo-info {
  opacity: 1;
}

.photo-info small:first-child {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-info small:last-child {
  color: #4ade80;
  font-weight: 550;
}

/* Compression progress toast styling */
#compression-progress-toast {
  background: var(--color-primary-bg);
  min-width: 250px;
}

#compression-progress-toast .toast-icon {
  color: var(--color-primary);
}

/* ======================
// NOTES VIEW STYLES
// ====================== */

/* ======================
// REDESIGNED NOTES VIEW (v2)
// ====================== */

.notes-view-root {
  display: flex;
  margin-top: var(--header-height);
  margin-bottom: var(--bottom-nav-height);
  height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
  transition: margin-left var(--transition-base), max-width var(--transition-base);
}

@media (min-width: 768px) {
  .notes-view-root {
    margin-left: var(--sidebar-width);
    max-width: calc(100vw - var(--sidebar-width));
    margin-bottom: 0;
    height: calc(100vh - var(--header-height));
  }
}

/* Notes board: tabs, search and New note on one row, tags, then cards */
.notes-board {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
  padding: 20px 28px 32px;
  overflow-y: auto;
}

.nb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.nb-tabs {
  display: flex;
  gap: 4px;
}

.nb-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.nb-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nb-tab.is-active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
}

.nb-count {
  min-width: 18px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.nb-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.nb-search-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
}

.nb-search-wrap svg {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.nb-search-input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 34px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}

.nb-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.nb-search-input::placeholder {
  color: var(--text-muted);
}

.nb-new {
  flex-shrink: 0;
  height: 34px;
  white-space: nowrap;
}

.nb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 16px;
}

.nb-tags[hidden] {
  display: none;
}

.nb-tag {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.nb-tag:hover {
  background: var(--bg-hover);
}

.nb-tag[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.nb-empty {
  grid-column: 1 / -1;
  padding: 64px 16px;
  text-align: center;
  color: var(--text-muted);
}

.nb-empty svg {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  opacity: 0.35;
}

.nb-empty h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.nb-empty p {
  margin: 0;
  font-size: 13.5px;
}

/* Cards: the deal on top, the note's own words, when it was last edited */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 148px;
  padding: 14px 16px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.note-card:hover {
  border-color: color-mix(in srgb, var(--border-color) 55%, var(--text-muted));
  box-shadow: var(--shadow-md);
}

.note-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nc-top {
  display: flex;
  min-width: 0;
}

/* Pinned: a pin in the corner, clear of the deal and the title */
.note-card {
  position: relative;
}

.note-card.pinned > :is(.nc-top, .nc-title, .nc-content:first-of-type) {
  padding-right: 22px;
}

.nc-pin-icon {
  position: absolute;
  top: 15px;
  right: 14px;
  width: 15px;
  height: 15px;
  color: var(--color-warning);
}

.nc-title {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nc-content {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.nc-content.is-empty {
  color: var(--text-muted);
  font-style: italic;
}

.nc-footer {
  margin-top: auto;
  padding-top: 4px;
}

.nc-date {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Slide-over Editor */
.note-slide-over {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 1050;
  visibility: hidden;
  transition: visibility 0s 0.3s;
}

.note-slide-over.active {
  visibility: visible;
  transition: visibility 0s;
}

.nso-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.note-slide-over.active .nso-backdrop {
  opacity: 1;
}

.nso-content {
  position: absolute;
  top: 0;
  right: -600px;
  width: 100%;
  max-width: 600px;
  height: 100%;
  background: var(--bg-primary);
  box-shadow: var(--shadow-2xl);
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid var(--border-color);
}

.nso-tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.nso-tool-btn:hover {
  background: var(--bg-tertiary);
  color: var(--color-primary);
}

.nso-tool-btn i {
  width: 16px;
  height: 16px;
}

.nso-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color-light);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.nso-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nso-toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 8px;
}

/* Tagging Suggestions */
.tagging-suggestions {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 3000;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  animation: slide-up 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
}

.suggestion-item:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.suggestion-item i {
  color: var(--color-primary);
  flex-shrink: 0;
}

.suggestion-item div {
  display: flex;
  flex-direction: column;
}

.suggestion-item span {
  font-weight: 600;
  font-size: 0.9rem;
}

.suggestion-item small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Identified Tags in Editor */
.person-tag,
.company-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 550;
  font-size: 0.9em;
  margin: 0 2px;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.person-tag {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-light);
}

.company-tag {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  /* slightly darker indigo */
  border: 1px solid rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .company-tag {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.person-tag:hover,
.company-tag:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Editor Placeholder */
[contenteditable]:empty:before {
  content: attr(placeholder);
  color: var(--text-muted);
  opacity: 0.6;
  pointer-events: none;
  display: block;
}

.note-slide-over.active .nso-content {
  right: 0;
}

.nso-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.nso-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nso-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.nso-close-btn:hover {
  background: var(--bg-tertiary);
}

.nso-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
}

.nso-header-right {
  display: flex;
  gap: 0.5rem;
}

.nso-action-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nso-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nso-action-btn.danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.nso-body {
  flex: 1;
  padding: 2rem 3rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nso-title-input {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  border: none;
  background: transparent;
  width: 100%;
  margin-bottom: 1rem;
}

.nso-title-input:focus {
  outline: none;
}

.nso-meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color-light);
}

.nso-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.nso-meta-item i {
  width: 14px;
  height: 14px;
}

/* The deal a note was written on: a label on the card, a link in the open note */
.nc-deal,
.nso-deal-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  font: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.nc-deal {
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 500;
}

.nc-deal span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nso-deal-link {
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.nso-deal-link strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-primary);
}

.nc-deal:hover,
.nso-deal-link:hover {
  border-color: color-mix(in srgb, var(--border-color) 60%, var(--text-muted));
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nc-deal:focus-visible,
.nso-deal-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.nso-deal-link.is-static {
  cursor: default;
}

.nc-deal-icon,
.nso-deal-open {
  flex-shrink: 0;
  color: var(--text-muted);
}

.nso-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  position: sticky;
  top: -2rem;
  z-index: 10;
}

.nso-toolbar-group {
  display: flex;
  gap: 0.125rem;
}

.nso-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 0.25rem;
}

.nso-tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nso-tool-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nso-editor-content {
  flex: 1;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text-primary);
  outline: none;
}

.nso-editor-content p {
  margin-bottom: 1rem;
}

/* Mentions & Hashtags in Editor */
.mention-span {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  padding: 0 0.375rem;
  border-radius: 4px;
  font-weight: 600;
}

.hashtag-span {
  color: var(--color-secondary);
  font-weight: 600;
}

/* Stops list */

/* Outlier notice */

/* Footer accents */

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Status indicator dots */
.task-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.dot-high { background: #ef4444; }
.dot-medium { background: #f59e0b; }
.dot-low { background: #3b82f6; }
.dot-pending { background: #f59e0b; }
.dot-in_progress { background: #3b82f6; }
.dot-completed { background: #10b981; }

/* Task Detail Modal */
.task-detail-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  padding: 1rem;
}

.task-detail-modal.active {
  display: flex;
}

.tdv-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.tdv-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tdv-badges-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tdv-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

.tdv-status-pending {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.tdv-status-in_progress {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border: 1px solid rgba(47, 95, 208, 0.25);
}

.tdv-status-completed {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.tdv-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  margin: 0;
}

.tdv-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 550;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
}

.tdv-pill-priority-high {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.25);
}

.tdv-pill-priority-medium {
  background: rgba(217, 119, 6, 0.08);
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.25);
}

.tdv-pill-priority-low {
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.25);
}

.tdv-pill-due {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.tdv-pill-overdue {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.25);
}

.tdv-pill-nodate {
  background: var(--bg-primary);
  color: var(--text-muted);
  border-color: var(--border-color-light);
}

.tdv-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.tdv-section {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.tdv-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tdv-desc {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.875rem;
  font-size: 0.84rem;
  color: var(--text-primary);
  line-height: 1.55;
  white-space: pre-wrap;
}

.tdv-people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.625rem;
}

.tdv-person {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
}

.tdv-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.tdv-avatar-blue {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border: 1px solid rgba(47, 95, 208, 0.2);
}

.tdv-avatar-purple {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.tdv-person-info {
  min-width: 0;
}

.tdv-person-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tdv-person-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tdv-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.tdv-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 32px;
  padding: 0 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tdv-edit-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.tdv-delete-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tdv-delete-btn:hover {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.tdv-lock-notice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 100%;
}

[data-theme="dark"] .tdv-header {
  background: #161b22;
  border-bottom-color: #262c36;
}

[data-theme="dark"] .tdv-desc,
[data-theme="dark"] .tdv-person {
  background: #0f1318;
  border-color: #262c36;
}

[data-theme="dark"] .tdv-footer {
  background: #12161c;
  border-top-color: #262c36;
}

[data-theme="dark"] .tdv-edit-btn {
  background: #181d24;
  border-color: #262c36;
}

/* External Toggle Button for Password */
.toggle-password-external {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 48px;
  /* Match input height */
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle-password-external:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--bg-tertiary);
}

/* ==========================================================================
   Tour (onboarding.js): a small card beside the sidebar item it explains
   ========================================================================== */

.safi-crm-spotlight-card {
  position: fixed;
  z-index: 10070;
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 16px 16px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);
  color: var(--text-primary);
  animation: safi-tour-in 0.2s ease both;
}

@keyframes safi-tour-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.safi-spotlight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.safi-spotlight-step {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
}

.safi-spotlight-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin: -6px -6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.safi-spotlight-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.safi-spotlight-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
}

.safi-spotlight-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.safi-spotlight-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
}

.safi-spotlight-nav {
  display: flex;
  gap: 6px;
}

.safi-spotlight-exit,
.safi-spotlight-btn-prev,
.safi-spotlight-btn-next {
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.safi-spotlight-exit {
  margin-left: -12px;
  background: transparent;
  color: var(--text-muted);
}

.safi-spotlight-exit:hover {
  color: var(--text-primary);
}

.safi-spotlight-btn-prev {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.safi-spotlight-btn-prev:hover {
  background: var(--bg-tertiary);
}

.safi-spotlight-btn-next {
  background: var(--color-primary);
  color: #fff;
}

.safi-spotlight-btn-next:hover {
  filter: brightness(0.94);
}

.safi-crm-spotlight-card button:focus {
  outline: none;
}

.safi-crm-spotlight-card button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Drawn inside the item so the sidebar edge never clips it */
.safi-tour-target-ring {
  outline: none !important;
  box-shadow: inset 0 0 0 1.5px var(--color-primary) !important;
  background-color: var(--color-primary-bg, rgba(47, 95, 208, 0.08)) !important;
}

@media (max-width: 600px) {
  .safi-crm-spotlight-card {
    left: 16px !important;
    right: 16px !important;
    bottom: calc(var(--bottom-nav-height, 64px) + 16px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto !important;
  }
}

/* ===== PWA INSTALL BANNER ===== */
.install-banner {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.04);
  z-index: var(--z-fixed);
  padding: 10px 10px 10px 12px;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 901px) {
  .install-banner {
    bottom: 24px;
  }
}

.install-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.install-banner-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
}

.install-banner-text {
  flex: 1;
  min-width: 0;
}

.install-banner-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.install-banner-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-muted);
}

.install-banner-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.install-banner-btn:hover {
  background: var(--color-primary-dark);
}

.install-banner-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-left: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.install-banner-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 100%);
    opacity: 0;
  }

  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.page-header-row {
  align-items: center;
  flex-wrap: wrap;
}

/* View Toggle for Managers */
.view-toggle {
  display: flex;
  background: var(--bg-secondary);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 0.25rem;
}

.toggle-btn {
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.toggle-btn:hover {
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--bg-secondary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* Live Search Results */
.search-input-group {
  position: relative;
}

.live-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 250px;
  overflow-y: auto;
  display: none;
}

.live-search-results.active {
  display: block;
}

.live-search-results .search-result-item {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.625rem;
}

.live-search-results .search-result-item .search-result-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}

.live-search-results .search-result-item:hover {
  background: var(--bg-tertiary);
}

.live-search-results .search-result-item .title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.live-search-results .search-result-item .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.live-search-results .search-result-item.add-new {
  border-top: 1px solid var(--border-color);
  color: var(--color-primary);
  font-weight: 600;
  background: var(--color-primary-bg);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* View Details Grid */
.view-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-field.full-row {
  grid-column: 1 / -1;
}

.detail-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.detail-value {
  font-size: 1rem;
  color: var(--text-primary);
  word-break: break-word;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

/* Compact spacing for Company modal details */
#company-view-modal .view-details-grid {
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

#company-view-modal .detail-field {
  gap: 0.25rem;
}

#company-view-modal .detail-value {
  padding: 0.5rem;
  min-height: 2rem;
  font-size: 0.95rem;
  align-items: flex-start;
}

/* Make links inside modal detail values wrap nicely and look compact */
#company-view-modal .detail-value a,
#person-view-modal .detail-value a,
#opportunity-view-modal .detail-value a {
  display: inline-block;
  padding: 0.28rem 0.6rem;
  margin: 0;
  background: transparent;
  color: var(--color-primary);
  text-decoration: none;
  border-radius: 8px;
  white-space: normal;
  word-break: break-word;
}

/* If the domain/email uses the pill class, neutralize heavy pill styling in the sidebar */
#company-view-modal .detail-value .company-summary-domain-link,
#person-view-modal .detail-value .company-summary-domain-link {
  padding: 0.28rem 0.6rem;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  font-weight: 600;
}

/* Direction Badge Styling */
.direction-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.direction-badge.inbound {
  background: #ffef4d;
  color: #353935;
}

.direction-badge.outbound {
  background: #353935;
  color: #ffef4d;
}

/* Employees list in Company View */
.company-employees-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
}

.company-employee {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 8px;
  border-radius: 8px;
  transition: background 120ms ease, transform 120ms ease;
  cursor: default;
}

.company-employee:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.03));
  transform: translateY(-1px);
}

.company-employee .employee-left {
  flex: 0 0 auto;
}

.company-employee .mention-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-on-accent, #ffffff);
  background: #2b6ff5;
}

.company-employee .employee-main {
  flex: 1 1 auto;
  min-width: 0;
}

.company-employee .employee-name {
  font-size: 1.02rem;
  color: var(--text-primary);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-employee .employee-role {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.company-employee .employee-actions {
  margin-left: 8px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.company-employee .employee-actions .btn,
.company-employee .employee-actions .view-employee {
  padding: 6px 8px;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
}

/* Subtle divider between employees */
.company-employee+.company-employee {
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

@media (max-width: 800px) {
  .company-employee {
    padding: 8px 6px;
    gap: 10px;
  }

  .company-employee .mention-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  .company-employee .employee-name {
    font-size: 0.95rem;
  }
}

/* Search Input Wrapper */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem 0 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

/* Stray rule preserved from previous block */
.view-toolbar+.spreadsheet-container .spreadsheet-cell {
  font-weight: 550;
}

/* ===== GLOBAL MOBILE HARDENING ===== */
/* ===== TECHNICIAN DASHBOARD FILTER CONTROLS ===== */
/* ===== FORM CONSISTENCY LAYER ===== */
:root {
  --form-control-height: 40px;
  --form-control-radius: var(--radius-md);
  --form-control-font-size: 0.9375rem;
}

:is(.form-field input,
  .form-field select,
  .categories-input,
  .competitors-input,
  .phone-number,
  .technician-filter-control) {
  min-height: var(--form-control-height);
  border-radius: var(--form-control-radius);
  font-size: var(--form-control-font-size);
  line-height: 1.35;
}

:is(.form-field textarea) {
  border-radius: var(--form-control-radius);
  font-size: var(--form-control-font-size);
  line-height: 1.45;
  min-height: 96px;
}

:is(.form-field input,
  .form-field select,
  .form-field textarea,
  .categories-input,
  .competitors-input,
  .phone-number,
  .technician-filter-control) {
  border: 1.25px solid var(--border-color);
  background: var(--bg-primary);
}

:is(.form-field input,
  .form-field select,
  .form-field textarea,
  .categories-input,
  .competitors-input,
  .phone-number,
  .technician-filter-control):focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

:is(.form-field input,
  .form-field select,
  .form-field textarea,
  .categories-input,
  .competitors-input,
  .phone-number,
  .technician-filter-control)[aria-invalid="true"],
:is(.form-field input,
  .form-field select,
  .form-field textarea,
  .categories-input,
  .competitors-input,
  .phone-number,
  .technician-filter-control).is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger-bg) 70%, transparent);
}

.form-field label {
  font-weight: 600;
  letter-spacing: 0.1px;
}

.field-helper {
  font-size: 0.78rem;
  margin-top: -0.15rem;
  line-height: 1.35;
}

.field-error,
.form-error {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--color-danger);
}

.required-indicator {
  color: var(--color-danger);
  font-weight: 700;
}

.optional-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--border-color-light);
}

.technician-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ===== TOKENIZED UI UTILITIES ===== */
.modal-size-sm {
  max-width: min(460px, 92vw) !important;
}

.modal-size-md {
  max-width: min(760px, 94vw) !important;
}

.modal-size-lg {
  max-width: min(980px, 96vw) !important;
}

.modal-size-xl {
  max-width: min(1120px, 97vw) !important;
}

.modal-size-transfer {
  max-width: min(820px, 95vw) !important;
}

.modal-size-photo {
  max-width: min(92vw, 1200px) !important;
  max-height: 90vh;
}

.u-inline-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.u-flex-1 {
  flex: 1;
}

.u-maxw-320 {
  max-width: 320px;
}

.u-icon-16 {
  width: 16px;
  height: 16px;
}

.u-search-icon-muted {
  color: var(--text-muted);
}

.u-p-md {
  padding: var(--space-4);
}

.u-p-xl {
  padding: var(--space-7);
}

.u-grid-col-full {
  grid-column: 1 / -1;
}

.u-spacer-md {
  margin-bottom: 1.5rem;
}

.u-map-sm {
  height: 200px;
}

.u-map-md {
  height: 300px;
}

.u-map-lg {
  height: 400px;
}

.u-my-md {
  margin: 1rem 0;
}

.u-mt-md {
  margin-top: 1rem;
}

.u-flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.u-photo-contain {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.technician-filter-control {
  width: auto;
  min-width: 170px;
  height: var(--control-height-md);
  padding: 0 2rem 0 var(--space-3);
  border-radius: var(--btn-radius);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 550;
  box-shadow: none;
}

.technician-filter-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

#filter-date.technician-filter-control {
  min-width: 160px;
  padding-right: var(--space-3);
}

/* ==============================================
   VISITS HUB - PREMIUM MANAGER VIEW
   State-of-the-art design for enterprise CRM
   ============================================== */

/* ===== MAIN CONTAINER ===== */
.visits-hub {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeInUp 0.4s var(--motion-ease-emphasized);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== HERO STATS SECTION ===== */

.visits-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.visits-stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 550;
}

.visits-stat-sparkline {
  height: 32px;
  margin-top: 0.75rem;
  opacity: 0.8;
}

/* ===== COMMAND BAR ===== */
.visits-command-bar {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.visits-view-toggle {
  display: flex;
  height: var(--control-height-md);
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  background: var(--bg-tertiary);
  box-sizing: border-box;
}

.visits-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 100%;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.visits-view-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.visits-view-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-color);
}

.visits-view-btn svg {
  width: 15px;
  height: 15px;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MAIN CONTENT AREA ===== */
.visits-main-content {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  min-height: 600px;
}

.visits-list-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.visits-sort-select {
  padding: 0.375rem 1.75rem 0.375rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

/* List Container with scroll */
.visits-list-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.visits-list-container::-webkit-scrollbar {
  width: 6px;
}

.visits-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.visits-list-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.visits-list-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== VISIT CARD ===== */
.visit-card-premium {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.visit-card-premium:hover {
  border-color: color-mix(in srgb, var(--border-color) 55%, var(--text-muted));
}

.visit-card-premium.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.visit-card-premium:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.visit-card-premium[data-type="new_lead"] { --visit-type-color: #3b82f6; }
.visit-card-premium[data-type="follow_up"] { --visit-type-color: #8b5cf6; }
.visit-card-premium[data-type="demo"] { --visit-type-color: #f59e0b; }
.visit-card-premium[data-type="closing"] { --visit-type-color: #10b981; }
.visit-card-premium[data-type="support"] { --visit-type-color: #6b7280; }

.visit-card-layout {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  column-gap: 12px;
}

.visit-card-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.visit-card-body {
  min-width: 0;
}

.visit-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.visit-card-company {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visit-card-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.visit-card-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 6px;
  margin-top: 2px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.visit-card-sub .is-danger {
  color: var(--color-danger);
}

.visit-card-sep {
  opacity: 0.6;
}

.visit-card-notes {
  margin: 8px 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.visit-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  min-height: 24px;
}

.visit-card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.visit-card-tag {
  padding: 1px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.visit-card-fare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.visit-card-fare-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.visit-card-fare.fare-requested .visit-card-fare-dot { background: var(--color-warning); }
.visit-card-fare.fare-approved .visit-card-fare-dot { background: var(--color-success); }
.visit-card-fare.fare-rejected .visit-card-fare-dot { background: var(--color-danger); }

.visit-card-fare-amount {
  color: var(--text-muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.visit-card-fare-amount::before {
  content: '·';
  margin-right: 6px;
  opacity: 0.6;
}

.visit-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.visit-card-action {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.visit-card-premium:hover .visit-card-action,
.visit-card-action:focus-visible {
  opacity: 1;
}

.visit-card-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.visit-card-review {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.visit-card-review:hover {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--border-color) 55%, var(--text-muted));
}

/* Timeline view still uses the stacked card layout */
.visit-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.visit-card-main {
  flex: 1;
  min-width: 0;
}

.visit-card-rep {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.visit-card-rep-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
}

.visit-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.visit-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== VISIT DETAIL: FARE APPROVAL ===== */
.visit-fare-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.visit-fare-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.visit-fare-card-head .visit-detail-section-title {
  margin-bottom: 0;
}

.visit-fare-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.visit-fare-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.visit-fare-status.fare-requested .visit-fare-status-dot { background: var(--color-warning); }
.visit-fare-status.fare-approved .visit-fare-status-dot { background: var(--color-success); }
.visit-fare-status.fare-rejected .visit-fare-status-dot { background: var(--color-danger); }

.visit-detail-meta-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.visit-fare-reason {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.visit-fare-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.visit-fare-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.visit-fare-field input {
  max-width: 180px;
  font-variant-numeric: tabular-nums;
}

.visit-fare-field textarea {
  min-height: 64px;
  resize: vertical;
}

.visit-fare-hint {
  color: var(--text-muted);
}

.visit-fare-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== ACTIVITY SIDEBAR ===== */
.visits-activity-sidebar {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.activity-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color-light);
}

.activity-sidebar-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.activity-live-dot {
  width: 8px;
  height: 8px;
  background: var(--color-success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.activity-sidebar-tabs {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border-color-light);
}

.activity-tab {
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.activity-tab:hover {
  color: var(--text-primary);
}

.activity-tab.active {
  color: var(--color-primary);
}

.activity-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px 2px 0 0;
}

/* Align icons and text in activity tabs */
.activity-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.activity-tab svg,
.activity-tab i {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

.activity-tab .lucide {
  transform: translateY(0);
  /* reset any icon offsets */
}

.activity-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Activity Timeline */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-timeline-item {
  display: flex;
  gap: 0.875rem;
  padding: 0.75rem 0;
  position: relative;
}

.activity-timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 44px;
  bottom: -8px;
  width: 2px;
  background: var(--border-color-light);
}

.activity-timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.activity-timeline-icon.success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.activity-timeline-icon.warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.activity-timeline-content {
  flex: 1;
  min-width: 0;
}

.activity-timeline-title {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.activity-timeline-title strong {
  font-weight: 600;
}

.activity-timeline-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Team Leaderboard */
.team-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.leaderboard-item:hover {
  background: var(--bg-tertiary);
}

.leaderboard-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
  background: #f2c94c;
  color: #7c5800;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
  background: #cfd2d6;
  color: #5a5a5a;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
  background: #c98a50;
  color: #5c3d1e;
}

.leaderboard-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8125rem;
}

.leaderboard-info {
  flex: 1;
  min-width: 0;
}

.leaderboard-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.leaderboard-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ===== TIMELINE VIEW ===== */
.visits-timeline-view {
  display: none;
}

.visits-timeline-view.active {
  display: block;
}

.timeline-group {
  margin-bottom: 2rem;
}

.timeline-visit-card {
  margin-left: 1rem;
}

.timeline-group-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  padding: 0.5rem 0;
  z-index: 1;
}

.timeline-group-date {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-group-line {
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.timeline-group-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.25rem 0.625rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

/* ===== MAP VIEW ===== */
.visits-map-view {
  display: none;
}

.visits-map-view.active {
  display: block;
  height: 100%;
}

.visits-map-container {
  height: 500px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.visits-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ===== VISIT DETAIL PANEL ===== */
.visit-detail-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 480px;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  transition: right 0.3s var(--motion-ease-emphasized);
  display: flex;
  flex-direction: column;
}

.visit-detail-panel.open {
  right: 0;
}

.visit-detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.visit-detail-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.visit-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.visit-detail-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.visit-detail-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.visit-detail-actions {
  display: flex;
  gap: 0.5rem;
}

.visit-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.visit-detail-section {
  margin-bottom: 1.5rem;
}

.visit-detail-section:last-child {
  margin-bottom: 0;
}

.visit-detail-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.visit-detail-company {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.visit-detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.visit-detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.visit-detail-meta-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.visit-detail-meta-value {
  font-size: 0.9375rem;
  font-weight: 550;
  color: var(--text-primary);
}

.visit-detail-notes {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.visit-detail-photo {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.visit-detail-photo img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.visit-detail-photo img:hover {
  transform: scale(1.02);
}

/* AI Insight Block in Detail Panel */
.visit-detail-section .ai-insight {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.visit-detail-section .ai-insight::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: none;
}

.visit-detail-section .ai-insight-content {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.visit-detail-section .ai-insight-content p {
  margin-bottom: 0.75rem;
}

.visit-detail-section .ai-insight-content p:last-child {
  margin-bottom: 0;
}

.visit-detail-section .ai-insight-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.visit-detail-section .ai-insight-content ul,
.visit-detail-section .ai-insight-content ol {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
}

.visit-detail-section .ai-insight-content li {
  margin-bottom: 0.375rem;
}

/* ===== EMPTY STATE ===== */
.visits-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.visits-empty-state[hidden] {
  display: none;
}

.visits-empty-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.visits-empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.visits-empty-description {
  font-size: 0.9375rem;
  color: var(--text-muted);
  max-width: 320px;
}

/* ===== LOADING SKELETON ===== */
.visits-skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.visits-skeleton-card {
  height: 140px;
  margin-bottom: 0.875rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .visits-main-content {
    grid-template-columns: 1fr;
  }

  .visits-activity-sidebar {
    display: none;
  }
}

/* ===== PHOTO MODAL ===== */
.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.photo-modal.open {
  opacity: 1;
  visibility: visible;
}

.photo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
}

.photo-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.photo-modal.open .photo-modal-content {
  transform: scale(1);
}

.photo-modal-image {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.photo-modal-close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.photo-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* ============================================================
   COMPREHENSIVE MOBILE OPTIMIZATIONS
   All mobile-specific styles consolidated for easy maintenance
   ============================================================ */

/* Page Header Row for Call Logs and similar views */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 1rem;
}

/* Filters Section */
.filters-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.search-input-wrapper {
  position: relative;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

.filter-actions .btn {
  flex: 1;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ===== UTILITY CLASSES ===== */
.mt-sm {
  margin-top: 0.5rem;
}

.mt-md {
  margin-top: 1rem;
}

.mt-lg {
  margin-top: 1.5rem;
}

.mb-sm {
  margin-bottom: 0.5rem;
}

.mb-md {
  margin-bottom: 1rem;
}

.mb-lg {
  margin-bottom: 1.5rem;
}

/* Text truncation utilities */
.text-clamp-1 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.text-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.text-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Photo Grid Layouts */
.photo-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.photo-grid .photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item-more {
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-group-inline {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-group-end {
  display: flex;
  justify-content: flex-end;
}

/* ===== USER MANAGEMENT CARD ===== */
.user-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}

.user-card-info {
  flex: 1;
  min-width: 0;
}

.user-card-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card-email {
  color: var(--text-muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ===== EXTRA SMALL DEVICES (≤480px) ===== */
/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {

  /* Larger touch targets */
  .btn {
    min-height: 44px;
  }

  .nav-item {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }

  .bottom-nav-item {
    min-height: 48px;
  }

  /* Remove hover effects that cause sticky states on touch */
  .visit-card:hover,
  .card:hover,
  .stat-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  /* Better tap feedback */
  .btn:active,
  .nav-item:active,
  .bottom-nav-item:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
  }

  /* Disable resize handles on mobile */
  .resize-handle {
    display: none;
  }

  /* Scroll snap for horizontal scrolling elements */
  .pipeline-filters {
    scroll-snap-type: x mandatory;
  }

  .pipeline-filter {
    scroll-snap-align: start;
  }
}

/* ===== LANDSCAPE MOBILE ===== */
/* ===== SAFE AREA INSETS (Notch/Home Indicator) ===== */

/* ============================================
   VISITS AND TECHNICIANS
   Enhanced Mobile Design (≤768px)
   ============================================ */

/* ===== SMALLER MOBILE BREAKPOINT (≤480px) ===== */
/* ==========================================================================
   RECORD VIEW MODALS — Company & Person (Redesigned)
   ========================================================================== */

/* Modal overlay setup — centered dialog */
.record-view-modal {
  align-items: center;
  justify-content: center;
}

/* The panel itself */
.record-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(920px, 96vw);
  height: min(660px, 94vh);
  max-height: 94vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  animation: recordModalPop 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  z-index: 1;
}

@keyframes recordModalPop {
  from {
    transform: scale(0.96) translateY(8px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* ── Hero ── */
.record-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.record-hero-avatar {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.record-hero-avatar img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 14px;
  position: absolute;
  inset: 0;
  display: none;
}

.record-hero-avatar--person {
  border-radius: 50%;
  background: var(--color-primary);
}

.record-hero-info {
  flex: 1;
  min-width: 0;
}

.record-hero-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.record-hero-name {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.record-hero-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  white-space: nowrap;
}

.record-hero-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.record-hero-domain a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.825rem;
  color: var(--color-primary);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
  transition: background 0.15s, transform 0.1s;
}

.record-hero-domain a:hover {
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  transform: translateY(-1px);
}

.record-hero-domain a svg {
  flex-shrink: 0;
}

.record-hero-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.record-hero-cat-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--bg-tertiary, var(--bg-secondary));
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.record-hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 550;
}

.record-hero-subtitle a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.record-hero-subtitle a:hover {
  text-decoration: underline;
}

.record-hero-contact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.record-hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 3px 10px 3px 8px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: border-color 0.15s, color 0.15s;
}

.record-hero-chip svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.record-hero-chip:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Hero Actions */
.record-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.record-hero-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
}

#company-view-edit-btn,
#person-view-edit-btn,
#opportunity-view-edit-btn,
#opportunity-view-delete-btn,
#task-view-edit-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-hero-actions .modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
}

.record-hero-edit-btn:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

#company-view-edit-btn:hover,
#person-view-edit-btn:hover,
#opportunity-view-edit-btn:hover,
#task-view-edit-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

#opportunity-view-delete-btn:hover {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

.record-hero-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.record-hero-close-btn:hover {
  background: var(--bg-tertiary);
}

/* ── Body Layout ── */
.record-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.record-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
}

/* ── Tabs ── */
.record-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.record-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 10px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: inherit;
  position: relative;
  bottom: -1px;
  white-space: nowrap;
}

.record-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
}

.record-tab:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.record-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: transparent;
}

/* ── Tab Panels ── */
.record-tab-panels {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.record-tab-panel {
  display: block;
}

.record-tab-panel[style*="display:none"] {
  display: none !important;
}

/* ── Sidebar ── */
.record-sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.record-sidebar-section {
  margin-bottom: 8px;
}

.record-sidebar-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0 8px;
  margin-bottom: 2px;
}

/* Field Card */
.record-field-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  transition: background 0.12s;
  margin-bottom: 2px;
}

.record-field-card:hover {
  background: var(--bg-secondary);
}

.rfc-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.rfc-icon svg {
  width: 13px;
  height: 13px;
  stroke: var(--color-primary);
  fill: none;
}

.rfc-body {
  flex: 1;
  min-width: 0;
}

.rfc-label {
  font-size: 0.695rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.rfc-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 550;
  word-break: break-word;
  line-height: 1.4;
}

.rfc-value a {
  color: var(--color-primary);
  text-decoration: none;
}

.rfc-value a:hover {
  text-decoration: underline;
}

.rfc-mono {
  font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
  font-size: 0.8rem;
}

.rfc-desc {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ── Tab Panel Content items ── */

/* Opportunity cards in view modals */
.record-opp-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: default;
}

.record-opp-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 12px rgba(var(--color-primary-rgb, 47, 95, 208), 0.12);
}

.record-opp-card-stage {
  width: 6px;
  border-radius: 3px;
  align-self: stretch;
  flex-shrink: 0;
  background: var(--color-primary);
}

.record-opp-card-body {
  flex: 1;
  min-width: 0;
}

.record-opp-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-opp-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.record-opp-card-meta .stage-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  text-transform: capitalize;
}

.record-opp-card-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.record-opp-card-action {
  margin-left: auto;
}

/* Employee row inside company modal */
.record-employee-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  transition: background 0.12s;
  cursor: pointer;
  margin-bottom: 2px;
}

.record-employee-row:hover {
  background: var(--bg-secondary);
}

.record-employee-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.record-employee-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.record-employee-role {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.record-employee-action {
  margin-left: auto;
}

/* Call row */
.record-call-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.record-call-row:hover {
  border-color: var(--color-primary);
}

.record-call-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, #22c55e 12%, transparent);
  border: 1.5px solid color-mix(in srgb, #22c55e 30%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.record-call-icon svg {
  width: 15px;
  height: 15px;
  stroke: #22c55e;
}

.record-call-icon--inbound {
  background: color-mix(in srgb, #3b82f6 12%, transparent);
  border-color: color-mix(in srgb, #3b82f6 30%, transparent);
}

.record-call-icon--inbound svg {
  stroke: #3b82f6;
}

.record-call-body {
  flex: 1;
  min-width: 0;
}

.record-call-contact {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.record-call-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.record-call-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.record-call-outcome-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  background: color-mix(in srgb, #22c55e 12%, transparent);
  color: #16a34a;
  border: 1px solid color-mix(in srgb, #22c55e 25%, transparent);
}

/* Visit row */
.record-visit-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.record-visit-row:hover {
  border-color: var(--color-primary);
}

.record-visit-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.record-visit-dot svg {
  width: 15px;
  height: 15px;
  stroke: var(--color-primary);
}

.record-visit-body {
  flex: 1;
  min-width: 0;
}

.record-visit-type {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.record-visit-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.record-visit-notes {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 5px;
  line-height: 1.4;
}

.record-visit-action {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Empty state for tabs */
.record-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
}

.record-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.record-empty-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-muted);
}

.record-empty-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.record-empty-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  max-width: 260px;
  line-height: 1.5;
}

/* ==========================================================================
   RECORD VIEW MODAL — REVAMP ENHANCEMENTS
   ========================================================================== */

/* ── Stats Bar ── */
.record-stats-bar {
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 0;
  background: var(--border-color);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.record-stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--bg-primary);
  gap: 2px;
  min-width: 0;
  transition: background 0.15s;
}

.record-stat-item:first-child {
  border-radius: 0;
}

.record-stat-item:hover {
  background: var(--bg-secondary);
}

.record-stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.record-stat-value--primary {
  color: var(--color-primary);
}

.record-stat-value--success {
  color: #22c55e;
}

.record-stat-value--warning {
  color: #f59e0b;
}

.record-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Tab count badges ── */
.record-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  margin-left: 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.record-tab.active .record-tab-count {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  border-color: color-mix(in srgb, var(--color-primary) 25%, transparent);
}

/* ── Quick Actions in sidebar ── */
.record-quick-actions {
  display: flex;
  gap: 6px;
  padding: 0 0 12px;
  flex-wrap: wrap;
}

.record-quick-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.record-quick-action svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.record-quick-action:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
  transform: translateY(-1px);
}

.record-quick-action--email:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: color-mix(in srgb, #3b82f6 6%, transparent);
}

.record-quick-action--call:hover {
  border-color: #22c55e;
  color: #22c55e;
  background: color-mix(in srgb, #22c55e 6%, transparent);
}

.record-quick-action--directions:hover {
  border-color: #f59e0b;
  color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 6%, transparent);
}

/* ── Last Activity indicator in hero ── */
.record-hero-last-activity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

.record-hero-last-activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.record-hero-last-activity-dot--stale {
  background: #f59e0b;
}

.record-hero-last-activity-dot--cold {
  background: #ef4444;
}

/* ── Enhanced tab panel transitions ── */
.record-tab-panel {
  animation: recordTabFadeIn 0.2s ease;
}

@keyframes recordTabFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Improved sidebar section dividers ── */
.record-sidebar-section + .record-sidebar-section {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

/* ── Better edit button states ── */
#company-view-edit-btn:hover,
#person-view-edit-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ── Dark mode tweaks ── */
[data-theme="dark"] .record-modal-panel {
  background: var(--bg-secondary);
  border-left-color: var(--border-color);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .record-hero {
  background: var(--bg-primary);
}

[data-theme="dark"] .record-sidebar {
  background: var(--bg-primary);
}

[data-theme="dark"] .record-tabs {
  background: var(--bg-primary);
}

[data-theme="dark"] .record-hero-edit-btn {
  background: var(--bg-secondary);
}

[data-theme="dark"] .record-stat-item {
  background: var(--bg-primary);
}

[data-theme="dark"] .record-stat-item:hover {
  background: var(--bg-secondary);
}

[data-theme="dark"] .record-quick-action {
  background: var(--bg-primary);
}

/* ── Mobile responsive ── */
/* ==========================================================================
   OPPORTUNITY VIEW MODAL (Compact Dashboard Redesign)
   ========================================================================== */

[data-theme="dark"] .ov-side-col {
  background: rgba(255, 255, 255, 0.02);
}

.ov-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ov-section-title i,
.ov-section-title svg {
  color: var(--color-primary);
  opacity: 0.8;
}

.ov-next-step-box {
  background: color-mix(in srgb, var(--color-primary) 5%, var(--bg-primary));
  border: 1px solid color-mix(in srgb, var(--color-primary) 15%, var(--border-color));
  border-radius: 10px;
  padding: 14px;
}

.ov-next-step-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ov-next-step-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: 0.03em;
}

.ov-next-step-date {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  padding: 2px 8px;
  border-radius: 6px;
}

.ov-next-step-content {
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--text-primary);
  line-height: 1.5;
}

.ov-notes-container {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* ── Deal detail: one quiet panel, fields edit in place ─────────────── */
.od-modal {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.od-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: min(820px, 92vh);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 24px 64px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: recordModalPop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] .od-panel {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.od-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Header */
.od-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 16px 16px 24px;
}

.od-avatar {
  position: relative;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-tertiary);
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.od-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 6px;
  object-fit: contain;
  background: var(--bg-secondary);
}

.od-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.od-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.od-title.od-editable {
  min-height: 0;
  padding: 1px 6px;
  margin-left: -6px;
  font-size: 1.25rem;
  font-weight: 650;
}

.od-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* A long company name stays on one line and ends in "…" (the full name is in
   its tooltip) */
.od-subtitle > .od-company {
  min-width: 0;
  max-width: 100%;
}

.od-company-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.od-company {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text-secondary);
}

.od-company .od-icon {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
}

.od-company.is-link {
  cursor: pointer;
}

.od-company.is-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.od-dot {
  color: var(--text-muted);
  opacity: 0.6;
}

.od-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.od-icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.od-icon-btn .od-icon {
  width: 16px;
  height: 16px;
}

.od-icon-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.od-icon-btn.is-danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.od-icon-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* Body: properties, then notes / calls / tasks */
.od-body {
  flex: 1;
  min-height: 0;
  padding: 0 24px 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.od-props {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 2px 0 14px;
}

.od-prop {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.od-prop-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.od-prop-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-width: 0;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

/* A value you can click to edit */
.od-editable {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 3px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background 0.12s;
}

.od-editable:hover {
  background: var(--bg-active);
}

.od-editable:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
}

.od-readonly {
  padding: 3px 0;
}

.od-editable.is-empty,
.od-readonly.is-empty {
  color: var(--text-muted);
}

.od-input {
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  margin-left: -8px;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-primary);
  outline: none;
}

.od-input:disabled {
  opacity: 0.6;
}

.od-input--name {
  padding: 1px 6px;
  margin-left: -6px;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.od-input--value,
.od-input--probability {
  max-width: 160px;
}

.od-input--next_step_date {
  max-width: 180px;
}

.od-input--notes {
  display: block;
  width: calc(100% + 24px);
  min-height: 120px;
  padding: 10px 12px;
  margin: 0 -12px;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
}

.od-muted {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.od-muted.is-warning {
  color: var(--color-warning);
}

.od-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.78rem;
  color: var(--color-primary);
  cursor: pointer;
}

.od-link:hover {
  text-decoration: underline;
}

.od-link--strong {
  font-size: 0.8125rem;
  font-weight: 550;
}

.od-due.is-overdue {
  font-weight: 550;
  color: var(--color-danger);
}

.od-due.is-today {
  font-weight: 550;
  color: var(--color-warning);
}

.od-tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.od-person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.od-person-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  font-size: 0.55rem;
  font-weight: 600;
  color: #fff;
}

.od-person-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Stage: a pill in the stage's color, with the shared dropdown inside */
.od-stage {
  display: inline-flex;
}

.od-stage .crm-dd-trigger,
.od-stage .od-readonly {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--stage-color) 24%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--stage-color) 10%, transparent);
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-primary);
}

.od-stage .crm-dd-trigger::before,
.od-stage .od-readonly::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stage-color);
  flex-shrink: 0;
}

.od-stage .crm-dd-trigger:hover:not(.is-disabled),
.od-stage .crm-dd.is-open .crm-dd-trigger {
  border-color: color-mix(in srgb, var(--stage-color) 45%, transparent);
  background: color-mix(in srgb, var(--stage-color) 16%, transparent);
  color: var(--text-primary);
}

/* A closed dropdown's menu waits inside the panel (it moves to <body> when open);
   keep it from widening the panel on narrow screens */
#opportunity-detail .crm-dd-panel,
#task-detail-content .crm-dd-panel {
  display: none;
}

/* Owner: the shared dropdown, styled as plain text until hovered */
.od-prop-value > .crm-dd--inline {
  margin-left: -8px;
}

.od-prop-value > .crm-dd--inline .crm-dd-trigger {
  height: 28px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.od-prop-value > .crm-dd--inline .crm-dd-trigger:hover:not(.is-disabled),
.od-prop-value > .crm-dd--inline.is-open .crm-dd-trigger {
  border-color: transparent;
  background: var(--bg-active);
}

/* Tabs */
.od-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 20px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin: 0 -24px;
  padding: 0 24px;
  background: var(--bg-secondary);
}

.od-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.od-tab:hover,
.od-tab.is-active {
  color: var(--text-primary);
}

.od-tab.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--text-primary);
}

.od-tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.od-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.od-tab-panel {
  padding: 14px 0 18px;
}

.od-notes {
  min-height: 96px;
  padding: 10px 12px;
  margin: 0 -12px;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
  transition: background 0.12s;
}

.od-notes:hover {
  background: var(--bg-hover);
}

.od-notes:focus-visible {
  outline: 2px solid var(--color-primary);
}

.od-notes.is-empty {
  color: var(--text-muted);
}

.od-notes.is-readonly {
  min-height: 0;
  cursor: default;
}

.od-notes.is-readonly:hover {
  background: none;
}

.od-notes .mentioned-person {
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: var(--color-primary-bg);
  font: inherit;
  color: var(--color-primary);
  cursor: pointer;
}

.od-list {
  display: flex;
  flex-direction: column;
  margin: 0 -10px;
}

.od-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.od-item:hover {
  background: var(--bg-hover);
}

.od-item-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
}

.od-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.od-item-title {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-primary);
}

.od-item.is-done .od-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.od-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.od-item-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.od-empty {
  margin: 0;
  padding: 28px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.od-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 24px;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Phones: a bottom sheet */
@media (max-width: 640px) {
  .od-modal {
    align-items: flex-end;
    padding: 0;
  }

  .od-panel {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
  }

  .od-header {
    padding: 18px 8px 12px 16px;
  }

  .od-body {
    padding: 0 16px 4px;
  }

  .od-tabs {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .od-footer {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }

  .od-prop {
    grid-template-columns: 108px minmax(0, 1fr);
  }

  .od-title,
  .od-title.od-editable,
  .od-input--name {
    font-size: 1.125rem;
  }
}

/* Deal panel: next step, tasks and notes */
.od-next-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.od-plain-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.od-plain-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.od-check {
  position: relative;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.od-check::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid transparent;
  border-width: 0 1.75px 1.75px 0;
  transform: rotate(45deg);
}

.od-check:hover {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.od-check:hover::after {
  border-color: var(--color-success);
}

.od-check.is-checked {
  border-color: var(--color-success);
  background: var(--color-success);
}

.od-check.is-checked::after {
  border-color: #fff;
}

.od-check:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Add-task and add-note boxes */
.od-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.od-composer-input,
.od-composer-date {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.od-composer-input:focus,
.od-composer-date:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.od-composer--task .od-composer-input {
  flex: 1;
  min-width: 0;
}

.od-composer-date {
  flex-shrink: 0;
  width: 150px;
}

/* The app's date picker wraps the input; size the wrapper instead */
.od-composer .calendar-input-wrapper {
  flex: 0 0 160px;
}

.od-composer .calendar-input-wrapper .od-composer-date {
  width: 100%;
}

.od-composer-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--color-primary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}

.od-composer--task .od-composer-btn {
  height: 34px;
}

.od-composer-btn:hover {
  background: var(--color-primary-dark);
}

.od-composer-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.od-composer--note {
  flex-direction: column;
  align-items: stretch;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.od-composer--note:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.od-composer--note .od-composer-input,
.od-composer--note .od-composer-input:focus {
  height: auto;
  min-height: 44px;
  padding: 0;
  border: 0;
  box-shadow: none;
  font-size: 0.875rem;
  line-height: 1.55;
  resize: vertical;
}

.od-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Task rows */
.od-task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
}

.od-task:hover {
  background: var(--bg-hover);
}

.od-task .od-check {
  margin-top: 2px;
}

.od-task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.od-task.is-done .od-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Notes */
.od-notes-list {
  display: flex;
  flex-direction: column;
}

.od-note {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color-light);
}

.od-note:last-child {
  border-bottom: 0;
}

.od-note-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.8125rem;
}

.od-note-author {
  font-weight: 600;
  color: var(--text-primary);
}

.od-note-delete {
  width: 26px;
  height: 26px;
  margin-left: auto;
  opacity: 0;
}

.od-note:hover .od-note-delete,
.od-note-delete:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .od-note-delete {
    opacity: 1;
  }
}

.od-note-body {
  padding-left: 28px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.od-note--legacy .od-note-author {
  font-weight: 500;
  color: var(--text-muted);
}

.od-note--legacy .od-notes {
  min-height: 0;
}

@media (max-width: 640px) {
  .od-composer--task {
    flex-wrap: wrap;
  }

  .od-composer--task .od-composer-input {
    flex-basis: 100%;
  }

  .od-composer-date,
  .od-composer .calendar-input-wrapper {
    flex: 1;
    width: auto;
  }
}

/* ── Company and person panels (record-views.js): the same layout ──────────── */

/* Links that look like the subtitle's company button */
a.od-company,
a.od-icon-btn,
a.od-link {
  text-decoration: none;
}

a.od-company.is-link:hover,
a.od-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* A small "open" arrow beside an editable value (website, email) */
.od-icon-link {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: -4px;
  border-radius: 6px;
  color: var(--text-muted);
}

.od-icon-link .od-icon {
  width: 14px;
  height: 14px;
}

.od-icon-link:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.od-icon-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.od-item.is-muted .od-item-title {
  color: var(--text-muted);
}

/* People in related lists: initials instead of a dot */

/* ── Visit panel (team-dashboard.js): read-only, same layout ────────────────── */
.od-title-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.od-title-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.vd-warning {
  font-weight: 550;
  color: var(--color-danger);
}

.vd-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.vd-section-head .td-section-title {
  margin: 0;
}

.vd-fare .od-props {
  padding-bottom: 4px;
}

/* Fare approval folds open and closed; the summary keeps the amount and status in view */
.vd-fare-summary {
  margin-bottom: 0;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.vd-fare-summary::-webkit-details-marker {
  display: none;
}

.vd-fare[open] > .vd-fare-summary {
  margin-bottom: 6px;
}

.vd-fare-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.vd-fare-heading .td-section-title {
  margin: 0;
}

.vd-fare-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s;
}

.vd-fare[open] .vd-fare-chevron {
  transform: rotate(90deg);
}

.vd-fare-summary:hover .td-section-title {
  color: var(--text-primary);
}

.vd-fare-summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 6px;
}

.vd-fare-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-top: 6px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-primary);
}

.vd-fare-field {
  display: grid;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
}

.vd-fare-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  resize: vertical;
}

.vd-fare-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.vd-fare-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.vd-ai {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.vd-ai > :first-child {
  margin-top: 0;
}

.vd-ai > :last-child {
  margin-bottom: 0;
}

/* AI summary: a few quiet points, then the next step on its own line */
.vd-ai-points {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vd-ai-points li {
  position: relative;
  padding-left: 16px;
  color: var(--text-primary);
}

.vd-ai-points li::before {
  content: '';
  position: absolute;
  top: 0.62em;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}

.vd-ai-points strong {
  font-weight: 600;
}

.vd-ai-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
}

.vd-ai-points + .vd-ai-next {
  margin-top: 14px;
}

.vd-ai-next-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.vd-ai-next p {
  margin: 0;
}

.vd-ai-next .vd-ai-points li::before {
  background: var(--text-primary);
}

.vd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vd-photo {
  display: block;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: none;
  overflow: hidden;
  cursor: zoom-in;
}

.vd-photo img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.vd-map {
  height: 200px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.vd-coords {
  margin: 6px 0 0;
}

/* ── Task detail: the deal panel's layout, plus a done checkbox and its source ── */
.td-panel {
  width: min(600px, 100%);
}

.td-check {
  position: relative;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  padding: 0;
  border: 2px solid color-mix(in srgb, var(--text-muted) 70%, transparent);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.td-check::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid transparent;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.td-check:hover {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.td-check:hover::after {
  border-color: var(--color-success);
}

.td-check.is-checked {
  border-color: var(--color-success);
  background: var(--color-success);
}

.td-check.is-checked::after {
  border-color: #fff;
}

.td-check.is-static {
  cursor: default;
}

/* Touch screens give every button a 40px minimum height; inline controls in
   these panels keep their size (the checkbox gets a larger invisible tap area) */
.td-check,
.od-check,
.od-subtitle button,
.od-subtitle a,
.od-panel .od-link,
.od-panel .od-plain-link,
.od-panel .od-icon-link {
  min-height: 0;
  min-width: 0;
}

.td-check::before,
.od-check::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.td-check:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.od-title.is-done {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

/* Subtitles read as one sentence and wrap like text on narrow screens */
.od-subtitle,
.td-source {
  display: block;
  line-height: 1.55;
}

.od-subtitle > *,
.td-source > * {
  margin-right: 5px;
  vertical-align: middle;
}

/* A name and short labels (deal, company and person panels): one line, and
   only the name gives way, ending in "…" (the full name is in its tooltip) */
.od-subtitle.od-subtitle--one-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
}

.od-subtitle--one-line > * {
  flex-shrink: 0;
  white-space: nowrap;
}

.od-subtitle--one-line > .od-company {
  flex-shrink: 1;
}

.td-source .od-icon {
  width: 13px;
  height: 13px;
  margin-top: -2px;
  color: var(--text-muted);
}

/* Due: the app's date picker opens from a transparent input laid over the value */
.td-due {
  position: relative;
  display: inline-flex;
}

.td-due .calendar-input-wrapper {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.td-due .calendar-input-wrapper input {
  width: 100%;
  height: 100%;
  padding: 0 !important;
  border: 0;
  cursor: pointer;
}

.td-due .calendar-icon-trigger {
  display: none;
}

.td-due .od-editable {
  white-space: nowrap;
}

.td-due:hover .od-editable {
  background: var(--bg-active);
}

.td-due:focus-within .od-editable {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
}

/* The deal this task belongs to, as a card you can open */
.td-deal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 30px;
  padding: 4px 8px 4px 10px;
  margin-left: -2px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.td-deal:hover {
  border-color: color-mix(in srgb, var(--border-color) 60%, var(--text-muted));
  background: var(--bg-tertiary);
}

.td-deal:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.td-deal-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.td-deal-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.td-deal .od-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.td-section {
  padding: 14px 24px 18px;
  margin: 2px -24px 0;
  border-top: 1px solid var(--border-color);
}

.td-section-title {
  margin: 0 0 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .td-section {
    padding: 14px 16px 18px;
    margin: 2px -16px 0;
  }
}

/* ── Deal form (new / edit) ───────────────────────────────────────── */
/* One control style for every field: text inputs, dropdowns, the date picker,
   the note box and the two tag fields share height, surface, border, type and
   focus ring. Scoped by id because the shared modal rules use ids too. */
#opportunity-modal .opp-form {
  --opp-control-h: 40px;
  --opp-control-radius: 8px;
  --opp-control-font: 0.875rem;
}

#opportunity-modal .opp-form .form-field label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
}

#opportunity-modal .opp-form .field-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

#opportunity-modal .opp-form .field-group {
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

#opportunity-modal .opp-form .form-field {
  gap: 6px;
  margin-bottom: 0.875rem;
}

#opportunity-modal .opp-form .field-group > .form-field {
  margin-bottom: 0;
}

/* Text inputs, the note box, and the dropdown triggers */
#opportunity-modal .opp-form .form-field input:not(.opp-token-input),
#opportunity-modal .opp-form .form-field textarea,
#opportunity-modal .opp-form .crm-dd-trigger,
#opportunity-modal .opp-form .opp-token-field {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--opp-control-radius);
  background: var(--bg-secondary);
  font-family: inherit;
  font-size: var(--opp-control-font);
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

#opportunity-modal .opp-form .form-field input:not(.opp-token-input),
#opportunity-modal .opp-form .crm-dd-trigger {
  height: var(--opp-control-h);
  min-height: var(--opp-control-h);
  padding: 0 12px;
}

#opportunity-modal .opp-form .form-field textarea {
  min-height: 84px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

#opportunity-modal .opp-form .form-field input::placeholder,
#opportunity-modal .opp-form .form-field textarea::placeholder {
  font-weight: 400;
  color: var(--text-muted);
}

#opportunity-modal .opp-form .form-field input:not(.opp-token-input):hover,
#opportunity-modal .opp-form .form-field textarea:hover,
#opportunity-modal .opp-form .crm-dd-trigger:hover,
#opportunity-modal .opp-form .opp-token-field:hover {
  border-color: color-mix(in srgb, var(--border-color) 65%, var(--text-muted));
  background: var(--bg-secondary);
}

#opportunity-modal .opp-form .form-field input:not(.opp-token-input):focus,
#opportunity-modal .opp-form .form-field textarea:focus,
#opportunity-modal .opp-form .crm-dd.is-open .crm-dd-trigger,
#opportunity-modal .opp-form .crm-dd-trigger:focus-visible,
#opportunity-modal .opp-form .opp-token-field:focus-within {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

/* Dropdowns fill their column like the inputs beside them */
#opportunity-modal .opp-form .crm-dd {
  display: flex;
  width: 100%;
}

#opportunity-modal .opp-form .crm-dd-label {
  font-weight: 500;
}

/* Company search: no icon, same padding as every other field */
#opportunity-modal .opp-form .search-container input {
  padding: 0 12px !important;
}

#opportunity-modal .opp-form .search-results {
  max-height: 248px;
  padding: 4px;
  border-radius: 10px;
}

/* Company sits in the left column; let its suggestions span the whole row so
   long names (and the branch at the end of them) stay readable */
@media (min-width: 641px) {
  #opportunity-modal .opp-form .field-group .search-results {
    right: auto;
    width: calc(200% + 0.75rem);
  }
}

#opportunity-modal .opp-form .search-results .search-result-item {
  gap: 10px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 6px;
}

#opportunity-modal .opp-form .search-results .search-result-item:hover,
#opportunity-modal .opp-form .search-results .search-result-item.is-active {
  background: var(--bg-tertiary);
}

#opportunity-modal .opp-form .search-results .opp-suggest-avatar {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}

#opportunity-modal .opp-form .search-results .search-result-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 500;
}

#opportunity-modal .opp-form .search-result-item--custom {
  margin-top: 4px;
  border-top: 1px solid var(--border-color-light);
  border-radius: 0 0 6px 6px;
}

#opportunity-modal .opp-form .search-result-item:first-child.search-result-item--custom {
  margin-top: 0;
  border-top: 0;
}

#opportunity-modal .opp-form .search-result-hint {
  font-weight: 400;
  color: var(--text-muted);
}

/* Win chance: number box with a % suffix and no spinner */
#opportunity-modal .opp-form input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

#opportunity-modal .opp-form input[type="number"]::-webkit-inner-spin-button,
#opportunity-modal .opp-form input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#opportunity-modal .opp-percent-input {
  position: relative;
}

#opportunity-modal .opp-form .opp-percent-input input {
  padding-right: 2rem;
}

#opportunity-modal .opp-form .opp-percent-input input:disabled {
  color: var(--text-muted);
  background: var(--bg-tertiary);
  cursor: not-allowed;
}

#opportunity-modal .opp-percent-input span {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  font-size: var(--opp-control-font);
  color: var(--text-muted);
  pointer-events: none;
}

#opportunity-modal .opp-form .probability-reset-btn {
  margin-left: auto;
}

/* Next step: task title and due date on one row; the date uses the app's picker */
#opportunity-modal .opp-next-step-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 172px;
  gap: 0.5rem;
}

#opportunity-modal .opp-form .calendar-input-wrapper .calendar-icon-trigger svg {
  width: 16px;
  height: 16px;
}

/* Tag fields (competitors, teammates): one box that looks like an input, with
   chips and a borderless text entry inside it */
#opportunity-modal .opp-form .opp-token-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: var(--opp-control-h);
  padding: 5px 6px;
  cursor: text;
}

#opportunity-modal .opp-token-list {
  display: contents;
}

#opportunity-modal .opp-form .opp-token-input {
  flex: 1 1 140px;
  min-width: 120px;
  height: 28px;
  min-height: 0;
  padding: 0 6px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-family: inherit;
  font-size: var(--opp-control-font);
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
}

#opportunity-modal .opp-form .opp-token-input::placeholder {
  font-weight: 400;
  color: var(--text-muted);
}

#opportunity-modal .opp-token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 28px;
  padding: 0 3px 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text-primary);
}

#opportunity-modal .opp-token:has(.opp-token-avatar) {
  padding-left: 3px;
}

#opportunity-modal .opp-token--owner {
  padding-right: 8px;
}

.opp-token-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  font-size: 0.55rem;
  font-weight: 650;
  color: #fff;
}

.opp-token-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#opportunity-modal .opp-token-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#opportunity-modal .opp-token-meta {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

#opportunity-modal .opp-token-remove {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

#opportunity-modal .opp-token-remove:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

#opportunity-modal .opp-token-remove:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
}

/* Teammate suggestions: one compact line per person */
#opportunity-modal .opp-assignees-dropdown {
  max-height: 248px;
  padding: 4px;
  border-radius: 10px;
}

#opportunity-modal .opp-assignee-option {
  gap: 10px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 6px;
}

#opportunity-modal .opp-assignee-option:hover,
#opportunity-modal .opp-assignee-option.is-active {
  background: var(--bg-tertiary);
}

#opportunity-modal .opp-assignee-option.is-selected {
  background: transparent;
}

#opportunity-modal .opp-assignee-option.is-selected:hover,
#opportunity-modal .opp-assignee-option.is-selected.is-active {
  background: var(--bg-tertiary);
}

#opportunity-modal .opp-assignee-option .opp-assignee-opt-name {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
}

#opportunity-modal .opp-assignee-option.is-selected .opp-assignee-opt-name {
  color: var(--text-primary);
}

#opportunity-modal .opp-assignee-option .opp-assignee-opt-role {
  margin: 0;
  font-size: 0.75rem;
  text-transform: none;
}

/* More: competitors and teammates */
#opportunity-modal .opp-form-more {
  padding-top: 0.875rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border-color);
}

#opportunity-modal .opp-form-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
  cursor: pointer;
}

#opportunity-modal .opp-form-more > summary:hover {
  color: var(--text-primary);
}

#opportunity-modal .opp-form-more > summary::-webkit-details-marker {
  display: none;
}

#opportunity-modal .opp-form-more > summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

#opportunity-modal .opp-form-more[open] > summary {
  margin-bottom: 0.875rem;
}

#opportunity-modal .opp-form-more[open] > summary::before {
  transform: rotate(45deg);
}

#opportunity-modal .opp-form-more .form-field:last-child {
  margin-bottom: 0;
}

/* Phones: taller controls, and 16px text so iOS doesn't zoom into fields */
@media (max-width: 640px) {
  #opportunity-modal .opp-form {
    --opp-control-h: 44px;
    --opp-control-font: 1rem;
  }

  #opportunity-modal .opp-next-step-row {
    grid-template-columns: 1fr;
  }

  #opportunity-modal .opp-token {
    height: 32px;
  }
}

.ov-competitors-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ov-comp-tag {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.ov-meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 6px 0;
  border-bottom: 1px dotted var(--border-color);
}

.ov-meta-item:last-child {
  border-bottom: none;
}

.ov-meta-label {
  color: var(--text-muted);
  font-weight: 550;
}

.ov-meta-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* ===== BOTTOM ACTION BAR ===== */
.bottom-action-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: var(--z-fixed);
  transition: transform 0.4s var(--motion-ease-emphasized), opacity 0.3s ease;
  pointer-events: none;
  opacity: 0;
}

.bottom-action-bar.active {
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
  opacity: 1;
}

.bab-content {
  background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.bab-selection-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 550;
  font-size: 0.95rem;
}

.bab-count {
  background: var(--color-primary);
  color: white;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.8rem;
  padding: 0 4px;
}

.bab-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
}

.bab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.bab-btn i,
.bab-btn svg {
  width: 16px;
  height: 16px;
}

.bab-btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.bab-btn-danger:hover {
  background: var(--color-danger);
  color: white;
}

.bab-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.bab-btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Selection header th — matches td cell sizing exactly */
/* Selection header th — matches td cell sizing exactly */
.spreadsheet-table th.th-selection {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  padding: 0 !important;
  text-align: center;
  vertical-align: middle;
  cursor: default !important;
  line-height: 0;
}

/* Custom Checkbox Component - Redesigned from Scratch */
.custom-chk-container {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  min-height: 20px !important;
  max-height: 20px !important;
  position: relative !important;
  cursor: pointer !important;
  margin: 0 auto !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
  vertical-align: middle !important;
  line-height: 1 !important;
}

.custom-chk-container input[type="checkbox"],
.custom-chk-container .selection-checkbox {
  position: absolute !important;
  opacity: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  cursor: pointer !important;
  z-index: 2 !important;
  left: 0 !important;
  top: 0 !important;
  border: none !important;
  background: transparent !important;
  outline: none !important;
}

.custom-chk-container .selection-checkbox::after {
  display: none !important;
}

.custom-chk-visual {
  width: 15px !important;
  height: 15px !important;
  min-width: 15px !important;
  max-width: 15px !important;
  min-height: 15px !important;
  max-height: 15px !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 4px !important;
  background: #ffffff !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  pointer-events: none !important;
  transition: all 0.15s ease !important;
  position: relative !important;
}

.custom-chk-container:hover .custom-chk-visual {
  border-color: #94a3b8 !important;
  background: #f8fafc !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1) !important;
}

.custom-chk-container input:checked + .custom-chk-visual {
  background: var(--color-primary, #2563eb) !important;
  border-color: var(--color-primary, #2563eb) !important;
}

/* Crisp clean checkmark for row selection */
.custom-chk-container input.row-select:checked + .custom-chk-visual::after {
  content: '' !important;
  display: block !important;
  width: 4px !important;
  height: 8px !important;
  border: solid #ffffff !important;
  border-width: 0 2px 2px 0 !important;
  transform: rotate(45deg) translate(-0.5px, -0.5px) !important;
  box-sizing: border-box !important;
}

/* Crisp horizontal minus bar for header select-all */
.custom-chk-container input#companies-select-all:checked + .custom-chk-visual::after,
.custom-chk-container input#people-select-all:checked + .custom-chk-visual::after {
  content: '' !important;
  display: block !important;
  width: 8px !important;
  height: 2px !important;
  background: #ffffff !important;
  border-radius: 1px !important;
  box-sizing: border-box !important;
}

/* Dark mode adjustments */
[data-theme="dark"] .custom-chk-visual {
  background: #1e2227 !important;
  border-color: #475569 !important;
}

[data-theme="dark"] .custom-chk-container:hover .custom-chk-visual {
  border-color: #64748b !important;
  background: #283039 !important;
}

[data-theme="dark"] .custom-chk-container input:checked + .custom-chk-visual {
  background: var(--color-primary, #2563eb) !important;
  border-color: var(--color-primary, #2563eb) !important;
}

.spreadsheet-table tr:has(.row-select:checked) td {
  background: rgba(var(--color-primary-rgb), 0.06) !important;
}

[data-theme="dark"] .spreadsheet-table tr:has(.row-select:checked) td {
  background: rgba(var(--color-primary-rgb), 0.12) !important;
}

.spreadsheet-table th.th-selection {
  width: 44px !important;
  max-width: 44px !important;
  min-width: 44px !important;
  padding: 0 !important;
  text-align: center !important;
  vertical-align: middle !important;
}

.spreadsheet-table td:has(.custom-chk-container),
.spreadsheet-cell-wrapper:has(.custom-chk-container) {
  width: 44px !important;
  max-width: 44px !important;
  min-width: 44px !important;
  padding: 0 !important;
  text-align: center !important;
  vertical-align: middle !important;
}

.spreadsheet-cell:has(.custom-chk-container) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
}

/* Sticky Actions column solid background - prevent text bleed-through when scrolling */
.spreadsheet-table th.th-actions,
.spreadsheet-table th:last-child {
  background: var(--spreadsheet-header-bg, #f8fafc) !important;
  background-color: var(--spreadsheet-header-bg, #f8fafc) !important;
  border-left: 1px solid var(--spreadsheet-border, #e2e8f0) !important;
}

.spreadsheet-table td.td-actions,
.spreadsheet-table td:last-child,
.spreadsheet-table tbody tr td.td-actions,
.spreadsheet-table tbody tr td:last-child {
  background: #ffffff !important;
  background-color: #ffffff !important;
  border-left: 1px solid var(--spreadsheet-border, #e2e8f0) !important;
}

.spreadsheet-table tbody tr:hover td.td-actions,
.spreadsheet-table tbody tr:hover td:last-child {
  background: var(--row-hover, #f8fafc) !important;
  background-color: var(--row-hover, #f8fafc) !important;
}

[data-theme="dark"] .spreadsheet-table th.th-actions,
[data-theme="dark"] .spreadsheet-table th:last-child {
  background: var(--spreadsheet-header-bg, #1a1e24) !important;
  background-color: var(--spreadsheet-header-bg, #1a1e24) !important;
}

[data-theme="dark"] .spreadsheet-table td.td-actions,
[data-theme="dark"] .spreadsheet-table td:last-child,
[data-theme="dark"] .spreadsheet-table tbody tr td.td-actions,
[data-theme="dark"] .spreadsheet-table tbody tr td:last-child {
  background: #14171c !important;
  background-color: #14171c !important;
}

[data-theme="dark"] .spreadsheet-table tbody tr:hover td.td-actions,
[data-theme="dark"] .spreadsheet-table tbody tr:hover td:last-child {
  background: var(--row-hover, rgba(255, 255, 255, 0.04)) !important;
  background-color: var(--row-hover, rgba(255, 255, 255, 0.04)) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   WORKFLOWS — Visual automation builder
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Page ──────────────────────────────────────────────────────────────────── */
.wf-page {
  display: flex;
  flex-direction: column;
}
.wf-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-5) var(--page-gutter) var(--space-4);
  gap: var(--space-3);
}
.wf-page-title {
  font-size: var(--type-xxl);
  font-weight: 650;
  color: var(--text-primary);
  margin: 0;
}
.wf-page-subtitle {
  font-size: var(--type-sm);
  color: var(--text-muted);
  margin: var(--space-1) 0 0;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.wf-tabs {
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--page-gutter);
  border-bottom: 1px solid var(--border-color);
}
.wf-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--type-sm);
  font-weight: 550;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  margin-bottom: -1px;
}
.wf-tab:hover {
  color: var(--text-secondary);
}
.wf-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--color-primary);
}

.wf-tab-content {
  min-height: 200px;
}

.wf-loading {
  padding: var(--space-7);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--type-sm);
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.wf-empty {
  text-align: center;
  padding: var(--space-9) var(--space-5);
}
.wf-empty-icon {
  margin-bottom: var(--space-4);
}
.wf-empty-title {
  font-size: var(--type-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
}
.wf-empty-text {
  color: var(--text-muted);
  font-size: var(--type-md);
  max-width: 400px;
  margin: 0 auto var(--space-5);
  line-height: 1.5;
}

/* ── Workflow list cards ──────────────────────────────────────────────────── */
.wf-list {
  display: flex;
  flex-direction: column;
}
.wf-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: var(--space-3) var(--page-gutter);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.wf-card:hover {
  background: var(--bg-hover);
}
.wf-card-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1;
}
.wf-card-info {
  min-width: 0;
}
.wf-card-name {
  font-size: var(--type-md);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wf-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: 2px;
  flex-wrap: wrap;
}
.wf-card-trigger-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--type-xs);
  font-weight: 550;
  color: var(--badge-color, var(--text-secondary));
}
.wf-card-condition-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--type-xxs);
  font-weight: 600;
  color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 10%, transparent);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}
.wf-card-action-count {
  font-size: var(--type-xs);
  color: var(--text-muted);
}
.wf-card-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.wf-card-run-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-right: var(--space-2);
}
.wf-card-run-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--indicator-color, var(--text-muted));
  flex-shrink: 0;
}
.wf-card-run-time {
  font-size: var(--type-xxs);
  color: var(--text-muted);
  white-space: nowrap;
}
.wf-card-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.wf-card-btn-danger:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.wf-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.wf-toggle-track {
  display: block;
  width: 34px;
  height: 20px;
  background: var(--bg-gray);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
}
.wf-toggle.active .wf-toggle-track {
  background: var(--color-success);
}
.wf-toggle-thumb {
  display: block;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform var(--transition-fast);
}
.wf-toggle.active .wf-toggle-thumb {
  transform: translateX(14px);
}
.wf-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   WORKFLOW BUILDER
   ═══════════════════════════════════════════════════════════════════════════════ */

.wf-builder {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* ── Builder header ───────────────────────────────────────────────────────── */
.wf-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
  gap: var(--space-3);
}
.wf-builder-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
}
.wf-builder-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.wf-builder-name-input {
  border: none;
  background: transparent;
  font-size: var(--type-lg);
  font-weight: 600;
  color: var(--text-primary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  width: 100%;
  max-width: 400px;
  transition: background var(--transition-fast);
}
.wf-builder-name-input:hover {
  background: var(--bg-hover);
}
.wf-builder-name-input:focus {
  outline: none;
  background: var(--bg-tertiary);
}
.wf-builder-name-input.wf-input-error {
  outline: 2px solid var(--color-danger);
}
.wf-builder-active-toggle {
  display: flex;
  align-items: center;
}

/* ── Canvas ───────────────────────────────────────────────────────────────── */
.wf-canvas {
  flex: 1;
  overflow: auto;
  padding: var(--space-7) var(--space-5);
  background: var(--bg-primary);
  background-image: radial-gradient(circle, var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;
}
.wf-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Blocks (trigger, action, condition) ──────────────────────────────────── */
.wf-block {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  gap: var(--space-3);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}
.wf-block:hover {
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-sm);
}
.wf-block-color-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.wf-block-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--block-color, var(--text-muted)) 10%, transparent);
  color: var(--block-color, var(--text-muted));
  flex-shrink: 0;
}
.wf-block-body {
  flex: 1;
  min-width: 0;
}
.wf-block-label {
  font-size: var(--type-xxs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.wf-block-title {
  font-size: var(--type-md);
  font-weight: 600;
  color: var(--text-primary);
}
.wf-block-object {
  font-weight: 500;
  color: var(--text-secondary);
}
.wf-block-description {
  font-size: var(--type-xs);
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.wf-block-actions {
  display: flex;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}
.wf-block:hover .wf-block-actions {
  opacity: 1;
}
.wf-block-edit-btn,
.wf-block-delete-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.wf-block-edit-btn:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}
.wf-block-delete-btn:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* Empty trigger block */
.wf-block-empty {
  border-style: dashed;
  cursor: pointer;
}
.wf-block-empty:hover {
  background: var(--bg-hover);
}
.wf-block-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Condition block & pills ──────────────────────────────────────────────── */
.wf-block-condition {
  align-items: flex-start;
}
.wf-block-condition .wf-block-icon {
  margin-top: 2px;
}
.wf-conditions-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}
.wf-condition-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xs);
  font-size: var(--type-xxs);
  color: var(--text-primary);
  line-height: 1.4;
}
.wf-condition-field {
  font-weight: 600;
  color: var(--text-secondary);
}
.wf-condition-op {
  color: var(--color-warning);
  font-weight: 500;
}
.wf-condition-val {
  color: var(--text-primary);
  font-weight: 550;
}
.wf-condition-remove {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  margin-left: 2px;
  transition: color var(--transition-fast);
}
.wf-condition-remove:hover {
  color: var(--color-danger);
}

/* Add condition button (inline, small) */
.wf-add-condition-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--type-xs);
  font-weight: 550;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.wf-add-condition-btn:hover {
  border-color: var(--color-warning);
  color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 6%, transparent);
}

/* ── Condition editor (in panel) ──────────────────────────────────────────── */
.wf-condition-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.wf-condition-row .wf-field-input {
  flex: 1;
  min-width: 0;
}
.wf-condition-field-select {
  flex: 1.2 !important;
}
.wf-condition-op-select {
  flex: 1.3 !important;
}
.wf-condition-value-input {
  flex: 1 !important;
}
.wf-add-condition-inline-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--type-sm);
  font-weight: 550;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.wf-add-condition-inline-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Connector ────────────────────────────────────────────────────────────── */
.wf-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 40px;
  position: relative;
}
.wf-connector.disabled {
  opacity: 0.3;
}
.wf-connector-line {
  width: 2px;
  flex: 1;
  background: var(--border-color);
}
.wf-connector-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-color);
  flex-shrink: 0;
}

/* ── Add action button ────────────────────────────────────────────────────── */
.wf-add-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3);
  background: transparent;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--type-sm);
  font-weight: 550;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.wf-add-action-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-bg);
}

/* ── Field badges ─────────────────────────────────────────────────────────── */
.wf-field-count {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-radius: var(--radius-xs);
  font-size: var(--type-xxs);
  font-weight: 600;
}
.wf-target-label {
  color: var(--text-secondary);
  font-weight: 550;
}

/* ── Run History ──────────────────────────────────────────────────────────── */
.wf-history-table {
  border-bottom: 1px solid var(--border-color);
}
.wf-history-header {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--page-gutter);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--type-xs);
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.wf-history-row {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--page-gutter);
  border-bottom: 1px solid var(--border-color-light);
  font-size: var(--type-sm);
  transition: background var(--transition-fast);
}
.wf-history-row:last-child {
  border-bottom: none;
}
.wf-history-row:hover {
  background: var(--bg-hover);
}
.wf-history-col {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.wf-history-col-status {
  width: 64px;
  flex-shrink: 0;
  justify-content: flex-start;
}
.wf-history-col-workflow {
  flex: 2;
  font-weight: 550;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wf-history-col-trigger {
  flex: 2;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.wf-history-col-actions {
  flex: 1;
  color: var(--text-muted);
}
.wf-history-col-time {
  flex: 1;
  color: var(--text-muted);
  font-size: var(--type-xs);
  justify-content: flex-end;
}
.wf-history-trigger-badge {
  font-size: var(--type-xxs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.wf-history-record-name {
  font-size: var(--type-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

/* ── Notification user list (in action editor) ────────────────────────────── */
.wf-notify-users-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.wf-notify-user-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.wf-notify-user-item:hover {
  background: var(--bg-hover);
}
.wf-notify-user-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.wf-notify-user-name {
  font-size: var(--type-sm);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SIDE PANEL (picker / editor)
   ═══════════════════════════════════════════════════════════════════════════════ */

.wf-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.wf-panel-overlay.active {
  opacity: 1;
}
.wf-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}
.wf-panel.active {
  transform: translateX(0);
}
.wf-panel-wide {
  width: 480px;
}
.wf-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color-light);
  flex-shrink: 0;
}
.wf-panel-header h3 {
  margin: 0;
  font-size: var(--type-lg);
  font-weight: 650;
  color: var(--text-primary);
}
.wf-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}
.wf-panel-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-color-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
}
.wf-panel-hint {
  font-size: var(--type-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-4);
  line-height: 1.5;
}
.wf-panel-label {
  font-size: var(--type-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin: var(--space-5) 0 var(--space-2);
  display: block;
}
.wf-panel-label:first-child {
  margin-top: 0;
}

/* ── Option list (trigger/action type selector) ───────────────────────────── */
.wf-option-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.wf-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.wf-option:hover {
  border-color: var(--color-primary-light);
  background: var(--bg-hover);
}
.wf-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}
.wf-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--opt-color, var(--text-muted)) 10%, transparent);
  color: var(--opt-color, var(--text-muted));
  flex-shrink: 0;
}
.wf-option-info {
  flex: 1;
  min-width: 0;
}
.wf-option-label {
  font-size: var(--type-md);
  font-weight: 550;
  color: var(--text-primary);
}
.wf-option-desc {
  font-size: var(--type-xs);
  color: var(--text-muted);
  margin-top: 1px;
}
.wf-option-check {
  color: var(--color-primary);
  flex-shrink: 0;
}

/* Object selector (smaller) */
.wf-object-options {
  flex-direction: row;
  gap: var(--space-2);
}
.wf-option-sm {
  flex: 1;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-3) var(--space-2);
  gap: var(--space-2);
}
.wf-option-sm .wf-option-icon {
  width: 32px;
  height: 32px;
}
.wf-option-sm .wf-option-label {
  font-size: var(--type-sm);
}

/* ── Live search ──────────────────────────────────────────────────────────── */
.wf-editor-section {
  margin-bottom: var(--space-5);
}
.wf-search-input-wrapper {
  position: relative;
}
.wf-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.wf-search-input {
  width: 100%;
  height: var(--control-height-lg);
  padding: 0 var(--space-3) 0 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--type-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.wf-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}
.wf-search-results {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}
.wf-search-result {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: var(--type-sm);
  color: var(--text-primary);
  width: 100%;
  transition: background var(--transition-fast);
}
.wf-search-result:hover {
  background: var(--bg-hover);
}
.wf-search-loading {
  padding: var(--space-3);
  text-align: center;
  font-size: var(--type-sm);
  color: var(--text-muted);
}
.wf-search-selected {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-success-bg);
  border-radius: var(--radius-sm);
  font-size: var(--type-sm);
  color: var(--text-primary);
  font-weight: 550;
}

/* ── Fields editor grid ───────────────────────────────────────────────────── */
.wf-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.wf-field-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.wf-field-row-wide {
  grid-column: 1 / -1;
}
.wf-field-label {
  font-size: var(--type-xs);
  font-weight: 600;
  color: var(--text-secondary);
}
.wf-field-input {
  height: var(--control-height-md);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--type-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast);
}
.wf-field-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}
textarea.wf-field-input {
  height: auto;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  min-height: 56px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   WORKFLOW — MOBILE
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .wf-page-header {
    flex-direction: column;
    gap: var(--space-3);
  }
  .wf-page-header .btn {
    align-self: stretch;
    justify-content: center;
  }
  .wf-tabs {
    overflow-x: auto;
    gap: 0;
  }
  .wf-builder-header {
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
  }
  .wf-builder-header-left {
    width: 100%;
  }
  .wf-builder-header-right {
    width: 100%;
    justify-content: space-between;
  }
  .wf-builder-name-input {
    max-width: none;
    font-size: var(--type-md);
  }
  .wf-canvas {
    padding: var(--space-5) var(--space-3);
  }
  .wf-panel {
    width: 100%;
    border-radius: 0;
  }
  .wf-panel-wide {
    width: 100%;
  }
  .wf-fields-grid {
    grid-template-columns: 1fr;
  }
  .wf-object-options {
    flex-direction: column;
  }
  .wf-option-sm {
    flex-direction: row;
  }
  .wf-condition-row {
    flex-wrap: wrap;
  }
  .wf-condition-row .wf-field-input {
    min-width: 100px;
  }
  .wf-history-header {
    display: none;
  }
  .wf-history-row {
    flex-wrap: wrap;
    gap: var(--space-1);
  }
  .wf-history-col-trigger {
    flex-basis: 100%;
    order: 5;
  }
  .wf-history-col-time {
    flex: unset;
    margin-left: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UPS MAINTENANCE REPORT — Multi-step mobile-first form
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Form container ─────────────────────────────────────────────────────────── */
.ups-form-container {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height, 56px) - 70px);
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 88px; /* space for sticky footer */
}

/* ── Progress bar (sticky top) ──────────────────────────────────────────────── */
.ups-progress-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-primary);
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--border-color-light, var(--border-color));
}
.ups-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ups-progress-step-text {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.ups-progress-section-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.ups-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-gray, #e5e7eb);
  border-radius: 100px;
  overflow: hidden;
}
.ups-progress-fill {
  height: 100%;
  background: #6366f1;
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Steps viewport ─────────────────────────────────────────────────────────── */
.ups-steps-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.ups-steps-track {
  display: flex;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .ups-steps-track {
    transition: none;
  }
  .ups-progress-fill {
    transition: none;
  }
}
.ups-step {
  flex: 0 0 100%;
  min-width: 100%;
  padding: 20px 16px 24px;
  box-sizing: border-box;
}
.ups-step-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.ups-step-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* ── Form fields ────────────────────────────────────────────────────────────── */
.ups-field {
  margin-bottom: 16px;
}
.ups-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.ups-field-label .ups-required {
  color: #ef4444;
  margin-left: 2px;
}
.ups-field-unit {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
}
.ups-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.ups-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.ups-input.ups-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.ups-input[disabled],
.ups-input[readonly] {
  background: var(--bg-tertiary, #f1f5f9);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.75;
}
textarea.ups-input {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}
.ups-error-message {
  display: block;
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
  font-weight: 500;
  min-height: 0;
}
.ups-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ups-field-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ── Toggle / selector buttons ──────────────────────────────────────────────── */
.ups-toggle-group {
  display: flex;
  gap: 0;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border-color);
}
.ups-toggle-btn {
  flex: 1;
  min-height: 48px;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
  position: relative;
  text-align: center;
}
.ups-toggle-btn:not(:last-child) {
  border-right: 1.5px solid var(--border-color);
}
.ups-toggle-btn:hover:not(.selected) {
  background: var(--bg-hover, #f8f9fa);
}

/* Selected states */
.ups-toggle-btn.selected:not([class*="toggle-"]) {
  background: #eff6ff;
  color: #1d4ed8;
}
.ups-toggle-btn.selected.toggle-yes {
  background: #dcfce7;
  color: #15803d;
}
.ups-toggle-btn.selected.toggle-no {
  background: #fee2e2;
  color: #dc2626;
}
.ups-toggle-btn.selected.toggle-na {
  background: #f1f5f9;
  color: #475569;
}
.ups-toggle-btn.selected.toggle-pass {
  background: #dcfce7;
  color: #15803d;
}
.ups-toggle-btn.selected.toggle-fail {
  background: #fee2e2;
  color: #dc2626;
}
.ups-toggle-btn.selected.toggle-not-tested {
  background: #f1f5f9;
  color: #475569;
}
.ups-toggle-btn.selected.toggle-normal {
  background: #ede9fe;
  color: #6d28d9;
}
.ups-toggle-btn.selected.toggle-bypass {
  background: #fef3c7;
  color: #b45309;
}
.ups-toggle-btn.selected.toggle-fault {
  background: #fee2e2;
  color: #dc2626;
}
.ups-toggle-btn.selected.toggle-single,
.ups-toggle-btn.selected.toggle-three,
.ups-toggle-btn.selected.toggle-rackmount,
.ups-toggle-btn.selected.toggle-tower,
.ups-toggle-btn.selected.toggle-opt {
  background: #eff6ff;
  color: #1d4ed8;
}

/* Dark mode toggle adjustments */
[data-theme="dark"] .ups-toggle-btn.selected:not([class*="toggle-"]) { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-opt { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-yes { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-no { background: rgba(220, 38, 38, 0.2); color: #f87171; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-na { background: rgba(100, 116, 139, 0.2); color: #94a3b8; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-pass { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-fail { background: rgba(220, 38, 38, 0.2); color: #f87171; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-not-tested { background: rgba(100, 116, 139, 0.2); color: #94a3b8; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-normal { background: rgba(109, 40, 217, 0.2); color: #a78bfa; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-bypass { background: rgba(180, 83, 9, 0.2); color: #fbbf24; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-fault { background: rgba(220, 38, 38, 0.2); color: #f87171; }
[data-theme="dark"] .ups-toggle-btn.selected.toggle-single,
[data-theme="dark"] .ups-toggle-btn.selected.toggle-three,
[data-theme="dark"] .ups-toggle-btn.selected.toggle-rackmount,
[data-theme="dark"] .ups-toggle-btn.selected.toggle-tower { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }

.ups-toggle-group.ups-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ── Sticky nav footer ──────────────────────────────────────────────────────── */
.ups-nav-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color-light, var(--border-color));
  backdrop-filter: blur(12px);
}
.ups-nav-btn {
  flex: 1;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  border-radius: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ups-nav-btn:active {
  transform: scale(0.97);
}
.ups-nav-btn-primary {
  background: #6366f1;
  color: #fff;
  border-color: transparent;
}
.ups-nav-btn-primary:hover {
  background: #4f46e5;
}
.ups-nav-btn-submit {
  background: #16a34a;
  color: #fff;
  border-color: transparent;
}
.ups-nav-btn-submit:hover {
  background: #15803d;
}
.ups-nav-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Success screen ─────────────────────────────────────────────────────────── */
.ups-success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  min-height: 60vh;
}
.ups-success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}
.ups-success-icon svg {
  width: 40px;
  height: 40px;
  color: #16a34a;
}
.ups-success-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.ups-success-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.ups-success-report-id {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-tertiary, #f1f5f9);
  padding: 8px 16px;
  border-radius: 8px;
  margin-bottom: 32px;
  word-break: break-all;
}
.ups-success-btn {
  min-height: 48px;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  border-radius: 12px;
  cursor: pointer;
  border: none;
  background: #6366f1;
  color: #fff;
  transition: background 0.2s, transform 0.1s;
}
.ups-success-btn:active {
  transform: scale(0.97);
}

/* ── UPS Visit launch card ──────────────────────────────────────────────────── */
.ups-visit-card {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  max-width: 400px;
  margin: 0 auto;
}
.ups-visit-card:hover {
  border-color: #6366f1;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12);
  transform: translateY(-2px);
}
.ups-visit-card:active {
  transform: translateY(0);
}
.ups-visit-card-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #ede9fe;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
[data-theme="dark"] .ups-visit-card-icon {
  background: rgba(109, 40, 217, 0.2);
}
.ups-visit-card-icon svg {
  width: 32px;
  height: 32px;
  color: #7c3aed;
}
.ups-visit-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.ups-visit-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Log Visit — new horizontal form cards ─────────────────────────────────── */
.lv-form-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 16px 16px 16px;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.lv-form-card:hover {
  border-color: var(--color-primary, #6366f1);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
  background: var(--bg-tertiary);
}
.lv-form-card:active {
  transform: scale(0.99);
}
.lv-form-card-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--color-primary-bg, rgba(99,102,241,0.08));
  color: var(--color-primary, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lv-form-card-body {
  flex: 1;
  min-width: 0;
}
.lv-form-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lv-form-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lv-form-card-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ── Section divider ────────────────────────────────────────────────────────── */
.ups-section-divider {
  height: 1px;
  background: var(--border-color-light, var(--border-color));
  margin: 20px 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UPS REPORTS — Manager viewer (inside Technicians dashboard)
   ═══════════════════════════════════════════════════════════════════════════════ */

.ups-reports-section {
  margin-top: 24px;
}
.ups-reports-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* The managers' Submissions page runs edge to edge: a header band, then the table */
.main-content > .ups-reports-section .ups-reports-header {
  margin-bottom: 0;
  padding: var(--space-3) var(--page-gutter);
  border-bottom: 1px solid var(--border-color);
}
.main-content > .ups-reports-section .ups-reports-table-wrap {
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border-color);
}
.main-content > .ups-reports-section .ups-reports-table th:first-child,
.main-content > .ups-reports-section .ups-reports-table td:first-child {
  padding-left: var(--page-gutter);
}
.main-content > .ups-reports-section .ups-reports-table th:last-child,
.main-content > .ups-reports-section .ups-reports-table td:last-child {
  padding-right: var(--page-gutter);
}
.main-content > .ups-reports-section .pagination-container {
  margin-top: 0;
  padding: var(--space-3) var(--page-gutter);
  border-top: 0;
}

/* ── Reports table ──────────────────────────────────────────────────────────── */
.ups-reports-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
}
.ups-reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ups-reports-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary, var(--bg-secondary));
  white-space: nowrap;
}
.ups-reports-table td {
  padding: 12px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color-light, var(--border-color));
  vertical-align: middle;
}
.ups-reports-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}
.ups-reports-table tbody tr:hover {
  background: var(--bg-hover, rgba(99, 102, 241, 0.04));
}
.ups-reports-table tbody tr:last-child td {
  border-bottom: none;
}
.ups-report-id-cell {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-secondary);
}
.ups-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ups-status-badge-pass {
  background: #dcfce7;
  color: #15803d;
}
.ups-status-badge-fail {
  background: #fee2e2;
  color: #dc2626;
}
[data-theme="dark"] .ups-status-badge-pass {
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
}
[data-theme="dark"] .ups-status-badge-fail {
  background: rgba(220, 38, 38, 0.2);
  color: #f87171;
}
.ups-reports-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Pagination bar ─────────────────────────────────────────────────────────── */
/* visits pagination wrapper divs — padding matches list container */
#visits-cards-pg, #visits-timeline-pg {
  padding: 0 16px;
}

/* ── Report detail view ─────────────────────────────────────────────────────── */
.ups-report-detail {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}
.ups-report-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary, var(--bg-secondary));
  gap: 12px;
  flex-wrap: wrap;
}
.ups-report-detail-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.ups-report-detail-actions {
  display: flex;
  gap: 8px;
}
.ups-report-detail-body {
  padding: 20px;
}
.ups-report-section {
  margin-bottom: 24px;
}
.ups-report-section:last-child {
  margin-bottom: 0;
}
.ups-report-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color-light, var(--border-color));
}
.ups-report-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}
.ups-report-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ups-report-field-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.ups-report-field-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Signature & Photo Upload ────────────────────────────────────────────────── */
/* ── Form builder drag-and-drop ─────────────────────────────── */
.fb-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 2px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.fb-field-card:hover .fb-drag-handle { opacity: 1; }
.fb-field-card.fb-dragging { opacity: 0.35; }
.fb-field-card.fb-drag-over {
  outline: 2px dashed var(--color-primary);
  outline-offset: 2px;
}

/* ── Group / subfield builder rows ──────────────────────────── */
.fb-subfields-wrap {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg-primary);
  width: 100%;
  box-sizing: border-box;
}
.fb-subfield-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.fb-subfield-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-secondary);
}
.fb-subfield-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.fb-subfield-card-extra {
  margin-top: 6px;
}

/* ── Group field in fill view ────────────────────────────────── */
.cf-group-field > .ups-field-label {
  font-weight: 600;
  margin-bottom: 6px;
}
.cf-group-subfields {
  border-left: 1px solid var(--border-color);
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cf-group-subfields .ups-field { margin-bottom: 10px; }
.cf-sf-label { font-size: 0.82rem; color: var(--text-muted); }

/* ── Signature pad ──────────────────────────────────────────── */
.cf-signature-wrap {
  border: 2px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
[data-theme="dark"] .cf-signature-wrap {
  background: #1e2530;
}
.cf-signature-canvas {
  display: block;
  width: 100%;
  height: 150px;
  cursor: crosshair;
  touch-action: none;
}
.cf-signature-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.cf-signature-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ups-photo-upload-wrap {
  position: relative;
  width: 100%;
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}
.ups-photo-upload-wrap:hover {
  border-color: var(--color-primary);
  background: var(--bg-hover);
}
.ups-photo-input {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}
.ups-photo-preview-box {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
}
.ups-photo-preview-box svg {
  width: 32px; height: 32px;
  color: var(--text-secondary);
}
.ups-photo-preview-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: none;
  background: #000;
}

.ups-signature-wrap {
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  overflow: hidden;
  position: relative;
  touch-action: none; /* Prevent scroll while signing */
}
.ups-signature-canvas {
  width: 100%;
  height: 160px;
  display: block;
  cursor: crosshair;
}
.ups-signature-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  z-index: 5;
}
.ups-signature-clear:hover {
  background: rgba(0, 0, 0, 0.7);
}

.ups-report-photo-thumb {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  cursor: pointer;
}
.ups-report-sig-thumb {
  max-width: 200px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UPS REPORT — Print / PDF Styles
   ═══════════════════════════════════════════════════════════════════════════════ */
@media print {
  @page {
    size: A4;
    margin: 14mm 18mm;
  }

  body.ups-print-mode {
    margin: 0 !important;
    padding: 0 !important;
  }

  body.ups-print-mode > *:not(.ups-print-target) {
    display: none !important;
  }

  .ups-print-target {
    display: block !important;
    width: 100%;
    background: #fff !important;
    color: #111 !important;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 1.6;
    box-sizing: border-box;
  }

  /* ── Header ────────────────────────────────── */
  .ups-print-header {
    text-align: center;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 2px solid #111;
  }

  .ups-print-header h1 {
    font-size: 17px;
    margin: 0 0 3px;
    font-weight: 800;
    letter-spacing: -0.01em;
  }

  .ups-print-header p {
    font-size: 10px;
    color: #555;
    margin: 1px 0;
  }

  .ups-print-header .ups-print-doc-title {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #111;
    margin-top: 10px;
  }

  /* ── Sections ──────────────────────────────── */
  .ups-print-section {
    margin-bottom: 0;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
  }

  .ups-print-section:last-of-type {
    border-bottom: none;
  }

  .ups-print-section h3 {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #999;
    margin: 0 0 6px;
    padding: 0;
  }

  /* ── Data grid ─────────────────────────────── */
  .ups-print-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 16px;
    row-gap: 2px;
    font-size: 11px;
  }

  .ups-print-field {
    display: flex;
    gap: 4px;
    align-items: baseline;
    break-inside: avoid;
    page-break-inside: avoid;
    overflow: hidden;
  }

  .ups-print-field-label {
    color: #888;
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 72px;
    max-width: 120px;
  }

  .ups-print-field-value {
    color: #111;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 0;
  }

  /* ── Photos ────────────────────────────────── */
  .ups-print-photo-pair {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .ups-print-photo-single {
    grid-column: 1 / -1;
    margin-top: 8px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .ups-print-photo-caption {
    font-size: 9px;
    color: #aaa;
    margin-bottom: 3px;
    font-weight: 400;
  }

  .ups-print-photo-pair img,
  .ups-print-photo-single img {
    width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: contain;
    object-position: left top;
    display: block;
  }

  .ups-print-photo-single img {
    max-width: 280px;
  }

  /* ── Signatures ────────────────────────────── */
  .ups-print-sig-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 8px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .ups-print-sig-caption {
    font-size: 9px;
    color: #888;
    margin-bottom: 4px;
  }

  .ups-print-sig-row img {
    max-width: 200px;
    max-height: 70px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
  }

  /* ── Footer ────────────────────────────────── */
  .ups-print-footer {
    margin-top: 14px;
    padding-top: 6px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 9px;
    color: #bbb;
  }

  /* Hide non-print elements */
  .ups-nav-footer,
  .ups-progress-bar,
  .bottom-nav,
  .sidebar,
  .app-header,
  .ups-report-detail-actions {
    display: none !important;
  }
}

@keyframes slideInToast {
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ════════════════════════════════════════════════════════════════
   TECHNICIAN VIEWS (Mobile-first Cards, Detail View, Per-Step Photos)
   ════════════════════════════════════════════════════════════════ */

.ups-tech-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ups-tech-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.ups-tech-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ups-tech-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ups-tech-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.ups-tech-card-actions .btn {
  flex: 1;
  text-align: center;
  justify-content: center;
}

/* Per-step Photo styling */
.ups-step-photo-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 4/3;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 16px;
}

.ups-step-photo-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.ups-step-photo-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  pointer-events: none;
}

.ups-step-photo-preview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Print/Detail View Images */
.ups-report-photo-thumb {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

/* ===== ACTIVITY TIMELINE ===== */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-4) 0;
  max-width: 800px;
  margin: 0 auto;
}

.timeline-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.timeline-date-header {
  font-size: var(--type-sm);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  margin-left: 48px;
}

.timeline-item {
  display: flex;
  gap: var(--space-3);
  position: relative;
}

.timeline-connector {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 32px;
  flex-shrink: 0;
}

.timeline-connector::before {
  content: '';
  position: absolute;
  top: 32px;
  bottom: -24px;
  width: 2px;
  background-color: var(--border-color);
  z-index: 1;
}

.timeline-group:last-child .timeline-item:last-child .timeline-connector::before {
  display: none;
}

.timeline-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  color: var(--text-muted);
}

/* Activity Card */
.activity-card {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--card-radius);
  border: var(--card-border);
  box-shadow: var(--card-elevation);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.activity-card-header {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-color-light);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}

.activity-title {
  font-size: var(--type-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.activity-time {
  font-size: var(--type-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.activity-card-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.activity-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.activity-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  font-size: var(--type-xs);
  color: var(--text-secondary);
  font-weight: 550;
}

.activity-chip svg {
  color: var(--text-muted);
}

.activity-notes {
  font-size: var(--type-md);
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--bg-tertiary);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}

/* Type specific styling */
.type-new_lead .timeline-icon-wrap { border-color: var(--color-primary); color: var(--color-primary); }
.type-follow_up .timeline-icon-wrap { border-color: var(--color-warning); color: var(--color-warning); }
.type-demo .timeline-icon-wrap { border-color: #8b5cf6; color: #8b5cf6; }
.type-closing .timeline-icon-wrap { border-color: var(--color-success); color: var(--color-success); }
.type-support .timeline-icon-wrap { border-color: var(--text-muted); color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════
   OPPORTUNITY ASSIGNEES — Team member tagging
   ═══════════════════════════════════════════════════════════════════ */

/* ── Picker Container (in modal) ─────────────────────────────────── */
.opp-assignees-picker {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  min-height: 44px;
  transition: border-color 0.15s;
  position: relative;
}

.opp-assignees-picker:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.opp-assignees-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 0;
}

.opp-assignees-chips:empty {
  padding: 0;
}

/* ── Individual chip (selected member) ───────────────────────────── */
.opp-assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 4px;
  border-radius: var(--radius-full);
  background: var(--color-primary-bg);
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
  font-size: 0.775rem;
  font-weight: 550;
  color: var(--color-primary);
  white-space: nowrap;
  max-width: 200px;
}

/* Owner chip — distinct amber tint, no remove button, cursor default */
.opp-assignee-chip--owner {
  background: color-mix(in srgb, #f59e0b 10%, transparent);
  border-color: color-mix(in srgb, #f59e0b 25%, transparent);
  cursor: default;
  padding-right: 6px;
}

.opp-assignee-chip--owner .opp-assignee-chip-role {
  color: #b45309;
}

.opp-owner-chip-icon {
  color: #f59e0b;
  flex-shrink: 0;
  margin-left: 2px;
}

.opp-assignee-chip-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0;
  overflow: hidden;
  position: relative;
}

.opp-assignee-chip-avatar img,
.opp-assignee-opt-avatar img,
.opp-assignee-bubble img,
.ov-assignee-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.opp-assignee-chip-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.opp-assignee-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-primary);
}

.opp-assignee-chip-role {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: capitalize;
}

.opp-assignee-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
  line-height: 1;
}

.opp-assignee-chip-remove:hover {
  opacity: 1;
  color: var(--color-danger);
}

/* ── Search input inside picker ──────────────────────────────────── */
.opp-assignees-search-wrap {
  position: relative;
  padding: 6px 10px 8px;
}

.opp-assignees-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  padding: 0;
}

.opp-assignees-input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

/* ── Dropdown results ─────────────────────────────────────────────── */
.opp-assignees-dropdown {
  /* position: fixed + top/left/width set by JS so it escapes
     the modal-body overflow-y:auto stacking context */
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 10000;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

[data-theme="dark"] .opp-assignees-dropdown {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.opp-assignees-empty {
  padding: 12px 14px;
  font-size: 0.825rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Dropdown option ─────────────────────────────────────────────── */
.opp-assignee-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.opp-assignee-option:hover,
.opp-assignee-option.is-active {
  background: var(--bg-hover);
}

.opp-assignee-option.is-selected {
  background: var(--color-primary-bg);
}

.opp-assignee-option.is-selected .opp-assignee-opt-name {
  color: var(--color-primary);
}

.opp-assignee-opt-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.opp-assignee-opt-info {
  flex: 1;
  min-width: 0;
}

.opp-assignee-opt-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-assignee-opt-role {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 1px;
  text-transform: capitalize;
}

.opp-assignee-opt-check {
  color: var(--color-primary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s;
}

.opp-assignee-option.is-selected .opp-assignee-opt-check {
  opacity: 1;
}

/* ── Stacked avatars on kanban card ──────────────────────────────── */
.opp-assignees-stack {
  display: flex;
  align-items: center;
}

.opp-assignee-bubble {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--color-surface);
  margin-left: -6px;
  position: relative;
  cursor: default;
  transition: transform 0.15s;
  flex-shrink: 0;
  overflow: hidden;
}

.opp-assignee-bubble:first-child {
  margin-left: 0;
}

.opp-assignee-bubble:hover {
  transform: translateY(-2px);
  z-index: 10;
}

.opp-assignee-overflow {
  background: var(--bg-tertiary) !important;
  color: var(--text-muted) !important;
  border-color: var(--border-color) !important;
  font-size: 0.6rem;
}

/* ── View modal assignees section ────────────────────────────────── */
.ov-assignees-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ov-assignee-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ov-assignee-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.ov-assignee-info {
  flex: 1;
  min-width: 0;
}

.ov-assignee-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ov-assignee-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 2px;
}

.ov-assignee-role-badge.role-manager {
  background: color-mix(in srgb, #8b5cf6 12%, transparent);
  color: #8b5cf6;
}

.ov-assignee-role-badge.role-sales_rep {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.ov-assignee-role-badge.role-technician {
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
  color: var(--color-success);
}

/* Owner label inside the role badge */
.ov-assignee-role-badge[class*="role-"]::first-line {
  font-weight: 700;
}

.ov-assignees-empty {
  font-size: 0.825rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ── Dark mode adjustments ───────────────────────────────────────── */
[data-theme="dark"] .opp-assignees-picker {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .opp-assignee-bubble {
  border-color: var(--bg-tertiary);
}

/* ═══════════════════════════════════════════════════════════
   CHANGELOG / WHAT'S NEW MODAL
   ═══════════════════════════════════════════════════════════ */

.cl-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.cl-backdrop.cl-visible {
  opacity: 1;
  pointer-events: all;
}

.cl-backdrop.cl-hiding {
  opacity: 0;
  pointer-events: none;
}

.cl-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.985);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.cl-backdrop.cl-visible .cl-modal {
  transform: translateY(0) scale(1);
}

/* ── Header ── */
.cl-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border-color-light);
  flex-shrink: 0;
}

.cl-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.cl-header-text {
  flex: 1;
  min-width: 0;
}

.cl-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

.cl-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.cl-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  margin-top: -2px;
}

.cl-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Body ── */
.cl-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 8px;
  overscroll-behavior: contain;
}

.cl-body::-webkit-scrollbar {
  width: 4px;
}
.cl-body::-webkit-scrollbar-track {
  background: transparent;
}
.cl-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.cl-release {
  padding: 18px 0 14px;
}

.cl-release + .cl-release {
  border-top: 1px solid var(--border-color-light);
}

.cl-release-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.cl-version {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.cl-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cl-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.cl-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* ── Tags ── */
.cl-tag {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  margin-top: 1px;
}

.cl-tag--new {
  background: rgba(47, 95, 208, 0.10);
  color: var(--color-primary);
}

.cl-tag--improved {
  background: rgba(22, 163, 74, 0.10);
  color: var(--color-success);
}

.cl-tag--fixed {
  background: rgba(202, 138, 4, 0.10);
  color: var(--color-warning);
}

.cl-item-text {
  font-size: 0.855rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Footer ── */
.cl-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-color-light);
  flex-shrink: 0;
}

.cl-btn-primary {
  width: 100%;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  letter-spacing: -0.01em;
}

.cl-btn-primary:hover {
  background: var(--color-primary-dark);
}

.cl-btn-primary:active {
  transform: scale(0.985);
}

/* ── Dark mode ── */
[data-theme="dark"] .cl-modal {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ── Mobile ── */
@media (max-width: 540px) {
  .cl-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .cl-modal {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 88vh;
    transform: translateY(100%);
  }

  .cl-backdrop.cl-visible .cl-modal {
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════
   Custom Fields
   ═══════════════════════════════════════════════════════════════ */

/* Checkbox toggle inside custom field forms */
.cf-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
}

.cf-checkbox-text {
  font-size: var(--type-md);
  color: var(--text-secondary);
  font-weight: 500;
  user-select: none;
}

/* ── Settings: Custom Fields Management ───────────────────────── */

.cf-mgmt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.cf-mgmt-header h4 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cf-entity-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 20px;
}

.cf-entity-tab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.cf-entity-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.cf-entity-tab:hover:not(.active) {
  color: var(--text-secondary);
}

.cf-field-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cf-field-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cf-field-item:hover {
  border-color: var(--border-color-light);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cf-field-sort {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.cf-field-sort button {
  width: 22px;
  height: 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.cf-field-sort button:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.cf-field-sort button:disabled {
  opacity: 0.25;
  cursor: default;
}

.cf-field-info {
  flex: 1;
  min-width: 0;
}

.cf-field-name {
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.cf-field-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cf-field-type-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.cf-field-required-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

.cf-field-options-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.cf-field-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cf-field-actions button {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.cf-field-actions button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.cf-field-actions button.cf-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

/* Empty state */
.cf-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.cf-empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.cf-empty-state h4 {
  margin: 0 0 4px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.cf-empty-state p {
  margin: 0;
  font-size: 0.8125rem;
}

/* Add/Edit field form */
.cf-form-card {
  background: var(--bg-secondary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.cf-form-card .form-field {
  margin-bottom: 12px;
}

.cf-form-card .form-field:last-child {
  margin-bottom: 0;
}

.cf-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cf-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.cf-options-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  min-height: var(--control-height-md);
  cursor: text;
  transition: border-color var(--transition-fast);
}

.cf-options-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

.cf-option-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  font-weight: 500;
}

.cf-option-chip-remove {
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  transition: color 0.15s;
}

.cf-option-chip-remove:hover {
  color: var(--color-danger);
}

.cf-options-input {
  flex: 1;
  min-width: 80px;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  height: 26px !important;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

/* Safi: the session ended, sign in again */
.ai-chat-bubble .ai-signin-btn {
  display: inline-flex;
  margin-top: 10px;
}

/* ── Company and person panels: details on the left, activity on the right ──
   (modules/features/record-views.js, modules/ui/record-activity.js). Below
   900px the two panes stack and scroll as one. */
.od-panel--wide {
  width: min(1120px, 100%);
  height: min(820px, 92vh);
}

.od-body.rp-split {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  border-top: 1px solid var(--border-color);
}

.rp-side {
  min-height: 0;
  padding: 14px 20px 20px 24px;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rp-side-title {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rp-side .od-prop {
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
}

/* Labels sit on the first line of a value that wraps (a long address) */
.rp-side .od-prop-label,
.rp-side .od-prop-value {
  min-height: 34px;
}

.rp-side .td-section {
  padding: 14px 20px 18px 24px;
  margin: 2px -20px 0 -24px;
}

.rp-main {
  min-height: 0;
  padding: 18px 24px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rp-main .od-tabs {
  margin: 0 -24px;
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.rp-main .od-tabs::-webkit-scrollbar {
  display: none;
}

.rp-main .od-tab {
  flex-shrink: 0;
}

/* Highlights */
.ra-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.ra-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  font: inherit;
  color: inherit;
  text-align: left;
}

.ra-tile.is-link {
  cursor: pointer;
  transition: border-color var(--transition-fast, 100ms ease);
}

.ra-tile.is-link:hover {
  border-color: color-mix(in srgb, var(--text-primary) 18%, transparent);
}

.ra-tile.is-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.ra-tile-label,
.ra-tile-meta {
  overflow: hidden;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ra-tile-value {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ra-tile-value.is-empty {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ra-tile.is-overdue .ra-tile-meta {
  font-weight: 550;
  color: var(--color-danger);
}

/* Activity: one bordered list, a sentence per row, as on Attio */
.ra-list {
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.ra-list > li {
  position: relative;
}

/* A faint line from one avatar down to the next */
.ra-list > li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 33px;
  bottom: -5px;
  left: 23.5px;
  width: 1px;
  background: var(--border-color);
}

.ra-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 14px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast, 100ms ease);
}

.ra-row:hover {
  background: var(--bg-hover);
}

.ra-row:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.ra-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
}

.ra-avatar.is-system {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.ra-avatar.is-system svg {
  width: 11px;
  height: 11px;
}

.ra-text {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  line-height: 22px;
  color: var(--text-secondary);
}

.ra-text strong {
  font-weight: 550;
  color: var(--text-primary);
}

.ra-detail {
  display: block;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 18px;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ra-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 22px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ra-more {
  display: block;
  margin: 8px auto 0;
  padding: 0 12px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.ra-more:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Narrower screens: one column, the whole body scrolls */
@media (max-width: 900px) {
  .od-panel--wide {
    width: min(680px, 100%);
    height: auto;
  }

  .od-body.rp-split {
    display: block;
    padding: 0 24px 4px;
    overflow-y: auto;
    border-top: 0;
  }

  .rp-side,
  .rp-main {
    padding: 0;
    border-right: 0;
    overflow: visible;
  }

  .rp-side-title {
    display: none;
  }

  .rp-side .od-prop {
    grid-template-columns: 132px minmax(0, 1fr);
  }

  .rp-side .td-section {
    padding: 14px 24px 18px;
    margin: 2px -24px 0;
  }

  .rp-main {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 640px) {
  .od-body.rp-split {
    padding: 0 16px 4px;
  }

  .rp-side .od-prop {
    grid-template-columns: 108px minmax(0, 1fr);
  }

  .rp-side .td-section {
    padding: 14px 16px 18px;
    margin: 2px -16px 0;
  }

  .rp-main {
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .rp-main .od-tabs {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .ra-highlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .ra-tile {
    padding: 10px 12px;
  }
}

/* A contact's initials, as in the People table: an outlined circle, no colour
   (member colours are for teammates) */
.rp-contact-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-secondary);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.od-avatar.rp-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  font-size: 0.8rem;
}
