/* NEIIA Stakeholder Map — shared styles */
:root {
  --brand: #0E7A3C;
  --brand-50: #E8F4EC;
  --brand-600: #0B6431;
  --ink: #0F172A;
  --body: #334155;
  --muted: #64748B;
  --border: #E2E8F0;
  --surface: #F8FAFC;
  --amber: #F59E0B;
  --red: #DC2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--body);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
h1, h2, h3, h4 { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
a { color: inherit; text-decoration: none; }

.shell { max-width: 1320px; margin: 0 auto; padding: 0 20px; }
.shell-wide { max-width: 1600px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.shell-header {
  background: white;
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 40;
}
.shell-header .shell, .shell-header .shell-wide {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.wordmark-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--brand);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}
.shell-tabs {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}
.shell-tabs .tab {
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  color: var(--body);
}
.shell-tabs .tab:hover { background: #F1F5F9; }
.shell-tabs .tab.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.shell-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.header-search {
  width: 280px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  position: relative;
}
.header-search-wrap { position: relative; }
.header-search-wrap svg { position: absolute; left: 11px; top: 9px; color: var(--muted); pointer-events: none; }
.header-search:focus { outline: none; border-color: var(--brand); background: white; }
.view-toggle {
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.view-toggle .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--brand); }
.view-toggle.public .dot { background: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: white; border-color: #CBD5E1; color: #334155; }
.btn-secondary:hover { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--body); }
.btn-ghost:hover { background: #F1F5F9; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---------- Hub landing ---------- */
.hub-hero {
  background: linear-gradient(135deg, #F0F7F2 0%, #FFFFFF 100%);
  padding: 60px 0 50px;
}
.hub-hero h1 { font-size: 40px; line-height: 1.1; max-width: 720px; margin: 0 0 16px; }
.hub-hero .sub { font-size: 17px; color: var(--muted); max-width: 640px; margin: 0 0 28px; }
.hub-cta-row { display: flex; gap: 10px; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 36px 0; }
.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.kpi-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--ink); margin-top: 6px; line-height: 1; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 4px; }

.view-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0 36px; }
.view-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  display: block;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.view-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(14,122,60,0.1); }
.view-card .icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.view-card h3 { font-size: 18px; margin: 0 0 6px; }
.view-card p { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.view-card .more { font-weight: 600; color: var(--brand); font-size: 13px; }

.feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 60px; }
.feat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: block;
  transition: border-color .15s;
}
.feat-card:hover { border-color: var(--brand); }
.feat-card .badge-row { display: flex; gap: 6px; margin-bottom: 8px; }
.feat-card .name { font-weight: 700; color: var(--ink); font-size: 14px; }
.feat-card .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.hub-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 40px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Section header ---------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-h h2 { font-size: 18px; }
.section-h .count { font-size: 13px; color: var(--muted); }

/* ---------- Chips + dots ---------- */
.color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  vertical-align: middle;
}
.sub-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #F1F5F9;
  color: var(--ink);
  white-space: nowrap;
}
.sub-chip.outline { background: white; border: 1px solid var(--border); }
.priority-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}
.priority-critical { background: var(--brand-50); color: var(--brand); }
.priority-high { background: #FEF3C7; color: #B45309; }
.priority-medium { background: #DBEAFE; color: #1D4ED8; }
.priority-low { background: #F1F5F9; color: #475569; }
.priority-monitor { background: #F1F5F9; color: var(--muted); }
.status-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.status-active { background: var(--brand-50); color: var(--brand); }
.status-merged, .status-dissolved, .status-dormant {
  background: #FEE2E2; color: var(--red);
}

/* ---------- Filter sidebar ---------- */
.filter-side {
  width: 240px;
  background: white;
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
.filter-side h4 { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 0 8px; }
.filter-side h4:first-child { margin-top: 0; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  color: var(--body);
  transition: background .12s;
}
.filter-chip:hover { background: var(--surface); }
.filter-chip.active { background: var(--brand-50); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.filter-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  color: var(--body);
}
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.filter-reset {
  width: 100%;
  margin-top: 18px;
  padding: 8px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--body);
  cursor: pointer;
}
.filter-counter { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- Tables ---------- */
.tbl-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead th {
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  color: #475569;
  padding: 11px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  cursor: pointer;
  white-space: nowrap;
}
.tbl thead th:hover { color: var(--ink); }
.tbl thead th .sort-icon { color: #CBD5E1; margin-left: 4px; }
.tbl thead th.sorted-asc .sort-icon,
.tbl thead th.sorted-desc .sort-icon { color: var(--brand); }
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--body);
  vertical-align: middle;
}
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.dissolved td { color: var(--muted); }
.tbl tbody tr.dissolved .name-cell { text-decoration: line-through; }
.tbl .name-cell { font-weight: 600; color: var(--ink); }
.tbl .acronym {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--brand-50);
  color: var(--brand);
  margin-left: 8px;
  letter-spacing: 0.02em;
}
.tbl a.ext-link { color: var(--brand); }
.tbl a.ext-link:hover { text-decoration: underline; }

/* ---------- Map view layout ---------- */
.map-layout { display: flex; height: calc(100vh - 60px); }
#map { flex: 1; height: 100%; }
.leaflet-popup-content-wrapper { border-radius: 10px; }

/* ---------- Entity slide panel ---------- */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.panel-backdrop.open { opacity: 1; pointer-events: auto; }
.entity-panel {
  position: fixed;
  right: -460px;
  top: 0;
  bottom: 0;
  width: 460px;
  background: white;
  z-index: 1001;
  transition: right .25s ease;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(15,23,42,0.12);
}
.entity-panel.open { right: 0; }
.entity-panel-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.entity-panel-header .color-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.entity-panel-header .acronym-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  color: white;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 12px;
}
.entity-panel-header h2 { font-size: 19px; line-height: 1.3; margin: 0 0 8px; }
.entity-panel-header .meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.entity-panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.entity-panel-close:hover { background: #E2E8F0; color: var(--ink); }
.entity-panel-body { padding: 20px 22px; }
.entity-section { margin-bottom: 20px; }
.entity-section h4 { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 8px; }
.entity-section p, .entity-section li { font-size: 13px; color: var(--body); margin: 0 0 4px; }
.entity-section ul { padding-left: 18px; margin: 0; }
.entity-section .kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.entity-section .kv dt { color: var(--muted); }
.entity-section .kv dd { margin: 0; color: var(--ink); }
.entity-section a.link { color: var(--brand); }
.entity-section a.link:hover { text-decoration: underline; }
.entity-panel-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: white;
  display: flex;
  gap: 8px;
}

/* ---------- Org chart ---------- */
.org-tree {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}
.org-branch { margin: 6px 0; }
.org-branch > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.org-branch > summary::-webkit-details-marker { display: none; }
.org-branch > summary:hover { background: var(--surface); }
.org-branch > summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  margin-right: 6px;
  transition: transform .15s;
}
.org-branch[open] > summary::before { transform: rotate(90deg); }
.org-children {
  margin-left: 20px;
  border-left: 1px dashed var(--border);
  padding-left: 18px;
  margin-top: 4px;
}
.org-leaf {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  margin: 2px 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--body);
  text-align: left;
  width: 100%;
}
.org-leaf:hover { background: var(--surface); border-color: var(--border); color: var(--ink); }
.org-leaf .leaf-name { flex: 1; }
.org-leaf .leaf-acronym { font-weight: 700; color: var(--ink); margin-right: 6px; font-size: 12px; }
.org-leaf.dissolved { opacity: 0.5; }
.org-leaf.dissolved .leaf-name { text-decoration: line-through; }

/* ---------- Entity profile page ---------- */
.entity-hero {
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
  background: white;
}
.entity-hero .hero-inner { display: flex; gap: 24px; align-items: flex-start; }
.entity-hero .acronym-circle-lg {
  width: 80px; height: 80px;
  border-radius: 18px;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 26px;
  flex-shrink: 0;
}
.entity-hero h1 { font-size: 30px; margin: 0 0 8px; }
.entity-hero .acronym-big { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; }
.entity-hero .chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.entity-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  padding: 32px 0;
}
.entity-grid .card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 16px;
}
.entity-grid h3 { font-size: 15px; margin: 0 0 10px; }
.entity-grid .kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.entity-grid .kv dt { color: var(--muted); }
.entity-grid .kv dd { margin: 0; color: var(--ink); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast {
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.toast.success { background: var(--brand); }

/* ---------- Mobile drawer ---------- */
.mobile-only { display: none; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; cursor: pointer; }

@media (max-width: 900px) {
  .header-search { width: 160px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .view-cards, .feat-grid { grid-template-columns: 1fr; }
  .entity-grid { grid-template-columns: 1fr; }
  .map-layout { flex-direction: column; }
  .filter-side {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: 100;
    transition: transform .25s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.08);
  }
  .filter-side.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .mobile-only { display: block; }
  #map { height: calc(100vh - 60px); }
  .entity-panel { width: 100%; right: -100%; }
  .entity-panel.open { right: 0; }
  /* Table to card */
  .tbl thead { display: none; }
  .tbl tbody tr { display: block; margin: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: white; }
  .tbl tbody td { display: flex; padding: 4px 0; border: none; }
  .tbl tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    min-width: 100px;
    font-size: 11px;
    text-transform: uppercase;
  }
}

/* ---------- Print (entity profile) ---------- */
@media print {
  .no-print, .shell-header, .entity-panel, .panel-backdrop, .toast-wrap { display: none !important; }
  body { background: white; color: black; }
  .entity-hero, .entity-grid .card { box-shadow: none; border-color: #ddd; page-break-inside: avoid; }
  .entity-grid { grid-template-columns: 1fr; }
}
