/* ── Dashboard Styles ── */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-secondary: #666;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Header */
#header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h1 { font-size: 18px; font-weight: 700; }
.nav-link { font-size: 13px; color: var(--primary); text-decoration: none; }
.nav-link:hover { text-decoration: underline; }
.header-center { display: flex; align-items: center; gap: 8px; }
.header-center label { font-size: 13px; color: var(--text-secondary); }
.header-center input[type="date"] { padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.hidden { display: none !important; }

/* Buttons */
.btn-primary {
  padding: 6px 14px; background: var(--primary); color: #fff; border: none;
  border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  padding: 6px 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
.btn-secondary:hover { background: #f0f0f0; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.badge { background: var(--primary); color: #fff; border-radius: 10px; padding: 2px 8px; font-size: 12px; font-weight: 600; }

/* Filter bar */
#filterBar {
  display: flex; align-items: flex-start; gap: 16px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group > label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.5px; }

/* Multi-select filter */
.multi-select {
  display: flex; flex-wrap: wrap; gap: 4px; max-width: 320px; position: relative;
}
.multi-select .filter-chip {
  padding: 3px 10px; border-radius: 12px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); user-select: none;
  transition: all 0.15s;
}
.multi-select .filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.multi-select .filter-chip:hover { border-color: var(--primary); }

/* Searchable multi-select */
.multi-select.searchable { flex-direction: column; max-height: none; }
.multi-select .filter-search {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
  width: 200px;
}
.multi-select .options-list {
  display: flex; flex-wrap: wrap; gap: 4px; max-height: 80px; overflow-y: auto;
  margin-top: 4px;
}

/* Range filter */
.range-filter { display: flex; align-items: center; gap: 6px; }
.range-filter input {
  width: 80px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
}
.range-filter span { color: var(--text-secondary); }

#clearFilters { align-self: flex-end; margin-left: auto; }

/* Main layout */
#main { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px 20px; }

/* Map */
#mapSection { display: flex; flex-direction: column; gap: 8px; }
.section-header { display: flex; align-items: center; justify-content: space-between; }
.section-header h2 { font-size: 15px; font-weight: 600; }
.legend-toggle { display: flex; align-items: center; gap: 6px; }
.legend-toggle label { font-size: 12px; color: var(--text-secondary); }
.legend-toggle select { padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
#map { height: 400px; border-radius: var(--radius); border: 1px solid var(--border); }
#mapLegendDisplay {
  display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; padding: 6px 0;
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Stats section */
#statsSection { display: flex; flex-direction: column; gap: 16px; }

/* Summary cards */
#summaryCards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card-value { font-size: 22px; font-weight: 700; }
.card-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Panels */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* Funnel chart */
#funnelChart { display: flex; flex-direction: column; gap: 6px; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-label { width: 90px; font-size: 12px; font-weight: 500; text-align: right; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; height: 28px; background: #f0f0f0; border-radius: 4px; overflow: hidden; position: relative; }
.funnel-bar {
  height: 100%; border-radius: 4px; display: flex; align-items: center; padding: 0 8px;
  font-size: 11px; font-weight: 600; color: #fff; min-width: 2px; transition: width 0.4s ease;
  white-space: nowrap;
}
.funnel-value { font-size: 12px; width: 80px; text-align: right; flex-shrink: 0; color: var(--text-secondary); }

/* Breakdown table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); font-weight: 600; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
tr:hover td { background: #fafafa; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th.sorted-asc::after { content: " ▲"; font-size: 10px; }
th.sorted-desc::after { content: " ▼"; font-size: 10px; }

/* Bottom section */
#bottom { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 0 20px 20px; }


/* Status colors */
.status-new { background: #3b82f6; }
.status-undecided { background: #8b5cf6; }
.status-booked { background: #f59e0b; }
.status-paid { background: #16a34a; }
.status-completed { background: #06b6d4; }
.status-lost { background: #ef4444; }
.status-spam { background: #9ca3af; }
.status-duplicate { background: #d1d5db; }
.status-vendor { background: #78716c; }
.status-unknown { background: #6b7280; }

/* Responsive */
@media (max-width: 1024px) {
  #main { grid-template-columns: 1fr; }
  #bottom { grid-template-columns: 1fr; }
  #summaryCards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  #summaryCards { grid-template-columns: 1fr; }
  #filterBar { flex-direction: column; }
}
