/* webapp/static/style.css — Module 10 Dashboard shared styles.
   Clean, minimal, mobile-first SaaS look. Large tap targets throughout
   (buttons/inputs are at least 44px tall) since the primary user is a
   plumber using this one-handed, on a phone, between jobs. */

:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e5ea;
  --color-text: #14181f;
  --color-text-muted: #626a78;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-critical: #dc2626;
  --color-high: #ea580c;
  --color-medium: #d97706;
  --color-low: #64748b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.06), 0 1px 6px rgba(20, 24, 31, 0.05);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

button, input, select {
  font-family: inherit;
  font-size: 1rem;
}

/* ---------- Layout shell ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  display: inline-block;
}

.app-header .user-email {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  display: none;
}

@media (min-width: 640px) {
  .app-header .user-email { display: inline; }
}

.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 12px 32px 12px;
}

/* Bottom nav on mobile, top tabs on larger screens */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
}

.app-nav a {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.app-nav a.active { color: var(--color-primary); }

@media (min-width: 640px) {
  .app-nav {
    position: static;
    border-top: none;
    justify-content: flex-start;
    gap: 4px;
    padding: 0 16px;
    background: transparent;
  }
  .app-nav a {
    flex: none;
    padding: 8px 16px;
    border-radius: 8px;
  }
  .app-nav a.active { background: #eef2ff; }
}

/* ---------- Buttons & inputs (large tap targets) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

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

.input-field {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.input-field:focus { outline: 2px solid var(--color-primary); outline-offset: -1px; }

label { font-weight: 600; font-size: 0.9rem; display: block; margin-bottom: 6px; }

/* ---------- Login page ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
}

.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 4px 0;
}

.login-card p.subtitle {
  color: var(--color-text-muted);
  margin: 0 0 24px 0;
  font-size: 0.9rem;
}

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

.error-banner {
  background: #fef2f2;
  color: var(--color-critical);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* ---------- Filters / search ---------- */

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filters-bar select,
.filters-bar input[type="search"] {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.92rem;
}

.filters-bar input[type="search"] { flex: 1 1 220px; }
.filters-bar select { flex: 1 1 130px; }

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-muted);
}

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

.results-count { color: var(--color-text-muted); font-size: 0.85rem; margin: 4px 0 12px 0; }

/* ---------- Opportunity cards ---------- */

.opportunity-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.opportunity-card .card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.opportunity-card h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.35;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.badge-critical { background: var(--color-critical); }
.badge-high { background: var(--color-high); }
.badge-medium { background: var(--color-medium); }
.badge-low { background: var(--color-low); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 8px 0;
}

.meta-row span strong { color: var(--color-text); }

.summary-text {
  font-size: 0.9rem;
  color: var(--color-text);
  margin: 8px 0 12px 0;
  line-height: 1.45;
}

.card-actions { display: flex; gap: 8px; }
.card-actions .btn { width: auto; flex: 1; min-height: 44px; padding: 10px 14px; font-size: 0.9rem; }

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 48px 16px;
}

/* ---------- Recent Calls section (Module 12, M2) ----------
   Additive only -- reuses .opportunity-card/.empty-state/.results-count
   styling above; adds just a heading + top border to visually separate
   it from the main opportunity list. */

.recent-calls-section {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border, #e2e2e2);
}

.recent-calls-heading {
  font-size: 1.05rem;
  margin: 0 0 4px 0;
}

/* ---------- Map page ---------- */

#map-canvas {
  width: 100%;
  height: calc(100vh - 210px);
  min-height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leaflet-popup-content { font-size: 0.85rem; min-width: 220px; }
.leaflet-popup-content h4 { margin: 0 0 6px 0; font-size: 0.95rem; }
.leaflet-popup-content .popup-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.82rem;
}

.marker-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 10px 0;
}

.marker-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ============================================================
   UI Polish Phase 1 additions (Module 12). Presentation-layer
   only -- no selectors above this line were removed or renamed,
   so every existing class still works exactly as before. New
   rules below extend the same design tokens (--color-*, --radius,
   --shadow) already defined at the top of this file.
   ============================================================ */

/* ---------- Brand block (base.html) ---------- */

.app-header .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.app-header .brand-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.app-header .brand-subtitle {
  display: none;
  font-weight: 500;
  font-size: 0.68rem;
  color: var(--color-text-muted);
}

@media (min-width: 640px) {
  .app-header .brand-subtitle { display: block; }
}

/* ---------- Nav "Coming Soon" placeholders ---------- */

.app-nav a.nav-soon {
  position: relative;
  opacity: 0.7;
}

.nav-soon-tag {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

@media (min-width: 640px) {
  .app-nav a.nav-soon { display: inline-flex; align-items: center; gap: 6px; }
  .nav-soon-tag {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 1px 7px;
  }
}

/* ---------- Coming Soon page ---------- */

.coming-soon-panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
  margin-top: 8px;
}

.coming-soon-title {
  color: var(--color-text);
  font-size: 1.15rem;
  margin: 0 0 8px 0;
}

.coming-soon-text {
  font-size: 0.9rem;
  margin: 0;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- KPI summary cards ---------- */

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

@media (min-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-card .kpi-label {
  font-size: 0.76rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.kpi-card .kpi-note {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* ---------- Opportunity card icons (presentation only) ---------- */

.meta-row .meta-icon {
  display: inline-block;
  margin-right: 3px;
}

.card-actions .btn .link-icon {
  margin-right: 6px;
}

/* ---------- Section headings (shared by opportunities / calls / status) ---------- */

.section-heading {
  font-size: 1.05rem;
  margin: 0 0 4px 0;
}

.section-block {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.section-block:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ---------- Recent Calls table ---------- */

.calls-table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table.calls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 720px;
}

table.calls-table th,
table.calls-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

table.calls-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

table.calls-table tr:last-child td { border-bottom: none; }

table.calls-table td.issue-cell {
  white-space: normal;
  min-width: 220px;
  max-width: 320px;
}

.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pill-review { background: var(--status-warn-bg); color: var(--status-warn-text); }
.status-pill-logged { background: var(--status-ok-bg); color: var(--status-ok-text); }
/* Phase 3 "run automatically": /admin/scheduler's third status
   (Error) -- Running/Paused already reuse status-pill-logged/-review
   above, this is the one new state that needed a color -- same
   --status-critical-bg token operations/health.py's dashboard.html
   already uses for critical KPI icons. */
.status-pill-critical { background: var(--status-critical-bg); color: var(--color-critical); }

/* ---------- System Status card ---------- */

.status-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 640px) {
  .status-grid { grid-template-columns: repeat(2, 1fr); }
}

.status-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
}

.status-row:last-child { border-bottom: none; }

.status-row .status-row-label { color: var(--color-text); font-weight: 600; }
.status-row .status-row-detail { color: var(--color-text-muted); font-size: 0.78rem; display: block; margin-top: 1px; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  flex-shrink: 0;
}

.status-dot-ok { background: var(--color-accent); }
.status-dot-warn { background: var(--color-medium); }
.status-dot-off { background: var(--color-text-muted); }

.status-value {
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ============================================================
   Phase 2, UI-1: Design System tokens + Sidebar/Topbar shell.
   See DESIGN_SYSTEM.md for the full reference. Additive only --
   nothing above this line is renamed or removed, so every Phase 1
   selector keeps working exactly as before. New tokens live in a
   second :root block (valid CSS) rather than editing the original
   one, to keep this change low-risk to review/diff.
   ============================================================ */

:root {
  /* Extended palette (formalizes colors already used inline in Phase 1) */
  --color-primary-light: #eef2ff;
  --color-accent: #16a34a;
  --color-warning: #d97706;
  --color-surface-sunken: #f8f9fb;
  --color-text-subtle: #9aa2b0;

  /* Semantic status tints (UI-4 dark-mode prep): every ok/warn/
     critical/off badge, pill, icon chip, and timeline dot across
     the app draws from these instead of a repeated hardcoded hex
     pair, so a future dark theme redefines colors in one place. */
  --status-ok-bg: #dcfce7;
  --status-ok-text: #166534;
  --status-warn-bg: #fef3c7;
  --status-warn-text: #92400e;
  --status-critical-bg: #fee2e2;
  --status-off-bg: #f1f5f9;
  --status-pipeline-bg: #f3e8ff;
  --color-on-accent: #ffffff;

  /* Typography scale */
  --text-xs: 0.72rem;
  --text-sm: 0.82rem;
  --text-base: 0.9rem;
  --text-md: 1.05rem;
  --text-lg: 1.3rem;
  --text-xl: 1.75rem;

  /* Spacing scale (4px base unit) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radius scale */
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Elevation */
  --shadow-md: 0 4px 14px rgba(20, 24, 31, 0.10), 0 2px 6px rgba(20, 24, 31, 0.06);

  /* Chart palette (reserved for UI-3 -- no charts exist yet) */
  --chart-1: #2563eb;
  --chart-2: #16a34a;
  --chart-3: #d97706;
  --chart-4: #dc2626;
  --chart-5: #7c3aed;
  --chart-6: #0891b2;

  /* Layout constants */
  --sidebar-width: 232px;
  --topbar-height: 60px;
}

/* ---------- Ghost button (new variant, additive) ---------- */

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  min-height: 40px;
  padding: 8px 12px;
}

.btn-ghost:hover { color: var(--color-text); background: var(--color-surface-sunken); }

/* ---------- Interactive card hover (opt-in via .card-hoverable) ---------- */

.card-hoverable { transition: box-shadow 0.15s ease; }
.card-hoverable:hover { box-shadow: var(--shadow-md); }

/* ============================================================
   App shell: Sidebar + Topbar + content, one implementation for
   every breakpoint (UI-4). The Phase 1 .app-header/.app-nav mobile
   fallback chrome was retired in UI-4 -- this sidebar+topbar is now
   the single navigation source of truth at mobile, tablet, and
   desktop widths (see base.html and the media query below).
   ============================================================ */

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

/* UI-4: the sidebar is now the SAME element at every breakpoint -- an
   off-canvas drawer below 1024px (fixed, translated off-screen, toggled
   via .sidebar-open + the topbar hamburger), a permanent column at
   >=1024px (see the media query below). Not a separate mobile nav. */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  width: min(var(--sidebar-width), 82vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-surface-sunken);
  border-right: 1px solid var(--color-border);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.sidebar.sidebar-open {
  transform: translateX(0);
  box-shadow: var(--shadow-md);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 24, 0.45);
  z-index: 45;
}

.sidebar-backdrop.visible { display: block; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--space-4);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  display: inline-block;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  overflow: hidden;
}

.sidebar-brand-name { font-weight: 700; font-size: var(--text-md); white-space: nowrap; }
.sidebar-brand-subtitle {
  font-weight: 500;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.sidebar-nav a:hover { background: var(--color-surface-sunken); color: var(--color-text); }
.sidebar-nav a.active { background: var(--color-primary-light); color: var(--color-primary); }

.sidebar-nav .nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.sidebar-nav .nav-soon-tag {
  margin-left: auto;
  font-size: 0.6rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 1px 6px;
  color: var(--color-text-subtle);
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

/* ---------- Topbar (every breakpoint, UI-4) ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 15;
  gap: var(--space-3);
}

.topbar-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.05rem;
  flex-shrink: 0;
}

.topbar-menu-btn:hover { background: var(--color-surface-sunken); }

.topbar .user-email {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  display: none;
}

@media (min-width: 640px) {
  .topbar .user-email { display: inline; }
}

@media (max-width: 479px) {
  .topbar { padding: 0 var(--space-3); gap: var(--space-2); }
  .topbar-context-label { display: none; }
}

.topbar-context {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.topbar-context-label {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  font-weight: 600;
  display: block;
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  font-size: 1rem;
}

.topbar-icon-btn:hover { background: var(--color-surface-sunken); border-color: var(--color-border); }

.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Desktop breakpoint: sidebar becomes a permanent
   sticky column instead of an off-canvas drawer, hamburger hides. ---------- */

@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    left: auto;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    flex-shrink: 0;
    transform: none;
    box-shadow: none;
    z-index: auto;
  }

  .sidebar-backdrop { display: none !important; }

  .topbar-menu-btn { display: none; }

  .topbar { padding: 0 var(--space-5); gap: var(--space-4); }

  .app-main {
    max-width: 1120px;
    padding: var(--space-5) var(--space-6) var(--space-6) var(--space-6);
  }
}

/* ============================================================
   UI-2: Dashboard redesign. Additive only -- every selector above
   this line keeps working. See DESIGN_SYSTEM.md addendum for the
   new section-card / empty-state / analytics-bar / mini-map
   patterns introduced here.
   ============================================================ */

/* ---------- Sidebar polish ---------- */

.sidebar-nav a {
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav a.active {
  box-shadow: inset 3px 0 0 var(--color-primary);
}

/* ---------- Section card: the canonical wrapper for every
   dashboard section (Urgent Activity, Maps & Signals, Jobs,
   Recent Calls, Analytics Preview, System Health). ---------- */

.section-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}

.section-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
}

.section-card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.section-card-titles { min-width: 0; }
.section-card-title { font-size: var(--text-md); font-weight: 700; margin: 0; }
.section-card-subtitle { font-size: var(--text-xs); color: var(--color-text-muted); margin: 1px 0 0 0; }

/* ---------- KPI cards v2 ---------- */

.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.kpi-card-icon.status-ok { background: var(--status-ok-bg); color: var(--color-accent); }
.kpi-card-icon.status-warn { background: var(--status-warn-bg); color: var(--color-warning); }
.kpi-card-icon.status-critical { background: var(--status-critical-bg); color: var(--color-critical); }

.kpi-card .kpi-value { font-size: var(--text-xl); }
.kpi-card .kpi-label { font-weight: 600; color: var(--color-text); font-size: var(--text-sm); }
.kpi-card .kpi-desc { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ---------- Empty states with CSS-only icon ---------- */

.empty-state-icon {
  font-size: 2.1rem;
  color: var(--color-text-subtle);
  margin-bottom: var(--space-2);
  line-height: 1;
}

.empty-state-title { font-weight: 600; color: var(--color-text); margin: 0 0 4px 0; }
.empty-state-text { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0; }

/* ---------- Urgent Activity ---------- */

.urgent-list { display: flex; flex-direction: column; gap: 8px; }

.urgent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
  border-left: 3px solid var(--color-text-subtle);
  font-size: var(--text-sm);
}

.urgent-item.urgent-critical { border-left-color: var(--color-critical); }
.urgent-item.urgent-high { border-left-color: var(--color-high); }
.urgent-item.urgent-review { border-left-color: var(--color-warning); }

.urgent-item-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urgent-item-meta { color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }

/* ---------- Analytics Preview (lightweight, no chart library --
   full interactive charts are UI-3 scope) ---------- */

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 900px) {
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
}

.analytics-card {
  background: var(--color-surface-sunken);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.analytics-card-title { font-size: var(--text-sm); font-weight: 700; margin: 0 0 var(--space-3) 0; }

.bar-list { display: flex; flex-direction: column; gap: 8px; }

.bar-row { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); }

.bar-row-label {
  width: 110px;
  flex-shrink: 0;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill { height: 100%; background: var(--color-primary); border-radius: 999px; }

.bar-row-value { width: 26px; flex-shrink: 0; text-align: right; color: var(--color-text); font-weight: 600; }

/* ---------- Compact dashboard map ---------- */

.mini-map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#dashboard-map-canvas { width: 100%; height: 260px; }

.map-placeholder {
  height: 260px;
  border-radius: var(--radius);
  background: var(--color-surface-sunken);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4);
}

/* ---------- System status: extra detail line ---------- */

.status-row-updated {
  display: block;
  font-size: 0.68rem;
  color: var(--color-text-subtle);
  margin-top: 1px;
}

/* ============================================================
   UI-3: Charts, Status cards, Timeline. Additive only -- every
   selector above this line keeps working. See DESIGN_SYSTEM.md's
   UI-3 additions section for the full reference.
   ============================================================ */

/* ---------- Analytics charts (Chart.js canvases) ---------- */

.analytics-card-stat {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: var(--space-2);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 160px;
}

.chart-container.chart-container-sm { height: 120px; }

/* ---------- Status cards (System Health) ---------- */

.status-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .status-card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
  .status-card-grid { grid-template-columns: repeat(3, 1fr); }
}

.status-card {
  background: var(--color-surface-sunken);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.status-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.status-card-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  background: var(--color-border);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.status-card-icon.status-ok { background: var(--status-ok-bg); color: var(--color-accent); }
.status-card-icon.status-warn { background: var(--status-warn-bg); color: var(--color-warning); }
.status-card-icon.status-off { background: var(--color-border); color: var(--color-text-subtle); }

.status-card-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-card-badge.status-ok { background: var(--status-ok-bg); color: var(--status-ok-text); }
.status-card-badge.status-warn { background: var(--status-warn-bg); color: var(--status-warn-text); }
.status-card-badge.status-off { background: var(--status-off-bg); color: var(--color-text-muted); }

.status-card-title { font-weight: 600; color: var(--color-text); font-size: var(--text-sm); }
.status-card-detail { font-size: var(--text-xs); color: var(--color-text-muted); }
.status-card-updated { font-size: 0.68rem; color: var(--color-text-subtle); margin-top: 2px; }

/* ---------- Activity Timeline ---------- */

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.timeline-item {
  position: relative;
  display: flex;
  gap: var(--space-3);
  padding-bottom: var(--space-1);
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: -14px;
  width: 2px;
  background: var(--color-border);
}

.timeline-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  flex-shrink: 0;
  z-index: 1;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.timeline-type-job .timeline-item-icon { background: var(--status-ok-bg); color: var(--color-accent); }
.timeline-type-pipeline .timeline-item-icon { background: var(--status-pipeline-bg); color: var(--chart-5); }

.timeline-item-body { min-width: 0; flex: 1; }

.timeline-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.timeline-item-title {
  font-weight: 600;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-item-time {
  font-size: 0.68rem;
  color: var(--color-text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
}

.time
/* ============================================================
   UI-4: Responsive pass. The sidebar/topbar unification above is
   the main structural piece; these are the remaining small-screen
   refinements so every section (KPIs, section-cards, charts,
   status cards, timeline, tables) stays comfortable down to narrow
   phone widths, not just "not broken." No new components, no
   separate mobile markup -- same DOM, same classes, at every size.
   ============================================================ */

@media (max-width: 379px) {
  .section-card { padding: var(--space-4); }
  .kpi-card { padding: 12px; }
  .analytics-card { padding: var(--space-3); }
  .status-card { padding: var(--space-3); }
}

/* Opportunity card action buttons stack on very narrow screens
   instead of squeezing two 44px-tall buttons side by side. */
@media (max-width: 399px) {
  .card-actions { flex-direction: column; }
  .card-actions .btn { flex: none; width: 100%; }
}

/* Bar-row labels (Analytics, when charts are empty and the older
   dependency-free list markup is reused elsewhere) get a bit more
   room back once the sidebar is off-canvas and not competing for
   width on tablet portrait. */
/* ---------- Phase G.2: Company Lead Inbox / notifications ----------
   Additive only -- reuses .opportunity-card/.badge/.meta-row/.card-actions/
   .filters-bar/.chip-row/.section-card/.urgent-list/.timeline from above;
   this block adds the handful of things those didn't already cover:
   a "danger" button variant for Decline (no .btn-danger existed before
   this phase), an unread-count dot for the topbar notification bell
   (previously a static, non-interactive placeholder), and a light tint
   for lead cards a company hasn't opened yet. */

.btn-danger {
  background: #fff;
  color: var(--color-critical);
  border: 1px solid var(--color-critical);
}
.btn-danger:hover { background: #fef2f2; }

.topbar-icon-btn { position: relative; text-decoration: none; }

.notification-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--color-critical);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.lead-card-unread { border-left: 3px solid var(--color-primary); }

.lead-card-expires {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.stat-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 4px 0 0 0;
}

.stat-card-row strong { color: var(--color-text); }

@media (min-width: 640px) and (max-width: 1023px) {
  .bar-row-label { width: 150px; }
}
