/* ========================================================
   DARK THEME (default)
   ======================================================== */
:root,
:root[data-theme="dark"] {
  --bg-0: #0a0b0f;
  --bg-1: #12141a;
  --bg-2: #1a1d26;
  --bg-3: #1e2230;
  --bg-hover: #232736;
  --border: #262a36;
  --border-strong: #323749;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0ac;
  --text-muted: #5a6170;
  --accent: #b22222;
  --accent-hover: #c62929;
  --accent-soft: rgba(178, 34, 34, 0.16);
  --accent-strong: rgba(178, 34, 34, 0.32);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --success: #10b981;
  --shadow-lg: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.4);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Contextual tokens that need to flip per theme */
  --nav-bg: rgba(18, 20, 26, 0.85);
  --avatar-text: #fca5a5;
  --brand-gradient: linear-gradient(135deg, #b22222 0%, #7f1d1d 100%);
  --page-gradient-1: rgba(178, 34, 34, 0.09);
  --page-gradient-2: rgba(178, 34, 34, 0.05);

  /* Lead status palette — color per SPEC §3 (stable across themes) */
  --st-coral:   #f87171;
  --st-amber:   #f59e0b;
  --st-amber2:  #fbbf24;
  --st-blue:    #3b82f6;
  --st-indigo:  #6366f1;
  --st-teal:    #14b8a6;
  --st-green:   #34d399;
  --st-green2:  #10b981;
  --st-green3:  #059669;
  --st-gray:    #6b7280;
  --st-purple:  #a855f7;
}

/* ========================================================
   LIGHT THEME
   ======================================================== */
:root[data-theme="light"] {
  --bg-0: #f6f7f9;
  --bg-1: #ffffff;
  --bg-2: #f3f4f6;
  --bg-3: #e9ecef;
  --bg-hover: #eef0f4;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --accent: #b22222;
  --accent-hover: #991b1b;
  --accent-soft: rgba(178, 34, 34, 0.08);
  --accent-strong: rgba(178, 34, 34, 0.22);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --success: #047857;
  --shadow-lg: 0 18px 50px -24px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 20px -10px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);

  --nav-bg: rgba(255, 255, 255, 0.88);
  --avatar-text: #991b1b;
  --page-gradient-1: rgba(178, 34, 34, 0.04);
  --page-gradient-2: rgba(178, 34, 34, 0.02);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-0);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app { min-height: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-soft); color: var(--text-primary); }

/* =====================================================
   LOGIN SCREEN
   ===================================================== */

.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 900px 600px at 50% -10%, var(--page-gradient-1), transparent 70%),
    radial-gradient(ellipse 600px 400px at 85% 110%, var(--page-gradient-2), transparent 70%),
    var(--bg-0);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}
.brand { text-align: center; margin-bottom: 1.75rem; }
.brand-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 0.25rem;
}
.brand-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* Logo image (shared across login / client / nav). The PNG has a
   transparent background, but its black elements (R's, roofline,
   wordmark) vanish on dark surfaces. Dark mode inverts luminance via
   invert(1) and rotates hue 180° so the red door stays red —
   net effect: black → white, white → black, red ≈ red. */
.rr-logo {
  display: block;
  max-width: 100%;
  height: auto;
}
.rr-logo-full {
  width: 100%;
  max-width: 280px;
}
.rr-logo-nav {
  height: 42px;
  width: 96px;
  object-fit: cover;
  object-position: center 38%;
}

[data-theme="dark"] .rr-logo,
:root:not([data-theme]) .rr-logo {
  filter: invert(1) hue-rotate(180deg);
}
form.stack > * + * { margin-top: 1.125rem; }
.footnote {
  margin-top: 1.5rem; text-align: center;
  font-size: 0.8125rem; color: var(--text-muted);
}

/* =====================================================
   FIELDS (shared between login + forms)
   ===================================================== */

.field { display: block; }
.field label {
  display: block;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem; letter-spacing: 0.01em;
}
.field .req { color: var(--danger); }
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8125rem;
  color: var(--text-primary);
  font-size: 0.9375rem; font-family: inherit;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:hover:not(:focus),
.field select:hover:not(:focus),
.field textarea:hover:not(:focus) {
  border-color: var(--border-strong);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='%239aa0ac' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* --------- Password input with eye toggle --------- */

.password-input-wrap {
  position: relative;
}
.password-input-wrap input {
  /* leave room on the right for the toggle button */
  padding-right: 2.5rem !important;
}
.password-toggle {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
  padding: 0;
  font-family: inherit;
}
.password-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-3);
}
.password-toggle:focus-visible {
  outline: none;
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.eye-icon { width: 18px; height: 18px; display: block; }
.password-toggle[aria-pressed="true"]  .eye-show { display: none; }
.password-toggle[aria-pressed="false"] .eye-hide { display: none; }

.password-mismatch {
  margin-top: -0.25rem;
  font-size: 0.8125rem;
  color: #fca5a5;
  padding: 0.125rem 0;
}
[data-theme="light"] .password-mismatch { color: #b91c1c; }

.field.inline {
  display: flex; flex-direction: column; gap: 0.375rem;
}
.field.inline label { margin-bottom: 0; }
.inline-label {
  display: block;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 0.375rem;
}

/* =====================================================
   BUTTONS
   ===================================================== */

button, .primary, .ghost {
  font-family: inherit;
}

.primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: white;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  font-size: 0.9375rem; font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
button.primary { width: 100%; padding: 0.8125rem; }
form .primary { width: 100%; padding: 0.8125rem; }
.primary:hover:not(:disabled) { background: var(--accent-hover); color: white; }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: 0.55; cursor: not-allowed; }
a.primary { width: auto; }

.ghost {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  text-decoration: none;
}
.ghost:hover:not(:disabled) {
  background: var(--bg-2); color: var(--text-primary);
  border-color: var(--border-strong);
}
.ghost:disabled { opacity: .5; cursor: not-allowed; }

.ghost.small, .primary.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.125rem; line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-primary); }

/* =====================================================
   ALERTS
   ===================================================== */

.alert {
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.alert.error {
  background: var(--danger-soft);
  border-color: rgba(239,68,68,.25);
  color: #fca5a5;
}
.alert.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}
[data-theme="light"] .alert.success { color: #047857; }

/* =====================================================
   APP SHELL (nav + main)
   ===================================================== */

.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--nav-bg);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.625rem 1.5rem;
}
.nav-brand {
  display: inline-flex; align-items: center;
  color: var(--text-primary);
  text-decoration: none;
  padding: 4px;
  border-radius: var(--radius-sm);
}
.nav-brand:hover { color: var(--text-primary); }
.nav-brand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav-links {
  display: flex; align-items: center; gap: 0.125rem;
  flex: 1;
}
.nav-link {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-2);
}
.nav-link.is-active {
  color: var(--text-primary);
  background: var(--bg-2);
}

.nav-user {
  display: flex; align-items: center; gap: 0.5rem;
}
.nav-avatar {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--avatar-text);
  font-size: 0.8125rem; font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-theme-toggle {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  padding: 0;
}
.nav-theme-toggle:hover {
  background: var(--bg-2);
  color: var(--text-primary);
  border-color: var(--border);
}
.nav-theme-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.theme-icon { width: 16px; height: 16px; }
/* Dark mode shows the sun (tap → light). Light mode shows the moon. */
[data-theme="dark"]  .theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun  { display: none; }
/* Fallback when no theme attr is set — treat as dark. */
:root:not([data-theme]) .theme-icon-moon { display: none; }
.nav-signout {
  background: transparent; color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem; font-family: inherit;
  cursor: pointer;
}
.nav-signout:hover {
  color: var(--text-primary);
  background: var(--bg-2);
  border-color: var(--border);
}

.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}
.app-main.narrow { max-width: 780px; }

/* =====================================================
   PAGE HEADER + LAYOUT BLOCKS
   ===================================================== */

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.5rem; font-weight: 600;
  letter-spacing: -0.02em;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 0.25rem;
}
.page-actions {
  display: flex; align-items: center; gap: 0.625rem;
}

.breadcrumbs {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8125rem; color: var(--text-muted);
  margin-bottom: 0.875rem;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--text-primary); }
.breadcrumbs span { color: var(--text-muted); }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 {
  font-size: 1rem; font-weight: 600; letter-spacing: -0.01em;
}
.placeholder-card-inline {
  padding: 1.25rem;
  text-align: center;
  background: transparent;
  border: 1px dashed var(--border);
  box-shadow: none;
}

/* =====================================================
   EMPTY / LOADING
   ===================================================== */

.empty-state {
  padding: 3rem 1.5rem; text-align: center;
  color: var(--text-secondary);
}
.empty-state h2 {
  font-size: 1.125rem; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.empty-state p { margin-bottom: 0.5rem; }
.empty-state.small { padding: 1.5rem; }

.loading {
  padding: 2rem; text-align: center;
  color: var(--text-muted); font-size: 0.875rem;
}

/* =====================================================
   SEGMENTED CONTROL (Calendar / List toggle)
   ===================================================== */

.segmented {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}
.segmented-btn {
  background: transparent;
  border: none;
  padding: 0.4rem 0.875rem;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer; font-family: inherit;
  transition: color .15s ease, background .15s ease;
}
.segmented-btn.is-active {
  background: var(--bg-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* =====================================================
   CALENDAR
   ===================================================== */

.calendar-card { padding-bottom: 0.5rem; }
.calendar-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.calendar-title {
  font-size: 1.0625rem; font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1; text-align: center;
}
.calendar-header .icon-btn { flex-shrink: 0; }
.calendar-header .small { margin-left: 0.5rem; }

.calendar-legend {
  display: flex; flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.legend-item {
  display: inline-flex; align-items: center;
  gap: 0.5rem;
}

.calendar-grid { padding: 0.75rem 0.75rem 1rem; }
.cal-weekdays, .cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-weekdays {
  padding-bottom: 0.5rem;
}
.cal-weekday {
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: center; padding: 0.375rem 0;
}
.cal-day {
  aspect-ratio: 1 / 0.95;
  min-height: 76px;
  padding: 0.4rem 0.5rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column;
  background: var(--bg-1);
}
.cal-day.is-empty {
  background: transparent;
  border-color: transparent;
}
.cal-day.is-filled {
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.cal-day.is-filled:hover { border-color: var(--border-strong); background: var(--bg-2); }
.cal-day.is-today { border-color: var(--accent); }
.cal-day.is-today .cal-date { color: var(--accent); font-weight: 600; }
.cal-day.is-selected {
  background: var(--bg-3);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft) inset;
}
.cal-date {
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary);
}
.cal-dots {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: auto; padding-top: 0.5rem;
  align-items: center;
}
.dot-more {
  font-size: 0.6875rem; color: var(--text-muted); margin-left: 0.125rem;
}

/* =====================================================
   STATUS DOTS & BADGES
   ===================================================== */

.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.3);
}
.dot-coral   { background: var(--st-coral); }
.dot-amber   { background: var(--st-amber); }
.dot-amber2  { background: var(--st-amber2); }
.dot-blue    { background: var(--st-blue); }
.dot-indigo  { background: var(--st-indigo); }
.dot-teal    { background: var(--st-teal); }
.dot-green   { background: var(--st-green); }
.dot-green2  { background: var(--st-green2); }
.dot-green3  { background: var(--st-green3); }
.dot-gray    { background: var(--st-gray); }
.dot-purple  { background: var(--st-purple); }

.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-coral   { background: rgba(248,113,113,.12); color: #fca5a5; border-color: rgba(248,113,113,.25); }
.badge-amber   { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.25); }
.badge-amber2  { background: rgba(251,191,36,.12); color: #fde68a; border-color: rgba(251,191,36,.25); }
.badge-blue    { background: rgba(59,130,246,.14); color: #93c5fd; border-color: rgba(59,130,246,.28); }
.badge-indigo  { background: rgba(99,102,241,.14); color: #a5b4fc; border-color: rgba(99,102,241,.28); }
.badge-teal    { background: rgba(20,184,166,.14); color: #5eead4; border-color: rgba(20,184,166,.28); }
.badge-green   { background: rgba(52,211,153,.14); color: #6ee7b7; border-color: rgba(52,211,153,.28); }
.badge-green2  { background: rgba(16,185,129,.14); color: #6ee7b7; border-color: rgba(16,185,129,.28); }
.badge-green3  { background: rgba(5,150,105,.18); color: #a7f3d0; border-color: rgba(5,150,105,.28); }
.badge-gray    { background: rgba(107,114,128,.14); color: #d1d5db; border-color: rgba(107,114,128,.3); }
.badge-purple  { background: rgba(168,85,247,.14); color: #d8b4fe; border-color: rgba(168,85,247,.28); }

.chip {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem; font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* =====================================================
   LEAD ROW / DAY PANEL
   ===================================================== */

.lead-list {
  list-style: none;
  padding: 0.25rem;
}
.lead-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s ease;
}
.lead-row:hover { background: var(--bg-2); }
.lead-row + .lead-row { border-top: 1px solid var(--border); }
.lead-name { font-weight: 500; }

/* =====================================================
   DATA TABLE
   ===================================================== */

.table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table thead th {
  text-align: left;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.data-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background .12s ease;
}
.data-table tbody tr:hover { background: var(--bg-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .nowrap { white-space: nowrap; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  gap: 0.75rem;
}
.pagination-controls {
  display: flex; align-items: center; gap: 0.5rem;
}
.page-indicator {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0 0.375rem;
}

/* =====================================================
   FILTER BAR
   ===================================================== */

.filter-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  align-items: end;
}

/* =====================================================
   LEAD DETAIL
   ===================================================== */

.lead-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1.5rem; margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.lead-header-main { flex: 1; min-width: 240px; }
.lead-header-actions {
  min-width: 240px;
  display: flex; flex-direction: column; gap: 0.375rem;
}
.lead-meta {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.625rem;
  margin-top: 0.625rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.lead-meta.small { font-size: 0.8125rem; }
.lead-meta strong { color: var(--text-primary); font-weight: 500; }

.status-msg { font-size: 0.8125rem; color: var(--text-muted); min-height: 1rem; }
.status-msg.ok { color: var(--success); }
.status-msg.error { color: #fca5a5; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem 1.5rem;
  padding: 1rem 1.25rem;
}
.kv {
  display: flex; flex-direction: column;
  gap: 0.25rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}
.kv:last-child, .kv:nth-last-child(2):not(:nth-child(odd)) { border-bottom: none; }
.kv-wide { grid-column: 1 / -1; }
.kv dt {
  font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 500;
}
.kv dd {
  font-size: 0.9375rem;
  color: var(--text-primary);
  word-break: break-word;
}

.checklist {
  padding: 0.5rem 0;
}
.checklist-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: var(--text-secondary);
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.checklist-item:hover:not(:disabled) {
  background: var(--bg-2);
  color: var(--text-primary);
}
.checklist-item:hover:not(:disabled):not(.is-done) .checklist-check {
  border-color: var(--accent);
}
.checklist-item:focus-visible {
  outline: none;
  background: var(--bg-2);
  box-shadow: inset 2px 0 0 var(--accent);
}
.checklist-item:disabled { cursor: wait; opacity: 0.65; }
.checklist-item.is-done { color: var(--text-primary); }
.checklist-check {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.75rem; font-weight: 700;
  color: transparent;
  transition: background .15s ease, border-color .15s ease;
}
.checklist-item.is-done .checklist-check {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.checklist-label { flex: 1; }

/* =====================================================
   FORM GRID (Add Lead)
   ===================================================== */

.form-grid {
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.form-grid .fs {
  border: none;
  display: flex; flex-direction: column; gap: 0.875rem;
}
.form-grid legend {
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}
.grid-3 {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0.875rem;
}
.form-actions {
  display: flex; justify-content: flex-end;
  gap: 0.625rem;
}
.form-actions .primary { width: auto; padding: 0.65rem 1.25rem; }

/* =====================================================
   INLINE FORMS (Add Note / Add Task / Add Appointment)
   ===================================================== */

.inline-form {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.75rem;
}
.inline-form textarea,
.inline-form input,
.inline-form select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.8125rem;
  color: var(--text-primary);
  font-size: 0.9375rem; font-family: inherit;
}
.inline-form textarea {
  resize: vertical;
  min-height: 72px;
}
.inline-form textarea:focus,
.inline-form input:focus,
.inline-form select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.inline-form-actions {
  display: flex; justify-content: flex-end;
  gap: 0.5rem;
}
.inline-form .primary,
.inline-form-actions .primary {
  width: auto;
}

/* Subhead separator (e.g. Upcoming / Past, Leads / Appointments) */
.subhead {
  padding: 0.875rem 1.25rem 0.375rem;
  font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.subhead-muted { opacity: 0.75; }

/* =====================================================
   NOTES
   ===================================================== */

.notes-list {
  list-style: none;
  padding: 0.25rem 0;
}
.note {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.note:last-child { border-bottom: none; }
.note-meta {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.375rem;
}
.note-author {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-primary);
}
.note-meta .icon-btn.note-delete {
  margin-left: auto;
  opacity: 0;
  transition: opacity .15s ease;
}
.note:hover .note-meta .icon-btn.note-delete { opacity: 1; }
.note-content {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* =====================================================
   TASKS
   ===================================================== */

.task-list {
  list-style: none;
  padding: 0.25rem 0;
}
.task {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background .12s ease;
}
.task:last-child { border-bottom: none; }
.task-toggle {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: transparent;
  font-size: 0.8125rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background .15s ease, border-color .15s ease;
  margin-top: 2px;
}
.task-toggle:hover { border-color: var(--accent); }
.task.is-done .task-toggle {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.task-main { flex: 1; min-width: 0; }
.task-title {
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 500;
  word-wrap: break-word;
}
.task.is-done .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.task-desc {
  margin-top: 0.2rem;
  word-wrap: break-word;
}
.task-meta {
  margin-top: 0.3rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  align-items: center;
}
.overdue-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px;
  background: var(--danger-soft);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.28);
}
.task.is-overdue {
  background: rgba(239,68,68,.04);
}
.task .task-delete {
  opacity: 0;
  transition: opacity .15s ease;
  margin-left: auto;
  flex-shrink: 0;
  margin-top: 2px;
}
.task:hover .task-delete { opacity: 1; }

/* =====================================================
   APPOINTMENTS
   ===================================================== */

.appt-list {
  list-style: none;
  padding: 0.25rem 0;
}
.appt-list.is-past { opacity: 0.65; }
.appt {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.appt:last-child { border-bottom: none; }
.appt-date {
  width: 52px; flex-shrink: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0.35rem 0;
  border-radius: var(--radius-md);
  background: var(--bg-2);
  border: 1px solid var(--border);
  line-height: 1;
}
.appt-date.type-teal   { border-color: rgba(20,184,166,.35);  background: rgba(20,184,166,.08); }
.appt-date.type-indigo { border-color: rgba(99,102,241,.35);  background: rgba(99,102,241,.08); }
.appt-date.type-gray   { border-color: rgba(107,114,128,.35); background: rgba(107,114,128,.08); }
.appt-month {
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.appt-day {
  font-size: 1.125rem; font-weight: 600;
  color: var(--text-primary);
}
.appt-main { flex: 1; min-width: 0; }
.appt-title {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 500;
}
.appt-meta { margin-top: 0.25rem; }
.appt-desc {
  margin-top: 0.3rem;
  color: var(--text-secondary);
  word-wrap: break-word;
}

/* Compact variant used inside the day-panel on the calendar view. */
.appt-list-compact .lead-row {
  padding: 0.6rem 1rem;
}

/* =====================================================
   APPOINTMENT MARKERS (calendar day cells)
   ===================================================== */

.cal-appts {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding-top: 3px;
  align-items: center;
}
.appt-marker {
  display: inline-block;
  width: 10px; height: 5px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}
.mk-teal   { background: var(--st-teal); }
.mk-indigo { background: var(--st-indigo); }
.mk-gray   { background: var(--st-gray); }

/* =====================================================
   DASHBOARD
   ===================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  display: block;
  padding: 1.125rem 1.25rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, transform .05s ease, background .15s ease;
}
.stat-card:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.stat-card:active { transform: translateY(1px); }
.stat-card.is-accent { border-color: var(--accent-strong); background: var(--accent-soft); }
.stat-card.is-alert  { border-color: rgba(239,68,68,.3);   background: rgba(239,68,68,.05); }
.stat-label {
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.stat-value {
  font-size: 1.875rem; font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
}
.stat-card.is-alert .stat-value { color: #fca5a5; }
.stat-hint {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
}
.pipeline-cell {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.9rem 1.25rem;
  background: var(--bg-1);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: background .15s ease;
}
.pipeline-cell:hover {
  background: var(--bg-2);
  color: var(--text-primary);
}
.pipeline-cell.is-empty { color: var(--text-muted); }
.pipeline-dot { flex-shrink: 0; }
.pipeline-label { flex: 1; }
.pipeline-count {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 1.5rem;
  text-align: right;
}
.pipeline-cell:hover .pipeline-count { color: var(--text-primary); }

/* =====================================================
   MODAL
   ===================================================== */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  animation: modalFade 0.15s ease;
}
@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%; max-width: 480px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  animation: modalIn 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-title {
  font-size: 1.125rem; font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}
.modal-body {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
  line-height: 1.55;
}
.modal-body p + p { margin-top: 0.625rem; }
.modal-body p strong { color: var(--text-primary); font-weight: 500; }
.modal-body .field { margin-bottom: 0; }
.modal-body form.stack > * + * { margin-top: 0.875rem; }
.modal-error { margin-bottom: 0.75rem; }
.modal-actions {
  display: flex; justify-content: flex-end;
  gap: 0.5rem;
}
.modal-actions .primary,
.modal-actions .ghost { width: auto; padding: 0.55rem 1rem; }

/* =====================================================
   DANGER BUTTON VARIANTS
   ===================================================== */

.primary.is-danger {
  background: var(--danger);
}
.primary.is-danger:hover:not(:disabled) {
  background: #dc2626;
}

.ghost.is-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}
.ghost.is-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.55);
}

/* =====================================================
   INLINE EDIT SLOTS
   ===================================================== */

.inline-edit-slot {
  display: inline-block;
  width: 100%;
  min-width: 0;
}
.inline-edit-slot.is-editing {
  display: block;
}

.inline-edit {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  max-width: 100%;
  transition: background .12s ease, border-color .12s ease;
}
.inline-edit:hover {
  background: var(--bg-2);
  border-color: var(--border);
}
.inline-edit:focus-visible {
  outline: none;
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.inline-edit-value {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.inline-edit-value a { color: inherit; }
.inline-edit-placeholder {
  color: var(--text-muted);
  font-style: italic;
  /* Italic glyphs slant past their character box; the parent's
     overflow:hidden (for ellipsis truncation) clips the trailing char
     without this breathing room. */
  padding-inline-end: 0.15rem;
}
.inline-edit-pencil {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity .12s ease;
  flex-shrink: 0;
}
.inline-edit:hover .inline-edit-pencil,
.inline-edit:focus-visible .inline-edit-pencil { opacity: 1; }

.inline-edit-form {
  display: flex; flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem 0;
}
.inline-edit-control {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.625rem;
  color: var(--text-primary);
  font: inherit;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.inline-edit-control:focus { outline: none; }
textarea.inline-edit-control { resize: vertical; min-height: 72px; }
select.inline-edit-control {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='%239aa0ac' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  padding-right: 1.75rem;
}
.inline-edit-error { margin: 0; }
.inline-edit-actions {
  display: flex;
  gap: 0.375rem;
}
/* Override the form-wide "button.primary fills the row" rule set by the
   login form — inline edits need Save + Cancel side-by-side. Save takes
   the remaining space; Cancel sizes to its text so "Cancel" never wraps. */
.inline-edit-actions .primary {
  width: auto;
  flex: 1;
}
.inline-edit-actions .ghost {
  flex-shrink: 0;
  white-space: nowrap;
}

/* =====================================================
   DANGER ZONE (lead detail)
   ===================================================== */

.danger-zone {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.03);
}
.danger-zone .card-header {
  border-bottom-color: rgba(239, 68, 68, 0.2);
}
.danger-zone-body {
  padding: 1rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.danger-zone-copy { flex: 1; min-width: 220px; }
.danger-zone-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

/* =====================================================
   TEAM PAGE
   ===================================================== */

.team-name {
  display: flex; align-items: center; gap: 0.75rem;
}
.team-actions {
  display: flex; align-items: center; gap: 0.375rem;
  justify-content: flex-end;
}
.role-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 1.75rem 0.35rem 0.625rem;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='%239aa0ac' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: border-color .15s ease;
}
.role-select:hover:not(:disabled) { border-color: var(--border-strong); }
.role-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.role-select:disabled { opacity: 0.6; cursor: wait; }

/* =====================================================
   PROPERTIES (lead detail)
   ===================================================== */

.property-list {
  padding: 0.75rem;
  display: flex; flex-direction: column;
  gap: 0.75rem;
}
.property-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  padding: 1rem 1.125rem;
}
.property-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.5rem;
}
.property-address { flex: 1; min-width: 0; }
.property-title {
  font-size: 0.9375rem; font-weight: 500;
  color: var(--text-primary);
  word-wrap: break-word;
}
.property-card-actions {
  display: flex; align-items: center; gap: 0.5rem;
  flex-shrink: 0;
}

.property-status-wrap {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background .12s ease;
}
.property-status-select {
  background: transparent;
  border: none;
  font: inherit;
  font-size: 0.75rem; font-weight: 500;
  padding: 0.2rem 1.75rem 0.2rem 0.625rem;
  border-radius: 999px;
  color: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' opacity='0.6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.property-status-select:focus { outline: none; }
.property-status-select:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

.property-status-gray  { background: rgba(107,114,128,.14); color: #d1d5db; border-color: rgba(107,114,128,.3); }
.property-status-amber { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.25); }
.property-status-blue  { background: rgba(59,130,246,.14); color: #93c5fd; border-color: rgba(59,130,246,.28); }
.property-status-green { background: rgba(52,211,153,.14); color: #6ee7b7; border-color: rgba(52,211,153,.28); }
.property-status-coral { background: rgba(248,113,113,.14); color: #fca5a5; border-color: rgba(248,113,113,.28); }

.property-card-body {
  display: flex; flex-direction: column; gap: 0.375rem;
}
.property-link a { font-size: 0.875rem; }
.property-notes {
  margin-top: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  white-space: pre-wrap;
}

/* =====================================================
   DOCUMENTS (lead detail)
   ===================================================== */

.documents-toolbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.documents-grid {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.5rem;
}
.doc-slot {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  color: var(--text-primary);
  transition: border-color .12s ease, background .12s ease;
  min-width: 0;
  overflow: hidden;
}
.doc-slot.is-empty { opacity: 0.75; }
.doc-slot.is-uploaded:hover { border-color: var(--accent); }

/* Main click target — view the document inline. On empty slots this
   element is a non-interactive <div> with the same layout. */
.doc-slot-view {
  flex: 1;
  min-width: 0;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.doc-slot.is-uploaded .doc-slot-view {
  cursor: pointer;
  transition: background .12s ease;
}
.doc-slot.is-uploaded .doc-slot-view:hover { background: var(--bg-3); }
.doc-slot.is-uploaded .doc-slot-view:focus-visible {
  outline: none;
  background: var(--bg-3);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Download icon button on the right side of uploaded slots. */
.doc-slot-download {
  flex-shrink: 0;
  width: 44px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.doc-slot-download:hover {
  color: var(--text-primary);
  background: var(--bg-3);
}
.doc-slot-download:focus-visible {
  outline: none;
  color: var(--accent);
  background: var(--bg-3);
  box-shadow: inset 2px 0 0 var(--accent);
}
.doc-slot-download svg { width: 18px; height: 18px; }

.doc-slot-check {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--success);
  color: white;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9375rem;
  flex-shrink: 0;
}
.doc-slot-check-empty {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  color: var(--text-muted);
  border-radius: 999px;
  flex-shrink: 0;
}
.doc-slot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.doc-slot-label {
  font-size: 0.9375rem;
  font-weight: 500;
}
.doc-slot-meta {
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =====================================================
   PUBLIC CLIENT UPLOAD PAGE
   ===================================================== */

.client-wrap {
  min-height: 100vh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2.5rem 1.25rem;
  background:
    radial-gradient(ellipse 900px 600px at 50% -10%, var(--page-gradient-1), transparent 70%),
    radial-gradient(ellipse 600px 400px at 85% 110%, var(--page-gradient-2), transparent 70%),
    var(--bg-0);
}
.client-card {
  width: 100%; max-width: 560px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.client-brand {
  display: flex; justify-content: center;
  margin-bottom: 1.75rem;
  color: var(--text-primary);
}
.client-brand .rr-logo {
  width: 100%;
  max-width: 280px;
  height: auto;
}
.client-greeting {
  font-size: 1.375rem; font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.client-intro p { color: var(--text-secondary); }
.client-intro { margin-bottom: 1.5rem; }

.client-progress {
  margin-top: 1rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.client-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}
.client-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  transition: width .3s ease;
}

.client-success {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 1rem 1.25rem; margin-bottom: 1.25rem;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
}
.client-success-mark {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--success); color: white;
  border-radius: 999px; font-weight: 700;
  flex-shrink: 0;
}
.client-success h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.125rem; }
.client-success p { font-size: 0.875rem; margin: 0; }

.client-list {
  list-style: none; padding: 0;
  display: flex; flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.client-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  transition: border-color .12s ease, background .12s ease;
}
.client-item:hover:not(.is-busy) { border-color: var(--border-strong); }
.client-item.is-done { border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.04); }
.client-item.is-busy { opacity: 0.75; }

.client-item-label {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
}
.client-item.is-busy .client-item-label { cursor: wait; }
.client-item-label input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}
.client-item-check {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  color: white; font-weight: 700; font-size: 0.9375rem;
  flex-shrink: 0;
  transition: background .15s ease, border-color .15s ease;
}
.client-item.is-done .client-item-check {
  background: var(--success);
  border-color: var(--success);
}
.client-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.client-item-title { font-weight: 500; color: var(--text-primary); }
.client-item-meta { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.125rem; }
.client-item-action { flex-shrink: 0; }
.client-item-upload, .client-item-replace {
  display: inline-flex; align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 500;
  background: var(--accent-soft);
  color: var(--avatar-text);
  border: 1px solid var(--accent-strong);
}
.client-item.is-done .client-item-replace {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.client-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.client-footnote { margin-top: 0.5rem; text-align: center; }

.client-error {
  text-align: center;
  padding: 1.5rem 0;
}
.client-error h2 { font-size: 1.125rem; margin-bottom: 0.5rem; }
.client-error p { color: var(--text-secondary); margin-bottom: 0.5rem; }

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

/* =====================================================
   LEAD DETAIL TABS
   ===================================================== */

#lead-header-area { margin-bottom: 1.25rem; }

.tab-bar {
  display: flex;
  gap: 0.25rem;
  padding: 0.375rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.tab-bar::-webkit-scrollbar { height: 6px; }
.tab-bar::-webkit-scrollbar-track { background: transparent; }
.tab-bar::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.tab-btn {
  flex-shrink: 0;
  padding: 0.5rem 0.9rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background .15s ease, color .15s ease;
}
.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-2);
}
.tab-btn.is-active {
  color: var(--text-primary);
  background: var(--bg-3);
  box-shadow: var(--shadow-sm);
}
.tab-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tab-panel {
  /* Hidden panels still occupy no space since we use the [hidden] attr. */
}

/* =====================================================
   ATTACHMENTS (lead detail)
   ===================================================== */

.att-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.375rem;
  margin: 0.75rem 1.25rem 1rem;
  padding: 1.25rem 1rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.att-dropzone:hover:not(.is-busy),
.att-dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--bg-3);
  color: var(--text-primary);
  outline: none;
}
.att-dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}
.att-dropzone.is-busy {
  cursor: wait;
  color: var(--text-primary);
}
.att-dropzone u { text-decoration: underline; color: var(--text-primary); }
.att-dropzone-icon {
  font-size: 1.375rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.125rem;
}
.att-error { margin: 0 1.25rem 1rem; }

.att-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem 1.25rem 1.25rem;
}
.att-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s ease, transform .05s ease;
}
.att-card:hover { border-color: var(--border-strong); }
.att-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.att-card:active { transform: translateY(1px); }

.att-thumb {
  width: 100%;
  height: 150px;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: var(--text-muted);
}
.att-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.att-thumb-pdf {
  background: linear-gradient(135deg, #1a1d26 0%, #232736 100%);
  color: var(--accent);
}
.att-thumb-loading { font-size: 1.125rem; opacity: 0.6; }

.att-card-body {
  padding: 0.625rem 0.75rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  flex: 1;
}
.att-card-filename {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-card-meta {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}
.att-card-caption {
  margin-top: 0.125rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
}
.att-card-footer { margin-top: auto; padding-top: 0.25rem; }

/* ── Kebab menu ──────────────────────────────────────────────── */
.att-kebab-wrap {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
}

.att-kebab {
  opacity: 0;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 7px;
  background: var(--bg-3) !important;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: opacity .12s ease;
}

.att-card:hover .att-kebab,
.att-card:focus-within .att-kebab { opacity: 1; }

.att-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 150px;
  z-index: 50;
  padding: 0.25rem 0;
}

.att-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .1s;
}
.att-dropdown-item:hover { background: var(--bg-2); }
.att-dropdown-danger     { color: var(--danger); }

/* =====================================================
   ADD LEAD: SCREENSHOT UPLOAD
   ===================================================== */

.new-lead-tabs {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.screenshot-panel {
  padding: 1.25rem;
}

.screenshot-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem;
  min-height: 220px;
  padding: 2rem 1.5rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-2);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.screenshot-dropzone:hover,
.screenshot-dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--bg-3);
  color: var(--text-primary);
  outline: none;
}
.screenshot-dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}
.screenshot-icon {
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.screenshot-dropzone-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.screenshot-processing {
  display: flex; align-items: center; gap: 0.875rem;
  min-height: 220px;
  padding: 2rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-2);
  justify-content: center;
}
.screenshot-processing .client-spinner {
  width: 24px; height: 24px;
  border-width: 3px;
  flex-shrink: 0;
}
.screenshot-processing-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.prefill-banner {
  display: flex; align-items: flex-start; gap: 0.75rem;
  margin: 1rem 1.25rem 0;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.5;
}
.prefill-banner-icon {
  font-size: 1.125rem;
  line-height: 1;
  flex-shrink: 0;
}
.prefill-banner-body strong { color: var(--text-primary); font-weight: 500; }

/* =====================================================
   LIGHT-THEME CONTRAST OVERRIDES
   Pastel text colours (e.g. #fca5a5, #6ee7b7) work on the dark
   tinted backgrounds but wash out against a white card. Swap in
   the corresponding 700-range shades when the light theme is on.
   ===================================================== */

[data-theme="light"] .badge-coral   { color: #b91c1c; background: rgba(220, 38, 38, 0.08);  border-color: rgba(220, 38, 38, 0.28); }
[data-theme="light"] .badge-amber   { color: #b45309; background: rgba(245, 158, 11, 0.1);  border-color: rgba(245, 158, 11, 0.3); }
[data-theme="light"] .badge-amber2  { color: #b45309; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.3); }
[data-theme="light"] .badge-blue    { color: #1d4ed8; background: rgba(59, 130, 246, 0.1);  border-color: rgba(59, 130, 246, 0.3); }
[data-theme="light"] .badge-indigo  { color: #4338ca; background: rgba(99, 102, 241, 0.1);  border-color: rgba(99, 102, 241, 0.3); }
[data-theme="light"] .badge-teal    { color: #0f766e; background: rgba(20, 184, 166, 0.1);  border-color: rgba(20, 184, 166, 0.3); }
[data-theme="light"] .badge-green   { color: #047857; background: rgba(16, 185, 129, 0.1);  border-color: rgba(16, 185, 129, 0.3); }
[data-theme="light"] .badge-green2  { color: #047857; background: rgba(16, 185, 129, 0.1);  border-color: rgba(16, 185, 129, 0.3); }
[data-theme="light"] .badge-green3  { color: #065f46; background: rgba(5, 150, 105, 0.12);  border-color: rgba(5, 150, 105, 0.32); }
[data-theme="light"] .badge-gray    { color: #374151; background: rgba(107, 114, 128, 0.1); border-color: rgba(107, 114, 128, 0.3); }
[data-theme="light"] .badge-purple  { color: #7e22ce; background: rgba(168, 85, 247, 0.1);  border-color: rgba(168, 85, 247, 0.3); }

[data-theme="light"] .alert.error         { color: #b91c1c; border-color: rgba(220, 38, 38, 0.28); }
[data-theme="light"] .overdue-badge       { color: #b91c1c; border-color: rgba(220, 38, 38, 0.28); }
[data-theme="light"] .status-msg.error    { color: #b91c1c; }

/* Appointment date-block tints use the same hues as the type colours —
   soften them a touch for white surfaces. */
[data-theme="light"] .appt-date.type-teal   { background: rgba(20, 184, 166, 0.08);  border-color: rgba(20, 184, 166, 0.35); }
[data-theme="light"] .appt-date.type-indigo { background: rgba(99, 102, 241, 0.08);  border-color: rgba(99, 102, 241, 0.35); }
[data-theme="light"] .appt-date.type-gray   { background: rgba(107, 114, 128, 0.08); border-color: rgba(107, 114, 128, 0.35); }

[data-theme="light"] .client-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(5, 150, 105, 0.3);
}
[data-theme="light"] .client-success h3 { color: #065f46; }

[data-theme="light"] .task.is-overdue   { background: rgba(220, 38, 38, 0.03); }
[data-theme="light"] .danger-zone       { background: rgba(220, 38, 38, 0.02); }

/* Calendar status dots have a faint dark ring in dark mode that vanishes on
   light backgrounds — give them a subtle light-mode ring instead. */
[data-theme="light"] .status-dot { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); }

/* =====================================================
   UTILITIES
   ===================================================== */

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

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

@media (max-width: 820px) {
  .nav-inner { gap: 0.75rem; padding: 0.75rem 1rem; }
  .nav-brand-text { display: none; }
  .nav-link { padding: 0.4rem 0.625rem; font-size: 0.8125rem; }
  .app-main { padding: 1.25rem 1rem 2.5rem; }
  .page-header { align-items: flex-start; }
  .filter-bar { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .lead-header-actions { min-width: 0; width: 100%; }
  .property-card-head { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .property-card-actions { align-self: flex-end; }
}

@media (max-width: 560px) {
  .grid-3 { grid-template-columns: 1fr; }
  .cal-day { min-height: 62px; padding: 0.3rem; }
  .cal-date { font-size: 0.75rem; }
  .status-dot { width: 7px; height: 7px; }
  .cal-dots { gap: 3px; padding-top: 0.3rem; }
  .cal-appts { gap: 2px; padding-top: 2px; }
  .appt-marker { width: 8px; height: 4px; }
  .nav-signout { display: none; }
  .page-title { font-size: 1.25rem; }
  .appt { gap: 0.75rem; }
  .appt-date { width: 44px; }
}

@media (max-width: 480px) {
  .login-card { padding: 2rem 1.5rem; }
  .brand h1 { font-size: 1.25rem; }
}
