/* =========================================================
   CivLab · Saint Paul — Design System
   Light theme · Clean civic aesthetic
   ========================================================= */

/* --- Tokens --- */
:root {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.8125rem, 0.75rem + 0.3vw,  0.9375rem);
  --text-base: clamp(0.9375rem, 0.875rem + 0.25vw, 1rem);
  --text-lg:   clamp(1rem,     0.9rem  + 0.5vw,   1.25rem);
  --text-xl:   clamp(1.25rem,  1rem    + 0.75vw,  1.5rem);

  /* Spacing */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem;
  --sp-4: 1rem;    --sp-5: 1.25rem; --sp-6: 1.5rem;
  --sp-8: 2rem;    --sp-10: 2.5rem; --sp-12: 3rem;

  /* Colors — Light theme */
  --bg:             #f5f4f0;
  --surface:        #ffffff;
  --surface-2:      #fafaf8;
  --surface-hover:  #f0efe9;
  --border:         #e2e0da;
  --divider:        #ebe9e3;

  --text:           #1a1916;
  --text-muted:     #6b6a66;
  --text-faint:     #a8a7a3;

  /* Brand accent — Capitol blue-maroon (Minnesota flag inspired) */
  --accent:         #2a4a8b;
  --accent-hover:   #1e3670;
  --accent-light:   #dce6f8;
  --accent-text:    #1e3670;

  /* Node ring colors */
  --ring-elected:   #c0392b;
  --ring-dept:      #7b5ea7;
  --ring-board:     #2980b9;
  --ring-center:    #2a4a8b;

  /* Radius */
  --r-sm: 0.375rem;
  --r-md: 0.625rem;
  --r-lg: 1rem;
  --r-xl: 1.25rem;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(26,25,22,0.07);
  --shadow-md: 0 4px 14px rgba(26,25,22,0.09);
  --shadow-lg: 0 8px 28px rgba(26,25,22,0.12);

  /* Transitions */
  --ease: 160ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --header-h: 52px;
  --sidebar-w: 360px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

/* Dark mode */
[data-theme="dark"] {
  --bg:             #15140f;
  --surface:        #1c1b15;
  --surface-2:      #201f19;
  --surface-hover:  #2a2920;
  --border:         #2e2d26;
  --divider:        #262520;
  --text:           #d4d3cf;
  --text-muted:     #817f79;
  --text-faint:     #55534e;
  --accent:         #6b8fd9;
  --accent-hover:   #90aae8;
  --accent-light:   #1e2a42;
  --accent-text:    #90aae8;
  --ring-elected:   #e57373;
  --ring-dept:      #b39ddb;
  --ring-board:     #64b5f6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 28px rgba(0,0,0,0.45);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  line-height: 1.55;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
h1,h2,h3,h4 { text-wrap: balance; line-height: 1.2; }
p { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* --- Header --- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left { display: flex; align-items: center; flex-shrink: 0; }

.logo-link {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  color: var(--text);
  transition: opacity var(--ease);
}
.logo-link:hover { opacity: 0.75; }

.logo-icon { flex-shrink: 0; }

/* Lollipop + ballot box mark (inline SVG) */
.logo-icon .logo-ballot-body {
  fill: #e4e4e7;
  stroke: #a1a1aa;
  stroke-width: 0.85;
}
[data-theme="dark"] .logo-icon .logo-ballot-body {
  fill: #3f3f46;
  stroke: #71717a;
}
.logo-icon .logo-ballot-slot {
  fill: #c4c4cc;
  stroke: #8b8b96;
  stroke-width: 0.65;
}
[data-theme="dark"] .logo-icon .logo-ballot-slot {
  fill: #52525b;
  stroke: #6b7280;
}
.logo-icon .logo-lollipop-stick {
  stroke: #92400e;
  stroke-width: 2.45;
  stroke-linecap: round;
  fill: none;
}
[data-theme="dark"] .logo-icon .logo-lollipop-stick {
  stroke: #d97706;
}
.logo-icon .logo-lollipop-candy {
  fill: #f472b6;
  stroke: #db2777;
  stroke-width: 0.75;
}
[data-theme="dark"] .logo-icon .logo-lollipop-candy {
  fill: #f9a8d4;
  stroke: #ec4899;
}
.logo-icon .logo-lollipop-shine {
  fill: #ffffff;
  opacity: 0.5;
}
[data-theme="dark"] .logo-icon .logo-lollipop-shine {
  opacity: 0.35;
}

.logo-text {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.logo-brand { color: var(--text); }
.logo-divider { color: var(--text-faint); font-weight: 300; }
.logo-city { color: var(--text-muted); }

.header-center {
  flex: 1;
  max-width: 380px;
  margin: 0 auto;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-4);
  color: var(--text-muted);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  color: var(--text);
}
.search-bar input {
  border: none;
  background: none;
  font-size: var(--text-sm);
  color: var(--text);
  width: 100%;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-faint); }

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.header-nav { display: flex; gap: var(--sp-1); }

.header-level-wrap {
  position: relative;
}

.header-level-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}
.header-level-btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-faint);
}

.header-level-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 11rem;
  padding: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
}

.header-level-item {
  display: block;
  width: 100%;
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--sp-2) var(--sp-3);
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.header-level-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.header-level-item.active {
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-btn {
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all var(--ease);
}
.nav-btn:hover { color: var(--text); background: var(--surface-hover); }
.nav-btn.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--ease);
  border: 1px solid var(--border);
}
.icon-btn:hover { color: var(--text); background: var(--surface-hover); }

/* --- Main Layout --- */
.main-layout {
  margin-top: var(--header-h);
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Custom scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--divider); border-radius: var(--r-full); }

/* News view — the default sidebar content */
.sidebar-news-view {
  padding: var(--sp-6) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  flex: 1;
}

/* Entity view — shown when a node is selected */
.sidebar-entity-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.sidebar-news-view[hidden]   { display: none; }
.sidebar-entity-view[hidden] { display: none; }

.sev-back-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
  transition: color var(--ease), background var(--ease);
  flex-shrink: 0;
  letter-spacing: 0.01em;
}
.sev-back-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.sev-content {
  padding: var(--sp-5) var(--sp-5) var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  flex: 1;
}

/* Entity view inner elements reuse dip-* visual style via sev-* */
.sev-type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: var(--sp-1);
}

.sev-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}

.sev-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: var(--sp-1);
}

.sev-tabs {
  display: flex;
  border-bottom: 1px solid var(--divider);
  gap: 0;
}

.sev-tab {
  flex: 1;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-faint);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--ease);
}
.sev-tab:hover { color: var(--text-muted); }
.sev-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.sev-tab-body {
  padding-top: var(--sp-3);
}

.sev-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.65;
  max-width: none;
}

.sev-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: var(--sp-2);
  transition: color var(--ease);
}
.sev-link:hover { color: var(--accent-hover); }

.sidebar-section { display: flex; flex-direction: column; gap: var(--sp-3); }

.section-heading {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-divider {
  height: 1px;
  background: var(--divider);
  flex-shrink: 0;
}

/* News */
.news-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.65;
  max-width: none;
}
.news-link {
  display: inline;
  font-weight: 500;
  transition: color var(--ease);
}
.news-link:hover { color: var(--accent); }

.entity-pill {
  background: var(--accent-light);
  color: var(--accent-text);
  padding: 0.05em 0.4em;
  border-radius: var(--r-sm);
  font-size: 0.85em;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.entity-pill.entity-dept {
  background: #f3f0fb;
  color: #6b46c1;
}
[data-theme="dark"] .entity-pill { background: var(--accent-light); color: var(--accent-text); }
[data-theme="dark"] .entity-pill.entity-dept { background: #2d1f4e; color: #b39ddb; }

sup.cite {
  font-size: 0.7em;
  line-height: 1;
  vertical-align: super;
  margin-left: 1px;
}
sup.cite a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
sup.cite a:hover { text-decoration: underline; }

.read-more-btn {
  font-size: var(--text-xs);
  color: var(--accent);
  font-weight: 600;
  padding: 0;
  margin-top: var(--sp-1);
  text-align: left;
  transition: color var(--ease);
}
.read-more-btn:hover { color: var(--accent-hover); }

.news-extra { margin-top: var(--sp-2); }

/* Topics */
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.topic-chip {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg);
  transition: all var(--ease);
}
.topic-chip:hover,
.topic-chip.active {
  background: var(--accent-light);
  color: var(--accent-text);
  border-color: var(--accent-light);
}

.view-all-btn {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  padding: 0;
  text-align: left;
  transition: color var(--ease);
}
.view-all-btn:hover { color: var(--accent-hover); }

/* People Grid */
.people-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.person-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  cursor: pointer;
  transition: all var(--ease);
}
.person-card:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.person-avatar {
  width: 64px; height: 64px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.person-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}
.person-dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.person-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.person-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
}

.person-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: none;
}

.profile-link {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  align-self: flex-start;
  transition: color var(--ease);
}
.profile-link:hover { color: var(--accent-hover); }

/* Stats Bar */
.stats-bar {
  display: flex;
  align-items: stretch;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-3) var(--sp-2);
  gap: var(--sp-1);
}
.stat-value {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-weight: 500;
}
.stat-sep {
  width: 1px;
  background: var(--divider);
  align-self: stretch;
  flex-shrink: 0;
}

/* Fiscal */
.stats-fiscal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.fiscal-header {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}
.fiscal-year-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.fiscal-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}
.fiscal-metric {
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  border-right: 1px solid var(--divider);
}
.fiscal-metric:last-child { border-right: none; }
.fiscal-metric-label {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-weight: 500;
  line-height: 1.2;
}
.fiscal-metric-value {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.fiscal-metric-change {
  font-size: 0.68rem;
  font-weight: 600;
}
.fiscal-metric-change.positive { color: #16a34a; }
.fiscal-metric-change.negative { color: #dc2626; }
.fiscal-metric-change.neutral { color: var(--text-faint); }

/* About blurb */
.about-blurb {
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.about-blurb p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: none;
}
.about-blurb a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 2px;
}
.about-blurb a:hover {
  color: var(--accent-hover);
}
.disclaimer { color: var(--text-faint) !important; font-style: italic; }

/* =====================
   GRAPH PANEL
   ===================== */
.graph-panel {
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-md);
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all var(--ease);
}
.tab-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}
.tab-panel[hidden] { display: none; }

/* Graph tab: canvas fills full height, node label is a small strip below */
#panel-graph {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.graph-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
}

.graph-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
  box-shadow: var(--shadow-sm);
}
.graph-nav-btn:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--text-faint);
}
.graph-nav-prev { left: var(--sp-2); }
.graph-nav-next { right: var(--sp-2); }

.council-inline {
  flex-shrink: 0;
  max-height: min(38vh, 320px);
  overflow-y: auto;
  border-top: 1px solid var(--divider);
  background: var(--surface);
}
.council-inline-inner {
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
}
.council-inline .council-view {
  height: auto;
  max-height: none;
  padding: 0;
  overflow: visible;
  gap: var(--sp-3);
}
.council-inline .council-subtitle {
  margin-top: 0;
}
.council-inline .council-grid {
  padding-bottom: var(--sp-2);
}

/* Canvas chart */
#orgChart {
  width: 100%;
  height: 100%;
  max-width: 100%;
  cursor: default;
  flex: 1;
  min-height: 0;
}

/* Desktop node label — shown below canvas when a node is selected */
.desktop-node-label {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg);
  letter-spacing: 0.01em;
  min-height: 0;
  line-height: 1.3;
  border-top: 1px solid var(--divider);
  transition: min-height var(--ease), padding var(--ease);
}
.desktop-node-label:empty {
  min-height: 0;
  padding: 0;
  border-top: none;
}
.desktop-node-label.has-label {
  min-height: 34px;
}

/* =====================
   BUDGET PANEL
   ===================== */
.budget-view {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}
.budget-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
}
.budget-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: calc(-1 * var(--sp-4));
  max-width: none;
}
.budget-bars {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.budget-bar-item {
  display: grid;
  grid-template-columns: 220px 1fr 80px;
  align-items: center;
  gap: var(--sp-4);
}
.budget-bar-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.budget-bar-track {
  height: 22px;
  background: var(--bg);
  border-radius: var(--r-full);
  overflow: hidden;
  border: 1px solid var(--divider);
}
.budget-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 4px;
}
.budget-bar-amount {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text);
}

/* =====================
   COUNCIL PANEL
   ===================== */
.council-view {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}
.council-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
}
.council-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: calc(-1 * var(--sp-4));
  max-width: none;
}
.council-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}
.council-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: all var(--ease);
}
.council-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.council-ward-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}
.council-member-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
}
.council-role {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.council-neighborhoods {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  max-width: none;
}
.council-party {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-weight: 500;
}

/* =====================
   DESKTOP / MOBILE SPLIT
   ===================== */

/* Desktop: show desktop layout, hide mobile */
.desktop-layout { display: flex; flex-direction: column; min-height: 100dvh; }
.mobile-layout  { display: none; }

@media (max-width: 720px) {
  .desktop-layout { display: none; }
  .mobile-layout  { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
}
@media (max-width: 900px) and (min-width: 721px) {
  :root { --sidebar-w: 300px; }
}

/* =====================
   MOBILE LAYOUT
   ===================== */

/* Header */
.mobile-header {
  flex-shrink: 0;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  z-index: 20;
}
.mobile-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.875rem;
}
.mobile-logo-city { color: var(--text-muted); font-weight: 400; }
.mobile-logo-text { color: var(--text); }
.mobile-search-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  transition: all var(--ease);
}
.mobile-search-btn:hover { color: var(--text); background: var(--surface-hover); }

/* Graph wrap */
.mobile-graph-wrap {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#mobileOrgChart {
  flex: none;
  width: 100%;
  display: block;
  /* height set by JS */
}
.mobile-node-label {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg);
  letter-spacing: 0.01em;
  min-height: 32px;
  line-height: 1.3;
}

/* Mobile toolbar */
.mobile-toolbar {
  flex-shrink: 0;
  height: 52px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  position: relative;
  z-index: 30;
}
.mobile-toolbar-left  { display: flex; align-items: center; }
.mobile-toolbar-center { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.mobile-toolbar-right  { display: flex; align-items: center; gap: var(--sp-1); }

.mobile-dropdown-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
  transition: all var(--ease);
}
.mobile-dropdown-btn:active { background: var(--surface-hover); }
.mobile-filter-btn { padding: 0.35rem 0.65rem; }

.mobile-cat-dot {
  width: 10px; height: 10px;
  border-radius: var(--r-full);
  background: var(--text-faint);
  flex-shrink: 0;
  transition: background var(--ease);
}

.mobile-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  overflow: hidden;
  z-index: 50;
}
.mobile-cat-dropdown {
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 8px);
}
.mobile-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--ease);
}
.mobile-dropdown-item:hover,
.mobile-dropdown-item.active {
  background: var(--surface-hover);
  color: var(--text);
}
.mobile-dropdown-item .dot {
  width: 10px; height: 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.mobile-nav-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all var(--ease);
}
.mobile-nav-btn:active { background: var(--surface-hover); color: var(--text); }

/* Mobile info panel — scrollable bottom sheet */
.mobile-info-panel {
  flex-shrink: 0;
  max-height: 38vh;
  overflow-y: auto;
  background: var(--surface);
  border-top: 2px solid var(--border);
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
}
.mobile-info-panel::-webkit-scrollbar { width: 3px; }
.mobile-info-panel::-webkit-scrollbar-thumb { background: var(--divider); border-radius: var(--r-full); }

/* Info panel content */
.mip-type {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: var(--sp-1);
}
.mip-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: var(--sp-2);
}
.mip-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: none;
  margin-bottom: var(--sp-3);
}
.mip-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: var(--sp-4);
}
.mip-link:hover { color: var(--accent-hover); }

/* Mobile news view */
.mobile-news-view {
  padding: var(--sp-1) 0;
}
.mobile-news-view h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: var(--sp-3);
}
.mobile-news-view .news-text {
  font-size: 0.875rem;
  line-height: 1.65;
  max-width: none;
}

/* Mobile budget view */
.mobile-budget-view { padding: var(--sp-2) 0; }
.mobile-budget-view h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-1);
}
.mobile-budget-view p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
  max-width: none;
}
.mobile-budget-view .budget-bars { display: flex; flex-direction: column; gap: var(--sp-2); }
.mobile-budget-view .budget-bar-item {
  display: grid;
  grid-template-columns: 130px 1fr 62px;
  align-items: center;
  gap: var(--sp-2);
}
.mobile-budget-view .budget-bar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-budget-view .budget-bar-track {
  height: 18px;
  background: var(--bg);
  border-radius: var(--r-full);
  overflow: hidden;
  border: 1px solid var(--divider);
}
.mobile-budget-view .budget-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.8s cubic-bezier(.16,1,.3,1);
  min-width: 3px;
}
.mobile-budget-view .budget-bar-amount {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
}

/* Mobile council view */
.mobile-council-view { padding: var(--sp-1) 0; }
.mobile-council-view h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-1);
}
.mobile-council-view p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
  max-width: none;
}
.mobile-council-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.mobile-council-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg);
  border-radius: var(--r-md);
}
.mobile-ward-badge {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}
.mobile-council-info { flex: 1; min-width: 0; }
.mobile-council-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
}
.mobile-council-role {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mobile-council-hoods {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ── Info panel tabs ─────────────────────────────────── */
.mip-council-embed {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--divider);
}
.mip-council-embed-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

.mip-header { margin-bottom: var(--sp-3); }

.mip-tabs {
  display: flex;
  border-bottom: 1px solid var(--divider);
  margin-bottom: var(--sp-4);
  gap: 0;
}
.mip-tab {
  flex: 1;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-faint);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--ease);
  white-space: nowrap;
}
.mip-tab:hover { color: var(--text-muted); }
.mip-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.mip-tab-body { padding-bottom: var(--sp-2); }

/* Connection list */
.mip-conn-group {
  margin-bottom: var(--sp-4);
}
.mip-conn-heading {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.mip-conn-count {
  font-weight: 400;
  color: var(--text-faint);
  font-size: 0.7rem;
}
/* mip-conn-row styles moved to a.mip-conn-row */
.mip-conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mip-conn-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

/* Clickable connection rows */
a.mip-conn-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  text-decoration: none;
  transition: background var(--ease);
  cursor: pointer;
}
a.mip-conn-row:active { background: var(--surface-hover); }
.mip-conn-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-faint);
}
