/* ================================================================
   assets/style.css — Molitics Plus Design System
   ================================================================ */

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
  --bg-primary:      #F2F5FB;
  --bg-secondary:    #FFFFFF;
  --bg-tertiary:     #EBF0F9;
  --bg-card:         #FFFFFF;
  --bg-sidebar:      #FFFFFF;
  --bg-topbar:       rgba(255,255,255,.88);
  --bg-input:        #EEF2FA;
  --text-primary:    #0C1528;
  --text-secondary:  #475577;
  --text-tertiary:   #8595B2;
  --border-color:    #DDE4F0;
  --border-hover:    #C4CFEA;
  --shadow-sm:       0 1px 3px rgba(12,21,40,.04), 0 1px 2px rgba(12,21,40,.02);
  --shadow-md:       0 4px 18px rgba(12,21,40,.07), 0 2px 5px rgba(12,21,40,.03);
  --shadow-lg:       0 12px 42px rgba(12,21,40,.09), 0 4px 14px rgba(12,21,40,.05);
  --accent-blue:     #2563EB;
  --accent-blue-soft:#DBEAFE;
  --accent-blue-glow:rgba(37,99,235,.14);
  --accent-red:      #DC2626;
  --accent-red-soft: #FEE2E2;
  --accent-green:    #059669;
  --accent-green-soft:#D1FAE5;
  --accent-yellow:   #D97706;
  --accent-yellow-soft:#FEF3C7;
  --accent-purple:   #7C3AED;
  --accent-purple-soft:#EDE9FE;
  --chart-grid:      #EBF0F9;
  --sidebar-active:  #DBEAFE;
  --gradient-primary:linear-gradient(135deg,#2563EB,#1D4ED8);
  --gradient-accent: linear-gradient(135deg,#2563EB 0%,#7C3AED 100%);
  --gradient-card:   linear-gradient(180deg,#FFF 0%,#F8FAFF 100%);
  --scrollbar-track: #EBF0F9;
  --scrollbar-thumb: #C4CFEA;
  --sidebar-width:   256px;
  --topbar-h:        66px;
  --radius-card:     14px;
  --radius-btn:      9px;
}
[data-theme="dark"] {
  --bg-primary:      #090D1A;
  --bg-secondary:    #101727;
  --bg-tertiary:     #182035;
  --bg-card:         #121C30;
  --bg-sidebar:      #0C1322;
  --bg-topbar:       rgba(12,19,34,.92);
  --bg-input:        #182035;
  --text-primary:    #EDF2FF;
  --text-secondary:  #8EA4CC;
  --text-tertiary:   #5C7099;
  --border-color:    #1C2B45;
  --border-hover:    #2E4268;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.35);
  --shadow-md:       0 4px 18px rgba(0,0,0,.45);
  --shadow-lg:       0 12px 42px rgba(0,0,0,.55);
  --accent-blue-soft:rgba(37,99,235,.15);
  --accent-red-soft: rgba(220,38,38,.15);
  --accent-green-soft:rgba(5,150,105,.15);
  --accent-yellow-soft:rgba(217,119,6,.15);
  --accent-purple-soft:rgba(124,58,237,.15);
  --chart-grid:      #1C2B45;
  --sidebar-active:  rgba(37,99,235,.12);
  --gradient-card:   linear-gradient(180deg,#121C30 0%,#101727 100%);
  --scrollbar-track: #101727;
  --scrollbar-thumb: #2E4268;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  transition: background .35s, color .35s;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  z-index: 50;
  display: flex; flex-direction: column;
  transition: width .3s cubic-bezier(.4,0,.2,1), transform .3s;
  box-shadow: var(--shadow-sm);
}
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-footer-text { opacity: 0; width: 0; overflow: hidden; white-space: nowrap; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0 12px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0 12px; }
.sidebar.collapsed .nav-item .nav-icon { margin-right: 0; }

.sidebar-logo {
  padding: 18px 22px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--border-color);
  height: var(--topbar-h);
}
.sidebar-logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37,99,235,.28);
}
.sidebar-logo-text {
  font-family: 'Outfit'; font-weight: 700; font-size: 17px; letter-spacing: -.3px;
  background: var(--gradient-accent);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px; }
.sidebar-section-title {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.3px; color: var(--text-tertiary);
  padding: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center;
  padding: 9px 11px; border-radius: 9px;
  cursor: pointer; color: var(--text-secondary);
  margin-bottom: 1px; font-size: 13.5px; font-weight: 500;
  position: relative; text-decoration: none;
  transition: background .18s, color .18s;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent-blue); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: var(--accent-blue); border-radius: 0 3px 3px 0;
}
.nav-icon { width: 18px; height: 18px; margin-right: 11px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border-color); }
.collapse-btn { font-family: 'DM Sans'; color: var(--text-tertiary); font-size: 13px; }

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; right: 0;
  height: var(--topbar-h);
  left: var(--sidebar-width);
  background: var(--bg-topbar);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-color);
  z-index: 40;
  display: flex; align-items: center;
  padding: 0 26px; gap: 14px;
  transition: left .3s cubic-bezier(.4,0,.2,1);
}
.sidebar.collapsed ~ .main-area .topbar { left: 68px; }

.search-box { flex: 1; max-width: 440px; position: relative; }
.search-box input {
  width: 100%; padding: 8px 14px 8px 38px;
  border-radius: 9px; border: 1px solid var(--border-color);
  background: var(--bg-input); color: var(--text-primary);
  font-size: 13.5px; font-family: 'DM Sans'; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }

.topbar-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; color: var(--text-secondary);
  transition: background .18s, border-color .18s, color .18s;
}
.topbar-btn:hover { background: var(--bg-tertiary); border-color: var(--border-hover); color: var(--text-primary); }
.topbar-badge {
  position: absolute; top: -3px; right: -3px;
  width: 17px; height: 17px; background: var(--accent-red); color: #fff;
  border-radius: 50%; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-secondary);
}
.constituency-selector {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer; font-size: 12.5px; color: var(--text-primary); font-weight: 500;
  transition: border-color .18s;
}
.constituency-selector:hover { border-color: var(--border-hover); }
.constituency-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-green); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: var(--gradient-accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  border: 2px solid var(--border-color);
  transition: border-color .18s;
}
.user-avatar:hover { border-color: var(--accent-blue); }

/* Theme toggle */
.theme-toggle {
  width: 42px; height: 23px; border-radius: 12px; padding: 2px;
  cursor: pointer; border: none;
  background: var(--border-color);
  transition: background .3s;
}
.theme-toggle .toggle-knob {
  width: 19px; height: 19px; border-radius: 50%; background: #fff;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  display: flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .theme-toggle { background: var(--accent-blue); }
[data-theme="dark"] .theme-toggle .toggle-knob { transform: translateX(19px); }

/* ── Notification dropdown ───────────────────────────────────── */
.notif-dropdown {
  position: absolute; top: 46px; right: 0;
  width: 350px; background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: 13px;
  box-shadow: var(--shadow-lg); z-index: 100;
  display: none; overflow: hidden;
}
.notif-dropdown.show { display: block; }
.notif-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center;
}
.notif-item {
  padding: 13px 16px; border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: background .18s;
}
.notif-item:hover { background: var(--bg-tertiary); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--accent-blue-soft); }

/* ── Main area ────────────────────────────────────────────────── */
.main-area { margin-left: var(--sidebar-width); transition: margin-left .3s cubic-bezier(.4,0,.2,1); }
.sidebar.collapsed ~ .main-area { margin-left: 68px; }
.main-content {
  padding: calc(var(--topbar-h) + 24px) 26px 32px;
  max-width: 1680px; margin: 0 auto;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 26px;
}
.page-title { font-family: 'Outfit'; font-size: 25px; font-weight: 700; letter-spacing: -.5px; }
.page-subtitle { color: var(--text-tertiary); font-size: 13px; margin-top: 3px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600; font-family: 'DM Sans';
  cursor: pointer; border: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .18s;
}
.btn-outline {
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-outline:hover { border-color: var(--border-hover); background: var(--bg-tertiary); }
.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: 0 3px 10px rgba(37,99,235,.28); }
.btn-primary:hover { filter: brightness(1.08); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s, border-color .25s;
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); }
.card-header {
  padding: 16px 18px 0;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.card-title { font-family: 'Outfit'; font-size: 14px; font-weight: 600; letter-spacing: -.15px; }
.card-body { padding: 14px 18px 18px; }

/* ── KPI Grid ────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 14px; margin-bottom: 22px; }
.kpi-card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow .25s, border-color .25s, transform .25s;
  cursor: default; overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); transform: translateY(-2px); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.kpi-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-trend {
  display: flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px;
}
.kpi-trend.up   { color: var(--accent-green); background: var(--accent-green-soft); }
.kpi-trend.down { color: var(--accent-red);   background: var(--accent-red-soft);   }
.kpi-value { font-family: 'Outfit'; font-size: 26px; font-weight: 700; letter-spacing: -1px; line-height: 1.1; }
.kpi-label { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; font-weight: 500; }

/* ── Clickable KPI cards ─────────────────────────────────────── */
.kpi-card[data-href] { cursor: pointer; position: relative; }
.kpi-card[data-href]:hover { border-color: var(--accent-blue, #3b82f6); }
.kpi-card[data-href]:focus-visible {
  outline: 2px solid var(--accent-blue, #3b82f6); outline-offset: 2px;
}
.kpi-card[data-href]::after {
  content: ''; position: absolute; right: 12px; bottom: 12px;
  width: 7px; height: 7px; border-right: 2px solid currentColor; border-top: 2px solid currentColor;
  transform: rotate(45deg) translateX(-3px); opacity: 0;
  color: var(--text-tertiary);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.kpi-card[data-href]:hover::after,
.kpi-card[data-href]:focus-visible::after { opacity: .85; transform: rotate(45deg) translateX(0); }
.kpi-card[data-href] .kpi-label { transition: color .2s; }
.kpi-card[data-href]:hover .kpi-label { color: var(--text-secondary, var(--text-tertiary)); }
@media (prefers-reduced-motion: reduce) {
  .kpi-card[data-href]::after { transition: none; }
}
.kpi-target-flash {
  animation: kpiTargetFlash 1.6s ease-out;
  scroll-margin-top: 90px;
}
[id][class*="card"] { scroll-margin-top: 90px; }
@keyframes kpiTargetFlash {
  0%   { box-shadow: 0 0 0 0 var(--accent-blue-soft, rgba(59,130,246,.45)); border-color: var(--accent-blue, #3b82f6); }
  40%  { box-shadow: 0 0 0 6px var(--accent-blue-soft, rgba(59,130,246,.25)); border-color: var(--accent-blue, #3b82f6); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

/* ── Layout grids ────────────────────────────────────────────── */
.grid-2   { display: grid; grid-template-columns: 1fr 1fr;   gap: 18px; margin-bottom: 22px; }
.grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 22px; }
.grid-3-1 { display: grid; grid-template-columns: 3fr 1fr; gap: 18px; margin-bottom: 22px; }

/* ── Time / filter pills ─────────────────────────────────────── */
.time-filter { display: flex; gap: 3px; background: var(--bg-tertiary); border-radius: 7px; padding: 3px; }
.time-pill {
  padding: 4px 11px; border-radius: 5px; font-size: 11px; font-weight: 600;
  cursor: pointer; color: var(--text-tertiary); border: none; background: transparent;
  font-family: 'DM Sans'; transition: all .18s;
}
.time-pill.active { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.filter-group { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chip {
  padding: 4px 11px; border-radius: 7px; font-size: 11.5px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-color);
  background: var(--bg-secondary); color: var(--text-secondary); font-family: 'DM Sans';
  transition: all .18s;
}
.filter-chip.active { background: var(--accent-blue-soft); color: var(--accent-blue); border-color: var(--accent-blue); }

/* ── Risk alerts ─────────────────────────────────────────────── */
.alert-item {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 13px; border-radius: 9px; margin-bottom: 7px;
  border: 1px solid transparent; transition: background .18s, border-color .18s;
}
.alert-item:hover { background: var(--bg-tertiary); border-color: var(--border-color); }
.alert-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.alert-dot.critical { background: var(--accent-red);    box-shadow: 0 0 7px rgba(220,38,38,.35); }
.alert-dot.warning  { background: var(--accent-yellow); box-shadow: 0 0 7px rgba(217,119,6,.35); }
.alert-dot.info     { background: var(--accent-green);  box-shadow: 0 0 7px rgba(5,150,105,.35); }
.alert-text { font-size: 12.5px; line-height: 1.5; }
.alert-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Status / priority badges ────────────────────────────────── */
.status-badge {
  display: inline-flex; padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
.status-badge.open        { background: var(--accent-red-soft);    color: var(--accent-red);    }
.status-badge.in_progress { background: var(--accent-yellow-soft); color: var(--accent-yellow); }
.status-badge.resolved    { background: var(--accent-green-soft);  color: var(--accent-green);  }
.priority-badge {
  display: inline-flex; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600;
}
.priority-badge.high   { background: var(--accent-red-soft);    color: var(--accent-red);    }
.priority-badge.medium { background: var(--accent-yellow-soft); color: var(--accent-yellow); }
.priority-badge.low    { background: var(--accent-green-soft);  color: var(--accent-green);  }

/* ── Live badge ──────────────────────────────────────────────── */
.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  background: var(--accent-red-soft); color: var(--accent-red);
}
.live-badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-red); animation: blink 1.4s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

/* ── Data table ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; color: var(--text-tertiary);
  padding: 9px 12px; border-bottom: 1px solid var(--border-color);
}
.data-table td { padding: 11px 12px; font-size: 13px; border-bottom: 1px solid var(--border-color); }
.data-table tr:hover td { background: var(--bg-tertiary); }
.data-table tr:last-child td { border-bottom: none; }

/* ── Map container ───────────────────────────────────────────── */
.map-container { width: 100%; height: 420px; border-radius: 10px; overflow: hidden; position: relative; }
#leafletMap { width: 100%; height: 100%; border-radius: 10px; }
.map-tooltip {
  position: absolute; padding: 9px 13px; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: 9px;
  box-shadow: var(--shadow-lg); font-size: 12px; pointer-events: none;
  z-index: 60; opacity: 0; transition: opacity .15s;
}

/* ── Map mode tabs ───────────────────────────────────────────── */
.map-mode-tabs { display: flex; gap: 4px; }
.map-mode-tab {
  padding: 5px 12px; border-radius: 7px; font-size: 11.5px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border-color);
  background: var(--bg-secondary); color: var(--text-secondary); font-family: 'DM Sans';
  transition: all .18s;
}
.map-mode-tab.active { background: var(--accent-blue-soft); color: var(--accent-blue); border-color: var(--accent-blue); }

/* ── Activity feed ───────────────────────────────────────────── */
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border-color);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.activity-icon svg { width: 15px; height: 15px; }
.activity-text { font-size: 13px; line-height: 1.45; }
.activity-time { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Social buzz card ────────────────────────────────────────── */
.buzz-bar-wrap { margin-bottom: 10px; }
.buzz-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 4px; color: var(--text-secondary);
}
.buzz-bar-track {
  height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden;
}
.buzz-bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }

/* ── Key Issues chart wrapper ────────────────────────────────── */
.issue-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.issue-row-label { font-size: 13px; color: var(--text-secondary); width: 110px; flex-shrink: 0; }
.issue-bar-track { flex: 1; height: 7px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.issue-bar-fill  { height: 100%; border-radius: 4px; }
.issue-pct { font-size: 12px; font-weight: 600; font-family: 'JetBrains Mono'; width: 34px; text-align: right; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9,13,26,.55);
  backdrop-filter: blur(4px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .28s;
}
.modal,
.modal-backdrop {
  z-index: 9999 !important;
}
.modal-backdrop.open { opacity: 1; }
.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(640px, 95vw); max-height: 90vh;
  overflow-y: auto;
  transform: translateY(18px) scale(.98);
  transition: transform .28s cubic-bezier(.34,1.56,.64,1);
}
.modal-backdrop.open .modal-box { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 24px 16px; border-bottom: 1px solid var(--border-color);
}
.modal-title   { font-family: 'Outfit'; font-size: 18px; font-weight: 700; }
.modal-subtitle{ font-size: 12.5px; color: var(--text-tertiary); margin-top: 3px; }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-color);
  background: var(--bg-tertiary); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: background .18s;
}
.modal-close:hover { background: var(--accent-red-soft); color: var(--accent-red); }
.modal-stats {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 12px;
  padding: 18px 24px; border-bottom: 1px solid var(--border-color);
}
.mstat { text-align: center; }
.mstat-val { font-family: 'Outfit'; font-size: 24px; font-weight: 700; }
.mstat-lbl { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.modal-section { padding: 18px 24px; border-bottom: 1px solid var(--border-color); }
.modal-section:last-of-type { border-bottom: none; }
.modal-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-tertiary); margin-bottom: 12px; }
.modal-footer {
  padding: 14px 24px;
  display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border-color);
}
.assign-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.assign-select {
  flex: 1; min-width: 160px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border-color); background: var(--bg-input);
  color: var(--text-primary); font-family: 'DM Sans'; font-size: 13px; outline: none;
  transition: border-color .18s;
}
.assign-select:focus { border-color: var(--accent-blue); }
.assign-btn { flex-shrink: 0; }
.assigned-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}
.assigned-row:last-child { border-bottom: none; }
.assigned-row span:last-of-type { margin-left: auto; }
.modal-issue-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-color); font-size: 13px;
}
.modal-issue-row:last-child { border-bottom: none; }

/* ── Responsive ──────────────────────────────────────────────── */
@media(max-width:1400px){ .kpi-grid{ grid-template-columns:repeat(3,1fr); } }
@media(max-width:1100px){
  .kpi-grid{ grid-template-columns:repeat(2,1fr); }
  .grid-2,.grid-2-1,.grid-3-1{ grid-template-columns:1fr; }
  .grid-3{ grid-template-columns:1fr 1fr; }
}
@media(max-width:1024px){
  .sidebar{ transform:translateX(-100%); }
  .sidebar.mobile-open{ transform:translateX(0); }
  .main-area{ margin-left:0!important; }
  .topbar{ left:0!important; }
}
@media(max-width:640px){
  .kpi-grid{ grid-template-columns:1fr; }
  .grid-3{ grid-template-columns:1fr; }
  .main-content{ padding:calc(var(--topbar-h) + 14px) 14px 24px; }
  .topbar{ padding:0 14px; }
  .page-header{ flex-direction:column; gap:10px; }
  .modal-stats{ grid-template-columns:repeat(2,1fr); }
}

/* ── Leaflet tile fix for dark mode ──────────────────────────── */
[data-theme="dark"] .leaflet-tile { filter: brightness(.7) invert(1) contrast(1.3) hue-rotate(200deg) saturate(.5) brightness(.7); }
[data-theme="dark"] .leaflet-container { background:#0a0e1a; }