/*
 * Growth Partner — application styles
 * Built on Pico CSS 2 with custom overrides
 */

/* Pico variable overrides */
:root {
  --pico-font-size: 93.75%;
  --pico-border-radius: 0.5rem;
  --pico-background-color: #f8fafc;
  --pico-color: #1e293b;
  --pico-muted-color: #64748b;
  --pico-muted-border-color: #e2e8f0;
  --pico-primary: #4f46e5;
  --pico-primary-hover: #4338ca;
  --pico-primary-focus: rgba(79, 70, 229, 0.15);
  --pico-primary-inverse: #ffffff;
  --pico-secondary: #64748b;
  --pico-secondary-hover: #475569;
  --pico-card-background-color: #ffffff;
  --pico-card-border-color: #e2e8f0;
  --pico-card-sectioning-background-color: #f8fafc;
  --pico-table-border-color: #e2e8f0;
  --pico-form-element-border-color: #cbd5e1;
  --pico-form-element-focus-color: #4f46e5;
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.main-wrap { margin-left: 13rem; flex: 1; min-width: 0; }
main.container { padding-top: 1.5rem; }

/* ── Sidebar ── */
.sidebar {
  width: 13rem;
  background: linear-gradient(180deg, #1e293b, #0f172a);
  position: fixed; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-brand { padding: 1.25rem 1rem; font-size: 1.1rem; font-weight: 700; color: #fff; border-bottom: 1px solid #334155; letter-spacing: -0.02em; }
.sidebar-nav { padding: 0.5rem 0; }
.sidebar-nav-main { flex: 1; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 1rem; color: #94a3b8;
  text-decoration: none; font-size: 0.85rem; font-weight: 500;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.sidebar-link:hover { color: #e2e8f0; background: rgba(255,255,255,0.05); }
.sidebar-link.active { color: #fff; border-left-color: #818cf8; background: rgba(255,255,255,0.08); }
.sidebar-icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.sidebar-icon svg { width: 100%; height: 100%; }
.sidebar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ── Country Switcher ── */
.country-switcher {
  display: flex; gap: 0; border-bottom: 1px solid #334155;
}
.country-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 0.5rem; color: #64748b; text-decoration: none;
  font-size: 0.8rem; font-weight: 600; transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.country-tab:hover { color: #cbd5e1; background: rgba(255,255,255,0.04); }
.country-tab.active { color: #fff; background: rgba(255,255,255,0.06); border-bottom-color: #818cf8; }
.country-flag { font-size: 1rem; }

.sidebar-admin { border-top: 1px solid #334155; padding-top: 0.5rem; }
.sidebar-admin .sidebar-link { font-size: 0.8rem; color: #64748b; padding: 0.4rem 1rem; }
.sidebar-admin .sidebar-link:hover { color: #cbd5e1; }
.sidebar-admin .sidebar-link.active { color: #cbd5e1; border-left-color: #64748b; }
.sidebar-toggle { display: none; }

/* ── Typography ── */
h1 { color: #1e293b; font-weight: 700; letter-spacing: -0.02em; }
h2 { color: #334155; font-weight: 600; }
h3, h4 { color: #475569; font-weight: 600; }

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.kpi-grid-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.kpi-grid-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem; margin-bottom: 2rem;
}
.kpi-card {
  text-align: center; padding: 1.25rem 1rem;
  border-left: 3px solid #4f46e5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}
.kpi-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.kpi-card h2 { margin-bottom: 0.25rem; color: #4f46e5; font-size: 1.75rem; }
.kpi-card small { color: var(--pico-muted-color); }
.kpi-card a { color: inherit; text-decoration: none; }
.kpi-card a:hover { text-decoration: none; opacity: 1; }
.kpi-card-primary {
  border-left-width: 4px;
  padding: 1.5rem 1rem;
}
.kpi-card-primary h2 { font-size: 2rem; }
.kpi-card-secondary {
  padding: 0.75rem 0.5rem;
  border-left-width: 2px;
  border-left-color: #e2e8f0;
}
.kpi-card-secondary h2 { font-size: 1.35rem; color: #475569; }

/* KPI delta badges */
.kpi-delta {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  padding: 0.1rem 0.4rem; border-radius: 9999px;
  margin-left: 0.3rem; vertical-align: super;
}
.kpi-delta-up { background: #d1fae5; color: #065f46; }
.kpi-delta-down { background: #fee2e2; color: #991b1b; }
.kpi-delta-neutral { background: #f1f5f9; color: #64748b; }

/* ── Next Action CTA ── */

/* ── Dashboard Actions Row ── */
.dashboard-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.dashboard-stats {
  display: flex; gap: 1rem;
}
.dashboard-stats .kpi-card {
  min-width: 120px;
}
.dashboard-import {
  display: flex; align-items: center; gap: 0.75rem;
}
.dashboard-import button, .dashboard-import input[type="submit"] {
  margin: 0; white-space: nowrap;
}

/* ── Pipeline Funnel ── */
.pipeline {
  display: flex; gap: 0; margin-bottom: 2rem;
  border-radius: 0.5rem; overflow: hidden;
  border: 1px solid #e2e8f0;
}
.pipeline-stage {
  flex: 1; text-align: center; padding: 0.6rem 0.5rem;
  text-decoration: none; transition: opacity 0.15s;
  position: relative;
}
.pipeline-stage:hover { opacity: 0.85; }
.pipeline-stage-count { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.pipeline-stage-label { display: block; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.pipeline-new { background: #dbeafe; color: #1e40af; }
.pipeline-contacted { background: #fef3c7; color: #92400e; }
.pipeline-approved { background: #d1fae5; color: #065f46; }
.pipeline-rejected { background: #fee2e2; color: #991b1b; }

/* ── Badges (status) ── */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem;
  border-radius: 9999px; font-size: 0.75rem;
  font-weight: 600; letter-spacing: 0.02em;
}
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* Badges (lead type — distinct from status) */
.badge-type-permit { background: #f1f5f9; color: #475569; }
.badge-type-company { background: #ede9fe; color: #5b21b6; }
.badge-type-industrial-site { background: #ccfbf1; color: #0f766e; }

/* ── Relevance Scores ── */
.score-high { color: #059669; font-weight: 700; }
.score-medium { color: #d97706; font-weight: 600; }
.score-low { color: var(--pico-muted-color); }
.score-blocked { color: #dc2626; font-weight: 600; }

/* ── Tables ── */
table { font-size: 0.9rem; }
thead th {
  background: #f1f5f9; color: #475569; font-weight: 600;
  text-transform: uppercase; font-size: 0.72rem;
  letter-spacing: 0.05em; border-bottom: 2px solid #e2e8f0;
}
tbody tr { transition: background-color 0.1s; }
tbody tr:hover { background-color: #f8fafc; }
td { vertical-align: middle; }

/* ── Filter bar ── */
.filters {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  align-items: end; margin-bottom: 1rem;
  padding: 0.75rem; background: #f1f5f9;
  border-radius: 0.5rem; border: 1px solid #e2e8f0;
}
.filters input, .filters select { margin-bottom: 0; font-size: 0.85rem; }

/* ── Flash messages ── */
.flash-notice {
  padding: 0.75rem 1rem; border-radius: 0.5rem; margin-bottom: 1.5rem;
  font-size: 0.9rem; border-left: 4px solid #4f46e5;
  background: #eef2ff; color: #3730a3;
}
.flash-alert {
  padding: 0.75rem 1rem; border-radius: 0.5rem; margin-bottom: 1.5rem;
  font-size: 0.9rem; border-left: 4px solid #dc2626;
  background: #fef2f2; color: #991b1b;
}

/* ── Cards ── */
article { box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #e2e8f0; }

/* ── Collapsible sections ── */
details summary .badge { vertical-align: middle; margin-left: 0.5rem; }

/* ── Definition lists (show pages) ── */
dt { color: #64748b; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
dd { color: #1e293b; margin-bottom: 0.75rem; }

/* ── Outline buttons ── */
button.outline, [type="submit"].outline, [role="button"].outline { border-color: #cbd5e1; color: #475569; }
button.outline:hover, [type="submit"].outline:hover, [role="button"].outline:hover { border-color: #4f46e5; color: #4f46e5; background: #eef2ff; }

/* ── Scrape status bar ── */
.scrape-status { padding: 0.5rem 1rem; margin-bottom: 2rem; background: #f1f5f9; border: 1px solid #e2e8f0; }

/* ── Pagination (Pagy) ── */
nav.pagy { background: transparent; box-shadow: none; }

/* ── Footer ── */
.attribution { text-align: center; font-size: 0.75rem; color: #94a3b8; padding: 2rem 0 1rem; border-top: 1px solid #e2e8f0; margin-top: 3rem; }

/* ── Signal chips ── */
.signal-bar {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  padding: 0.6rem 0.75rem; background: #f1f5f9;
  border-radius: 0.5rem; border: 1px solid #e2e8f0; margin-bottom: 1.5rem;
}
.signal-chip {
  display: inline-block; padding: 0.2rem 0.6rem;
  border-radius: 9999px; font-size: 0.75rem;
  font-weight: 600; letter-spacing: 0.02em;
}
.signal-chip-score { background: #4f46e5; color: #fff; }
.signal-chip-red { background: #fee2e2; color: #991b1b; }
.signal-chip-amber { background: #fef3c7; color: #92400e; }
.signal-chip-green { background: #d1fae5; color: #065f46; }
.signal-chip-blue { background: #dbeafe; color: #1e40af; }
.signal-chip-muted { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

/* ── Score help tooltip ── */
.score-help { cursor: help; color: var(--pico-muted-color); font-size: 0.7rem; text-decoration: none; border-bottom: 1px dashed #94a3b8; }

/* ── Loading spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 0.9rem; height: 0.9rem;
  border: 2px solid #e2e8f0; border-top-color: #4f46e5;
  border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle;
}
.btn-loading { pointer-events: none; opacity: 0.7; }

/* ── Filter count badge ── */
.filter-count {
  display: inline-block; background: #4f46e5; color: #fff;
  font-size: 0.65rem; font-weight: 700;
  padding: 0.1rem 0.4rem; border-radius: 9999px;
  margin-left: 0.3rem; vertical-align: middle;
}

/* ── Email draft ── */
.email-draft {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 0.5rem; padding: 1rem;
  font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap;
}
.copy-btn { cursor: pointer; }
.copy-btn.copied { color: #059669; }

/* ── Show page utilities ── */
.back-link { font-size: 0.85rem; color: var(--pico-muted-color); text-decoration: none; }
.back-link:hover { color: var(--pico-primary); }
.show-header { margin-bottom: 1.5rem; }
.show-header h1 { margin-bottom: 0.25rem; }
.show-subtitle { color: var(--pico-muted-color); margin-bottom: 0.25rem; }
.section-title { margin-top: 1.5rem; margin-bottom: 0.75rem; }
.action-group { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.details-section { margin-top: 1rem; }
.details-section summary { font-size: 0.9rem; cursor: pointer; }

/* ── Filter bar enhancements ── */
.filters-search { flex: 2; min-width: 200px; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem;
  color: var(--pico-muted-color);
}
.empty-state p { margin-bottom: 0; font-size: 0.95rem; }

/* ── Results count ── */
.results-count { font-size: 0.82rem; color: var(--pico-muted-color); margin-bottom: 0.75rem; }

/* ── Score breakdown ── */
.score-breakdown {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  align-items: center; margin-top: 0.5rem;
}
.score-breakdown-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 0.4rem 0.6rem; background: #f8fafc;
  border-radius: 0.375rem; border: 1px solid #e2e8f0;
  min-width: 70px; cursor: help;
}
.score-breakdown-value { font-size: 1rem; font-weight: 700; color: #475569; }
.score-breakdown-value.has-score { color: #4f46e5; }
.score-breakdown-label { font-size: 0.65rem; color: var(--pico-muted-color); text-transform: uppercase; letter-spacing: 0.03em; }

/* ── Card section header ── */
.card-header { font-size: 0.82rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.75rem; }

/* ── Page header with count ── */
.page-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.5rem; }
.page-header h1 { margin-bottom: 0; }
.page-header .count { font-size: 1rem; color: var(--pico-muted-color); font-weight: 400; }

/* ── KPI card type-color variants ── */
.kpi-card-permit { border-left-color: #475569; }
.kpi-card-permit h2 { color: #475569; }
.kpi-card-company { border-left-color: #5b21b6; }
.kpi-card-company h2 { color: #5b21b6; }
.kpi-card-industrial-site { border-left-color: #0f766e; }
.kpi-card-industrial-site h2 { color: #0f766e; }
.kpi-card-amber { border-left-color: #d97706; }
.kpi-card-amber h2 { color: #d97706; }
.kpi-card-green { border-left-color: #059669; }
.kpi-card-green h2 { color: #059669; }
.kpi-card-blue { border-left-color: #2563eb; }
.kpi-card-blue h2 { color: #2563eb; }
.kpi-card-red { border-left-color: #dc2626; }
.kpi-card-red h2 { color: #dc2626; }

/* Priority row highlight */
.row-high-priority { border-left: 3px solid #059669; }

/* ── Checkbox in filter bar ── */
.filters-checkbox { font-size: 0.82rem; display: flex; align-items: center; gap: 0.3rem; margin: 0; white-space: nowrap; }
.filters-checkbox input[type="checkbox"] { margin: 0; width: auto; }

/* ── Collapsible filters ── */
.filters-more { margin-top: 0; }
.filters-more summary { font-size: 0.82rem; color: var(--pico-muted-color); cursor: pointer; margin-bottom: 0.5rem; }
.filters-more .filters { margin-top: 0.5rem; }

/* ── Smooth transitions ── */
a { transition: color 0.15s; }

/* ── Prospect List (Followed page) ── */
.prospect-pipeline {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-radius: 0.5rem; overflow: hidden;
  border: 1px solid #e2e8f0;
}
.prospect-pipeline .pipeline-stage { cursor: pointer; }
.prospect-pipeline .pipeline-active { box-shadow: inset 0 -3px 0 currentColor; }
.pipeline-clear {
  padding: 0.6rem 0.75rem; display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: #64748b; text-decoration: none; font-size: 0.75rem; font-weight: 600;
  border-left: 1px solid #e2e8f0; transition: background 0.15s;
}
.pipeline-clear:hover { background: #e2e8f0; color: #475569; }

.prospect-list { display: flex; flex-direction: column; gap: 0; }

.prospect-card {
  border: 1px solid #e2e8f0;
  border-bottom: none;
  background: #fff;
  transition: box-shadow 0.15s;
}
.prospect-card:first-child { border-radius: 0.5rem 0.5rem 0 0; }
.prospect-card:last-child { border-bottom: 1px solid #e2e8f0; border-radius: 0 0 0.5rem 0.5rem; }
.prospect-card:only-child { border-radius: 0.5rem; border-bottom: 1px solid #e2e8f0; }
.prospect-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); z-index: 1; position: relative; }

.prospect-summary {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.65rem 1rem; cursor: pointer;
  transition: background 0.1s;
}
.prospect-summary:hover { background: #f8fafc; }

.prospect-score {
  flex-shrink: 0; width: 2.5rem; text-align: center;
  font-size: 1.05rem; font-weight: 700;
}

.prospect-main { flex: 2; min-width: 0; }
.prospect-name { font-weight: 600; font-size: 0.88rem; line-height: 1.3; }
.prospect-name a { color: inherit; text-decoration: none; }
.prospect-name a:hover { color: var(--pico-primary); }
.prospect-meta {
  display: flex; gap: 0.5rem; font-size: 0.72rem; color: var(--pico-muted-color);
  margin-top: 0.1rem;
}
.prospect-meta span:not(:last-child)::after { content: "·"; margin-left: 0.5rem; }

.prospect-signals { flex: 1; display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-start; }

.prospect-tag {
  display: inline-block; padding: 0.1rem 0.45rem;
  border-radius: 0.25rem; font-size: 0.68rem;
  font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
}
.prospect-tag-permit { background: #f1f5f9; color: #475569; }
.prospect-tag-site { background: #ccfbf1; color: #0f766e; }
.prospect-tag-hot { background: #fee2e2; color: #991b1b; }
.prospect-tag-muted { background: #f1f5f9; color: #64748b; }

.prospect-contact-preview { flex: 1; font-size: 0.8rem; min-width: 0; }
.prospect-contact-name { color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.prospect-contact-empty { color: #cbd5e1; font-style: italic; font-size: 0.75rem; }

.prospect-status { flex-shrink: 0; }
.prospect-expand-icon {
  flex-shrink: 0; width: 1.25rem; text-align: center;
  color: #cbd5e1; font-size: 0.7rem; transition: transform 0.2s;
}

/* Expanded detail panel */
.prospect-detail {
  max-height: 0; overflow: hidden;
  transition: max-height 0.25s ease-out, padding 0.25s ease-out;
  background: #f8fafc; border-top: none;
}
.prospect-detail-open {
  max-height: 500px; padding: 1rem;
  border-top: 1px solid #e2e8f0;
  transition: max-height 0.35s ease-in, padding 0.2s ease-in;
}
.prospect-detail-open + .prospect-summary .prospect-expand-icon,
.prospect-card:has(.prospect-detail-open) .prospect-expand-icon {
  transform: rotate(180deg);
}

.prospect-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}

.prospect-detail-col { min-width: 0; }

.prospect-detail-header {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: #64748b;
  margin-bottom: 0.5rem; padding-bottom: 0.3rem;
  border-bottom: 1px solid #e2e8f0;
}

.prospect-dl { margin: 0; }
.prospect-dl dt {
  font-size: 0.68rem; color: #94a3b8; font-weight: 500;
  text-transform: none; letter-spacing: 0; margin-top: 0.35rem;
}
.prospect-dl dd { font-size: 0.82rem; margin-bottom: 0.15rem; margin-left: 0; }

.prospect-contact-card {
  padding: 0.4rem 0; border-bottom: 1px solid #e2e8f0;
}
.prospect-contact-card:last-of-type { border-bottom: none; }
.prospect-contact-card-name { font-weight: 600; font-size: 0.82rem; color: #1e293b; }
.prospect-contact-card-role { font-size: 0.72rem; color: #64748b; }
.prospect-contact-card-channels { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.2rem; }
.prospect-channel {
  font-size: 0.72rem; color: var(--pico-primary);
  text-decoration: none; white-space: nowrap;
}
.prospect-channel:hover { text-decoration: underline; }

.prospect-activity-item { margin-bottom: 0.4rem; font-size: 0.82rem; }
.prospect-activity-label {
  display: block; font-size: 0.68rem; color: #94a3b8; font-weight: 500;
}

.prospect-detail-empty { font-size: 0.8rem; color: #94a3b8; margin: 0; display: flex; align-items: center; }

.prospect-actions {
  display: flex; gap: 0.5rem; align-items: center;
  margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid #e2e8f0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 3.5rem; }
  .sidebar-brand { padding: 1rem 0.5rem; font-size: 0; }
  .sidebar-brand::first-letter { font-size: 1.1rem; }
  .sidebar-label { display: none; }
  .sidebar-link { padding: 0.5rem; justify-content: center; gap: 0; border-left: none; }
  .sidebar-icon { width: 1.35rem; height: 1.35rem; }
  .sidebar-admin .sidebar-link { padding: 0.4rem; justify-content: center; }
  .main-wrap { margin-left: 3.5rem; }
  .kpi-grid-primary { grid-template-columns: 1fr 1fr; }
  .pipeline { flex-wrap: wrap; }
  .pipeline-stage { flex: 1 1 45%; }
}

@media (max-width: 480px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; width: 13rem; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-label { display: inline; }
  .sidebar-link { padding: 0.5rem 1rem; justify-content: flex-start; gap: 0.75rem; border-left: 3px solid transparent; }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 0.75rem; left: 0.75rem; z-index: 101;
    width: 2.25rem; height: 2.25rem; border-radius: 0.375rem;
    background: #1e293b; color: #fff; border: none; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .sidebar-toggle svg { width: 1.25rem; height: 1.25rem; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: rgba(0,0,0,0.4);
  }
  .sidebar.open ~ .sidebar-backdrop { display: block; }
  main.container { padding-top: 3.5rem; }
  .kpi-grid-primary { grid-template-columns: 1fr; }
  .kpi-grid-secondary { grid-template-columns: 1fr 1fr; }
}

/* ── Lists ── */
.list-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.list-card {
  display: flex; border: 1px solid #e2e8f0; border-radius: 0.5rem;
  background: #fff; text-decoration: none; color: inherit;
  transition: box-shadow 0.2s, transform 0.2s; overflow: hidden;
}
.list-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.list-card-color { width: 4px; flex-shrink: 0; }
.list-card-body { padding: 1rem; flex: 1; }
.list-card-name { font-weight: 600; font-size: 0.95rem; color: #1e293b; margin-bottom: 0.25rem; }
.list-card-desc { font-size: 0.8rem; color: #64748b; margin-bottom: 0.5rem; }
.list-card-meta { font-size: 0.72rem; color: #94a3b8; display: flex; gap: 0.75rem; }
.list-card-color-dot {
  display: inline-block; width: 0.75rem; height: 0.75rem;
  border-radius: 50%; vertical-align: middle; margin-right: 0.4rem;
}

/* Add-to-list button */
.list-add-btn {
  all: unset; cursor: pointer; font-size: 1rem; line-height: 1;
  color: var(--pico-muted-color); width: 1.5rem; height: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.25rem; transition: background 0.1s, color 0.1s;
}
.list-add-btn:hover { background: #eef2ff; color: var(--pico-primary); }

/* Popover dropdown */
.list-popover {
  display: none; position: absolute; top: 100%; left: 0; z-index: 50;
  min-width: 220px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 0.5rem; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 0.82rem;
}
.list-popover-open { display: block; }
.list-popover-loading { padding: 0.75rem; color: #94a3b8; text-align: center; }
.list-popover-empty { padding: 0.75rem; color: #94a3b8; font-style: italic; }
.list-popover-items { max-height: 200px; overflow-y: auto; padding: 0.25rem 0; }
.list-popover-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.75rem; cursor: pointer; font-size: 0.82rem;
  transition: background 0.1s;
}
.list-popover-item:hover { background: #f8fafc; }
.list-popover-item input[type="checkbox"] { margin: 0; width: auto; flex-shrink: 0; }
.list-popover-color {
  display: inline-block; width: 0.5rem; height: 0.5rem;
  border-radius: 50%; flex-shrink: 0;
}
.list-popover-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-popover-new {
  display: block; padding: 0.5rem 0.75rem; border-top: 1px solid #e2e8f0;
  color: var(--pico-primary); font-size: 0.78rem; text-decoration: none;
  font-weight: 500;
}
.list-popover-new:hover { background: #eef2ff; }

/* ── Searchable Select ── */
.searchable-select { position: relative; }
.searchable-select-input {
  width: 100%; font-size: 0.85rem; margin: 0;
  padding: 0.4rem 0.5rem;
}
.searchable-select-dropdown {
  display: none; position: absolute; top: 100%; left: 0;
  z-index: 60; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 0 0 0.5rem 0.5rem; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 260px; overflow-y: auto; min-width: 100%; width: max-content; max-width: 500px;
}
.searchable-select-open { display: block; }
.searchable-select-option {
  padding: 0.4rem 0.75rem; font-size: 0.8rem; cursor: pointer;
  transition: background 0.1s;
}
.searchable-select-option:hover, .searchable-select-highlighted { background: #f1f5f9; }
.searchable-select-option mark { background: #fef3c7; color: inherit; padding: 0; border-radius: 2px; }
.searchable-select-empty { padding: 0.5rem 0.75rem; font-size: 0.78rem; color: #94a3b8; font-style: italic; }

/* Table cell overflow for popover */
td { overflow: visible; }

/* ── Bulk Select ── */
.bulk-th, .bulk-td { width: 3rem; text-align: center; padding: 0.4rem 0.6rem !important; }
.bulk-th input[type="checkbox"], .bulk-td input[type="checkbox"] { margin: 0; width: 1.1rem; height: 1.1rem; cursor: pointer; }

/* Floating action bar */
.bulk-bar {
  position: fixed; bottom: -4rem; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; background: #1e293b; color: #fff;
  border-radius: 0.75rem; box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  font-size: 0.85rem; transition: bottom 0.25s ease;
  white-space: nowrap;
}
.bulk-bar-visible { bottom: 1.5rem; }
.bulk-bar-count { font-weight: 600; }
.bulk-bar-actions { display: flex; align-items: center; gap: 0.5rem; }
.bulk-bar-select {
  background: #334155; border: 1px solid #475569; color: #e2e8f0;
  font-size: 0.82rem; padding: 0.3rem 0.5rem; border-radius: 0.375rem;
  margin: 0; min-width: 160px;
}
.bulk-bar-select:focus { border-color: #818cf8; outline: none; }
.bulk-bar-submit {
  background: #4f46e5; color: #fff; border: none; padding: 0.35rem 0.75rem;
  font-size: 0.82rem; font-weight: 600; border-radius: 0.375rem;
  cursor: pointer; transition: background 0.15s; margin: 0;
}
.bulk-bar-submit:hover { background: #4338ca; }
.bulk-bar-submit:disabled { opacity: 0.7; cursor: wait; }
.bulk-bar-success { background: #059669 !important; }
.bulk-bar-clear {
  background: none; border: none; color: #94a3b8; font-size: 1.1rem;
  cursor: pointer; padding: 0 0.25rem; line-height: 1; margin: 0;
}
.bulk-bar-clear:hover { color: #fff; }

/* ── Login page ──────────────────────────────────────────────── */
.login-layout {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--pico-background-color);
}
.login-card {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 2.5rem 2rem; width: 100%; max-width: 24rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.login-card h2 { margin-bottom: 0.25rem; text-align: center; }
.login-subtitle { text-align: center; color: var(--pico-muted-color); margin-bottom: 1.5rem; }

/* ── Sidebar user section ────────────────────────────────────── */
.sidebar-user {
  margin-top: auto; padding: 0.75rem 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.sidebar-user-info { display: flex; flex-direction: column; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #e2e8f0; }
.sidebar-user-role { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-logout-btn {
  background: transparent; border: 1px solid #475569; color: #94a3b8;
  font-size: 0.7rem; padding: 0.25rem 0.5rem; border-radius: 0.25rem;
  cursor: pointer; white-space: nowrap;
}
.sidebar-logout-btn:hover { background: #334155; color: #e2e8f0; }

/* ── Nearby leads ── */
.nearby-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .nearby-layout { grid-template-columns: 1fr; }
}
.nearby-controls { min-width: 0; }
.nearby-map-container { position: sticky; top: 1rem; }
#nearby-map { height: 500px; border-radius: 8px; border: 1px solid var(--pico-muted-border-color); }
.origin-marker { background: transparent !important; border: none !important; }
.icp-segment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 1rem;
  margin-top: 0.5rem;
}
.icp-segment-grid .filters-checkbox { font-size: 0.85rem; }
