/* ============================================================
   Constructive Solution CRM — styles.css
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-border: #e5e9f2;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-subtle: #94a3b8;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #dbeafe;

  --color-success: #16a34a;
  --color-success-soft: #dcfce7;
  --color-warning: #d97706;
  --color-warning-soft: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --color-info-soft: #e0e7ff;
  --color-violet: #8b5cf6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.1);

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --header-h: 72px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
               Ubuntu, Cantarell, sans-serif;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--color-muted); margin: 0; font-size: 13px; }
.mt-12 { margin-top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: var(--color-surface-alt); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 8px;
  font-size: 18px; color: var(--color-muted);
}
.icon-btn:hover { background: var(--color-surface-alt); color: var(--color-text); }

/* ---------- Form controls ---------- */
.input,
.field input, .field select, .field textarea,
.filter-field input, .filter-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  color: var(--color-text);
}
.input-narrow { max-width: 220px; }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus, .filter-field input:focus, .filter-field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--color-muted); }
.field span { font-weight: 600; color: var(--color-text); }
.field .req { color: var(--color-danger); font-style: normal; margin-left: 2px; }
.field.full { grid-column: 1 / -1; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline span { white-space: nowrap; }

/* ---------- Auth screen ---------- */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff;
  border-radius: 16px; padding: 32px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand h1 { font-size: 18px; margin: 12px 0 4px; }
.auth-brand p { margin: 0; color: var(--color-muted); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error {
  background: var(--color-danger-soft); color: var(--color-danger);
  border-radius: var(--radius-sm); padding: 8px 12px; margin: 0;
  font-size: 12px; font-weight: 600; text-align: center;
}

.brand-mark {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-primary); color: #fff; border-radius: 12px;
  font-weight: 700; font-size: 16px;
}

.demo-accounts { margin-top: 8px; padding-top: 16px; border-top: 1px dashed var(--color-border); }
.demo-title { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.05em; text-align: center; }
.demo-title small { font-weight: 500; text-transform: none; letter-spacing: 0; }
.demo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.demo-chip {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; background: var(--color-surface-alt);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.demo-chip:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.demo-chip strong { font-size: 13px; color: var(--color-text); }
.demo-chip span { font-size: 11px; color: var(--color-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- App shell ----------
   Sidebar is position: fixed (see below), so we reserve its width with
   padding-left rather than a grid column. This avoids the grid auto-
   placement bug where a fixed child gets removed from flow and the
   remaining child (main-column) gets dropped into column 1, crushing
   the right-side content. */
.app-shell {
  min-height: 100vh;
  padding-left: var(--sidebar-w);
  transition: padding-left 0.25s ease;
}
.main-column { width: 100%; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 20px 16px;
  /* Fully fixed to the viewport — never moves when the page scrolls,
     regardless of any ancestor's overflow / transform. The .app-shell
     reserves matching space via padding-left so content sits beside it. */
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 20;
  /* If the nav list ever overflows vertically, allow scrolling inside the sidebar
     instead of pushing the whole sidebar past the viewport edge.
     scrollbar-gutter keeps width stable so icons don't shift on hover. */
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 25; }
.sidebar-overlay.show { display: block; }
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand .brand-mark { background: var(--color-primary); }
.sidebar-brand strong { color: #fff; display: block; font-size: 14px; }
.sidebar-brand small { color: #94a3b8; font-size: 11px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: #cbd5e1; font-weight: 500; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active { background: var(--color-primary); color: #fff; }
.nav-icon { width: 20px; text-align: center; font-size: 14px; }
.nav-pill {
  margin-left: auto;
  background: var(--color-danger); color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px; font-weight: 700;
  min-width: 18px; text-align: center;
}
.nav-pill:empty { display: none; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 16px; }
.sidebar-foot .btn-ghost { color: #cbd5e1; border-color: rgba(255, 255, 255, 0.12); }
.sidebar-foot .btn-ghost:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

/* ================================================
   Collapsible-sidebar polish
   ================================================ */
/* Note: do NOT override position here — base rule pins the sidebar with
   position: fixed. The chevron-pill child uses position: absolute, which
   resolves correctly against a fixed parent. */
.sidebar { transition: padding 0.25s ease, width 0.25s ease; }
.brand-text { display: flex; flex-direction: column; transition: opacity 0.15s ease; }

/* The little chevron pill that toggles collapsed mode */
.sidebar-collapse-btn {
  position: absolute;
  top: 28px; right: -13px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: 2px solid #0f172a;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; line-height: 1;
  z-index: 5;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, background 0.15s;
}
.sidebar-collapse-btn:hover {
  background: var(--color-primary-hover);
  transform: scale(1.1);
}

/* ---- EXPANDED state (default) — minor tightening ---- */
.sidebar-brand { gap: 12px; align-items: center; }
.nav-item {
  position: relative;
  /* ONLY transition colours — never anything that touches layout.
     A padding transition here was causing the icon to wobble in collapsed mode. */
  transition: background 0.15s ease, color 0.15s ease;
}
/* Lock the icon's box so a hover-induced colour change can never
   re-rasterise it at a different baseline (Windows emoji metrics shift
   slightly otherwise). */
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex: 0 0 auto;
}

/* ---- COLLAPSED state ---- */
.app-shell.sidebar-collapsed { padding-left: 76px; }
.app-shell.sidebar-collapsed .sidebar { width: 76px; }
.sidebar-collapsed .sidebar { padding: 20px 12px; }

/* Brand: hide text, centre the CS mark */
.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 4px 0 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-collapsed .brand-text { display: none; }

/* Nav: icons centred in 48×48 squares with rounded corners */
.sidebar-collapsed .sidebar-nav { gap: 6px; align-items: center; padding-top: 8px; }
.sidebar-collapsed .nav-item {
  font-size: 0;
  /* gap was 12px (inherited) which placed an invisible-but-real space
     between the icon and the hidden text node — that nudged the icon
     left-of-centre and re-painted on hover. Force it to zero. */
  gap: 0;
  justify-content: center;
  align-items: center;
  padding: 0;
  width: 48px; height: 48px;
  border-radius: 12px;
  /* Promote to its own layer so hover repaints don't trigger a layout pass. */
  will-change: background-color;
}
.sidebar-collapsed .nav-icon {
  font-size: 20px;
  width: 24px;
  height: 24px;
  line-height: 24px;
}

/* Active page in collapsed mode — solid blue tile with shadow */
.sidebar-collapsed .nav-item.active {
  background: var(--color-primary);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.45);
}

/* Approval badge as a tiny floating dot in the corner */
.sidebar-collapsed .nav-pill {
  position: absolute;
  top: -2px; right: -2px;
  margin: 0;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 10px;
  border: 2px solid #0f172a;
  display: grid; place-items: center;
}

/* Sign-out button: icon-only, centred */
.sidebar-collapsed .sidebar-foot {
  display: flex; justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}
.sidebar-collapsed .sidebar-foot .btn-block {
  font-size: 0;
  padding: 0;
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
}
.sidebar-collapsed .sidebar-foot .btn-block::before {
  content: "↪";
  font-size: 18px; line-height: 1;
}

/* ----------------------------------------------------------
   Unified tooltip — any element with [data-tip] gets a smooth
   dark popup on hover. Positioning via [data-tip-pos="top|right|bottom|left"].
   ---------------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  background: rgba(15, 23, 42, 0.95); color: #fff;
  padding: 6px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  z-index: 1000; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  animation: tip-fade 0.12s ease;
}
[data-tip-pos="top"]:hover::after {
  top: auto; bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
}
[data-tip-pos="right"]:hover::after {
  top: 50%; left: calc(100% + 12px);
  transform: translateY(-50%);
}
[data-tip-pos="left"]:hover::after {
  top: 50%; right: calc(100% + 12px); left: auto;
  transform: translateY(-50%);
}
@keyframes tip-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Sidebar foot button gets icon via ::before, so its tooltip ::after still works fine */
.sidebar-collapsed .sidebar-foot .btn-block::before { pointer-events: none; }

@media (max-width: 960px) {
  .app-shell.sidebar-collapsed { padding-left: 0; }
  .sidebar-collapse-btn { display: none; }
}

/* ---------- Impersonation banner ---------- */
.impersonation-banner {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  padding: 8px 24px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
  position: sticky; top: 0; z-index: 11;
  flex-wrap: wrap; gap: 8px;
}
.impersonation-banner strong { color: var(--color-text); }

/* ---------- Topbar ---------- */
.main-column { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--header-h); background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-titles { flex: 1; min-width: 0; }
.page-title { margin: 0; font-size: 18px; }
.page-subtitle { margin: 2px 0 0; font-size: 12px; color: var(--color-muted); }
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px;
  background: var(--color-primary-soft); color: var(--color-primary);
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.user-meta strong { display: block; font-size: 13px; }
.user-meta small { color: var(--color-muted); font-size: 11px; text-transform: capitalize; }

/* ---------- Content ---------- */
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card.no-padding { padding: 0; }
.card.span-2 { grid-column: span 2; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head small { color: var(--color-muted); font-size: 12px; }

.section-title { margin: 18px 0 8px; font-size: 13px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Filters ---------- */
.filters-card { padding: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-muted); font-size: 12px; font-weight: 500;
}
.chip.active { background: var(--color-primary-soft); color: var(--color-primary); border-color: var(--color-primary); }
.chip:hover { background: var(--color-surface-alt); }
.filter-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--color-muted); min-width: 130px; }
.filter-field span { font-weight: 600; color: var(--color-text); }
.filter-field input, .filter-field select { padding: 7px 10px; font-size: 13px; }
.filters .btn { margin-left: auto; align-self: flex-end; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-sm); position: relative;
}
.kpi-card .kpi-icon {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--color-primary-soft); color: var(--color-primary);
  display: grid; place-items: center; font-size: 16px;
}
.kpi-label { color: var(--color-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--color-text); margin-top: 4px; }
.kpi-trend { font-size: 12px; font-weight: 600; }
.kpi-trend.up { color: var(--color-success); }
.kpi-trend.down { color: var(--color-danger); }

/* ---------- Charts ---------- */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.chart-grid.equal { grid-template-columns: 1fr 1fr; }
.chart-box { position: relative; height: 280px; }

.funnel { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.funnel-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.funnel-bar-wrap { flex: 1; display: flex; justify-content: center; }
.funnel-bar {
  height: 38px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px;
  transition: width 0.3s ease; min-width: 50px;
}
.funnel-meta { width: 130px; display: flex; flex-direction: column; font-size: 12px; color: var(--color-muted); }
.funnel-meta strong { color: var(--color-text); font-size: 13px; text-transform: capitalize; }
.funnel-pct { width: 70px; text-align: right; color: var(--color-muted); font-size: 12px; font-weight: 600; }

.sources-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: center; }
.donut-box { height: 240px; position: relative; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.donut-center strong { font-size: 24px; color: var(--color-text); display: block; }
.donut-center small { color: var(--color-muted); font-size: 11px; }
.source-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.source-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--color-border); }
.source-list li:first-child { border-top: none; }
.source-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.source-info { flex: 1; min-width: 0; }
.source-name { font-size: 13px; font-weight: 500; }
.source-progress { height: 4px; background: var(--color-surface-alt); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.source-progress > span { display: block; height: 100%; border-radius: 999px; }
.source-numbers { text-align: right; }
.source-numbers strong { display: block; font-size: 13px; }
.source-numbers small { color: var(--color-muted); font-size: 11px; }

/* ---------- Toolbar ---------- */
.page-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-toolbar .input { flex: 1; max-width: 360px; min-width: 200px; }
.page-toolbar .btn { margin-left: auto; }

/* ---------- Data table ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left; padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px; vertical-align: top;
}
.data-table th {
  background: var(--color-surface-alt);
  font-weight: 600; font-size: 11px; color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table th.num, .data-table td.num { text-align: right; }
.data-table th.center, .data-table td.center { text-align: center; }
.data-table tfoot td { background: var(--color-surface-alt); border-top: 2px solid var(--color-border); }
.data-table tr:last-child td { border-bottom: none; }
.actions-col { width: 180px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn { padding: 6px 10px; font-size: 12px; }
.lead-cell { display: flex; align-items: center; gap: 10px; }
.lead-cell .lead-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lead-cell strong { font-weight: 600; }
.lead-cell small { color: var(--color-muted); font-size: 12px; }
.lead-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary);
  display: inline-grid; place-items: center;
  font-weight: 700; font-size: 13px;
  background-size: cover; background-position: center;
  flex-shrink: 0; overflow: hidden;
  border: 2px solid var(--color-border);
  transition: transform 0.12s, border-color 0.12s;
}
.lead-avatar.has-photo { cursor: zoom-in; }
.lead-avatar.has-photo:hover {
  transform: scale(1.15);
  border-color: var(--color-primary);
}
/* Smaller avatar in compact mode */
.leads-compact .lead-avatar { width: 26px; height: 26px; font-size: 11px; border-width: 1px; }

/* Tiny count overlay badge for avatars showing multiple site photos */
.lead-avatar { position: relative; }
.lead-avatar .photo-count {
  position: absolute; bottom: -2px; right: -2px;
  background: var(--color-primary); color: #fff;
  border-radius: 999px; padding: 0 5px;
  font-size: 9px; font-weight: 700; line-height: 14px;
  border: 2px solid #fff;
  min-width: 16px; text-align: center;
}

.check { color: var(--color-success); font-weight: 700; cursor: pointer; }
.cross { color: var(--color-subtle); cursor: pointer; }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge.new { background: var(--color-info-soft); color: #4338ca; }
.badge.contacted { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.qualified { background: var(--color-primary-soft); color: var(--color-primary); }
.badge.won, .badge.paid, .badge.active, .badge.connected, .badge.approved { background: var(--color-success-soft); color: var(--color-success); }
.badge.lost, .badge.overdue, .badge.disconnected, .badge.rejected { background: var(--color-danger-soft); color: var(--color-danger); }
.badge.draft, .badge.inactive { background: var(--color-surface-alt); color: var(--color-muted); }
.badge.sent, .badge.partial, .badge.pending { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.void { background: var(--color-surface-alt); color: var(--color-muted); text-decoration: line-through; }

/* ---------- Invoice-status hover tooltip (floating, body-attached) ---------- */
.status-tip { display: inline-block; cursor: help; }

#csc-status-tooltip {
  position: fixed;
  z-index: 100000;
  background: #111827;
  color: #ffffff;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  width: max-content;
  max-width: 320px;
  text-align: left;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.14s ease-out, transform 0.14s ease-out;
  font-family: inherit;
}
#csc-status-tooltip.is-open {
  opacity: 1;
  transform: translateY(0);
}
#csc-status-tooltip .csc-tip-head {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: #fbbf24;
  display: block;
}
#csc-status-tooltip .csc-tip-body {
  color: #f3f4f6;
}
#csc-status-tooltip::after {
  content: '';
  position: absolute;
  left: var(--csc-tip-arrow, 50%);
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #111827;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.20);
}
#csc-status-tooltip.is-below::after {
  bottom: auto;
  top: -6px;
  box-shadow: -3px -3px 8px rgba(0, 0, 0, 0.20);
}
.badge.stage-advance            { background: #e0e7ff; color: #4338ca; }
.badge.stage-on_dispatch        { background: #fef3c7; color: #92400e; }
.badge.stage-after_installation { background: #dbeafe; color: #1e40af; }
.badge.hot  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge.warm { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.cold { background: var(--color-info-soft);    color: #4338ca; }

/* Progress dots in the leads table */
.progress-dots { display: inline-flex; gap: 4px; }
.progress-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
  background: var(--color-surface-alt); color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.progress-dot.done {
  background: var(--color-success-soft); color: var(--color-success);
  border-color: transparent;
}

/* Sales progress card inside the lead detail */
.progress-card {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 16px 0;
}
.progress-title { margin: 0 0 8px; font-size: 13px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.progress-title small { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--color-muted); }
.progress-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--color-border);
}
.progress-row:last-child { border-bottom: none; }
.progress-row > div { flex: 1; min-width: 0; }
.progress-row strong { display: block; font-size: 13px; color: var(--color-text); }
.progress-row small { color: var(--color-muted); font-size: 11px; }

/* ---------- Products ---------- */
.products-layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid > .btn { grid-column: 1 / -1; justify-self: start; }
.form-grid > .full { grid-column: 1 / -1; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.product-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
}
.product-card img { width: 100%; height: 140px; object-fit: cover; background: var(--color-surface-alt); }
.product-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-name { font-weight: 600; font-size: 15px; }
.product-sku { color: var(--color-muted); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.product-price { color: var(--color-primary); font-weight: 700; }
.product-desc { color: var(--color-muted); font-size: 12px; flex: 1; }
.product-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.cat-pill {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--color-info-soft); color: #4338ca;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.product-unit { color: var(--color-muted); font-size: 12px; }
.product-unit strong { color: var(--color-text); font-size: 13px; }

/* ---------- Multi-product picker (lead form) ---------- */
.selected-products {
  list-style: none; padding: 8px;
  margin: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 40px;
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
}
.sp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 12px;
  background: var(--color-primary-soft); color: var(--color-primary);
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.sp-chip .qty {
  background: rgba(255,255,255,0.7);
  padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
}
.sp-chip button {
  width: 20px; height: 20px;
  border: none; background: rgba(255,255,255,0.6);
  border-radius: 50%; cursor: pointer;
  color: var(--color-primary); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; padding: 0;
}
.sp-chip button:hover { background: var(--color-danger); color: #fff; }
.sp-empty { color: var(--color-muted); font-size: 12px; font-weight: 500; }
.lead-product-picker {
  display: grid; grid-template-columns: 1fr 1fr 84px auto;
  gap: 6px; align-items: center; margin-top: 8px;
}
.lead-product-picker select, .lead-product-picker input {
  padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); background: #fff;
}
@media (max-width: 600px) {
  .lead-product-picker { grid-template-columns: 1fr; }
}

/* ---------- Category management ---------- */
.cat-manage {
  display: flex; gap: 16px; align-items: flex-start;
  flex-wrap: wrap; justify-content: space-between;
}
.cat-tags {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
  flex: 1; min-width: 240px;
}
.cat-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 12px;
  background: var(--color-info-soft); color: #4338ca;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.cat-tag .count {
  background: rgba(255,255,255,0.7);
  padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
}
.cat-tag button {
  width: 20px; height: 20px;
  border: none; background: rgba(255,255,255,0.5);
  border-radius: 50%; cursor: pointer;
  color: #4338ca; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; padding: 0;
}
.cat-tag button:hover { background: var(--color-danger); color: #fff; }
.cat-form { display: flex; gap: 8px; align-items: center; }
.cat-form input {
  padding: 7px 12px; font-size: 13px;
  min-width: 220px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.cat-form input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }

.check-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 0;
}
.check-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.check-pill input { margin: 0; cursor: pointer; }
.check-pill:hover { background: var(--color-surface-alt); }
.check-pill:has(input:checked) {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.product-actions { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--color-border); }
.product-actions .btn { flex: 1; padding: 6px 10px; font-size: 12px; }

/* ---------- Messaging ---------- */
.messaging-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.attachment {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--color-surface-alt);
  border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
}
.attachment-icon {
  width: 44px; height: 44px;
  background: var(--color-danger-soft); color: var(--color-danger);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.attachment-meta { flex: 1; display: flex; flex-direction: column; }
.attachment-meta small { color: var(--color-muted); font-size: 12px; }

.template-list, .message-log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.template-list li, .message-log li {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
  background: var(--color-surface);
}
.template-list .meta, .message-log .meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--color-muted); gap: 8px;
}
.template-list .body { color: var(--color-text); font-size: 12px; }
.template-list .row-actions .btn { padding: 4px 8px; font-size: 11px; }

.brochure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.brochure-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 14px;
  display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-sm);
}
.brochure-card .icon {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--color-danger-soft); color: var(--color-danger);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.brochure-meta { flex: 1; min-width: 0; }
.brochure-meta strong { display: block; font-size: 13px; }
.brochure-meta small { color: var(--color-muted); font-size: 11px; }

/* ---------- Settings (toggles, switches) ---------- */
.settings-list { display: flex; flex-direction: column; }
.setting-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--color-border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row > div:first-child { flex: 1; }
.setting-row p { margin: 2px 0 0; font-size: 12px; color: var(--color-muted); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--color-border); border-radius: 999px; transition: 0.2s;
}
.switch span::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + span { background: var(--color-primary); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Locations ---------- */
.location-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.location-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
}
.location-card h4 { margin: 0; font-size: 15px; }
.location-card .code {
  display: inline-block; padding: 2px 8px;
  background: var(--color-primary-soft); color: var(--color-primary);
  border-radius: 999px; font-size: 11px; font-weight: 600; align-self: flex-start;
}
.location-card p { margin: 0; color: var(--color-muted); font-size: 13px; }
.location-stats { display: flex; gap: 16px; padding-top: 10px; border-top: 1px solid var(--color-border); margin-top: auto; }
.location-stats div { font-size: 12px; color: var(--color-muted); }
.location-stats strong { display: block; color: var(--color-text); font-size: 16px; }
.location-actions { display: flex; gap: 8px; }
.location-actions .btn { flex: 1; padding: 6px 10px; font-size: 12px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px; flex-wrap: wrap;
}
.tab {
  padding: 10px 14px; border: none; background: transparent;
  color: var(--color-muted); font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid; place-items: center;
  z-index: 50; padding: 16px;
  overflow-y: auto;
}
.modal-card {
  background: #fff; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-md);
}
.modal-card.modal-lg { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head small { color: var(--color-muted); font-size: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Lead detail ---------- */
.detail-grid {
  display: grid; grid-template-columns: 140px 1fr 140px 1fr;
  gap: 12px 18px; margin: 0 0 16px;
}
.detail-grid dt { color: var(--color-muted); font-size: 12px; font-weight: 600; }
.detail-grid dd { margin: 0; font-size: 13px; }
.detail-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding-top: 12px; border-top: 1px dashed var(--color-border);
}

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.timeline li {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.timeline li:last-child { border-bottom: none; }
.tl-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--color-primary-soft); color: var(--color-primary);
  font-size: 13px;
}
.tl-body { flex: 1; min-width: 0; }
.tl-body .tl-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--color-muted); }
.tl-body strong { font-size: 13px; }
.tl-body p { margin: 4px 0 0; font-size: 12px; color: var(--color-muted); }

/* Latest comment in the Comments timeline */
.timeline li.latest {
  background: linear-gradient(0deg, var(--color-primary-soft), transparent);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  border-bottom-color: transparent;
}
.timeline li.latest .tl-body p { color: var(--color-text); font-weight: 600; }
.timeline li.latest .tl-body strong { color: var(--color-primary); }
/* Inline edit form for a comment in the timeline */
.timeline li.editing {
  background: var(--color-warning-soft);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-sm);
  padding: 12px;
  border-bottom: none;
}
.comment-edit-form {
  display: flex; flex-direction: column; gap: 8px;
}
.comment-edit-form select,
.comment-edit-form textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit; font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.comment-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.comment-edited-tag {
  display: inline-block;
  background: var(--color-surface-alt); color: var(--color-muted);
  padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-left: 6px; vertical-align: middle;
}

.timeline .latest-tag {
  display: inline-block;
  background: var(--color-primary); color: #fff;
  padding: 1px 8px; border-radius: 999px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-left: 6px; vertical-align: middle;
}
.serial-pill {
  display: inline-block;
  background: var(--color-info-soft); color: #4338ca;
  padding: 1px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-right: 6px;
}

/* ---------- Invoice summary ---------- */
.invoice-summary {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
  background: var(--color-surface-alt); padding: 14px;
  border-radius: var(--radius-sm); margin-bottom: 12px;
}
.invoice-summary > div { display: flex; flex-direction: column; }
.invoice-summary span { font-size: 11px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.invoice-summary strong { font-size: 14px; color: var(--color-text); margin-top: 2px; }

/* ============================================================
   Payment plan — three colour-coded stage cards (view) + three
   editor cards (edit) with % / ₹ mode toggle, live computed
   amount, due date, and a collection-progress strip.
   ============================================================ */
:root {
  --pt-stage-1:      #f97316; /* Advance — orange */
  --pt-stage-1-soft: #fff7ed;
  --pt-stage-2:      #2563eb; /* On Dispatch — blue */
  --pt-stage-2-soft: #eff6ff;
  --pt-stage-3:      #16a34a; /* After Installation — green */
  --pt-stage-3-soft: #f0fdf4;
}

.pt-section {
  margin-top: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}
.pt-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  gap: 10px; flex-wrap: wrap;
}
.pt-section-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pt-section-title .pt-icon { font-size: 16px; }
.pt-section-title strong   { font-size: 13px; color: var(--color-text); }
.pt-section-title .pt-section-sub { color: var(--color-muted); font-size: 12px; }

/* ===================== VIEW MODE ===================== */
.pt-view { padding: 16px; }
.pt-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.pt-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
}
.pt-card:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
.pt-card-bar {
  height: 4px;
  background: var(--pt-color, var(--color-primary));
}
.pt-stage-1 { --pt-color: var(--pt-stage-1); --pt-soft: var(--pt-stage-1-soft); }
.pt-stage-2 { --pt-color: var(--pt-stage-2); --pt-soft: var(--pt-stage-2-soft); }
.pt-stage-3 { --pt-color: var(--pt-stage-3); --pt-soft: var(--pt-stage-3-soft); }
.pt-card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.pt-card-head {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: center;
}
.pt-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--pt-color, var(--color-primary));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}
.pt-card-head strong { font-size: 13px; color: var(--color-text); display: block; }
.pt-card-head .pt-card-sub { color: var(--color-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; }
.pt-status-pill {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  white-space: nowrap;
}
.pt-status-pill.status-paid     { background: #d1fae5; color: #065f46; }
.pt-status-pill.status-overdue  { background: #fee2e2; color: #991b1b; }
.pt-status-pill.status-pending  { background: #fef3c7; color: #92400e; }

.pt-amount {
  font-size: 22px; font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.02em;
  margin-top: 4px;
  line-height: 1.1;
}
.pt-percent {
  font-size: 11px; color: var(--color-muted);
  font-weight: 600;
}

.pt-due-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--pt-soft, var(--color-surface-alt));
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.pt-due-row .pt-due-icon { font-size: 13px; }
.pt-due-row .pt-due-label { color: var(--color-muted); font-weight: 600; }
.pt-due-row strong { margin-left: auto; color: var(--color-text); font-size: 12px; }
.pt-due-row strong.pt-due-overdue { color: var(--color-danger); }

.pt-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--color-border);
}
.pt-card-actions .btn { flex: 1; }
.pt-paid-meta {
  font-size: 11px; color: var(--color-success);
  font-weight: 600;
  text-align: center;
  width: 100%;
}

/* Card colour-state tints */
.pt-card.is-paid    { background: linear-gradient(180deg, #f0fdf4 0%, var(--color-surface) 50%); }
.pt-card.is-overdue { background: linear-gradient(180deg, #fef2f2 0%, var(--color-surface) 50%); }

/* Empty-state */
.pt-empty {
  text-align: center;
  padding: 32px 16px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
}
.pt-empty-icon { font-size: 36px; margin-bottom: 6px; }
.pt-empty strong { display: block; font-size: 14px; color: var(--color-text); margin-bottom: 4px; }
.pt-empty p { margin: 0; color: var(--color-muted); font-size: 12px; }

/* Collection progress strip */
.pt-progress {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.pt-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.pt-progress-head small { color: var(--color-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.pt-progress-head strong { font-size: 13px; color: var(--color-text); }
.pt-progress-of { color: var(--color-muted); font-weight: 500; margin: 0 2px; }
.pt-progress-bar {
  height: 8px; border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}
.pt-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f97316 0%, #2563eb 50%, #16a34a 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.pt-progress-fill.full { background: #16a34a; }

/* ===================== EDIT MODE ===================== */
.pt-edit { padding: 16px; }
.pt-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.pt-edit-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 14px 14px 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
}
.pt-edit-bar {
  position: absolute; top: 0; bottom: 0; left: 0; width: 4px;
  background: var(--pt-color, var(--color-primary));
}
.pt-edit-head {
  display: flex; align-items: center; gap: 10px;
}
.pt-edit-head strong { font-size: 13px; display: block; color: var(--color-text); }
.pt-edit-head small { color: var(--color-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; }
.pt-edit-head > div { flex: 1; min-width: 0; }
/* "✓ Paid" badge that appears on the editor card when the stage was already
   marked paid — signals to the user that editing this row will reconcile
   the invoice's master Paid total automatically. */
.pt-edit-status {
  display: inline-flex;
  align-items: center;
  background: #d1fae5;
  color: #065f46;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Tip strip at top of editor */
.pt-edit-hint {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #1e40af;
}
.pt-edit-hint strong { font-weight: 700; }
.pt-edit-hint em { font-style: normal; font-weight: 700; color: var(--color-text); background: #fff; padding: 1px 6px; border-radius: 4px; }

/* Twin inputs (Percent + Amount, side by side) */
.pt-twin-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pt-twin-input {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.pt-twin-input small {
  font-size: 10px; color: var(--color-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}

/* Input with prefix or suffix */
.pt-input-wrap {
  position: relative;
  display: flex; align-items: stretch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.pt-input-wrap:focus-within {
  border-color: var(--pt-color, var(--color-primary));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pt-color, var(--color-primary)) 18%, transparent);
}
.pt-input-wrap input {
  flex: 1; min-width: 0; width: 100%;
  border: none; outline: none;
  background: transparent;
  padding: 8px 10px;
  font: inherit; font-size: 15px; font-weight: 700;
  color: var(--color-text);
  text-align: right;
}
/* Hide the number spinner — we don't need step controls */
.pt-input-wrap input::-webkit-outer-spin-button,
.pt-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pt-input-wrap input[type="number"] { -moz-appearance: textfield; }
.pt-input-prefix,
.pt-input-suffix {
  display: grid; place-items: center;
  padding: 0 10px;
  background: var(--pt-soft, var(--color-surface-alt));
  color: var(--pt-color, var(--color-primary));
  font-weight: 800; font-size: 14px;
  min-width: 32px;
  flex-shrink: 0;
}
.pt-input-prefix { border-right: 1px solid var(--color-border); }
.pt-input-suffix { border-left:  1px solid var(--color-border); }

.pt-due-input {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.pt-due-input small {
  font-size: 10px; color: var(--color-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.pt-due-input input {
  font: inherit; font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  width: 100%; max-width: 100%; box-sizing: border-box; min-width: 0;
}
.pt-due-input input:focus {
  outline: none;
  border-color: var(--pt-color, var(--color-primary));
}

/* Bottom summary strip */
.pt-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  align-items: center;
}
.pt-summary-cell { display: flex; flex-direction: column; }
.pt-summary-cell small { font-size: 10px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.pt-summary-cell strong { font-size: 14px; color: var(--color-text); margin-top: 2px; }
.pt-summary-status {
  font-size: 12px; font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.pt-summary-status.ok   { background: #d1fae5; color: #065f46; }
.pt-summary-status.warn { background: #fef3c7; color: #92400e; }
.pt-summary-status.err  { background: #fee2e2; color: #991b1b; }

/* Sequential payment-plan additions */
.pt-presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; padding: 8px 10px; background: var(--color-surface-alt); border-radius: 8px; }
.pt-presets small { color: var(--color-muted); font-weight: 600; margin-right: 4px; }
.pt-edit-rows { display: flex; flex-direction: column; gap: 10px; }
.pt-add-row-area { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pt-add-note { color: var(--color-muted); font-size: 11px; }
.pt-drag-handle { user-select: none; }
.pt-drag-handle:active { cursor: grabbing; }
.pt-card.is-skipped { opacity: 0.65; }
.pt-card.is-skipped .pt-card-bar { background: var(--color-muted); }
.pt-status-pill.status-skipped { background: var(--color-surface-alt); color: var(--color-muted); }

.pt-edit-actions {
  margin-top: 14px;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  .pt-cards, .pt-edit-grid { grid-template-columns: 1fr; }
  .pt-summary { grid-template-columns: 1fr 1fr; }
  .pt-summary-status { grid-column: 1 / -1; text-align: center; }
}

/* ============================================================
   Redesigned invoice detail — lead-basics card + editable amounts
   ============================================================ */
.invoice-lead-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.invoice-lead-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}
.invoice-lead-head .ilc-icon { font-size: 16px; }
.invoice-lead-head strong { font-size: 13px; color: var(--color-text); flex: 1; }
.invoice-lead-grid {
  display: grid; grid-template-columns: 100px 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 13px;
}
.invoice-lead-grid dt {
  color: var(--color-muted); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  padding-top: 2px;
}
.invoice-lead-grid dd { margin: 0; color: var(--color-text); word-break: break-word; }
.invoice-lead-grid dd .cat-pill {
  background: var(--color-primary-soft); color: var(--color-primary);
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  margin: 0 4px 4px 0; display: inline-block;
}

/* Amounts form */
.invoice-amounts {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.invoice-amounts .ia-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.invoice-amounts .ia-icon { font-size: 16px; }
.invoice-amounts .ia-head strong { font-size: 13px; color: var(--color-text); }
.invoice-amounts .ia-head small { color: var(--color-muted); margin-left: auto; font-size: 11px; }
.invoice-amounts .ia-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}
.invoice-amounts .field {
  display: flex; flex-direction: column; gap: 4px;
}
.invoice-amounts .field span {
  font-size: 11px; color: var(--color-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.invoice-amounts .field input,
.invoice-amounts .field select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px; font-weight: 600;
}
.invoice-amounts .field input:focus,
.invoice-amounts .field select:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.invoice-amounts .field.readonly {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  border: 1px dashed var(--color-border);
}
.ia-balance {
  display: block;
  font-size: 18px; font-weight: 800;
  margin-top: 2px;
}
.ia-balance.balance-due  { color: var(--color-danger); }
.ia-balance.balance-zero { color: var(--color-success); }

/* Flash animation when Paid/Balance receive a stage-payment update.
   Pulses a soft green halo + scale so it's obvious the master amounts
   were updated by the Mark-paid action on a payment-terms stage. */
@keyframes inv-flash-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0.55); background-color: #d1fae5; }
  50%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);    background-color: #d1fae5; }
  100% { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0);    background-color: transparent; }
}
.inv-flash {
  animation: inv-flash-pulse 1.3s ease-out;
  border-color: var(--color-success) !important;
}

/* ============================================================
   Mark-Paid modal — collection method + receiving firm picker
   ============================================================ */
.markpaid-amount {
  grid-column: 1 / -1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
  border: 1px solid #6ee7b7;
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.markpaid-amount span { color: #065f46; font-weight: 600; font-size: 12px; }
.markpaid-amount strong { color: #065f46; font-size: 22px; font-weight: 800; }

/* Proof-of-payment uploader inside the Mark-Paid modal */
.proof-uploader {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 4px;
}
.proof-upload-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--color-surface-alt);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  color: var(--color-text);
  transition: background 0.12s, border-color 0.12s;
  width: fit-content;
}
.proof-upload-btn:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.proof-upload-btn .proof-upload-icon { font-size: 16px; }

.proof-preview {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.proof-preview img {
  width: 96px; height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}
.proof-preview-meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--color-text);
  word-break: break-word;
}

/* Small thumbnail in the Payments-log table */
.proof-thumb-btn {
  background: none; border: none; cursor: pointer;
  padding: 0;
  display: inline-block;
}
.proof-thumb-btn img {
  width: 38px; height: 38px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  transition: transform 0.12s, box-shadow 0.12s;
}
.proof-thumb-btn:hover img {
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

/* "Received by" pill in payments table */
.received-by {
  font-size: 12px; font-weight: 600; color: var(--color-text);
}

/* Mini firm-details card shown under firm dropdown */
.firm-mini-card {
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.firm-mini-card .fmc-row {
  display: flex; align-items: center; gap: 8px;
  color: var(--color-text);
}
.firm-mini-card .fmc-row span:first-child { font-size: 14px; }
.firm-mini-card .fmc-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--color-surface);
  padding: 1px 6px; border-radius: 4px;
  font-size: 11px;
  border: 1px solid var(--color-border);
}

/* ============================================================
   Invoice → Lead products list with main categories
   ============================================================ */
.inv-products-list {
  display: flex; flex-direction: column; gap: 6px;
}
.ipl-row {
  padding: 6px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.ipl-name { font-size: 13px; color: var(--color-text); }
.ipl-name small { color: var(--color-muted); margin-left: 4px; }
.ipl-cats { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.ipl-cats .cat-pill {
  background: var(--color-primary-soft); color: var(--color-primary);
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  margin: 0;
}
.invoice-amounts .ia-actions {
  grid-column: 1 / -1;
  display: flex; justify-content: flex-end;
  margin-top: 6px;
}
@media (max-width: 700px) {
  .invoice-amounts .ia-grid { grid-template-columns: 1fr 1fr; }
  .invoice-lead-grid { grid-template-columns: 80px 1fr; }
}
@media (max-width: 480px) {
  .invoice-amounts .ia-grid { grid-template-columns: 1fr; }
}

/* ---------- API chip + reference ---------- */
.api-chip {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; user-select: none;
  transition: opacity 0.15s;
}
.api-chip.mock { background: var(--color-warning-soft); color: var(--color-warning); border-color: var(--color-warning); }
.api-chip.live { background: var(--color-success-soft); color: var(--color-success); border-color: var(--color-success); }
.api-chip:hover { opacity: 0.85; }

.api-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.api-module {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 12px; background: var(--color-surface-alt);
}
.api-module h4 { margin: 0 0 8px; font-size: 13px; }
.api-module ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.api-module li {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; display: flex; align-items: center; gap: 6px;
}
.method {
  display: inline-block; min-width: 46px; text-align: center;
  padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700;
  font-family: var(--font-sans);
}
.method.GET    { background: #e0e7ff; color: #4338ca; }
.method.POST   { background: #dcfce7; color: #16a34a; }
.method.PUT    { background: #fef3c7; color: #d97706; }
.method.PATCH  { background: #fef3c7; color: #d97706; }
.method.DELETE { background: #fee2e2; color: #dc2626; }

/* ---------- Attachment cards (measurements / quotations) ---------- */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.attachment-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.att-header { display: flex; gap: 10px; align-items: flex-start; }
.att-icon {
  width: 44px; height: 44px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0;
}
.att-icon.pdf { background: var(--color-danger-soft); color: var(--color-danger); }
.att-icon.img { background: var(--color-info-soft);   color: #4338ca; }
.att-meta { flex: 1; min-width: 0; }
.att-meta strong { display: block; font-size: 13px; word-break: break-word; }
.att-meta small { color: var(--color-muted); font-size: 11px; display: block; margin-top: 2px; }
.att-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.att-actions .btn, .att-actions a.btn {
  padding: 5px 10px; font-size: 11px; text-decoration: none; flex: 1; justify-content: center;
}

.locked-card {
  text-align: center;
  padding: 32px 20px;
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
}
.locked-icon { font-size: 36px; margin-bottom: 8px; }
.locked-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.locked-card p { color: var(--color-muted); font-size: 13px; margin: 0; max-width: 380px; margin-left: auto; margin-right: auto; }

/* ---------- Meeting list (lead detail) ---------- */
.meeting-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 10px; }
.meeting-entry {
  display: flex; gap: 12px; padding: 14px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.meeting-entry.upcoming { border-left: 3px solid var(--color-warning); }
.meeting-entry.overdue {
  background: linear-gradient(0deg, var(--color-warning-soft), transparent);
  border-left: 3px solid var(--color-danger);
}
.meeting-entry.completed { opacity: 0.7; }
.meeting-entry.cancelled { opacity: 0.55; }
.meeting-entry.cancelled .meeting-meta strong { text-decoration: line-through; }
.meeting-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-info-soft); color: #4338ca;
  display: grid; place-items: center; font-size: 16px;
  flex-shrink: 0;
}
.meeting-body { flex: 1; min-width: 0; }
.meeting-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--color-muted); align-items: center;
}
.meeting-meta strong { color: var(--color-text); font-size: 14px; }
.meeting-body p { margin: 6px 0 0; font-size: 13px; }

.meeting-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; margin-left: 6px;
  background: var(--color-info-soft); color: #4338ca;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  vertical-align: middle; cursor: help;
}
.meeting-badge.due {
  background: var(--color-danger-soft); color: var(--color-danger);
  animation: bell-pulse 1.6s ease-in-out infinite;
}

/* ---------- Leads-table S. No. column + view toggle ---------- */
.leads-sno-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--color-muted);
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  user-select: none; cursor: pointer;
}
.leads-sno-toggle input { margin: 0; cursor: pointer; }
.leads-sno-toggle:hover { border-color: var(--color-primary); }
.sno-col { width: 60px; text-align: center; font-variant-numeric: tabular-nums; color: var(--color-muted); font-weight: 600; }
.hide-sno .sno-col { display: none !important; }

/* ----- View menu (column visibility dropdown) ----- */
.view-menu-wrap { position: relative; display: inline-block; }
.view-panel {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  width: 220px;
  z-index: 200;
  animation: phone-pop 0.12s ease;
}
.view-panel .view-title {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 8px;
}
.view-panel label {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}
.view-panel label:hover { background: var(--color-surface-alt); padding-left: 6px; padding-right: 6px; margin: 0 -6px; }
.view-panel input[type="checkbox"] { cursor: pointer; }
.view-panel-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end;
}

/* Column-hide rules — column indices in the leads table:
   1=S.No · 2=Lead · 3=Mobile · 4=Area · 5=Address · 6=Stage · 7=Status
   8=Product · 9=Last comment · 10=Last call · 11=Progress · 12=Leads By · 13=Actions */
.leads-hide-area     th:nth-child(4),  .leads-hide-area     td:nth-child(4)  { display: none !important; }
.leads-hide-address  th:nth-child(5),  .leads-hide-address  td:nth-child(5)  { display: none !important; }
.leads-hide-stage    th:nth-child(6),  .leads-hide-stage    td:nth-child(6)  { display: none !important; }
.leads-hide-status   th:nth-child(7),  .leads-hide-status   td:nth-child(7)  { display: none !important; }
.leads-hide-product  th:nth-child(8),  .leads-hide-product  td:nth-child(8)  { display: none !important; }
.leads-hide-comment  th:nth-child(9),  .leads-hide-comment  td:nth-child(9)  { display: none !important; }
.leads-hide-lastcall th:nth-child(10), .leads-hide-lastcall td:nth-child(10) { display: none !important; }
.leads-hide-progress th:nth-child(11), .leads-hide-progress td:nth-child(11) { display: none !important; }
.leads-hide-leadsby  th:nth-child(12), .leads-hide-leadsby  td:nth-child(12) { display: none !important; }

/* ============================================================
   Clickable "sort by Next call" column header — toggles asc/desc/off
   ============================================================ */
.sortable-col {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.sortable-col:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.sortable-col span:first-child { vertical-align: middle; }
.sortable-col .sort-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--color-muted);
  font-weight: 700;
  vertical-align: middle;
  transition: color 0.15s, transform 0.12s;
}
.sortable-col:hover .sort-indicator { color: var(--color-primary); }
.sortable-col.sort-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.sortable-col.sort-active .sort-indicator {
  color: var(--color-primary);
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(29, 78, 216, 0.2);
}
.sortable-col.sort-asc  .sort-indicator { animation: sort-flip-asc  0.2s ease; }
.sortable-col.sort-desc .sort-indicator { animation: sort-flip-desc 0.2s ease; }
@keyframes sort-flip-asc  { from { transform: translateY(2px); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }
@keyframes sort-flip-desc { from { transform: translateY(-2px); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   Combined "Last / Next call" cell + inline editor popover
   ============================================================ */
.last-call-cell {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
  cursor: pointer;
  min-width: 130px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.last-call-cell:hover { background: var(--color-primary-soft); }
.lnc-row {
  display: grid;
  grid-template-columns: 16px 32px 1fr auto;
  gap: 4px;
  align-items: baseline;
  font-size: 11px;
  white-space: nowrap;
}
.lnc-row .lnc-icon { font-size: 12px; }
.lnc-row .lnc-label {
  color: var(--color-muted);
  font-weight: 600;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.lnc-row strong {
  font-weight: 700;
  color: var(--color-text);
  font-size: 12px;
}
.lnc-row .lnc-ago {
  color: var(--color-muted);
  font-size: 10px;
  font-style: italic;
}
.lnc-row.lnc-empty em {
  color: var(--color-muted);
  font-style: italic;
  font-size: 11px;
  font-weight: 500;
  grid-column: 3 / -1;
}

/* Next-call colour states (urgency) */
.lnc-next.lnc-overdue strong { color: var(--color-danger); }
.lnc-next.lnc-overdue .lnc-ago {
  color: var(--color-danger); font-weight: 700; font-style: normal;
}
.lnc-next.lnc-today strong   { color: var(--color-warning); }
.lnc-next.lnc-today .lnc-ago {
  color: var(--color-warning); font-weight: 700; font-style: normal;
}
.lnc-next.lnc-soon strong { color: var(--color-primary); }

/* Compact mode — drop the icons + labels, keep just the dates inline */
.leads-compact .last-call-cell { min-width: 100px; padding: 2px 4px; gap: 1px; }
.leads-compact .lnc-row { grid-template-columns: 12px 26px 1fr; }
.leads-compact .lnc-row .lnc-ago { display: none; }

/* ----- Inline editor popover (clicking the cell) ----- */
.call-dates-popover {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.18);
  width: 360px; max-width: calc(100vw - 24px);
  z-index: 250;
  display: flex; flex-direction: column;
  animation: phone-pop 0.12s ease;
}
.cdp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.cdp-head strong { font-size: 13px; }
.cdp-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cdp-current {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
}
.cdp-current div { display: flex; flex-direction: column; }
.cdp-current small { font-size: 10px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.cdp-current strong { font-size: 13px; color: var(--color-text); margin-top: 2px; }
.cdp-field { display: flex; flex-direction: column; gap: 4px; }
.cdp-field small { font-size: 11px; color: var(--color-muted); font-weight: 600; }
.cdp-field input {
  font: inherit; font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%; max-width: 100%; box-sizing: border-box; min-width: 0;
}
.cdp-field input:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.cdp-hint {
  font-size: 11px;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1.45;
}
.cdp-hint em { font-style: normal; font-weight: 700; }
.cdp-actions {
  display: flex; justify-content: flex-end; gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
  padding-top: 12px;
}

/* ----- COMPACT rows mode (single-line, fits in viewport without horizontal scroll) ----- */
.leads-compact { width: 100%; table-layout: auto; }
.leads-compact th, .leads-compact td {
  padding: 4px 8px !important;
  font-size: 11px !important;
  white-space: nowrap;
  vertical-align: middle;
  /* Keep overflow visible so tooltips on badges/dots can render outside the cell.
     Long-text truncation is applied per-cell to specific inner elements only. */
  overflow: visible;
}
/* Tooltips need an unclipped chain of ancestors to render — when in compact mode,
   the .table-wrap parent must be overflow:visible too (the default overflow-x:auto
   silently clips overflow-y, which kills tooltips that pop above a cell). */
.table-wrap:has(.leads-compact),
.table-wrap.overflow-visible {
  overflow-x: visible;
  overflow-y: visible;
}

/* Hide low-priority columns entirely so the rest fit horizontally
   (Address column = 5, Leads By column = 12) — both still visible in the lead detail.
   Column indices were shifted by +1 after the new "Last call" column was inserted at position 10. */
.leads-compact th:nth-child(5),  .leads-compact td:nth-child(5),
.leads-compact th:nth-child(12), .leads-compact td:nth-child(12) {
  display: none;
}

/* Lead cell — name only, no designation/company subtext */
.leads-compact .lead-cell strong { font-size: 11px; }
.leads-compact .lead-cell small  { display: none; }
.leads-compact .lead-cell { gap: 6px; }
.leads-compact .lead-avatar { width: 22px; height: 22px; font-size: 10px; border-width: 1px; }
.leads-compact .lead-avatar .photo-count { display: none; }

/* Mobile column — show only the primary phone, drop the alt/ref rows */
.leads-compact .phone-stack .phone-row + .phone-row { display: none; }
.leads-compact .phone-stack .phone-row { gap: 0; }
.leads-compact .phone-stack .phone-tag { display: none; }
.leads-compact .phone-row .phone-link { font-size: 11px; }
.leads-compact .dup-badge { font-size: 9px; padding: 0 4px; }

/* Area cell — just area, no city subline */
.leads-compact td:nth-child(4) br + small { display: none; }

/* Stage / Status pills — smaller, tighter */
.leads-compact .lead-stage-select, .leads-compact .lead-status-select {
  padding: 1px 16px 1px 6px; font-size: 10px;
  background-size: 7px; background-position: right 3px center;
}

/* Product cell — single line */
.leads-compact .product-cell { max-width: 110px; padding: 2px 4px; }
.leads-compact .product-cell .cmore { display: none; }
.leads-compact .product-cell br { display: none; }

/* Last comment cell — only the text, one line, narrow */
.leads-compact .comment-cell { max-width: 130px; padding: 2px 4px; }
.leads-compact .comment-cell .ctype, .leads-compact .comment-cell .cmore { display: none; }
.leads-compact .comment-cell .ctext { -webkit-line-clamp: 1; font-size: 10px; font-weight: 500; }

/* Progress dots — tighter and smaller */
.leads-compact .progress-dots { gap: 2px; }
.leads-compact .progress-dot { width: 16px; height: 16px; font-size: 9px; border-width: 1px; }

/* Action buttons — icon only, small squares */
.leads-compact .actions-col, .leads-compact td:last-child { width: 1%; }
.leads-compact .row-actions { gap: 3px; flex-wrap: nowrap; }
.leads-compact .row-actions [data-view],
.leads-compact .row-actions [data-edit],
.leads-compact .row-actions [data-delete] {
  font-size: 0;
  width: 24px; height: 24px;
  padding: 0;
  border-radius: 4px;
  display: inline-grid; place-items: center;
  flex-shrink: 0;
}
.leads-compact .row-actions [data-view]::before   { content: "👁"; font-size: 12px; }
.leads-compact .row-actions [data-edit]::before   { content: "✎"; font-size: 13px; }
.leads-compact .row-actions [data-delete]::before { content: "×"; font-size: 16px; line-height: 1; font-weight: 700; }

/* Badges next to lead name shrink */
.leads-compact .callback-badge, .leads-compact .meeting-badge { font-size: 9px; padding: 0 4px; }

/* GPS pin & copy buttons stay tiny */
.leads-compact .gps-pin, .leads-compact .gps-copy { width: 18px; height: 18px; font-size: 10px; margin-left: 2px; }

/* Collapsible filters on the Leads toolbar
   When .filters-hidden is set, every filter dropdown / labelled date field
   collapses out of view. The search box, sort, view-prefs and action buttons stay. */
.leads-toolbar.filters-hidden > select.input,
.leads-toolbar.filters-hidden > label.filter-field {
  display: none;
}
/* Clear-filters button stays visible even when filters are collapsed,
   so users can wipe active filters without having to expand the section first */
/* Active-filter pill on the toggle when collapsed */
.filters-active-pill {
  display: inline-block;
  background: var(--color-warning); color: #fff;
  padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  margin-left: 4px;
}

/* Inline-edit dropdowns in the Stage / Status columns */
.lead-stage-select, .lead-status-select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid transparent;
  padding: 3px 22px 3px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  text-transform: capitalize;
  cursor: pointer;
  font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2364748b' d='M3 4.5l3 3 3-3z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
  background-color: var(--color-surface-alt);
  color: var(--color-muted);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.lead-stage-select:hover, .lead-status-select:hover {
  box-shadow: 0 0 0 3px var(--color-primary-soft);
  border-color: var(--color-primary);
}
.lead-stage-select.hot,                .lead-status-select.lost      { background-color: var(--color-danger-soft);  color: var(--color-danger); }
.lead-stage-select.warm,               .lead-status-select.contacted { background-color: var(--color-warning-soft); color: var(--color-warning); }
.lead-stage-select.cold,               .lead-status-select.new       { background-color: var(--color-info-soft);    color: #4338ca; }
.lead-status-select.qualified                                       { background-color: var(--color-primary-soft); color: var(--color-primary); }
.lead-status-select.won                                              { background-color: var(--color-success-soft); color: var(--color-success); }
.lead-status-select.disqualified                                     { background-color: #f3f4f6;                  color: #6b7280; text-decoration: line-through; }
.badge.disqualified { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }

/* Hide-disqualified toggle button */
.leads-disqual-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  user-select: none;
}
.leads-disqual-toggle:hover { border-color: var(--color-primary); }
.leads-disqual-toggle.active {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

/* Inline invoice payment-status dropdown */
.invoice-status-select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid transparent;
  padding: 3px 22px 3px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  text-transform: capitalize;
  cursor: pointer;
  font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2364748b' d='M3 4.5l3 3 3-3z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
  background-color: var(--color-surface-alt);
  color: var(--color-muted);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.invoice-status-select:hover {
  box-shadow: 0 0 0 3px var(--color-primary-soft);
  border-color: var(--color-primary);
}
.invoice-status-select.draft   { background-color: var(--color-surface-alt);  color: var(--color-muted); }
.invoice-status-select.sent    { background-color: var(--color-warning-soft); color: var(--color-warning); }
.invoice-status-select.partial { background-color: var(--color-warning-soft); color: var(--color-warning); }
.invoice-status-select.paid    { background-color: var(--color-success-soft); color: var(--color-success); }
.invoice-status-select.overdue { background-color: var(--color-danger-soft);  color: var(--color-danger); }
.invoice-status-select.void    { background-color: var(--color-surface-alt);  color: var(--color-muted); text-decoration: line-through; }

/* Money badge on invoice row when a payment reminder is set */
.money-badge {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--color-success-soft); color: var(--color-success);
  border-radius: 999px; font-size: 11px; font-weight: 700;
  vertical-align: middle; cursor: help;
}
.money-badge.due {
  background: var(--color-danger-soft); color: var(--color-danger);
  animation: bell-pulse 1.6s ease-in-out infinite;
}

/* NPA flag for overdue invoices with remaining balance */
.npa-flag {
  display: inline-block;
  background: var(--color-danger-soft); color: var(--color-danger);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px; font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.05em;
}

/* ---------- Lead-row callback badge (pending callback indicator) ---------- */
.callback-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; margin-left: 6px;
  background: var(--color-warning-soft); color: var(--color-warning);
  border-radius: 999px; font-size: 10px; font-weight: 700;
  vertical-align: middle; cursor: help;
}
.callback-badge.due {
  background: var(--color-danger-soft); color: var(--color-danger);
  animation: bell-pulse 1.6s ease-in-out infinite;
}
@keyframes bell-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.08); opacity: 0.75; }
}

/* ---------- Call log ---------- */
.tab-count {
  display: inline-block; min-width: 18px; padding: 1px 6px;
  margin-left: 4px; border-radius: 999px;
  background: var(--color-primary); color: #fff;
  font-size: 10px; font-weight: 700; vertical-align: middle;
}
.call-log {
  list-style: none; padding: 0; margin: 16px 0 0;
  display: flex; flex-direction: column; gap: 10px;
}
.call-entry {
  display: flex; gap: 12px;
  padding: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.call-num {
  width: 36px; height: 36px;
  background: var(--color-primary-soft); color: var(--color-primary);
  border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.call-body { flex: 1; min-width: 0; }
.call-meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--color-muted); margin-bottom: 4px;
  flex-wrap: wrap;
}
.call-meta strong { color: var(--color-text); font-size: 13px; }
.call-body p { margin: 4px 0 6px; font-size: 13px; }
.call-callback {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; margin-top: 6px;
  background: var(--color-warning-soft); color: var(--color-warning);
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
}
.call-callback.dismissed { background: var(--color-surface-alt); color: var(--color-muted); text-decoration: line-through; }
.call-callback .callback-purpose { font-weight: 500; color: var(--color-text); }
.call-callback button {
  margin-left: auto; background: transparent; border: none;
  color: inherit; cursor: pointer; font-weight: 700;
}
.call-callback button:hover { color: var(--color-danger); }

/* ---------- Notifications bell + panel ---------- */
.notif-bell { position: relative; font-size: 18px; }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px;
  background: var(--color-danger); color: #fff;
  border-radius: 999px; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; padding: 0 4px;
  border: 2px solid #fff;
}
.notif-panel {
  position: absolute; top: calc(var(--header-h) - 8px); right: 24px;
  background: var(--color-surface);
  width: 380px; max-width: calc(100vw - 32px);
  max-height: 480px; overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md); z-index: 60;
}
.notif-panel header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.notif-panel h4 { margin: 0; font-size: 14px; }
.notif-panel ul { list-style: none; padding: 0; margin: 0; }
.notif-panel li {
  padding: 12px 16px; border-bottom: 1px solid var(--color-border);
  display: flex; gap: 10px; align-items: flex-start;
}
.notif-panel li:last-child { border-bottom: none; }
.notif-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-warning-soft); color: var(--color-warning);
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 16px;
}
.notif-body { flex: 1; min-width: 0; }
.notif-body strong { display: block; font-size: 13px; }
.notif-body small { color: var(--color-muted); font-size: 11px; display: block; margin-top: 2px; }
.notif-body p { margin: 4px 0 0; font-size: 12px; color: var(--color-text); }
.notif-actions { display: flex; gap: 6px; margin-top: 6px; }
.notif-actions .btn { padding: 3px 8px; font-size: 11px; }
.notif-dismiss {
  background: transparent; border: none;
  color: var(--color-muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 4px;
}
.notif-dismiss:hover { color: var(--color-danger); }

/* ---------- Reminder list (inside invoice detail) ---------- */
.reminder-list {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: flex; flex-direction: column; gap: 6px;
}
.reminder-list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 12px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm); font-size: 12px;
}
.reminder-list li.due { background: var(--color-warning-soft); }
.reminder-list .meta { color: var(--color-muted); }

/* ---------- Profile page ---------- */
.profile-form {
  display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start;
}
.profile-avatar-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.profile-avatar {
  width: 160px; height: 160px; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary);
  display: grid; place-items: center;
  font-size: 64px; font-weight: 700;
  background-size: cover; background-position: center;
  border: 3px solid var(--color-border);
  overflow: hidden;
}
.avatar { background-size: cover; background-position: center; }
@media (max-width: 760px) {
  .profile-form { grid-template-columns: 1fr; }
  .profile-avatar-wrap { margin-bottom: 8px; }
}

/* ---------- Cold-call extras (lead modal) ---------- */
.cold-call-card {
  background: var(--color-warning-soft);
  border: 1px dashed var(--color-warning);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.cold-call-row { display: flex; flex-direction: column; gap: 6px; }
.cold-call-label { font-size: 12px; font-weight: 700; color: var(--color-warning); text-transform: uppercase; letter-spacing: 0.04em; }

.site-photos-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.site-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px; margin-top: 4px;
}
.site-photos-grid:empty { display: none; }
/* Compact thumbnails on the lead detail (smaller, scrollable album) */
.site-photos-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(64px, 64px));
  gap: 6px; max-width: 100%;
  padding: 4px; max-height: 220px; overflow-y: auto;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
}
.site-photos-grid.compact .site-photo { aspect-ratio: 1; cursor: zoom-in; }
.site-photos-grid.compact .site-photo:hover { transform: scale(1.04); transition: transform 0.12s ease; }
.site-photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
}
.site-photo img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.site-photo-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%; border: none;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  cursor: pointer; font-size: 14px; line-height: 1;
  display: grid; place-items: center;
}
.site-photo-remove:hover { background: var(--color-danger); }
.site-location-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-location-actions code,
#leadLocationDisplay code {
  background: var(--color-surface);
  padding: 2px 8px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.acc-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  margin-left: 4px;
}
.acc-success { background: var(--color-success-soft); color: var(--color-success); }
.acc-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.acc-danger  { background: var(--color-danger-soft);  color: var(--color-danger); }

/* Location capture modal (WhatsApp-style) */
.location-modal-card { max-width: 520px; }
.location-status {
  text-align: center;
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.location-map { min-height: 220px; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-surface-alt); }
.location-map iframe { display: block; border: 0; }
.location-details {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
}
.location-coords { font-size: 14px; text-align: center; margin-bottom: 10px; }
.location-coords code {
  background: var(--color-surface);
  padding: 3px 10px; border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.location-accuracy {
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
}
.location-progress {
  text-align: center; margin-top: 8px; color: var(--color-muted);
}
.location-bar {
  margin-top: 10px; height: 6px;
  background: var(--color-border);
  border-radius: 999px; overflow: hidden;
}
.location-bar-fill {
  height: 100%; border-radius: 999px;
  background: var(--color-warning);
  transition: width 0.3s ease, background 0.3s ease;
}
.location-bar-fill.good    { background: var(--color-success); }
.location-bar-fill.fair    { background: var(--color-warning); }
.location-bar-fill.poor    { background: var(--color-danger); }

/* ---------- Data exports grid ---------- */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.export-btn {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-start; text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  cursor: pointer; font-family: inherit;
}
.export-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  transform: translateY(-1px);
}
.export-icon { font-size: 22px; margin-bottom: 6px; }
.export-btn strong { font-size: 14px; color: var(--color-text); }
.export-btn small { color: var(--color-muted); font-size: 11px; }

/* ---------- Last-comment cell + popover ---------- */
.comment-cell {
  max-width: 220px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  transition: background 0.12s;
}
.comment-cell:hover { background: var(--color-primary-soft); }
.comment-cell .ctype  { font-size: 11px; font-weight: 700; color: var(--color-primary); display: block; }
.comment-cell .ctext  {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; color: var(--color-text); font-weight: 600;
  margin: 2px 0;
}
.comment-cell .cmore  { color: var(--color-primary); font-weight: 600; font-size: 11px; }
.comment-cell .cempty { color: var(--color-muted); font-style: italic; font-size: 12px; }

.comments-popover {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 380px; max-width: calc(100vw - 24px);
  max-height: 440px;
  z-index: 200;
  display: flex; flex-direction: column;
  animation: phone-pop 0.12s ease;
}
.comments-popover-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  border-radius: var(--radius) var(--radius) 0 0;
}
.comments-popover-head strong { font-size: 13px; }
.comments-popover .timeline { padding: 0 14px 10px; overflow-y: auto; max-height: 380px; }

/* Lead-row product cell + popover list */
.product-cell {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  transition: background 0.12s;
}
.product-cell:hover { background: var(--color-primary-soft); }

.product-popover-list {
  list-style: none; margin: 0; padding: 8px 14px 14px;
  overflow-y: auto; max-height: 380px;
  display: flex; flex-direction: column; gap: 8px;
}
.product-popover-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.product-popover-item .pi-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary);
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 16px;
}
.product-popover-item .pi-body { flex: 1; min-width: 0; }
.product-popover-item .pi-body strong { display: block; font-size: 13px; }
.product-popover-item .pi-body small { color: var(--color-muted); font-size: 11px; display: block; margin-top: 2px; }
.product-popover-item .pi-qty {
  background: var(--color-primary); color: #fff;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
/* Remove button on each product row inside the popover */
.product-popover-item .pi-remove {
  background: transparent;
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.product-popover-item .pi-remove:hover { background: var(--color-danger); color: #fff; }

/* ----------------------------------------------------------
   Inline add-form inside both comments & products popovers
   ---------------------------------------------------------- */
.popover-add-form {
  padding: 10px 14px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  display: flex; flex-direction: column; gap: 6px;
}
#productsPopoverAddForm {
  border-bottom: none;
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.popover-add-form .paf-row {
  display: flex; gap: 6px; align-items: center;
}
.popover-add-form select,
.popover-add-form input,
.popover-add-form textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}
.popover-add-form textarea { resize: vertical; min-height: 48px; }
.popover-add-form select { flex: 1; }
.popover-add-form input[type="number"] { width: 70px; flex: 0 0 auto; }
.popover-add-form .paf-actions {
  display: flex; justify-content: flex-end; gap: 6px;
}
.popover-add-form .paf-empty {
  color: var(--color-muted);
  font-size: 11px; font-style: italic;
  padding: 4px 0;
}

/* Edit/Delete action row inside comments popover items */
.comments-popover .timeline .comment-edit-actions {
  display: flex; gap: 6px; margin-top: 6px;
}
.comments-popover .timeline .comment-edit-form {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  background: var(--color-warning-soft);
  border: 1px dashed var(--color-warning);
  border-radius: var(--radius-sm);
}
.comments-popover .timeline .comment-edit-form select,
.comments-popover .timeline .comment-edit-form textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.comments-popover .timeline .comment-edit-form textarea { resize: vertical; min-height: 60px; }

/* ----------------------------------------------------------
   Share-lead popup — exports a single lead's full information
   to WhatsApp / Telegram / SMS / Email / Native share / Copy / Print.
   ---------------------------------------------------------- */
.share-popup {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.18);
  width: 420px; max-width: calc(100vw - 24px);
  max-height: 540px;
  z-index: 250;
  display: flex; flex-direction: column;
  animation: phone-pop 0.14s ease;
}
.share-popup-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  border-radius: var(--radius) var(--radius) 0 0;
}
.share-popup-head strong { font-size: 14px; flex: 1; }
.share-popup-head .share-photo-pill {
  background: #d1fae5;
  color: #065f46;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  margin-right: 8px;
  white-space: nowrap;
}
.share-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px;
}
/* Disabled state — applied to "Photos only" when the lead has no photos */
.share-opt-disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none;
}
.share-opt .so-label small { display: block; font-size: 9px; }

/* Hero "Image card" tile — visually emphasised as the recommended option */
.share-opt-hero {
  border-color: var(--color-primary);
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.12);
}
.share-opt-hero:hover {
  background: linear-gradient(135deg, #dbeafe 0%, #ede9fe 100%);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}
.share-opt-hero .so-icon {
  width: 44px; height: 44px; font-size: 22px;
}
.share-opt {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: inherit; font-size: 11px;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.share-opt:hover { background: var(--color-primary-soft); border-color: var(--color-primary); }
.share-opt:active { transform: translateY(1px); }
.share-opt .so-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.share-opt .so-label { font-weight: 600; color: var(--color-text); }
.share-preview-wrap {
  border-top: 1px solid var(--color-border);
  padding: 10px 16px 14px;
  background: var(--color-surface-alt);
  border-radius: 0 0 var(--radius) var(--radius);
}
.share-preview-label {
  display: block;
  color: var(--color-muted);
  font-size: 11px;
  margin-bottom: 6px;
}
.share-preview {
  margin: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font: 11px/1.55 'Consolas', 'Menlo', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
  color: var(--color-text);
}

/* Modal head right-side action group (Share / Print / Close) */
.modal-head-actions {
  display: flex; align-items: center; gap: 6px;
}
.modal-head-actions .btn { white-space: nowrap; }

@media (max-width: 600px) {
  .share-popup { width: calc(100vw - 24px); }
  .share-options { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Phone quick-actions popup ---------- */
.phone-link {
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}
.phone-link:hover { border-bottom-color: var(--color-primary); }

/* Stacked phone numbers in the leads-table Mobile column */
.phone-stack { display: flex; flex-direction: column; gap: 3px; }
.phone-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; line-height: 1.2; }
.phone-tag {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 8px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.02em;
  background: var(--color-surface-alt); color: var(--color-muted);
  white-space: nowrap;
  line-height: 14px;
}
.phone-tag.primary { background: var(--color-primary-soft); color: var(--color-primary); }
.phone-tag.alt     { background: var(--color-warning-soft); color: var(--color-warning); }
.phone-tag.ref     { background: var(--color-info-soft);    color: #4338ca; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.phone-row .phone-link { font-size: 12px; }

/* GPS pin + copy buttons in the leads table Address cell */
.gps-pin, .gps-copy {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px; border: none;
  cursor: pointer; font-size: 11px;
  text-decoration: none;
  margin-left: 4px;
  vertical-align: middle;
  transition: background 0.12s, color 0.12s;
}
.gps-pin  { background: var(--color-success-soft); color: var(--color-success); }
.gps-copy { background: var(--color-info-soft);    color: #4338ca; }
.gps-pin:hover  { background: var(--color-success); color: #fff; }
.gps-copy:hover { background: #4338ca; color: #fff; }

.dup-badge {
  display: inline-flex; align-items: center;
  margin-left: 4px;
  padding: 1px 6px;
  background: var(--color-danger-soft); color: var(--color-danger);
  border-radius: 4px;
  font-size: 10px; font-weight: 700;
  cursor: help;
  animation: bell-pulse 2.4s ease-in-out infinite;
}

.phone-popup {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 240px;
  z-index: 200;
  overflow: hidden;
  animation: phone-pop 0.12s ease;
}
@keyframes phone-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.phone-popup-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.phone-popup-icon { font-size: 16px; }
.phone-popup-head strong {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.phone-popup-actions { display: flex; flex-direction: column; padding: 4px; }
.phone-action {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: none; background: transparent;
  text-align: left; text-decoration: none;
  font-size: 13px; font-weight: 500;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}
.phone-action span { width: 20px; text-align: center; font-size: 14px; }
.phone-action:hover { background: var(--color-surface-alt); }
.phone-action.call:hover     { background: var(--color-success-soft); color: var(--color-success); }
.phone-action.whatsapp:hover { background: #dcfce7; color: #16a34a; }
.phone-action.sms:hover      { background: var(--color-info-soft); color: #4338ca; }
.phone-action.log:hover      { background: var(--color-primary-soft); color: var(--color-primary); }

/* ---------- Photo lightbox ---------- */
.modal.lightbox {
  background: rgba(0, 0, 0, 0.92);
  padding: 24px;
  align-items: center; justify-content: center;
  display: grid; place-items: center;
}
.modal.lightbox.hidden { display: none !important; }
.modal.lightbox img {
  max-width: 96vw; max-height: 86vh;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal.lightbox iframe {
  width: 96vw; max-width: 1100px;
  height: 86vh;
  background: #fff;
  border: none; border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lightbox-close, .lightbox-nav {
  position: fixed;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: none; cursor: pointer;
  display: grid; place-items: center;
  font-weight: 700;
  transition: background 0.15s;
  z-index: 110;
}
.lightbox-close { top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1; }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; font-size: 36px; line-height: 1; }
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255, 255, 255, 0.35); }
.lightbox-nav:disabled { opacity: 0.25; cursor: not-allowed; }
.lightbox-caption {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65); color: #fff;
  padding: 8px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  max-width: 80vw; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--color-text); color: #fff;
  padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); z-index: 100; font-size: 13px;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .card.span-2 { grid-column: auto; }
  .messaging-layout { grid-template-columns: 1fr; }
  .invoice-summary { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: 120px 1fr; }
}
@media (max-width: 960px) {
  /* On mobile the sidebar slides in over the content — don't reserve space for it. */
  .app-shell { padding-left: 0; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform 0.2s ease; z-index: 30;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .products-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sources-layout { grid-template-columns: 1fr; }
  .donut-box { height: 200px; }
  .user-meta { display: none; }
  .filters .btn { margin-left: 0; }
  .page-toolbar .btn { margin-left: 0; }
}
@media (max-width: 600px) {
  .content { padding: 16px; }
  .data-table th, .data-table td { padding: 10px; font-size: 13px; }
  .topbar { padding: 0 16px; }
  .kpi-grid, .kpi-grid.cols-3 { grid-template-columns: 1fr; }
  .funnel-meta { width: 100px; }
  .funnel-pct { width: 50px; }
  .invoice-summary { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   Mobile-specific bug fixes for the leads table
   ============================================================
   On phones, the leads table is much wider than the viewport. The
   default .table-wrap { overflow-x: auto } gives it a horizontal
   scrollbar (good), but compact-mode's .table-wrap:has(.leads-compact)
   override sets overflow:visible — which in mobile causes the WHOLE
   PAGE to scroll horizontally and the table to spill past the screen
   edge. Force overflow-x:auto on mobile so the table scrolls inside
   its own container regardless of compact mode. Tooltips that need to
   escape can fall back to data-tip-pos="top" which uses bottom: positioning. */
@media (max-width: 960px) {
  .table-wrap,
  .table-wrap:has(.leads-compact),
  .table-wrap.overflow-visible {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
  /* Stop the body from scrolling sideways even if a child overflows. */
  body { overflow-x: hidden; }
  /* Tighten the topbar so the menu button + page title + user chip fit. */
  .topbar { gap: 8px; }
  .topbar .page-title { font-size: 15px; }
  .topbar .page-subtitle { display: none; }
  /* Modals on mobile — leave a tiny breathing margin and use full height. */
  .modal-card { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
}
@media (max-width: 600px) {
  /* Sidebar slide-in width on tiny screens — leave room for the close gesture. */
  .sidebar { width: min(280px, 85vw); }
  /* Action buttons in row-actions wrap rather than overlap on tiny screens. */
  .row-actions { flex-wrap: wrap; gap: 4px; }
  /* Page toolbars stack instead of cramming into one wrapping flex line. */
  .page-toolbar > .btn { width: auto; }
  /* Share popup + call-dates popover full-width on tiny phones */
  .share-popup, .call-dates-popover, .comments-popover {
    width: calc(100vw - 16px) !important;
    left: 8px !important;
    right: 8px !important;
  }
}


/* Refresh-button attention pulse on Mark Received buttons */
@keyframes csc-pulse-attn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}
.csc-pulse-attn {
  animation: csc-pulse-attn 1.4s ease-in-out 0s 2;
  position: relative;
  z-index: 1;
}


/* Per-row inline edit / unlock visuals */
.pt-lock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 13px;
  margin-left: 4px;
}
.pt-lock-badge.locked   { background: var(--color-surface-alt, #f3f4f6); color: var(--color-muted, #6b7280); }
.pt-lock-badge.unlocked { background: #fef3c7; color: #92400e; animation: csc-unlock-glow 1.2s ease-in-out infinite alternate; }
@keyframes csc-unlock-glow {
  from { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.0); }
  to   { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25); }
}

.pt-card.is-unlocked {
  outline: 2px solid #fbbf24;
  outline-offset: 1px;
  background: linear-gradient(0deg, rgba(254, 243, 199, 0.35), transparent);
}

.pt-inline-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 4px;
  padding: 10px;
  background: var(--color-surface-alt, #f9fafb);
  border: 0.5px dashed var(--color-border-secondary, #d1d5db);
  border-radius: 8px;
}
.pt-inline-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.pt-inline-field small { color: var(--color-muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.4px; }
.pt-inline-field input,
.pt-inline-field select {
  padding: 6px 8px;
  border: 0.5px solid var(--color-border-tertiary, #e5e7eb);
  border-radius: 6px;
  background: var(--color-background, #fff);
  font-size: 13px;
  font-family: inherit;
}
.pt-inline-hint {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--color-muted, #6b7280);
}


/* Delete button on plan rows */
.pt-delete-btn {
  color: var(--color-danger, #b91c1c) !important;
}
.pt-delete-btn:hover {
  background: rgba(220, 38, 38, 0.08) !important;
  border-color: rgba(220, 38, 38, 0.45) !important;
}


/* Invoices column-picker — hide columns via nth-child classes on the table */
#invoicesTable.invoices-hide-number   th:nth-child(1), #invoicesTable.invoices-hide-number   td:nth-child(1) { display: none !important; }
#invoicesTable.invoices-hide-customer th:nth-child(2), #invoicesTable.invoices-hide-customer td:nth-child(2) { display: none !important; }
#invoicesTable.invoices-hide-status   th:nth-child(3), #invoicesTable.invoices-hide-status   td:nth-child(3) { display: none !important; }
#invoicesTable.invoices-hide-total    th:nth-child(4), #invoicesTable.invoices-hide-total    td:nth-child(4) { display: none !important; }
#invoicesTable.invoices-hide-paid     th:nth-child(5), #invoicesTable.invoices-hide-paid     td:nth-child(5) { display: none !important; }
#invoicesTable.invoices-hide-balance  th:nth-child(6), #invoicesTable.invoices-hide-balance  td:nth-child(6) { display: none !important; }
#invoicesTable.invoices-hide-due      th:nth-child(7), #invoicesTable.invoices-hide-due      td:nth-child(7) { display: none !important; }
