/* ==========================================================================
   Erwin Forrest Builders CRM — styles
   Palette: Erwin Forrest brand green (from the logo, #166232) for chrome and
   primary actions, warm timber amber as a secondary accent, charcoal/slate
   navy for neutral "in progress" tones, off-white paper for content.
   ========================================================================== */

:root {
  --ink: #1f2933;
  --ink-soft: #45505c;
  --muted: #6b7686;
  --line: #aba79c;
  --paper: #faf8f4;
  --card: #ffffff;
  --brand: #166232;
  --brand-dark: #0d3f20;
  --navy: #2b3a55;
  --navy-dark: #202b40;
  --amber: #e07a2c;
  --amber-dark: #c4631c;
  --green: #3f8f5f;
  --red: #c1493b;
  --sidebar-w: 244px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 41, 51, 0.06), 0 6px 20px rgba(31, 41, 51, 0.06);
  font-size: 15px;
}

/* The [hidden] attribute must always win over any display rule below —
   otherwise elements we JS-toggle with .hidden = true/false (login screen,
   config error, app shell) can render simultaneously, stacked in the page. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: inherit; margin: 0; color: var(--ink); }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 800; margin-bottom: 12px; }
p { margin: 0; }
.muted { color: var(--muted); }
.mt { margin-top: 20px; }
.mt-lg { margin-top: 24px; }
.mt-sm { margin-top: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-sm { margin-bottom: 8px; }

/* ---------------------------- App shell ---------------------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-dark), var(--brand));
  color: #e9ecf1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; padding: 8px 4px 26px; }
.brand__logo { height: 58px; width: auto; display: block; max-width: 100%; }
.brand--center { justify-content: center; padding: 0 0 4px 0; }

.nav-group { margin-bottom: 18px; }
.nav-group__label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: #7d8aa1; padding: 6px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: #d7dce6;
  font-size: 0.88rem; font-weight: 500; cursor: pointer;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav-link.is-active { background: rgba(224,122,44,0.18); color: #fff; }
.nav-link .nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer { margin-top: auto; padding: 10px; font-size: 0.72rem; color: #7d8aa1; }

#nav-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 40;
  background: var(--brand); color: #fff; border: none; border-radius: 8px;
  width: 38px; height: 38px; font-size: 1.1rem;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

/* ---------------------------- View head / shared ---------------------------- */

.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-sub { color: var(--muted); margin-top: 4px; font-size: 0.9rem; }
.view-head__actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.view-tabs { display: flex; gap: 4px; background: #ece9e1; border-radius: 10px; padding: 4px; }
.view-tabs__btn {
  border: none; background: transparent; padding: 8px 18px; border-radius: 8px;
  font-size: 0.86rem; font-weight: 700; color: var(--ink-soft); cursor: pointer;
}
.view-tabs__btn:hover { color: var(--ink); }
.view-tabs__btn.is-active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

.breadcrumb { font-size: 0.82rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--muted); }

.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 9px 16px;
  font-size: 0.86rem; font-weight: 600; cursor: pointer; transition: filter 0.1s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.96); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--success { background: var(--green); color: #fff; }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger-ghost { background: #fff; color: var(--red); border-color: #e6cbc6; }
.btn--sm { padding: 5px 10px; font-size: 0.78rem; }

.search-input {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  font-size: 0.86rem; min-width: 220px; background: #fff;
}

.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filter-select {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
  font-size: 0.86rem; background: #fff; color: var(--ink-soft); font-family: inherit;
}
.filter-bar .search-input { flex: 1; min-width: 200px; max-width: 320px; }

.view-tab-bar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.view-tab {
  border: none; background: none; font-family: inherit; cursor: pointer;
  padding: 9px 16px; font-size: 0.86rem; font-weight: 700; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.view-tab:hover { color: var(--ink); }
.view-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------------------------- KPI tiles ---------------------------- */

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi-grid--3col { grid-template-columns: repeat(3, 1fr); }
.kpi-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); border-top: 3px solid var(--muted);
}
.kpi-tile--navy { border-top-color: var(--navy); }
.kpi-tile--amber { border-top-color: var(--amber); }
.kpi-tile--green { border-top-color: var(--green); }
.kpi-tile--slate { border-top-color: #8a97ab; }
.kpi-tile--red { border-top-color: var(--red); }
.kpi-tile__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.kpi-tile__value { font-size: 1.5rem; font-weight: 800; margin: 6px 0 2px; letter-spacing: -0.01em; }
.kpi-tile__sub { font-size: 0.76rem; color: var(--muted); }
.kpi-tile__breakdown { display: flex; gap: 14px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.kpi-tile__breakdown > div { display: flex; flex-direction: column; }
.kpi-tile__breakdown-num { font-size: 1rem; font-weight: 800; color: var(--ink); }
.kpi-tile__breakdown-label { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.kpi-inline { display: flex; gap: 26px; margin-bottom: 16px; }
.kpi-inline--wrap { flex-wrap: wrap; gap: 20px 26px; }
.kpi-inline__num { display: block; font-size: 1.25rem; font-weight: 800; }
.kpi-inline__label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.panel-divider { border-top: 1px solid var(--line); margin: 4px 0 16px; }
.panel-title--lg { font-size: 1.15rem; font-weight: 800; }
.kpi-inline-subtitle { font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }

/* ---------------------------- Charts / panels ---------------------------- */

.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-box {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; height: 260px;
}
.chart-box canvas { max-height: 200px; }
.chart-box--wide {}

.panel-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.panel--wide { grid-column: span 1; }
.panel__head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 16px; align-items: start; }

.empty-banner {
  background: #fff4e8; border: 1px solid #f0d4b0; color: #7a4a12;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; font-size: 0.88rem;
}
.empty-banner--danger { background: #fdecea; border-color: #f0c2bb; color: #7a2e23; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty-banner--success { background: #eaf6ee; border-color: #bfe2cb; color: #1e5c38; }
.empty-inline { color: var(--muted); font-size: 0.86rem; padding: 10px 0; }

.empty-state {
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 44px 24px; text-align: center; color: var(--ink-soft);
}
.empty-state p { margin-bottom: 8px; }

/* ---------------------------- Tables ---------------------------- */

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.data-table, .mini-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .mini-table th { text-align: left; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.data-table td, .mini-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mini-table th, .mini-table td { padding: 9px 10px; }
.data-table tbody tr:last-child td, .mini-table tbody tr:last-child td { border-bottom: none; }
.row-link { cursor: pointer; }
.data-table tbody tr.row-link:hover, .mini-table tbody tr.row-link:hover { background: #f7f5f0; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 0.78rem; color: var(--muted); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
}
.avatar--square { border-radius: 8px; background: var(--amber); }
.avatar--lg { width: 56px; height: 56px; font-size: 1.1rem; }

/* ---------------------------- Card grid (companies) ---------------------------- */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.entity-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); cursor: pointer; }
.entity-card:hover { border-color: #a8a290; }
.entity-card__top { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.entity-card__stats { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------------------------- Profile head ---------------------------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.profile-head__info { flex: 1; min-width: 200px; }
.profile-head__info h1 { margin-bottom: 2px; }
.lead-status-row { display: flex; gap: 8px; margin-bottom: 6px; }

.detail-list { display: grid; gap: 10px; margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 120px 1fr; gap: 8px; font-size: 0.86rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.notes-block { font-size: 0.86rem; white-space: pre-wrap; color: var(--ink-soft); background: #f7f5f0; border-radius: 8px; padding: 10px 12px; }

/* ---------------------------- Pills / badges ---------------------------- */

.pill { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 0.72rem; font-weight: 700; }
.pill--navy { background: rgba(43,58,85,0.12); color: var(--navy); }
.pill--stage { background: rgba(224,122,44,0.14); color: var(--amber-dark); }
.pill--green { background: rgba(63,143,95,0.14); color: var(--green); }
.pill--red { background: rgba(193,73,59,0.14); color: var(--red); }
.pill--muted { background: #ece9e1; color: var(--ink-soft); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(43,58,85,0.1); color: var(--navy);
  padding: 4px 6px 4px 10px; border-radius: 100px; font-size: 0.78rem; font-weight: 600;
}
.filter-chip__remove {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border: none; border-radius: 50%; background: rgba(43,58,85,0.16); color: var(--navy);
  font-size: 0.62rem; line-height: 1; cursor: pointer; padding: 0;
}
.filter-chip__remove:hover { background: var(--navy); color: #fff; }

/* ---------------------------- Layout: side panel ---------------------------- */

.project-tracking-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }

.side-panel-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.side-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
}
.side-panel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.side-panel-list li { cursor: pointer; padding: 8px; border-radius: 8px; }
.side-panel-list li:hover { background: #f7f5f0; }

/* ---------------------------- Stage tracker (lead detail) ---------------------------- */

.stage-tracker { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.stage-step {
  display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line);
  border-radius: 100px; padding: 6px 12px; font-size: 0.76rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.stage-step__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.stage-step.is-done { color: var(--ink-soft); }
.stage-step.is-done .stage-step__dot { background: var(--green); }
.stage-step.is-current { background: rgba(224,122,44,0.14); border-color: var(--amber); color: var(--amber-dark); }
.stage-step.is-current .stage-step__dot { background: var(--amber); }

.permit-status-box__pills { display: flex; gap: 8px; flex-wrap: wrap; row-gap: 8px; }
.permit-status-box__township { font-size: 0.82rem; color: var(--muted); }

/* ---------------------------- Progress bar ---------------------------- */

.progress-bar { width: 100%; height: 6px; border-radius: 100px; background: var(--line); overflow: hidden; }
.progress-bar--lg { height: 9px; margin: 8px 0; }
.progress-bar__fill { height: 100%; border-radius: 100px; background: var(--brand); transition: width 0.2s; }

/* ---------------------------- Pre-Construction checklist ---------------------------- */

.precon-summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.precon-summary__stat { font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; }

.precon-phase { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.precon-phase__title { font-size: 0.86rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); margin-bottom: 10px; }
.precon-step-list { display: flex; flex-direction: column; gap: 6px; }
.precon-step-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px;
  border-bottom: 1px solid var(--line);
}
.precon-step-row:last-child { border-bottom: none; }
.precon-step-row:hover { background: #f7f5f0; }
.precon-step-row__label { flex: 1; font-size: 0.86rem; }
.precon-step-row__status {
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 0.78rem;
  font-weight: 600; background: #fff; color: var(--ink-soft); flex-shrink: 0;
}
.precon-add-step { margin-top: 10px; }
.precon-add-step input {
  width: 100%; border: 1px dashed var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 0.82rem; color: var(--ink-soft); background: transparent;
}
.precon-add-step input:focus { border-style: solid; border-color: var(--brand); }

/* Mass Email */
.mass-email-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .mass-email-layout { grid-template-columns: 1fr; } }
.mass-email-compose, .mass-email-recipients {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.mass-email-compose textarea { min-height: 220px; }
.mass-email-recipients__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mass-email-recipients__sub { font-size: 0.8rem; margin: 0; }
.mass-email-list { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow-y: auto; }
.mass-email-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px;
  border-bottom: 1px solid var(--line); font-size: 0.86rem; cursor: pointer;
}
.mass-email-row:last-child { border-bottom: none; }
.mass-email-row:hover { background: #f7f5f0; }
.mass-email-row__name { flex-shrink: 0; }
.mass-email-row__email { font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------- Contacted checklist ---------------------------- */

.overdue-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--red); color: #fff; font-size: 0.85rem; font-weight: 800;
  vertical-align: middle; margin-left: 8px; cursor: default;
}
.contacted-list { display: flex; flex-direction: column; gap: 6px; }
.contacted-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; flex-wrap: wrap; }
.contacted-row:hover { background: #f7f5f0; }
.contacted-row.is-overdue { background: rgba(193, 73, 59, 0.08); }
.contacted-row__check { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; min-width: 200px; cursor: pointer; }
.contacted-row__check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.contacted-row__date {
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 0.78rem;
  color: var(--ink-soft); background: #fff;
}
.contacted-row__flag { font-size: 0.78rem; font-weight: 700; color: var(--red); }
.contacted-row__due { font-size: 0.78rem; }

/* ---------------------------- Project Tracking: List view ---------------------------- */

.project-table th, .project-table td { white-space: nowrap; padding: 10px 12px; }
.project-table th:first-child, .project-table td:first-child { white-space: normal; }
.progress-cell { display: flex; align-items: center; gap: 6px; }
.progress-cell .progress-bar { width: 64px; flex-shrink: 0; }
.project-table__step {
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap !important;
  color: var(--ink-soft); font-size: 0.84rem;
}
.stage-select {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 0.78rem;
  font-weight: 600; background: #fff; color: var(--ink-soft); cursor: pointer;
}
.date-inline-input {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font-size: 0.78rem;
  font-weight: 600; background: #fff; color: var(--ink-soft); font-family: inherit; width: 132px;
}

/* ---------------------------- Project Calendar (Gantt timeline) ---------------------------- */

.gantt-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: auto; max-height: 76vh;
}
.gantt-table { border-collapse: collapse; }
.gantt-table th, .gantt-table td { border: 1px solid var(--line); }
.gantt-table thead th {
  position: sticky; top: 0; z-index: 2; height: 24px; box-sizing: border-box;
  font-size: 0.66rem; font-weight: 700; text-align: center; padding: 0 3px; white-space: nowrap; color: var(--ink-soft);
}
.gantt-row--year th { background: #e4edea; top: 0; }
.gantt-row--month th { background: #eef0e6; top: 24px; }
.gantt-row--week th { background: #f2efe8; top: 48px; font-size: 0.62rem; color: var(--muted); }
.gantt-th-info {
  position: sticky; z-index: 3 !important; text-align: left !important; background: #f2efe8 !important;
  padding: 0 8px !important; height: auto !important; vertical-align: middle;
  font-size: 0.74rem !important; font-weight: 800 !important; color: var(--ink) !important;
}
.gantt-td-info {
  position: sticky; z-index: 1; background: var(--card); padding: 6px 8px;
  font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-info--divider { border-right: 2px solid var(--line) !important; box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.15); }
.gantt-date-input, .gantt-staff-select {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 4px; font-size: 0.72rem; font-family: inherit; background: #fff; color: var(--ink-soft);
}
.gantt-td--name { font-weight: 700; font-size: 0.82rem; color: var(--ink); cursor: pointer; }
.gantt-td--name:hover { color: var(--brand); text-decoration: underline; }
.gantt-cell { width: 26px; min-width: 26px; height: 30px; position: relative; padding: 0; }
.gantt-cell.is-bar { background: var(--green); }
.gantt-cell.is-milestone::after {
  content: '◆'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #1f2933; font-size: 10px; line-height: 1;
}

/* ---------------------------- Activity feed ---------------------------- */

.attention-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.attention-list li { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; }
.attention-list li:hover { background: #f7f5f0; }
.attention-list__text { font-size: 0.86rem; }
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; }
.activity-list li { display: flex; gap: 10px; align-items: flex-start; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 6px; flex-shrink: 0; }
.activity-dot--created { background: var(--navy); }
.activity-dot--stage_change { background: var(--amber); }
.activity-dot--won { background: var(--green); }
.activity-dot--lost { background: var(--red); }
.activity-dot--note { background: #8a97ab; }
.activity-dot--reopened { background: #7a5c9e; }
.activity-dot--project_stage_change { background: var(--brand); }
.activity-line { font-size: 0.86rem; }
.activity-time { font-size: 0.74rem; color: var(--muted); }
.note-form { display: flex; gap: 8px; margin-bottom: 14px; }
.note-form input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 0.84rem; }

/* ---------------------------- Modal ---------------------------- */

#modal-root.is-open { display: block; }
#modal-root { display: none; position: fixed; inset: 0; z-index: 100; }
.modal-overlay { position: fixed; inset: 0; background: rgba(20,24,30,0.5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal-card { background: #fff; border-radius: 12px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal-card--wide { max-width: 640px; }
.modal-card__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-card__head h3 { margin: 0; font-size: 1.05rem; }
.modal-card__body { padding: 20px; }
.icon-btn { border: none; background: transparent; font-size: 1rem; cursor: pointer; color: var(--muted); }
body.modal-open { overflow: hidden; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); position: relative; }
.field--full { grid-column: span 2; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 0.88rem; font-weight: 400; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff;
}
.field textarea { resize: vertical; }
.form-actions { grid-column: span 2; display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.confirm-text { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 4px; }

.revenue-row { display: flex; align-items: center; gap: 8px; }
.revenue-row input { flex: 1; min-width: 0; }
.revenue-readout { font-size: 0.86rem; font-weight: 700; color: var(--brand); white-space: nowrap; }

.subform { background: #f7f5f0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.subform__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em;
  margin-bottom: 10px;
}
.subform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.link-btn-inline {
  background: none; border: none; color: var(--brand); font-weight: 700; font-size: 0.84rem;
  cursor: pointer; padding: 0; text-decoration: underline;
}
.link-btn-inline--danger { color: var(--red); font-size: 0.76rem; text-transform: none; letter-spacing: 0; font-weight: 600; }

.permits-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.permit-row { display: flex; gap: 8px; align-items: center; }
.permit-row__type {
  flex: 1; font-family: inherit; font-size: 0.86rem; font-weight: 400; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.permit-row__status {
  font-family: inherit; font-size: 0.86rem; font-weight: 400; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; flex: 0 0 150px;
}
.permit-row__remove {
  border: none; background: none; color: var(--red); cursor: pointer; font-size: 0.9rem;
  width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0;
}
.permit-row__remove:hover { background: rgba(193,73,59,0.1); }

.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); max-height: 220px; overflow-y: auto;
}
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: 0.82rem; border-bottom: 1px solid var(--line); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.is-active { background: #f7f5f0; }
.autocomplete-item strong { display: block; color: var(--ink); font-weight: 700; }
.autocomplete-item span { color: var(--muted); font-size: 0.76rem; }
.autocomplete-banner {
  grid-column: span 2; background: rgba(22,98,50,0.1); border: 1px solid rgba(22,98,50,0.25);
  color: var(--brand-dark); border-radius: 8px; padding: 8px 12px; font-size: 0.8rem; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.autocomplete-banner button { background: none; border: none; color: var(--brand-dark); text-decoration: underline; cursor: pointer; font-size: 0.78rem; font-weight: 600; }

/* ---------------------------- Login screen ---------------------------- */

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--brand-dark), var(--brand)); padding: 24px;
}
.login-card {
  background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35); display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 1.3rem; margin-top: 8px; }
.login-card .field { gap: 6px; }
.login-card .brand__logo { height: 72px; }
.login-error {
  background: #fdecea; border: 1px solid #f0c2bb; color: #7a2e23; border-radius: 8px;
  padding: 8px 12px; font-size: 0.82rem;
}
.btn--block { width: 100%; padding: 11px; font-size: 0.9rem; }
.link-btn {
  background: none; border: none; color: #aab4c4; text-decoration: underline; cursor: pointer;
  font-size: 0.72rem; padding: 6px 0 0; display: block;
}
.link-btn:hover { color: #fff; }

/* ---------------------------- Toasts ---------------------------- */

#toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 0.84rem;
  opacity: 0; transform: translateY(6px); transition: all 0.2s; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--warn { background: var(--red); }

/* ---------------------------- Responsive ---------------------------- */

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 980px) {
  .chart-row, .panel-row, .detail-grid { grid-template-columns: 1fr; }
  .side-panel-layout { grid-template-columns: 1fr; }
  .side-panel { position: static; max-height: none; }
}

@media (max-width: 760px) {
  #nav-toggle { display: block; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left 0.2s; box-shadow: 0 0 30px rgba(0,0,0,0.3); }
  .sidebar.is-open { left: 0; }
  .main { padding: 70px 16px 60px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .field--full, .form-actions { grid-column: span 1; }
  .subform-grid { grid-template-columns: 1fr; }
  .permit-row { flex-wrap: wrap; }
  .permit-row__status { flex: 1 1 auto; }
  .detail-list > div { grid-template-columns: 100px 1fr; }
}

/* ---------------------------- Client Questionnaire (public, standalone page) ---------------------------- */

/* A plain printed-document look, matching a standard questionnaire
   template: bordered sheet, bold company name + subtitle, dividers
   between the header/intro/each section, section headings with an
   optional italic note, short answers inline ("1. Name: ___"), and
   square checkbox-style choices instead of native dropdowns. */
.qf-page { min-height: 100vh; background: #e9e5da; padding: 40px 20px; }
.qf-sheet {
  max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; box-shadow: var(--shadow); padding: 44px 52px;
}
.qf-logo { height: 88px; width: auto; display: block; margin-bottom: 10px; }
.qf-sheet__title { font-size: 1.2rem; font-weight: 800; color: var(--ink); margin: 2px 0 0; }
.qf-intro { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.6; margin: 0; }
.qf-divider { border: none; border-top: 2px solid var(--brand); margin: 18px 0; }
#q-success h2 { font-size: 1.2rem; margin-bottom: 8px; }

.qf-section + .qf-divider { margin: 24px 0; }
.qf-section__heading { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.qf-section__note { font-style: italic; color: var(--muted); font-size: 0.8rem; margin: 0 0 16px; }
.qf-section__fields { display: flex; flex-direction: column; gap: 16px; margin-top: 14px; }

.qf-q__label { font-weight: 600; font-size: 0.88rem; color: var(--ink); margin-bottom: 8px; }
.qf-required { color: var(--red); font-weight: 400; }

.qf-q--inline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.qf-q--inline .qf-q__label { margin-bottom: 0; white-space: nowrap; }
.qf-q--inline .qf-q__underline { flex: 1; min-width: 140px; }

.qf-q__underline {
  font-family: inherit; font-size: 0.88rem; color: var(--ink);
  border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 3px 2px; background: transparent;
}
.qf-q__underline:focus { outline: none; border-bottom: 2px solid var(--brand); padding-bottom: 2px; }
div.qf-q > textarea.qf-q__underline {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; resize: vertical;
}
div.qf-q > textarea.qf-q__underline:focus { border-color: var(--brand); }

.qf-q__choices { display: flex; flex-direction: column; gap: 9px; }
.qf-q__choices label {
  display: flex; align-items: center; gap: 9px; font-weight: 400; font-size: 0.86rem;
  color: var(--ink); cursor: pointer;
}
/* Square checkbox-style, even though these are single-choice (radio)
   fields under the hood — matches the reference template's ☐ options. */
.qf-q__choices input {
  appearance: none; -webkit-appearance: none; width: 15px; height: 15px; flex-shrink: 0;
  border: 1.5px solid var(--muted); border-radius: 3px; background: #fff; cursor: pointer; margin: 0;
}
.qf-q__choices input:checked { background: var(--brand); border-color: var(--brand); }

.qf-submit-row { margin-top: 32px; display: flex; justify-content: flex-end; }
.qf-submit-row .btn { padding: 11px 28px; }

@media (max-width: 600px) {
  .qf-sheet { padding: 32px 24px; }
}

/* ---------------------------- Public lead-capture form (lead-intake.html) ---------------------------- */

.qf-sheet #li-form.form-grid { margin-top: 24px; }
.qf-sheet .form-actions { grid-column: span 2; margin-top: 8px; justify-content: flex-end; }
.qf-sheet #li-success h2 { font-size: 1.2rem; margin-bottom: 8px; }
/* Honeypot — invisible to a real visitor (off-canvas, not display:none,
   since some bots skip display:none fields but still fill this in) and
   removed from tab order; see leadIntake.js for how a filled value is handled. */
.li-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------- Client Questionnaire (staff-side tracker) ---------------------------- */

.q-name-cell { display: flex; align-items: center; gap: 8px; }
.q-indicator {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--line); background: transparent;
}
.q-indicator.is-answered { background: var(--green); border-color: var(--green); }

.btn:disabled { opacity: 0.6; cursor: not-allowed; filter: none !important; }
.btn--answered { background: rgba(63, 143, 95, 0.14); color: var(--green); border-color: transparent; }

.q-response-pick {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 14px 16px; margin-bottom: 10px; font: inherit; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.q-response-pick:last-child { margin-bottom: 0; }
.q-response-pick:hover { border-color: var(--brand); }
.q-response-pick span:first-child { font-weight: 700; }

.q-response-back {
  display: inline-block; margin-bottom: 14px; padding: 0; font: inherit; font-weight: 600;
  color: var(--brand); background: none; border: none; cursor: pointer;
}

.q-response-section { margin-bottom: 20px; }
.q-response-section:last-of-type { margin-bottom: 0; }
.q-response-section__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
.q-response-list { display: flex; flex-direction: column; gap: 12px; margin: 0; }
/* Each question + answer gets its own shaded box so a long response list
   reads as separate items instead of one running block of text. */
.q-response-item { background: #e9e5da; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.q-response-list dt { font-size: 0.82rem; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.q-response-list dd { margin: 0; font-size: 0.9rem; color: var(--ink); white-space: pre-wrap; }

/* ---------------------------- Print / Save as PDF (one questionnaire response) ---------------------------- */

/* #print-root is populated on demand (see printQuestionnaireResponse in
   modal.js) right before window.print() and stays empty/hidden the rest
   of the time. On print, everything else on the page is hidden via
   visibility (not display) so the browser still paginates #print-root's
   content correctly across multiple pages instead of clipping it to
   whatever fit on screen. */
#print-root { display: none; }
@media print {
  /* Browsers skip background colors/images when printing by default
     (Chrome's "Background graphics" print option is unchecked unless the
     page forces it) — without this, the tan question-box shading below
     would silently print as plain white with just the border showing. */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body * { visibility: hidden; }
  #print-root, #print-root * { visibility: visible; }
  #print-root { display: block; position: absolute; top: 0; left: 0; width: 100%; }
  .print-sheet { max-width: 700px; margin: 0 auto; padding: 24px; }
  .print-logo { height: 88px; margin-bottom: 10px; }
  .print-meta { color: #444; margin: 6px 0 20px; font-size: 0.9rem; line-height: 1.5; }
  .print-sheet .q-response-item { break-inside: avoid; }
  .print-sheet .qf-section__heading { break-after: avoid; }
}

/* ---------------------------- Flatpickr (date fields, brand-matched) ---------------------------- */

.flatpickr-calendar { font-family: inherit; box-shadow: var(--shadow); border-radius: var(--radius); }
.flatpickr-day.selected, .flatpickr-day.selected:hover,
.flatpickr-day.startRange, .flatpickr-day.startRange:hover,
.flatpickr-day.endRange, .flatpickr-day.endRange:hover {
  background: var(--brand); border-color: var(--brand);
}
.flatpickr-day.today { border-color: var(--amber); }
.flatpickr-day.today:hover { border-color: var(--amber); background: var(--amber); color: #fff; }
.flatpickr-day:hover { background: rgba(22, 98, 50, 0.1); }
.flatpickr-months .flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month input.cur-year:focus { background: rgba(22, 98, 50, 0.08); }
span.flatpickr-weekday { color: var(--muted); }
