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

:root {
  --tap-size: 44px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;

  /* Design tokens — professional blue business-app palette.
     Every component reads these, so light/dark is just swapping
     this block via [data-theme]. */
  --bg-main: #f4f6f9;
  --bg-secondary: #eef1f6;
  --surface: #ffffff;
  --surface-muted: #f1f4f8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.10);
  /* Blue for TEXT and links (separate from --primary, which is also the
     fill behind white button text and can't serve both on dark navy). */
  --primary-text: #1d4ed8;
  --placeholder: #6b7280;
  --accent: #2563eb;
  --text-main: #0b1120;
  --text-muted: #4b5563;
  --border-soft: #e5e7eb;
  --border-strong: #cbd2dc;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.14);
  /* Darker shades for status TEXT on light surfaces (the base colors are
     for fills/borders and read too faint as small text). */
  --success-text: #166534;
  --warning-text: #b45309;
  --danger-text: #b91c1c;
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lift: 0 8px 24px rgba(15, 23, 42, 0.10);
}

/* Dark mode — deep blue-neutral, not pure black. Cards/surfaces are a
   step lighter than the page background so they read as separated
   without relying on heavy borders. Same semantic colors, shifted
   lighter to stay readable on dark surfaces. */
:root[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-secondary: #111c30;
  --surface: #172236;
  --surface-muted: #1c2942;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(59, 130, 246, 0.18);
  --primary-text: #60a5fa;
  --placeholder: #8b97ad;
  --accent: #38bdf8;
  --text-main: #f4f6fb;
  --text-muted: #aab4c8;
  --border-soft: #29374f;
  --border-strong: #3d4f6b;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.16);
  --success-text: #4ade80;
  --warning-text: #fbbf24;
  --danger-text: #fca5a5;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* Form controls don't inherit typography by default in browsers — every
   <input>/<select>/<textarea> was silently using the browser's default
   near-black text color regardless of theme. This is the fix: make them
   inherit color like normal text does, so dark mode actually reaches them. */
input,
select,
textarea,
button {
  min-height: var(--control-h, 40px);
  color: inherit;
  font-family: inherit;
}

/* Lucide icons — one consistent size/stroke, inline with text */
[data-lucide] {
  width: 17px;
  height: 17px;
  stroke-width: 2px;
  vertical-align: -3px;
  flex-shrink: 0;
}

/* =========================
   TOP NAVIGATION BAR
   Shared by main.html, finance.html, settings.html.
========================= */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}
.top-nav .nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
}
.top-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.top-nav .nav-links a {
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.top-nav .nav-links a:hover {
  background: var(--surface-muted);
  color: var(--text-main);
}
.top-nav .nav-links a.active {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.role-badge { display: inline-block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 8px; border-radius: var(--radius-sm); margin-left: 6px; vertical-align: middle; }
.role-badge.admin { background: var(--primary-soft); color: var(--primary-text); border: 1px solid var(--primary); }
.role-badge.user { background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--surface-muted); }

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.theme-toggle-btn:hover {
  background: var(--surface-muted);
  color: var(--text-main);
}

@media (max-width: 768px) {
  .top-nav { flex-wrap: wrap; gap: 8px; padding: 8px 14px; }
  .top-nav .nav-links a { padding: 6px 12px; font-size: 0.82rem; }
}

body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.dashboard-body {
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

/* =========================
   BODY & DASHBOARD LAYOUT
========================= */
body.dashboard-body {
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  color: var(--text-main);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

#Main_header {
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
  padding: 15px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.page-kicker,
.page-title,
.page-subtitle {
  display: block;
}

.page-header-actions button {
  min-height: 44px;
}

.section-copy {
  margin: 0;
}

.page-header {
  position: relative;
  z-index: 2;
}

.crm-dashboard {
  display: flex;
  flex: 1;
  overflow: hidden;
  width: 100%;
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
  width: min(760px, calc(100vw - 32px));
  max-width: 760px;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: 20px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;

  justify-content: flex-start;  /* ✅ NOT center */
  align-items: stretch;         /* ✅ NOT center */

  overflow-y: auto;
}

.sidebar h2 {
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--text-main);
}

.sidebar form {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

.input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.input-row input {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: none;
  outline: none;
}

/* Intake row: First Name / Last Name / Job Address */
.sidebar .input-row {
  align-items: stretch;
}

.sidebar #fName,
.sidebar #lName {
  flex: 0.9;
}

.sidebar #address {
  flex: 1.35;
}

/* New-client form: fields stack with even spacing */
.sidebar form input[type="email"],
.sidebar form input[type="tel"] {
  margin-bottom: 10px;
}

/* Buttons — one canonical set, reused by every page (no page-local
   duplicates). Rectangular proportions, no pill shapes. */
.btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.btn-secondary:hover { background: var(--surface-muted); }

.btn-danger {
  padding: 10px 20px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.search-bar input {
  width: 100%;
}

.search-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  padding: 8px 0 6px;
}

.status-counts {
  position: static;
  background: transparent;
  padding-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.status-count-chip {
  background: var(--surface);
  border: 1px solid var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.status-count-chip:hover {
  background: var(--surface-muted);
}
.status-count-chip.active {
  background: var(--border-strong);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* =========================
   CLIENT LIST
========================= */
.client-list {
  list-style: none;
  margin-top: 15px;
  overflow-y: auto;
  flex: 1;
}

.sidebar {
  align-items: center;
}

.clients-workspace,
.sidebar h2,
.sidebar form,
.search-bar,
.client-list {
  width: min(680px, 100%);
}

.clients-workspace {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.sidebar h2 {
  text-align: center;
}

#clientIntakeForm {
  margin: 0 auto 20px;
  align-self: center;
}

.sidebar .search-bar,
.sidebar .client-list {
  margin-inline: auto;
}

.client-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--surface-muted);
  border: 1px solid var(--surface);
  margin-bottom: 8px;
  position: relative;
}

.client-item:hover {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  transform: translateX(4px);
}

.client-item.active {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
}

/* Client cards (renderer) */
.client-card {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--surface-muted);
  border: 1px solid var(--surface);
  margin-bottom: 8px;
  position: relative;
}

.client-card:hover {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  transform: translateX(4px);
}

.client-card.active {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
}

.client-card.kb-selected {
  outline: 2px solid var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.client-card mark,
.client-item mark {
  background: rgba(255, 232, 143, 0.5);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* Extra spacing between items */
.client-item + .client-item,
.client-card + .client-card {
  margin-top: 8px;
}

/* =========================
   MAIN PANEL
========================= */
.main-content {
  display: none;
}



.detail-card {
  background: var(--surface);
  padding: 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  position: relative;
  border: 1px solid var(--border-soft);
}

.animate-panel {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  gap: 16px;
}

.detail-header h2 {
  font-size: 1.75rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.panel-header {
  align-items: flex-start;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.panel-kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 700;
}

.panel-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.panel-contact-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.panel-contact-links a,
.maps-link {
  color: var(--primary-text);
  text-decoration: none;
}

.panel-contact-links a[href^="mailto:"],
.panel-contact-links a[href^="tel:"] {
  color: var(--primary-text);
  -webkit-text-fill-color: var(--primary-text);
  word-break: break-word;
}

.panel-contact-links a[href^="mailto:"]:visited,
.panel-contact-links a[href^="tel:"]:visited {
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.panel-contact-links a[href^="mailto:"]:hover,
.panel-contact-links a[href^="tel:"]:hover {
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.panel-contact-links a:hover,
.maps-link:hover {
  text-decoration: underline;
}

.save-status-chip {
  margin-left: auto;
  font-size: 12px;
  color: var(--accent);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  white-space: nowrap;
}

.panel-grid {
  gap: 14px 12px;
}

.panel-full-span {
  grid-column: span 2;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-section {
  border-top: 1px solid var(--border-soft);
  padding-top: 16px;
  margin-top: 10px;
}

.panel-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 10px;
}

.panel-section-header h3 {
  margin: 0;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 700;
}

/* Plain form labels ("Assigned To", "Phone Number", etc.) inside the
   client/job panels — explicit color+weight instead of relying on
   inheritance, so they never come out too faint. */
#projectPanel label,
.detail-card label {
  display: block;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.panel-section-note {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.panel-inline-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-money-input {
  flex: 1;
}

.panel-balance-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 14px;
  margin-top: 4px;
}

.panel-metric {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--surface);
}

.panel-metric span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.panel-metric strong {
  color: #fff;
  font-size: 1.05rem;
}

.panel-list {
  margin-top: 10px;
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.panel-actions .btn-primary {
  flex: 1;
}

.panel-secondary-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}

/* Roofing grid */
.roofing-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.roofing-grid input,
.roofing-grid select,
.roofing-grid textarea {
  padding: 8px;
  border-radius: 6px;
  border: none;
  outline: none;
  width: 100%;
  background: var(--border-soft);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

.roofing-grid input:focus,
.roofing-grid select:focus,
.roofing-grid textarea:focus {
  box-shadow: 0 0 0 3px var(--primary-soft);
  border-color: var(--primary-soft);
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border-strong);
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  transition: all 0.3s ease;
}

.drop-zone-active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* Close button */
.close-x {
  color: var(--text-muted);
  font-size: 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Animations */
@keyframes slideInUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* =========================
   SHARED MODAL PATTERN
   One overlay/card pair reused by every modal in the app
   (email settings, company profile, PDF preview, add-user).
========================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  justify-content: center;
  align-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.5);
  z-index: 10000;
}

:root[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 20px;
}

/* =========================
   PDF MODAL
========================= */
#pdfModal {
  z-index: 9999;
}

#pdfModalContent {
  width: 95%;
  max-width: 1200px;
  height: 90%;
  padding: 10px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#pdfViewer {
  width: 100%;
  height: 100%;
}

#pdfViewer object {
  width: 100%;
  height: 100%;
}

#p-status {
  background-color: var(--surface);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}

/* =========================
   RESPONSIVE
========================= */
/* Notes section */
.notes-section {
  margin-top: 18px;
  padding-top: 14px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.notes-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notes-actions textarea {
  width: 100%;
  padding: 10px 12px;
  resize: vertical;
  min-height: 110px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  font-family: inherit;
}

.notes-list .note-edit-textarea {
  width: 100%;
  min-height: 120px;
  flex: 1;
  padding: 10px 12px;
  resize: vertical;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: var(--surface);
  color: var(--text-main);
  caret-color: var(--text-main);
  font-family: inherit;
  line-height: 1.45;
  box-sizing: border-box;
}

.notes-list .note-edit-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.notes-actions .add-note-btn {
  align-self: flex-end;
  width: 120px;
  padding: 8px 12px;
  font-size: 0.9rem;
  line-height: 1.1;
  height: 40px;
}

.loading-state,
.empty-state {
  color: var(--danger);
  font-size: 13px;
  padding: 10px;
}

.panel-section h3,
.notes-section h3 {
  color: var(--text-main);
}

.client-card .client-name,
.client-item .client-name {
  font-weight: 700;
  color: var(--text-main);
}

.client-card .client-meta,
.client-item .client-meta {
  margin-top: 4px;
  font-size: 0.9rem;
}

.client-status,
.status-count-row {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.client-status:hover,
.status-count-row:hover {
  filter: brightness(0.96);
  text-decoration: none;
}

@media (max-width: 768px) {
  body.dashboard-body {
    min-height: 100dvh;
  }

  #Main_header.page-header {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 14px;
  }

  .page-header-copy {
    gap: 6px;
  }

  .page-title {
    font-size: clamp(1.15rem, 5vw, 1.45rem);
  }

  .page-subtitle {
    max-width: none;
    font-size: 0.88rem;
    line-height: 1.4;
  }

  .page-header-actions {
    width: 100%;
  }

  .page-header-actions button {
    width: 100%;
  }

  .crm-dashboard {
    padding: 12px;
    gap: 12px;
    overflow: visible;
  }

  .crm-dashboard {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-width: none;
    padding: 16px;
    border-radius: 18px;
    margin: 0;
  }

  .sidebar .input-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .sidebar #fName,
  .sidebar #lName,
  .sidebar #address {
    flex: 1;
    width: 100%;
  }

  .sidebar h2,
  .sidebar form,
  .search-bar,
  .client-list,
  .clients-workspace {
    width: 100% !important;
    max-width: none !important;
  }

  .sidebar h2 {
    font-size: 1.05rem;
    margin-bottom: 12px;
  }

  .sidebar form {
    margin-bottom: 16px;
  }


  .client-list {
    max-height: none;
  }

  .roofing-grid {
    grid-template-columns: 1fr;
  }

  .client-item,
  .client-card {
    min-height: 56px;
    padding: 14px 14px 16px;
    border-radius: 14px;
  }

  .detail-card {
    padding: 14px;
    border-radius: 18px;
  }

  .detail-card .btn-primary {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.92rem;
    min-height: 44px;
  }

  .drop-zone {
    padding: 18px;
  }

  .notes-actions .add-note-btn {
    width: 100%;
    align-self: stretch;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    max-width: 100%;
  }

  #projectPanel {
    top: 0;
    left: 0;
    transform: none;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    padding: 10px;
    box-sizing: border-box;
  }

  #projectPanel .detail-card {
    height: 100%;
    width: min(100%, 920px);
    margin: 0 auto;
    padding-inline: clamp(16px, 5vw, 30px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #projectPanel .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  #projectPanel .panel-title-block,
  #projectPanel .panel-contact-links,
  #projectPanel .panel-section,
  #projectPanel .panel-full-span,
  #projectPanel .field-stack,
  #projectPanel .notes-section,
  #projectPanel .panel-list {
    width: 100%;
  }

  #projectPanel .save-status-chip {
    margin-left: 0;
    align-self: flex-start;
  }

  #projectPanel .panel-contact-links {
    align-items: flex-start;
    width: 100%;
  }

  #projectPanel .roofing-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
  }

  #projectPanel .roofing-grid > * {
    width: 100%;
  }

  #projectPanel .panel-full-span {
    grid-column: auto;
  }

  #projectPanel .field-stack {
    width: 100%;
  }

  #projectPanel .roofing-grid > label {
    display: block;
    margin-top: 6px;
    margin-bottom: -6px;
    color: rgba(241, 243, 255, 0.92);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  #projectPanel .roofing-grid > input,
  #projectPanel .roofing-grid > select,
  #projectPanel .roofing-grid > textarea,
  #projectPanel .roofing-grid > .field-stack {
    min-width: 0;
  }

  #projectPanel .roofing-grid > input,
  #projectPanel .roofing-grid > select,
  #projectPanel .roofing-grid > textarea,
  #projectPanel .field-stack input,
  #projectPanel .field-stack select,
  #projectPanel .field-stack textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    font-size: 16px;
  }

  #projectPanel .panel-inline-row {
    flex-direction: column;
    gap: 8px;
  }

  #projectPanel .panel-inline-row > * {
    width: 100%;
  }

  #projectPanel .panel-balance-row {
    flex-direction: column;
    gap: 10px;
  }

  #projectPanel .panel-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  #projectPanel .panel-actions .btn-primary {
    width: min(100%, 420px);
  }

  #projectPanel .panel-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  #projectPanel .panel-metric {
    width: 100%;
  }

  #projectPanel .notes-actions textarea {
    min-height: 180px;
    line-height: 1.45;
  }

  #projectPanel .notes-list > div,
  #projectPanel #pdf-list > div {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  #projectPanel .notes-list > div > div:first-child {
    margin-right: 0 !important;
  }

  #projectPanel .notes-list > div button,
  #projectPanel #pdf-list > div button,
  #projectPanel #pdf-list > div a {
    width: 100%;
  }

  #projectPanel .notes-section,
  #projectPanel .panel-list {
    margin-top: 8px;
    padding-top: 18px;
  }

  #projectPanel .notes-list {
    max-height: 32dvh;
    gap: 12px;
    padding-right: 2px;
  }

  #projectPanel .notes-list > div {
    padding: 12px 14px;
    border-radius: 14px;
  }

  #projectPanel #pdf-list {
    gap: 12px;
    margin-top: 12px;
  }

  #projectPanel #pdf-list > div {
    padding: 12px 14px 14px;
    border-radius: 14px;
  }

  #projectPanel #pdf-drop-zone,
  #projectPanel #pdf-upload-btn {
    width: 100%;
  }

  #projectPanel .close-x {
    top: 8px;
    right: 8px;
    font-size: 1.7rem;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  .crm-dashboard {
    padding: 6px;
    gap: 8px;
    align-items: stretch;
  }

  .sidebar {
    padding: 10px;
    border-radius: 16px;
    width: 100%;
    max-width: none;
    margin: 0;
    align-items: stretch;
  }

  .sidebar .search-bar {
    padding: 6px 0 4px;
  }

  .client-list {
    margin-top: 8px;
  }

  .client-item,
  .client-card {
    padding: 12px 12px 14px;
    margin-bottom: 10px;
  }

  .client-item::after,
  .client-card::after {
    left: 8px;
    right: 8px;
  }

  .sidebar h2,
  .sidebar form,
  .search-bar,
  .client-list,
  .clients-workspace {
    width: 100% !important;
    max-width: none !important;
  }

  .clients-workspace {
    align-items: stretch !important;
    width: 100% !important;
    max-width: none !important;
  }

  .clients-workspace h2,
  .clients-workspace form,
  .clients-workspace .search-bar,
  .clients-workspace .client-list {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .clients-workspace form,
  .clients-workspace .input-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }

  .clients-workspace input,
  .clients-workspace select,
  .clients-workspace textarea,
  .clients-workspace button,
  .clients-workspace .btn-primary,
  .clients-workspace .search-bar input,
  .clients-workspace .client-list,
  .clients-workspace .client-item,
  .clients-workspace .client-card {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
  }

  #clientIntakeForm {
    width: 100% !important;
    max-width: none !important;
    align-self: stretch !important;
    margin: 0 0 14px !important;
  }

  .clients-workspace .input-row {
    gap: 10px;
  }

  .sidebar .search-bar,
  .sidebar .client-list {
    margin-inline: 0;
  }

  .sidebar form {
    margin-bottom: 14px;
  }

  .sidebar #fName,
  .sidebar #lName,
  .sidebar #address,
  input[type="email"],
  input[type="tel"],
  .search-bar input,
  .sidebar button.btn-primary {
    width: 100%;
  }

  #projectPanel {
    padding: 8px;
  }

  #projectPanel .detail-card {
    padding: 14px 12px;
    border-radius: 18px;
    width: 100%;
    max-width: none;
    margin: 0 auto;
  }

  #projectPanel .panel-header {
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  #projectPanel .panel-inline-row,
  #projectPanel .panel-balance-row,
  #projectPanel .panel-actions {
    width: 100%;
  }

  #projectPanel .panel-section {
    padding-top: 18px;
    margin-top: 12px;
  }

  #projectPanel .panel-actions .btn-primary {
    width: min(100%, 420px);
  }
}
/* ===== MOBILE CLIENT VIEW SWITCH ===== */
@media (max-width: 768px) {

  .sidebar.mobile-hidden {
    display: none;
  }

  .main-content.mobile-full {
    width: 100%;
  }

}

@media (max-width: 768px) and (orientation: landscape) {
  #Main_header.page-header {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
  }

  .page-title {
    font-size: 1.15rem;
  }

  .page-subtitle {
    display: none;
  }

  .page-header-actions {
    width: auto;
    flex: 0 0 auto;
  }

  .page-header-actions button {
    width: auto;
    padding-inline: 16px;
  }

  .crm-dashboard {
    padding: 10px;
    gap: 10px;
  }

  .sidebar {
    padding: 14px;
  }

  .sidebar .input-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #projectPanel {
    padding: 8px;
  }

  #projectPanel .detail-card {
    padding: 12px;
  }

  #projectPanel .panel-header {
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
  }

  #projectPanel .panel-contact-links {
    margin-left: auto;
    align-items: flex-end;
    width: auto;
  }

  #projectPanel .panel-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* =========================
   DESKTOP CENTERED WORKSPACE
========================= */
@media (min-width: 769px) {
  .crm-dashboard {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0 16px 32px;
  }

  .sidebar,
  .main-content {
    width: min(760px, calc(100vw - 32px));
    max-width: 760px;
  }

  .main-content {
    display: none;
  }
}

/* =========================
   CENTER CLIENT WORKSPACE
========================= */
@media (min-width: 769px) {
  .crm-dashboard {
    justify-content: center !important;
  }

  .sidebar {
    align-items: center !important;
    justify-content: flex-start !important;
    margin-left: auto !important;
    margin-right: auto !important;
    border-right: none !important;
    border: 1px solid var(--border-soft) !important;
    border-radius: 18px !important;
  }

  .clients-workspace {
    width: min(760px, calc(100vw - 32px)) !important;
    max-width: 760px !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  .clients-workspace h2,
  .clients-workspace form,
  .clients-workspace .search-bar,
  .clients-workspace .client-list {
    width: min(680px, calc(100vw - 48px)) !important;
    max-width: 680px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .clients-workspace h2 {
    text-align: center !important;
  }

  .clients-workspace form {
    align-self: center !important;
  }

  .clients-workspace .input-row {
    width: 100%;
  }

  #clientIntakeForm {
    width: min(680px, calc(100vw - 48px)) !important;
    max-width: 680px !important;
  }

  .clients-workspace .search-bar {
    position: sticky;
  }
}



/* =========================
   MOBILE ADJUSTMENTS
========================= */
@media (max-width: 768px) {
  #projectPanel {
    top: 0;
    left: 0;
    transform: none;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    padding: 12px;
  }
}



/* =========================
   CLIENT MODAL PANEL
========================= */

#projectPanel {
  display: none; /* hidden by default */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(720px, 78vw, 980px);
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 25px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);

  z-index: 10000;
}

@media (max-width: 1366px) and (min-width: 769px) {
  #projectPanel {
    width: min(860px, calc(100vw - 28px));
    max-height: calc(100vh - 24px);
    padding: 20px;
  }
}

@media (max-width: 1100px) and (min-width: 769px) {
  #projectPanel {
    width: min(760px, calc(100vw - 20px));
    max-height: calc(100vh - 16px);
    padding: 16px;
    border-radius: 10px;
  }
}


/* dark background overlay */
#projectOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 0;
  pointer-events: none;
}
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 99999;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: 320px;
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-lift);
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--primary); }

/* ============================================================
   v2/v3 UI — jobs, tags, notifications, settings
   ============================================================ */
.user-badge {
  color: var(--text-muted);
}

.icon-btn {
  cursor: pointer;
  border-radius: 10px;
  border: none;
  color: white;
  padding: 10px 12px;
  font-size: 0.95rem;
}

/* Tag filter bar (sidebar) */
.tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
  padding: 8px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  align-items: center;
}
.tag-filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tag-chip {
  background: var(--primary-soft);
  color: var(--accent);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tag-chip:hover { background: var(--primary-soft); }
.tag-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* View toggle (Jobs | Clients) */
.view-toggle {
  display: flex;
  gap: 6px;
  margin: 10px 0 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.view-toggle-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.15s ease, color 0.15s ease;
}
.view-toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Job status filter tabs (front page dashboard) */
.status-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
}
.job-status-tab {
  background: var(--surface);
  border: 1px solid var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.job-status-tab:hover {
  background: var(--surface-muted);
}
.job-status-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Job dashboard cards */
.job-dash-card {
  padding: 12px 14px;
}
.job-dash-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.job-dash-client {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--primary-text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  min-height: 24px;
}
.job-dash-client:hover {
  text-decoration: underline;
}
.job-dash-status {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.job-dash-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.job-dash-sales {
  font-size: 0.8rem;
  color: var(--accent);
}
.job-dash-fin {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--accent);
}
.job-dash-tag {
  background: var(--primary-soft);
  border: 1px solid var(--border-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}
.job-dash-tag:hover {
  background: var(--primary-soft);
}
.job-dash-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

/* Grouped front page: clients with their jobs nested inside */
.grouped-client {
  margin: 0 0 14px;
  padding: 0;
}
.grouped-client-head {
  cursor: pointer;
  margin-bottom: 0;
  padding-bottom: 12px;
}
.grouped-client-head::after {
  display: none;
}
.grouped-client-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.grouped-client-head .client-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.client-primary-tag-mini {
  display: inline-block;
  background: var(--primary-soft);
  border: 1px solid var(--border-soft);
  color: var(--primary-text);
  border-radius: var(--radius-sm);
  padding: 1px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.client-primary-tag-mini:hover {
  background: var(--primary-soft);
}
.grouped-jobs {
  margin: 0 0 8px 14px;
  padding-left: 8px;
  border-left: 2px solid var(--primary-soft);
}
.grouped-jobs .client-card {
  margin-bottom: 6px;
}
.grouped-jobs .client-card::after {
  display: none;
}
.grouped-orphan {
  margin-top: 12px;
}

/* Job tags (inside panels) */
.job-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.job-tag {
  background: var(--primary-soft);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.job-tag-remove { color: var(--danger); font-weight: 700; }

/* Client panel: jobs list */
.client-jobs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.job-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.job-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}
.job-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}
.job-row-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.job-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.job-open-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Job photos grid */
.job-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.job-photo-card {
  position: relative;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
  min-height: 100px;
  display: flex;
  flex-direction: column;
}
.job-photo-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  cursor: pointer;
  display: block;
}
.job-photo-card a {
  color: var(--text-main);
  font-size: 0.82rem;
  text-decoration: none;
  padding: 10px 8px;
}
.job-photo-delete {
  background: rgba(74, 85, 104, 0.9);
  color: #fff;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.72rem;
  margin-top: auto;
}

/* Job finance rows */
.list-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.job-finance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.job-finance-row small { color: var(--text-muted); }
.job-finance-delete:hover { color: var(--text-muted); }

/* Notifications panel */
.notifications-panel {
  position: fixed;
  top: 62px;
  right: 16px;
  width: min(400px, calc(100vw - 32px));
  max-height: 70vh;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  z-index: 10002;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--text-main);
}
.notifications-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.95rem;
}
.notifications-mark-all {
  background: none;
  border: none;
  color: var(--primary-text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.notifications-list {
  overflow-y: auto;
  max-height: 60vh;
}
.notification-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-main);
}
.notification-item:hover { background: var(--surface-muted); }
.notification-item.read { opacity: 0.6; }
.notification-icon { font-size: 1.05rem; }
.notification-body small { color: var(--text-muted); }

/* Settings modal */
.settings-modal {
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
}
.settings-modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  color: var(--text-main);
  padding: 24px;
}
.settings-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.settings-tab {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.settings-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}
.settings-tab-panel { font-size: 0.92rem; }

/* Link-style button */
.link-btn { font-weight: 700; }
.link-btn:hover { text-decoration: underline; }

/* Print: keep only the panel content */
@media print {
  .notifications-panel,
  .settings-modal {
    display: none !important;
  }
}

/* ================================================================
   V3 — Client/Job workspace, tags, sales, line items, disclosure
   ================================================================ */
.client-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  padding: 10px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--surface-muted);
  border-radius: 10px;
}
.client-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}
.client-meta-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.client-meta-value {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}
.sales-chip {
  display: inline-block;
  background: var(--primary-soft);
  border: 1px solid var(--border-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  font-size: 0.78rem;
}
.client-primary-tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.client-primary-tag-chip {
  cursor: pointer;
  font-weight: 600;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
.client-tag-assign {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--border-soft);
  font-size: 0.85rem;
  max-width: 180px;
}
.client-tag-assign option {
  color: var(--text-main);
  background: var(--surface);
}
.client-filter-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 4px;
  padding: 6px 10px;
  background: var(--primary-soft);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--accent);
}
.client-filter-notice-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.client-filter-clear {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 8px;
  min-height: 32px;
  flex-shrink: 0;
}
.client-filter-clear:hover { color: #fff; }
.job-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.job-duplicate-btn {
  background: var(--border-soft);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
.job-row-meta span { margin-right: 12px; white-space: nowrap; }
.job-tag { font-family: inherit; }
.tag-chip-clear {
  background: rgba(232, 72, 77, 0.2);
  border-color: rgba(232, 72, 77, 0.4);
  color: var(--danger);
}

/* Collapsible sections (progressive disclosure) */
.panel-collapse { margin-top: 6px; }
.panel-collapse > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-soft);
  list-style-position: inside;
}
.panel-collapse > summary:hover { color: var(--primary-text); }
.panel-inner-grid { margin-top: 12px; }

/* Comfortable tap targets + no horizontal overflow on phones */
@media (max-width: 768px) {
  /* html is left alone on purpose. This used to set overflow-x: hidden on
     html AND body; with html no longer "visible", body stopped handing its
     overflow to the viewport and became its own (never-scrolling) scroll
     container. Mouse-wheel/trackpad scrolling then went to body and did
     nothing — split-screen and small windows could only be scrolled by
     dragging the scrollbar. body alone propagates to the viewport; clip
     (where supported) hides sideways overflow without any scroll container. */
  body, body.dashboard-body { overflow-x: hidden; }
  @supports (overflow-x: clip) {
    body, body.dashboard-body { overflow-x: clip; }
  }
  .job-row {
    flex-direction: column;
    align-items: stretch;
  }
  .job-row-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .job-row-meta span {
    display: inline-block;
    margin: 2px 8px 2px 0;
    white-space: normal;
  }
  .job-open-btn, .job-duplicate-btn, .sales-assign, .tag-chip, .job-tag, .client-filter-clear, .job-status-tab, .job-dash-tag, .job-dash-client {
    min-height: 40px;
  }
  .client-meta-item { min-width: 100%; }
  .panel-inline-row { flex-wrap: wrap; }
  #projectPanel input, #projectPanel select, #projectPanel textarea {
    max-width: 100%;
  }
}

/* ======================================================
   Restored: JOB MODAL, LINE ITEMS, JOB NOTES, JOB FILES,
   DETAILS GRID — these CRM-only components had no CSS at
   all after the Devries style.css copy (Devries doesn't
   have this feature), which broke the job modal's layout
   entirely. Restored from pre-redesign git history and
   already used the current token names verbatim.
   ====================================================== */

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.details-grid input,
.details-grid select,
.details-grid textarea {
  padding: 10px 12px;
  width: 100%;
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.details-grid input:focus,
.details-grid select:focus,
.details-grid textarea:focus,
.notes-actions textarea:focus {
  box-shadow: 0 0 0 3px var(--primary-soft);
  border-color: var(--primary);
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.client-stage-field select {
  font-weight: 700;
}

/* ======================================================
   + JOB button (top of Client Workspace)
   ====================================================== */
.add-job-row {
  display: flex;
}

.add-job-btn {
  width: 100%;
}

/* ======================================================
   JOB / NEW-JOB MODALS (Section 5) — shared responsive shell
   ====================================================== */
.job-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  padding: 16px;
  overflow-y: auto;
}

.job-modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lift);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.job-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: var(--tap-size);
  height: var(--tap-size);
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.job-modal-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.job-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.job-modal-field label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.job-modal-field input,
.job-modal-field select,
.job-modal-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background:var(--surface);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
}

.job-modal-field textarea {
  resize: vertical;
}

.job-title-input {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--border-soft) !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
}

.job-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.job-modal-readout {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border:1px solid var(--border-soft);
  font-weight: 700;
  min-height: var(--tap-size);
  display: flex;
  align-items: center;
}

.job-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.job-modal-actions .btn-primary {
  flex: 1 1 160px;
}

.job-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.job-payment-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.job-payment-row input {
  flex: 1 1 160px;
}

.job-payment-row button {
  flex: 0 0 auto;
}

/* ======================================================
   JOB TAGS (Section 2/7) — distinct from client stage & job status
   ====================================================== */
.job-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.job-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  font-size: 0.82rem;
  color: var(--text-main);
}

.job-tag-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  min-height: auto;
  padding: 0 2px;
}

.job-tag-add-row input {
  width: 100%;
}

/* ======================================================
   JOB LINE ITEMS (Section 1) — estimate/invoice cost breakdown
   ====================================================== */
.job-line-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.job-line-item-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border:1px solid var(--border-soft);
  font-size: 0.85rem;
}

.li-category-badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  color: var(--primary-hover);
  font-size: 0.72rem;
  white-space: nowrap;
}

.li-amount {
  font-weight: 700;
  white-space: nowrap;
}

.li-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  min-height: auto;
  padding: 0 4px;
}

.job-line-item-total {
  text-align: right;
  font-weight: 700;
  padding: 6px 10px;
}

.job-line-item-add-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.7fr 1fr auto;
  gap: 8px;
}

/* ======================================================
   JOB NOTES (job details panel) — same look as the client notes panel,
   scoped to a single job.
   ====================================================== */
.job-notes-field .notes-list {
  max-height: 220px;
  overflow-y: auto;
}

.job-note-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.job-note-content {
  flex: 1;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

.job-note-edit-textarea {
  flex: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-main);
  font-family: inherit;
  resize: vertical;
}

/* Note Edit/Delete/Save/Cancel use .btn-* .btn-sm (see CONTROLS). */
.job-note-action-btn { flex: 0 0 auto; }

/* ======================================================
   JOB FILES — Documents & Photos (separate categories, same component)
   ====================================================== */
.job-files-field .field-hint {
  margin-top: -4px;
  margin-bottom: 4px;
}

.job-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 32px;
}

.job-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.85rem;
}

.job-file-name {
  flex: 1;
  color: var(--primary-text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-file-name:hover {
  text-decoration: underline;
}

.job-file-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.job-file-delete-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  min-height: auto;
  padding: 0 4px;
  flex: 0 0 auto;
}

.job-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.job-photo-thumb {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: var(--surface-muted);
}

.job-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.job-photo-thumb .job-file-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  border-radius: 999px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.job-files-upload-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.job-file-progress {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.job-file-progress-track {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.job-file-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.job-file-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ======================================================
   RESPONSIVE: tablet / mobile collapse for job modals
   ====================================================== */
@media (max-width: 640px) {
  .job-modal-card {
    padding: 16px;
    max-height: 95vh;
  }

  .job-modal-grid {
    grid-template-columns: 1fr;
  }

  .job-modal-actions .btn-primary {
    flex: 1 1 100%;
  }

  .job-line-item-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "desc desc"
      "cat qty"
      "amount remove";
  }

  .job-line-item-row .li-desc { grid-area: desc; }
  .job-line-item-row .li-category-badge { grid-area: cat; }
  .job-line-item-row .li-qty { grid-area: qty; }
  .job-line-item-row .li-amount { grid-area: amount; }
  .job-line-item-row .li-remove { grid-area: remove; justify-self: end; }

  .job-line-item-add-grid {
    grid-template-columns: 1fr 1fr;
  }

  .job-files-upload-row {
    flex-direction: column;
  }

  .job-files-upload-row .panel-secondary-btn {
    width: 100%;
  }

  .job-photos-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }

  .job-file-row {
    flex-wrap: wrap;
  }
}

/* ======================================================
   RESPONSIVE FIXES (mobile audit)
   Targeted fixes for issues measured at 320–1024px widths.
   Placed last so they win over the earlier (partly !important)
   mobile blocks without editing those blocks.
   ====================================================== */

/* Workspace was 40px wider than the sidebar's content box, so the sidebar
   scrolled sideways at every width above 768px. Cap it to its container;
   the inner 680px column is unchanged, so the layout looks the same. */
@media (min-width: 769px) {
  .clients-workspace {
    max-width: 100% !important;
  }
}

@media (max-width: 768px) {
  /* Top nav: links overflowed the bar on narrow phones, which clipped the
     role badge and pushed the theme toggle off-screen (unreachable). */
  .top-nav .nav-links {
    flex-wrap: wrap;
    row-gap: 6px;
    max-width: 100%;
  }
  .top-nav .nav-links a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .theme-toggle-btn {
    width: var(--tap-size);
    min-height: var(--tap-size);
    flex-shrink: 0;
  }
  .role-badge {
    font-size: 0.7rem;
  }

  /* Search row: the portrait rule that makes every workspace button 100%
     wide also caught the filter button, squashing the search input to
     ~22px. Keep the input flexible and the filter button square. */
  .clients-workspace .search-bar input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
  }
  .clients-workspace .search-bar .filter-toggle-btn {
    flex: 0 0 var(--tap-size);
    width: var(--tap-size) !important;
    min-height: var(--tap-size);
  }

  /* Client panel: .details-grid stayed 2 columns while its full-span rows
     were reset to one column, so labels landed beside the wrong fields and
     inline `grid-column: span 2` items pushed the card to scroll sideways.
     !important is needed to beat those inline styles. */
  #projectPanel .details-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  #projectPanel .details-grid > * {
    grid-column: 1 / -1 !important;
    min-width: 0;
  }

  #projectPanel .close-x {
    width: var(--tap-size);
    height: var(--tap-size);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
  }

  #projectPanel .panel-contact-links a,
  #projectPanel .maps-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
  }
}

/* Touch devices wider than the 768px breakpoint (landscape phones,
   tablets) keep the desktop layout but still need finger-sized targets.
   Mouse/trackpad users are unaffected. */
@media (pointer: coarse) {
  .theme-toggle-btn {
    width: var(--tap-size);
    min-height: var(--tap-size);
    flex-shrink: 0;
  }
  .role-badge {
    font-size: 0.7rem;
  }
  #projectPanel .close-x {
    width: var(--tap-size);
    height: var(--tap-size);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
  }
  #projectPanel .panel-contact-links a,
  #projectPanel .maps-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
  }
}

/* ======================================================
   CLIENT OVERVIEW + JOB WORKSPACE (redesign)
   The client page is a condensed overview (totals, people, jobs); the
   detailed work lives in the + Job workspace. Uses the existing tokens so
   light and dark mode both follow the theme.
   ====================================================== */

/* Secondary / quiet buttons, readable in both themes. These replace inline
   "surface-muted background + white text" buttons that were white-on-white
   in light mode. */
.btn-primary.btn-quiet {
  background: var(--surface-muted);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn-primary.btn-quiet:hover { background: var(--border-soft); }
.btn-primary.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid var(--danger);
}
.btn-primary.btn-danger-soft:hover { background: var(--danger); color: #fff; }

/* Leftovers from the dark-only Devries theme that painted white text on
   the light theme's white surfaces. */
.panel-collapse > summary { color: var(--text-main); }
.panel-metric strong { color: var(--text-main); }

/* ---------- Homepage sidebar ---------- */
.filter-toggle-btn.has-active-filters {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-text);
}
.client-card .client-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.client-card .client-card-top .client-status { flex-shrink: 0; margin-top: 0; }
.client-card .client-meta-email { font-size: 0.82rem; }
.client-people {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-main);
}
.client-people-label {
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 2px;
}
.client-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 2px 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.client-group-header span { font-weight: 600; letter-spacing: 0; }

/* ---------- Client overview ---------- */
.client-overview-name {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.stage-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.client-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 2px;
}
.total-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  min-width: 0;
}
.total-tile-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.total-tile-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  overflow-wrap: anywhere;
}
.total-tile-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.client-totals-note {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Jobs list: one row per job, then + Job */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.jobs-empty {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: 4px 2px;
}
.jobs-list .job-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 2fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text-main);
  cursor: pointer;
  border-left: 4px solid var(--border-strong);
}
.jobs-list .job-row:hover,
.jobs-list .job-row:focus-visible {
  border-color: var(--primary);
  outline: none;
}
.job-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.jobs-list .job-row-title {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-row-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.job-row-status {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.job-row-status-neutral {
  color: var(--text-muted);
  background: var(--surface);
  border-color: var(--border-strong);
}
.job-row-money {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
}
.job-row-money > span { white-space: nowrap; }
.job-row-money-label {
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 2px;
}
.jobs-list .job-row-account {
  border-left-style: dashed;
  background: var(--surface);
}
.jobs-list .add-job-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px dashed var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}
.jobs-list .add-job-btn:hover { background: var(--primary); color: #fff; }

.panel-collapse > summary .summary-count {
  font-weight: 600;
  color: var(--text-muted);
}
#client-notes-details .notes-section { padding-top: 10px; }
#client-notes-details .notes-section > .panel-section-note { display: block; margin-bottom: 8px; }

/* ---------- Job workspace / client account ---------- */
.job-modal-card.job-workspace { width: min(920px, 100%); }
.job-workspace-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: calc(var(--tap-size) + 4px);
}
.job-workspace-top .save-status-chip { margin-left: auto; }
.job-workspace-heading { margin: -8px 0 0; font-size: 1.15rem; color: var(--text-main); }
.job-head-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1.6fr);
  gap: 12px;
  align-items: start;
}
.job-tags-field .job-tags-list { min-height: 0; }
.job-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}
.job-section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}
.job-money-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.job-money-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.job-modal-field input.is-computed {
  background: var(--surface-muted);
  color: var(--text-main);
  cursor: default;
}
.job-payments-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.job-payment-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--text-main);
}
.job-payment-item span:first-child { color: var(--text-muted); }
.job-payment-item.is-correction strong { color: var(--danger); }

.job-services-list { display: flex; flex-direction: column; gap: 6px; }
.job-services-table { display: flex; flex-direction: column; gap: 6px; }
.job-services-head,
.job-service-row {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.2fr) minmax(0, 0.6fr) minmax(0, 0.9fr) minmax(0, 0.9fr) 32px;
  gap: 8px;
  align-items: center;
}
.job-services-head {
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.job-service-row {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  font-size: 0.88rem;
  color: var(--text-main);
}
.job-service-row input,
.job-service-row select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
}
.job-service-row .li-num { text-align: right; }
.job-service-row .li-amount { text-align: right; }
.job-service-row .li-remove { color: var(--danger-text); font-size: 1.2rem; }
.job-services-table.is-readonly .job-service-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.job-services-table.is-readonly .li-qty { color: var(--text-muted); white-space: nowrap; }
.job-services-total {
  text-align: right;
  padding: 2px 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.job-services-total strong { color: var(--text-main); margin-left: 6px; }
.job-services-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.job-services-actions .btn-primary { padding: 8px 14px; font-size: 0.9rem; }
/* Estimate & invoice pricing: one total, or each service with its price. */
.job-pricing-display { align-items: flex-start; }
.job-pricing-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.job-pricing-display .segmented-toggle { max-width: 100%; }
.job-pricing-display .segmented-toggle-btn { flex: 1 1 auto; font-size: 0.9rem; line-height: 1.2; padding: 6px 14px; }
@media (max-width: 480px) {
  .job-pricing-display .segmented-toggle { width: 100%; }
  .job-pricing-display .segmented-toggle-btn { flex: 1 1 0; padding: 6px 8px; }
}
.job-line-item-add-grid[hidden] { display: none; }
.job-line-item-add-grid input,
.job-line-item-add-grid select {
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-main);
  font-family: inherit;
}
.job-client-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.job-client-files[hidden] { display: none; }
.job-client-files-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}
.job-client-files-title span { font-weight: 400; color: var(--text-muted); }
.job-client-files-list { display: flex; flex-direction: column; gap: 6px; }
.job-file-action {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-text);
  text-decoration: none;
  white-space: nowrap;
}
.job-file-action:hover { text-decoration: underline; }
.job-file-row .job-file-delete-btn { color: var(--danger-text); }
.scope-services-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; }

/* ---------- Service preset picker ---------- */
.picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Same layer as the job workspace; later dialogs (e.g. Manage Presets)
     stack on top because they are added to the page after it. */
  z-index: 20000;
  padding: 16px;
}
.picker-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lift);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.picker-heading { margin: 0; font-size: 1.1rem; color: var(--text-main); }
.picker-list { display: flex; flex-direction: column; gap: 6px; }
.picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--surface-muted);
  cursor: pointer;
  color: var(--text-main);
}
.picker-row:hover { border-color: var(--primary); }
.picker-row input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.picker-row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.picker-row-name { font-weight: 600; font-size: 0.92rem; }
.picker-row-desc { font-size: 0.78rem; color: var(--text-muted); }
.picker-row-rate { font-weight: 700; color: var(--text-main); white-space: nowrap; }
.picker-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.picker-actions .btn-primary { flex: 1 1 120px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .job-head-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-head-grid .job-tags-field { grid-column: 1 / -1; }
  .jobs-list .job-row { grid-template-columns: minmax(0, 1fr) auto; }
  .jobs-list .job-row .job-row-money { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 768px) {
  .client-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jobs-list .job-row { flex-direction: unset; align-items: center; }
}
@media (max-width: 640px) {
  .job-head-grid,
  .job-money-inputs { grid-template-columns: 1fr; }
  .job-services-head { display: none; }
  .job-service-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 32px;
    grid-template-areas:
      "desc desc desc remove"
      "cat cat cat cat"
      "qty price amount amount";
  }
  .job-service-row [data-field="description"] { grid-area: desc; }
  .job-service-row [data-field="category"] { grid-area: cat; }
  .job-service-row [data-field="quantity"] { grid-area: qty; }
  .job-service-row [data-field="unit_price"] { grid-area: price; }
  .job-service-row .li-amount { grid-area: amount; }
  .job-service-row .li-remove { grid-area: remove; }
  .job-services-table.is-readonly .job-service-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: none;
  }
  .job-payment-item { grid-template-columns: 1fr auto; }
  .job-payment-item span:nth-child(2) { display: none; }
}
@media (max-width: 380px) {
  .client-totals { gap: 6px; }
  .total-tile { padding: 8px; }
  .total-tile-value { font-size: 1rem; }
}

/* Upload buttons inside the job workspace / client account */
.job-section .panel-secondary-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.job-section .panel-secondary-btn:hover { background: var(--surface-muted); }

/* Money still owed stands out, in a shade readable in both themes. */
.total-tile.is-due .total-tile-value,
.job-row-money .is-due { color: var(--warning-text); }

/* Placeholder text readable in both themes (browser defaults were a faded
   copy of the text color — about 3.5:1 on the dark theme). */
input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

/* ---------- Job Costs (itemized expenses by category) ---------- */
.job-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.job-section-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-text);
  text-decoration: none;
}
.job-section-link:hover { text-decoration: underline; }
.job-cost-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.job-cost-cat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--text-main);
}
.job-cost-cat-name { color: var(--text-muted); font-weight: 600; }
.job-cost-cat strong { font-size: 1rem; color: var(--text-main); }
.job-cost-inactive { font-weight: 400; font-style: italic; }
.job-cost-total { border-color: var(--border-strong); background: var(--surface); }
.job-cost-total span { color: var(--text-main); font-weight: 700; }
.job-expenses-table { display: flex; flex-direction: column; gap: 6px; }
.job-expenses-head,
.job-expense-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
}
.job-expenses-head {
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.job-expense-row {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
}
.job-expense-row input,
.job-expense-row select,
.job-expense-add-grid input,
.job-expense-add-grid select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
}
.job-expense-row .exp-amount,
.job-expense-add-grid #exp-amount { text-align: right; }
.job-expense-row .exp-remove {
  border: none;
  background: transparent;
  color: var(--danger-text);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  min-height: auto;
  padding: 0 4px;
}
.job-expense-add-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.job-expense-add-grid .btn-primary { padding: 8px 14px; font-size: 0.9rem; }
@media (max-width: 640px) {
  .job-expenses-head { display: none; }
  .job-expense-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px;
    grid-template-areas:
      "desc desc remove"
      "cat amount amount";
  }
  .job-expense-row [data-field="description"] { grid-area: desc; }
  .job-expense-row [data-field="category_id"] { grid-area: cat; }
  .job-expense-row [data-field="amount"] { grid-area: amount; }
  .job-expense-row .exp-remove { grid-area: remove; }
  .job-expense-add-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .job-expense-add-grid #exp-description { grid-column: 1 / -1; }
  .job-expense-add-grid .btn-primary { grid-column: 1 / -1; }
}

/* =========================
   COMPACT LAYOUT PREFERENCE
   Settings -> Preferences -> "Compact dashboard layout" (html.crm-compact,
   set by public/js/theme.js). Only tightens spacing on the Clients page.
========================= */
html.crm-compact .crm-dashboard .sidebar { padding: 12px 14px; }
html.crm-compact .sidebar h2 { margin-bottom: 8px; }
html.crm-compact .sidebar form { margin-bottom: 12px; gap: 6px; }
html.crm-compact .client-card { padding: 7px 10px; margin-bottom: 4px; }
html.crm-compact .client-item + .client-item,
html.crm-compact .client-card + .client-card { margin-top: 4px; }
html.crm-compact #Main_header { padding-top: 8px; padding-bottom: 8px; }

/* =========================
   JOB DOCUMENTS / PHOTOS DRAG-AND-DROP
   The upload row is drawn as a drop zone; the whole section accepts
   dropped files and is highlighted while files are dragged over it.
========================= */
.job-dropzone {
  align-items: center;
  flex-wrap: wrap;
  padding: 12px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md, 10px);
  background: var(--surface-muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.job-dropzone-text {
  flex: 1 1 auto;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.job-files-field.is-dragover {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-md, 10px);
}
.job-files-field.is-dragover .job-dropzone {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.job-files-field.is-dragover .job-dropzone-text { color: var(--primary-text, var(--primary)); font-weight: 600; }
.job-dropzone.is-uploading { opacity: 0.7; }
/* Phones/tablets can't drag files from another app into the page. */
@media (pointer: coarse) {
  .job-dropzone { border-style: solid; border-width: 1px; background: transparent; padding: 0; border-color: transparent; }
  .job-dropzone-text { display: none; }
}
@media (max-width: 640px) {
  .job-dropzone-text { text-align: center; }
}

/* The single Job Cost field is only shown before the v7 migration; the
   display:flex on .job-modal-field would otherwise override [hidden]. */
.job-modal-field[hidden] { display: none; }
/* Upload progress shows only while uploading (display:flex overrode [hidden]). */
.job-file-progress[hidden] { display: none; }

/* Read-only Cost tile in the job's Money section (set by Job Costs). */
.total-tile.is-readonly .total-tile-sub { color: var(--text-muted); }

/* An older job's single typed-in cost, shown in Job Costs. */
.job-cost-legacy {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md, 10px);
  background: var(--surface-muted);
}
.job-cost-legacy-text { flex: 1 1 240px; display: flex; flex-direction: column; gap: 2px; }

/* =====================================================================
   CONTROLS — one system for every button, input, select and toggle
   ---------------------------------------------------------------------
   This is the last word on how controls LOOK (size, border, radius,
   colour, focus). Component rules above still decide layout (width,
   flex, grid placement). Sizes:
     default  40px tall  — forms, primary actions
     compact  34px tall  — dense rows (services, costs, table actions)
   Touch screens and phones get 44px (see the end of this section).
   ===================================================================== */
:root {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --control-h: 40px;
  --control-h-sm: 34px;
  --control-radius: 8px;
  --control-font: 0.9rem;
  --control-font-sm: 0.84rem;
  --control-pad-x: 12px;
  --btn-pad-x: 16px;
  --btn-pad-x-sm: 12px;
  --control-bg: var(--surface);
  --control-border: var(--border-strong);
  --control-border-hover: #9aa6b8;
  --control-disabled-bg: var(--surface-muted);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.28);
  --danger-solid: #dc2626;
  --danger-solid-hover: #b91c1c;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}
:root[data-theme="dark"] {
  --control-bg: #111c30;
  --control-border: #3d4f6b;
  --control-border-hover: #5b6f8f;
  --control-disabled-bg: #1a2539;
  --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.35);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aab4c8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* Native dropdown lists, date pickers and scrollbars follow the theme. */
  color-scheme: dark;
}

/* One typeface everywhere ('Nunito' was never loaded, so the browser fell
   back to Arial, and to Arial Black for the heavy headings). */
*,
body,
body.dashboard-body { font-family: var(--font-ui); }
h1, h2, h3, h4, .page-title, .stat-value, .total-tile-value { font-weight: 700; }

/* The hidden attribute always wins (display:inline-flex on buttons below
   would otherwise un-hide e.g. Expense Categories' "Save name"). */
[hidden] { display: none !important; }

/* ---------- Text inputs, selects, textareas ---------- */
input:not([type="checkbox"], [type="radio"], [type="file"], [type="color"], [type="range"], [type="hidden"], [type="button"], [type="submit"]),
select:not([hidden]),
textarea:not([hidden]) {
  min-height: var(--control-h);
  padding: 8px var(--control-pad-x);
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  background-color: var(--control-bg);
  color: var(--text-main);
  font-size: var(--control-font);
  line-height: 1.35;
  outline: none;
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
textarea:not([hidden]) { line-height: 1.5; }
input:not([type="checkbox"], [type="radio"], [type="file"], [type="color"], [type="range"], [type="hidden"], [type="button"], [type="submit"]):hover:not(:disabled):not(:focus),
select:not([hidden]):hover:not(:disabled):not(:focus),
textarea:not([hidden]):hover:not(:disabled):not(:focus) {
  border-color: var(--control-border-hover);
}
input:not([type="checkbox"], [type="radio"], [type="file"], [type="color"], [type="range"], [type="hidden"], [type="button"], [type="submit"]):focus,
select:not([hidden]):focus,
textarea:not([hidden]):focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background-color: var(--control-bg);
}
/* Read-only: tinted background, but the value stays fully readable. */
input[readonly]:not([type="checkbox"], [type="radio"]),
textarea[readonly] {
  background-color: var(--control-disabled-bg);
  color: var(--text-main);
  cursor: default;
}
/* Disabled: tinted and dimmed, clearly not editable. */
input:disabled, select:not([hidden]):disabled, textarea:not([hidden]):disabled {
  background-color: var(--control-disabled-bg);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 1;
}

/* Selects: one chevron, text never runs under it, readable options. */
select:not([hidden]) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  text-overflow: ellipsis;
  cursor: pointer;
}
select[multiple], select[size]:not([size="1"]) {
  padding-right: var(--control-pad-x);
  background-image: none;
}
select:not([hidden]) option, select optgroup {
  background-color: var(--surface);
  color: var(--text-main);
}

/* Number/date inputs: no spinner arrows; native date picker kept. */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.75; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Checkboxes/radios: native, brand-coloured, never stretched to 40px. */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

/* File inputs (Settings logo etc.): the picker button matches .btn-secondary. */
input[type="file"] {
  min-height: 0;
  font-size: var(--control-font-sm);
  color: var(--text-muted);
}
input[type="file"]::file-selector-button {
  height: var(--control-h-sm);
  margin-right: 10px;
  padding: 0 var(--btn-pad-x-sm);
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--text-main);
  font: 600 var(--control-font-sm) var(--font-ui);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-muted); }

/* ---------- Buttons ----------
   primary    .btn-primary, .job-open-btn
   secondary  .btn-secondary, .btn-primary.btn-quiet, .panel-secondary-btn,
              .job-duplicate-btn, header/modal ".secondary" buttons
   danger     .btn-danger, .btn-primary.btn-danger-soft
   small      add .btn-sm */
.btn-primary,
.btn-secondary,
.btn-danger,
.panel-secondary-btn,
.mt-action-btn,
.mt-icon-btn,
.job-open-btn,
.job-duplicate-btn,
.filter-toggle-btn,
.page-header-actions button,
.email-settings-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 0 var(--btn-pad-x);
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-family: var(--font-ui);
  font-size: var(--control-font);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transform: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}
/* Primary */
.btn-primary,
.mt-action-btn,
.mt-icon-btn,
.job-open-btn,
.page-header-actions button:not(.secondary),
.email-settings-actions button:not(.secondary) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled),
.mt-action-btn:hover:not(:disabled),
.mt-icon-btn:hover:not(:disabled),
.job-open-btn:hover:not(:disabled),
.page-header-actions button:not(.secondary):hover:not(:disabled),
.email-settings-actions button:not(.secondary):hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn-primary:active:not(:disabled),
.job-open-btn:active:not(:disabled) { background: #1e40af; border-color: #1e40af; }

/* Secondary */
.btn-secondary,
.btn-primary.btn-quiet,
.mt-action-btn.secondary,
.panel-secondary-btn,
.job-duplicate-btn,
.filter-toggle-btn,
.page-header-actions button.secondary,
.email-settings-actions button.secondary {
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--text-main);
}
.btn-secondary:hover:not(:disabled),
.btn-primary.btn-quiet:hover:not(:disabled),
.mt-action-btn.secondary:hover:not(:disabled),
.panel-secondary-btn:hover:not(:disabled),
.job-duplicate-btn:hover:not(:disabled),
.filter-toggle-btn:hover:not(:disabled),
.page-header-actions button.secondary:hover:not(:disabled),
.email-settings-actions button.secondary:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: var(--control-border-hover);
  color: var(--text-main);
}
.btn-secondary:active:not(:disabled),
.btn-primary.btn-quiet:active:not(:disabled),
.panel-secondary-btn:active:not(:disabled) { background: var(--border-soft); }

/* Destructive: outlined red, fills solid red on hover. */
.btn-danger,
.btn-primary.btn-danger-soft {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger-text);
}
.btn-danger:hover:not(:disabled),
.btn-primary.btn-danger-soft:hover:not(:disabled) {
  background: var(--danger-solid);
  border-color: var(--danger-solid);
  color: #fff;
}
.btn-danger:active:not(:disabled),
.btn-primary.btn-danger-soft:active:not(:disabled) { background: var(--danger-solid-hover); border-color: var(--danger-solid-hover); }

/* Small */
.btn-sm,
.btn-primary.btn-sm,
.btn-secondary.btn-sm,
.btn-danger.btn-sm,
.job-open-btn,
.job-duplicate-btn {
  min-height: var(--control-h-sm);
  padding: 0 var(--btn-pad-x-sm);
  font-size: var(--control-font-sm);
}

/* Square icon buttons (filter, theme) */
.filter-toggle-btn,
.theme-toggle-btn {
  width: var(--control-h);
  min-width: var(--control-h);
  min-height: var(--control-h);
  padding: 0;
  border-radius: var(--control-radius);
}
.theme-toggle-btn { border-color: var(--control-border); }
.filter-toggle-btn.has-active-filters {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-text);
}

/* Disabled — every button type */
button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.panel-secondary-btn:disabled,
button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Keyboard focus: a visible ring on every control, nothing on mouse click */
button:focus-visible,
a.btn-primary:focus-visible,
a.btn-secondary:focus-visible,
.top-nav .nav-links a:focus-visible,
.tab-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
button:focus:not(:focus-visible) { outline: none; }

/* Lucide icons inside buttons sit on the text's centre line */
button [data-lucide],
button svg.lucide {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Text links that act as buttons stay links (no box) */
.link-btn {
  background: none;
  border: none;
  padding: 4px 2px;
  min-height: 0;
  color: var(--primary-text);
  font-weight: 600;
  font-size: var(--control-font-sm);
  cursor: pointer;
}

/* Compact controls for dense, repeated rows (existing services and costs,
   filter/sort bar, category table). Add-rows below them stay full size. */
.job-service-row :is(input, select),
.job-expense-row :is(input, select),
.filter-row :is(input, select),
.sort-row select:not([hidden]),
.expense-cat-table input {
  min-height: var(--control-h-sm);
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: var(--control-font-sm);
}

/* Phones and touch screens: 44px targets; 16px text stops iOS zooming in. */
@media (max-width: 768px), (pointer: coarse) {
  :root {
    --control-h: 44px;
    --control-h-sm: 40px;
  }
}
@media (max-width: 768px) {
  input:not([type="checkbox"], [type="radio"], [type="file"], [type="color"], [type="range"], [type="hidden"], [type="button"], [type="submit"]),
  select:not([hidden]),
  textarea:not([hidden]) { font-size: 16px; }
}

/* Page header (Clients, Finance): centred over the centred content, with
   normal-weight subtitle (it inherited #Main_header's 900 weight). */
#Main_header.page-header {
  font-weight: 400;
  text-align: center;
  justify-content: center;
}
#Main_header .page-header-copy {
  width: 100%;
  align-items: center;
}
#Main_header .page-title { font-size: 1.5rem; }
#Main_header .page-subtitle { font-weight: 400; margin-inline: auto; }
@media (max-width: 768px) {
  #Main_header .page-title { font-size: clamp(1.15rem, 5vw, 1.4rem); }
}

/* ---------- Close buttons (client panel, job workspace, modals) ----------
   One square, quiet icon button in the top-right corner. */
.close-x,
.job-modal-close,
.email-settings-close,
#pdfModalClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.close-x:hover,
.job-modal-close:hover,
.email-settings-close:hover,
#pdfModalClose:hover {
  background: var(--surface-muted);
  border-color: var(--border-soft);
  color: var(--text-main);
}
.close-x { top: 14px; right: 14px; }
.job-modal-close { top: 14px; right: 14px; }
/* Keep the "Saved" chip clear of the close button. */
#projectPanel .panel-header,
.job-workspace-top { padding-right: 44px; }
@media (max-width: 768px), (pointer: coarse) {
  .close-x, .job-modal-close, .email-settings-close, #pdfModalClose,
  #projectPanel .close-x { width: var(--tap-size); height: var(--tap-size); }
  #projectPanel .panel-header, .job-workspace-top { padding-right: 52px; }
}

/* ---------- Client details: label beside its field ----------
   Labels were in a 50% column far from their fields and top-aligned
   against vertically centred inputs. */
@media (min-width: 769px) {
  #projectPanel .details-grid {
    grid-template-columns: minmax(120px, 170px) minmax(0, 1fr);
    column-gap: 20px;
    row-gap: 12px;
    align-items: start;
  }
  #projectPanel .details-grid > label {
    padding-top: 10px;
  }
}
#projectPanel .details-grid > label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}
.save-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-text);
}

/* Filter panel spans the client list; its Clear button matches the
   compact filter controls. */
.filter-panel { align-self: stretch; margin-inline: 0; }
.filter-actions .btn-secondary { min-height: var(--control-h-sm); font-size: var(--control-font-sm); }

/* Colour pickers (Settings -> Branding) match the other fields. */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 4px;
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  background: var(--control-bg);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }

/* Narrow phones: keep nav links, role badge and theme toggle on one row. */
@media (max-width: 480px) {
  .top-nav .nav-links { gap: 2px; }
  .top-nav .nav-links a { padding: 6px 9px; }
  .role-badge { margin-left: 2px; }
}

/* Placeholders inside read-only fields sit on the tinted background, so
   they use the darker muted colour to stay readable (4.5:1+). */
input[readonly]::placeholder,
textarea[readonly]::placeholder { color: var(--text-muted); }

/* ===== Job schedule fields (job window) ===== */
.job-duration-row { display: flex; align-items: center; gap: 8px; }
.job-duration-row input { width: 90px; flex: 0 0 auto; }
.job-duration-row span { color: var(--text-muted); font-size: 0.9rem; }
.job-schedule-hint { margin: -4px 0 12px; }

/* ===== Calendar page ===== */
/* Same compact, centred page header as the Clients and Finance pages. */
.calendar-page header#Main_header {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 16px 24px; margin-bottom: 20px; background: var(--surface); color: var(--text-main);
  border-bottom: 1px solid var(--border-soft); box-shadow: var(--shadow-soft);
  font-size: 1rem; font-weight: 400; width: 100%; box-sizing: border-box;
}
.calendar-page .page-header-copy { display: flex; flex-direction: column; gap: 4px; }
.calendar-page .page-kicker { font-size: 0.75rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--primary-text); font-weight: 700; }
.calendar-page .page-title { font-size: 1.45rem; font-weight: 800; line-height: 1.1; color: var(--text-main); }
.calendar-page .page-subtitle { margin: 0; font-size: 0.92rem; color: var(--text-muted); max-width: 72ch; }
.cal-page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px 40px; box-sizing: border-box; align-self: center; }
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.cal-arrow { padding: 0 10px; min-width: var(--control-h, 40px); }
.cal-title { margin: 0 0 0 6px; font-size: 1.2rem; font-weight: 700; color: var(--text-main); }
.cal-views, .segmented-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--control-radius, 8px); overflow: hidden; }
.cal-view-btn, .segmented-toggle-btn {
  border: none; background: var(--surface); color: var(--text-main); padding: 0 16px;
  min-height: var(--control-h, 40px); font-weight: 600; cursor: pointer;
}
.cal-view-btn + .cal-view-btn, .segmented-toggle-btn + .segmented-toggle-btn { border-left: 1px solid var(--border-strong); }
.cal-view-btn.is-active, .segmented-toggle-btn.is-active { background: var(--primary); color: #fff; }
.cal-notice { padding: 10px 14px; border-radius: var(--radius-md); margin-bottom: 12px; background: var(--surface-muted); color: var(--text-main); border: 1px solid var(--border-soft); }
.cal-notice.is-warning { background: var(--warning-soft); color: var(--warning-text); }
.cal-notice.is-error { background: var(--danger-soft); color: var(--danger-text); }
.cal-body { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); overflow: hidden; }
.cal-loading, .cal-empty { padding: 32px 20px; text-align: center; color: var(--text-muted); }
.cal-empty-hint { margin: 0; padding: 12px 16px; color: var(--text-muted); font-size: 0.9rem; border-top: 1px solid var(--border-soft); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border-soft); background: var(--surface-muted); }
.cal-weekdays div { padding: 8px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.cal-week {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 110px;
  row-gap: 3px; padding-bottom: 6px; position: relative; border-bottom: 1px solid var(--border-soft);
}
.cal-month .cal-week:last-child { border-bottom: none; }
.cal-week.is-tall { min-height: 360px; }
.cal-day-bg { border-right: 1px solid var(--border-soft); }
.cal-day-bg.is-last { border-right: none; }
.cal-day-bg.is-outside { background: var(--surface-muted); }
.cal-day-bg.is-today { background: var(--primary-soft); }
.cal-day-num {
  justify-self: start; margin: 6px 6px 2px; padding: 2px 8px; border: none; border-radius: 999px;
  background: transparent; color: var(--text-main); font-size: 0.85rem; font-weight: 600; cursor: pointer;
  min-height: 0; position: relative; z-index: 1;
}
.cal-day-num:hover { background: var(--surface-muted); }
.cal-day-num.is-outside { color: var(--text-muted); }
.cal-day-num.is-today { background: var(--primary); color: #fff; }
.cal-day-wd { font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.04em; }
.cal-event-slot { position: relative; z-index: 1; min-width: 0; padding: 0 4px; }
.cal-event {
  display: flex; gap: 6px; align-items: baseline; min-width: 0; padding: 3px 8px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary-text); border-left: 3px solid var(--primary);
  font-size: 0.8rem; line-height: 1.3; text-decoration: none; white-space: nowrap; overflow: hidden;
}
.cal-event:hover, .cal-event:focus-visible { background: var(--primary); color: #fff; outline: none; }
.cal-event.cont-before { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.cal-event.cont-after { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-event-client { font-weight: 700; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.cal-event-title { overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.cal-event.is-tall { flex-direction: column; align-items: stretch; gap: 1px; padding: 6px 8px; white-space: normal; }
.cal-event.is-tall .cal-event-client,
.cal-event.is-tall .cal-event-title { white-space: nowrap; }
.cal-event-meta { font-size: 0.75rem; opacity: 0.9; }
.cal-day-list { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.cal-event.cal-day-card { flex-direction: column; align-items: stretch; gap: 2px; padding: 12px 14px; font-size: 0.9rem; white-space: normal; border-radius: var(--radius-md); }
.cal-day-card-client { font-weight: 700; font-size: 1rem; }
.cal-day-card-meta { font-size: 0.85rem; opacity: 0.9; }
@media (max-width: 640px) {
  .cal-page { padding: 0 12px 32px; }
  .cal-title { width: 100%; margin: 4px 0 0; font-size: 1.05rem; }
  .cal-week { min-height: 84px; }
  .cal-week.is-tall { min-height: 220px; }
  .cal-weekdays div { padding: 6px 2px; text-align: center; font-size: 0.68rem; }
  .cal-day-num { margin: 4px 2px 2px; padding: 1px 6px; font-size: 0.78rem; }
  .cal-event-slot { padding: 0 1px; }
  .cal-event { padding: 2px 4px; font-size: 0.68rem; }
  .cal-event:not(.is-tall):not(.cal-day-card) .cal-event-title { display: none; }
}

/* ---------- Job panel: estimates & invoices (stored records) ---------- */
.job-estimate-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
}
.job-estimate-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-estimate-name { font-weight: 600; color: var(--text-main); }
.job-estimate-total { margin-left: auto; font-weight: 600; color: var(--text-main); white-space: nowrap; }
.job-estimate-details { color: var(--text-muted); font-size: 0.78rem; }
.job-estimate-status {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.job-estimate-status[data-status="sent"] { color: var(--primary-text); background: var(--primary-soft); border-color: transparent; }
.job-estimate-status[data-status="approved"],
.job-estimate-status[data-status="paid"] { color: var(--success-text); background: var(--success-soft); border-color: transparent; }
.job-estimate-status[data-status="overdue"],
.job-estimate-status[data-status="expired"],
.job-estimate-status[data-status="draft"] { color: var(--warning-text); background: var(--warning-soft); border-color: transparent; }
.job-estimate-status[data-status="declined"],
.job-estimate-status[data-status="void"] { color: var(--danger-text); background: var(--danger-soft); border-color: transparent; }
.job-estimate-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.job-estimate-actions .is-danger { margin-left: auto; }
.job-estimate-test-mode { color: var(--warning-text); font-weight: 600; }
.job-email-ready .job-estimate-form-actions { flex-wrap: wrap; }
.job-estimates-new { display: flex; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
.job-estimate-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.job-estimate-form-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--text-muted); }
.job-estimate-form-field input { max-width: 260px; }
.job-estimate-form-actions { display: flex; gap: 8px; }

.field-optional { font-weight: 400; opacity: 0.8; }

/* ---------- Calendar page: client appointments ---------- */
.cal-event.is-appointment { background: var(--warning-soft); color: var(--warning-text); border-left-color: var(--warning); }
.cal-event.is-appointment:hover, .cal-event.is-appointment:focus-visible { background: var(--warning); color: #fff; }
.cal-event.is-appointment.is-completed { opacity: 0.65; }
.cal-event.is-appointment.is-completed .cal-event-title,
.cal-event.is-appointment.is-completed .cal-day-card-title { text-decoration: line-through; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-muted); margin: 0 0 10px; }
.cal-legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.cal-legend-swatch.is-job { background: var(--primary); }
.cal-legend-swatch.is-appointment { background: var(--warning); }

/* ======================================================
   ACTIVITIES — appointments and reminders (not scheduled work)
   Shared by the client page, the job window and the Calendar
   (js/activities.js). Quiet and time-first so they never read like job bars.
   ====================================================== */
.activity-section-list { margin-bottom: 10px; }
.activity-group + .activity-group { margin-top: 12px; }
.activity-group-title {
  display: flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px;
}
.activity-group-title .summary-count { font-size: 0.72rem; color: var(--text-muted); }
.activity-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 12px; margin-bottom: 6px; cursor: pointer;
  border: 1px solid var(--border-soft); border-left: 3px solid var(--primary);
  border-radius: var(--radius-md); background: var(--surface); color: var(--text-main);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.activity-row:hover, .activity-row:focus-visible { background: var(--surface-muted); outline: none; transform: translateX(2px); }
.activity-row.is-overdue { border-left-color: var(--warning); }
.activity-row.is-completed { border-left-color: var(--success); opacity: 0.82; }
.activity-row-when { display: flex; flex-direction: column; flex: 0 0 120px; }
.activity-row-date { font-weight: 700; font-size: 0.82rem; }
.activity-row-time { font-size: 0.76rem; color: var(--text-muted); }
.activity-row-main { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.activity-row-title { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row.is-completed .activity-row-title { text-decoration: line-through; }
.activity-row-sub { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-chip {
  flex: 0 0 auto; padding: 2px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 700;
  background: var(--warning-soft); color: var(--warning-text); border: 1px solid var(--warning);
}
.activity-chip.is-done { background: var(--success-soft); color: var(--success-text); border-color: var(--success); }
.activity-add-btn { margin-top: 2px; }
.activity-modal-card { max-width: 520px; }
.activity-kind-note { display: block; margin-top: 2px; font-weight: 500; font-size: 0.78rem; color: var(--text-muted); text-transform: none; letter-spacing: normal; }
.activity-when-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.activity-done-toggle { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; font-size: 0.86rem; color: var(--text-main); }
.activity-done-toggle input { width: auto; }
.activity-links { margin: 6px 0; font-size: 0.85rem; }
.activity-links a { color: var(--primary-text); font-weight: 600; text-decoration: none; }
.activity-links a:hover { text-decoration: underline; }
.activity-error { color: var(--danger-text); }
#act-client-search { margin-bottom: 6px; }
@media (max-width: 600px) {
  .activity-when-grid { grid-template-columns: minmax(0, 1fr); }
  .activity-row-when { flex-basis: 84px; }
}

/* Calendar: the count on a day and the panel below the grid. */
.cal-day-act-count {
  display: inline-block; min-width: 15px; margin-left: 4px; padding: 0 4px;
  border-radius: 999px; font-size: 0.66rem; font-weight: 700; text-align: center;
  background: var(--warning-soft); color: var(--warning-text); border: 1px solid var(--warning);
  vertical-align: middle;
}
.cal-day-num.is-today .cal-day-act-count { background: #fff; color: var(--primary); border-color: #fff; }
.cal-activities { margin-top: 18px; }
.cal-activities-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-activities-title { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--text-main); }
.cal-activities-note { font-size: 0.82rem; color: var(--text-muted); }

/* ==========================================================================
   NOTIFICATIONS — the bell in the top bar (migration 0019).
   js/notifications.js builds the markup. The button reuses
   .theme-toggle-btn; colours come from the theme tokens. These rules come
   after the template's older .notifications-panel rules and replace them.
   ========================================================================== */
.notifications-wrap { position: relative; display: inline-flex; }
.notifications-wrap[hidden] { display: none; }
.notifications-btn { position: relative; }
.notifications-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 700;
  line-height: 18px; text-align: center;
}
.notifications-badge[hidden] { display: none; }
.notifications-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 10050;
  width: min(360px, calc(100vw - 24px)); max-height: none; display: block;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-lift); overflow: hidden;
}
.notifications-panel[hidden] { display: none; }
.notifications-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft); color: var(--text-main);
}
.notifications-list { max-height: min(420px, 60vh); overflow-y: auto; }
.notifications-empty { padding: 14px 12px; color: var(--text-muted); font-size: 0.85rem; }
.notification-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px;
  border: 0; border-bottom: 1px solid var(--border-soft); background: transparent; color: var(--text-main);
  font: inherit; font-size: 0.86rem; text-align: left; cursor: pointer;
}
.notification-item:hover, .notification-item:focus-visible { background: var(--surface-muted); }
.notification-item.read { color: var(--text-muted); opacity: 1; }
.notification-icon { flex: 0 0 auto; font-size: 1rem; line-height: 1.3; }
.notification-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notification-body small { color: var(--text-muted); font-size: 0.75rem; }
@media (max-width: 768px) {
  .notifications-panel { position: fixed; top: 56px; right: 12px; left: 12px; width: auto; }
}

/* An overpayment shown as a credit (finance.overpaymentCredit), in the "good" colour. */
.job-row-money .is-credit { color: var(--success-text); }
