* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #3d5af1;
  --blue-deep: #2a41c4;
  --ink: #14181f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --panel: #ffffff;
  --bg: #f4f5f9;
  --radius: 12px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

#app { display: flex; height: 100vh; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 292px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  z-index: 5;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  font-size: 9px; line-height: 8px; letter-spacing: 1px;
  color: var(--ink); width: 26px;
}
.brand h1 { font-size: 19px; letter-spacing: 0.5px; }
.byline { font-size: 11px; color: var(--muted); }

#search {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 14px; background: var(--bg);
}
#search:focus { outline: 2px solid var(--blue); border-color: transparent; }

.filter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-weight: 600; font-size: 14px; margin-top: 2px;
}
.link-btn {
  background: none; border: none; color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.link-btn:hover { color: var(--blue); }

.filter-group {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; background: #fff;
}
.filter-group summary {
  cursor: pointer; font-size: 14px; font-weight: 500;
  list-style: none; display: flex; justify-content: space-between;
}
.filter-group summary::after { content: "▾"; color: var(--muted); font-size: 11px; }
.filter-group[open] summary::after { content: "▴"; }
.filter-group .hint { font-weight: 400; color: var(--muted); font-size: 11px; }

.options { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.options-scroll { max-height: 220px; overflow-y: auto; }
.options label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; color: #374151;
}
.options label:hover { color: var(--ink); }
.options input { accent-color: var(--blue); }

.cheque-row { flex-direction: row; align-items: center; gap: 6px; }
.cheque-row input {
  width: 100%; min-width: 0; padding: 7px 8px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px;
}

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; padding: 4px 2px; cursor: pointer;
}
.toggle-row input { accent-color: var(--blue); transform: scale(1.2); }

#stats {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); line-height: 1.7;
}

/* ---------- main ---------- */
#main { flex: 1; position: relative; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  position: absolute; top: 16px; left: 20px; right: 20px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 4; pointer-events: none;
}
#topbar > * { pointer-events: auto; }

#count-pill {
  background: rgba(255,255,255,0.92); border-radius: 999px;
  padding: 7px 16px; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.view-toggle {
  background: rgba(255,255,255,0.92); border-radius: 999px; padding: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12); display: flex; gap: 2px;
}
.view-toggle button {
  border: none; background: none; padding: 6px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted);
}
.view-toggle button.active { background: var(--blue); color: #fff; }

#map-view { flex: 1; background: var(--blue); position: relative; overflow: hidden; }
#map-view svg { display: block; }

.bubble { cursor: pointer; }
.bubble circle.ring {
  fill: #fff; stroke: rgba(0,0,0,0.08); stroke-width: 1;
  transition: stroke 0.15s;
}
.bubble:hover circle.ring { stroke: #14181f; stroke-width: 2.5; }
.bubble.no-logo text {
  font-size: 10px; font-weight: 600; fill: var(--blue-deep);
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
}

#map-tooltip {
  position: absolute; pointer-events: none; z-index: 6;
  background: #14181f; color: #fff; font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 8px; opacity: 0;
  transition: opacity 0.1s; white-space: nowrap;
}

.empty-note {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85); font-size: 15px; pointer-events: none;
}

/* ---------- table ---------- */
#table-view { flex: 1; overflow: auto; padding: 66px 20px 20px; }
#table-view.hidden, #map-view.hidden { display: none; }

#table-view table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); font-size: 13px;
}
#table-view th, #table-view td { padding: 9px 12px; text-align: left; }
#table-view th {
  background: #fafafa; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted); position: sticky; top: 0;
}
#table-view th.sortable { cursor: pointer; user-select: none; }
#table-view th.sortable:hover { color: var(--ink); }
#table-view th.num, #table-view td.num { text-align: right; }
#table-view tbody tr { border-bottom: 1px solid #f1f2f4; cursor: pointer; }
#table-view tbody tr:hover { background: #f6f8ff; }
.tbl-logo {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); background: #fff; display: block;
}
.tag {
  display: inline-block; background: #eef1fe; color: var(--blue-deep);
  border-radius: 999px; padding: 2px 8px; font-size: 11px; margin: 1px 2px 1px 0;
}
.tag.stage { background: #e8f6ee; color: #157347; }

/* ---------- drawer ---------- */
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 390px; max-width: 92vw;
  background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,0.18);
  z-index: 20; overflow-y: auto; padding: 24px;
  transition: transform 0.2s ease;
}
#drawer.hidden { transform: translateX(110%); box-shadow: none; }
#drawer-close {
  position: absolute; top: 12px; right: 14px; border: none; background: none;
  font-size: 26px; color: var(--muted); cursor: pointer;
}
#drawer-close:hover { color: var(--ink); }

.drawer-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.drawer-logo {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); flex-shrink: 0;
}
.drawer-head h2 { font-size: 20px; }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.drawer-badges { margin: 4px 0 12px; }
.drawer-desc { font-size: 13.5px; line-height: 1.6; color: #374151; margin-bottom: 16px; }

.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.fact {
  background: var(--bg); border-radius: 10px; padding: 10px 12px;
}
.fact .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.fact .v { font-size: 14px; font-weight: 600; margin-top: 2px; }

.drawer-links { display: flex; gap: 10px; }
.drawer-links a {
  flex: 1; text-align: center; padding: 10px; border-radius: 10px;
  text-decoration: none; font-size: 13px; font-weight: 600;
  background: var(--blue); color: #fff;
}
.drawer-links a.secondary { background: #eef1fe; color: var(--blue-deep); }

/* ---------- v2: interactive additions ---------- */

.topbar-left { display: flex; gap: 10px; align-items: center; }
.map-control {
  background: rgba(255,255,255,0.92); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; display: flex; gap: 6px; align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.map-control label { color: var(--muted); font-weight: 600; }
.map-control select {
  border: none; background: none; font-size: 13px; font-weight: 500;
  cursor: pointer; outline: none;
}

#legend {
  position: absolute; bottom: 16px; left: 20px; z-index: 4;
  background: rgba(255,255,255,0.92); border-radius: 999px;
  padding: 7px 14px; font-size: 12px; display: flex; gap: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
#legend.hidden { display: none; }
.legend-item { display: flex; align-items: center; gap: 5px; font-weight: 500; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.group-label {
  fill: rgba(255,255,255,0.75); font-size: 15px; font-weight: 700;
  text-anchor: middle; letter-spacing: 0.4px; pointer-events: none;
}

.bubble.gone circle.ring { opacity: 0.55; }
.bubble.gone image { opacity: 0.4; filter: grayscale(1); }
.gone-strike { stroke: #ef4444; stroke-width: 3; stroke-linecap: round; opacity: 0.85; }

#map-tooltip .tt-sub { display: block; font-weight: 400; opacity: 0.75; font-size: 11px; }
#map-tooltip .tt-gone { color: #f87171; font-weight: 700; }

.bubble .initials {
  font-size: 10px; font-weight: 600; fill: var(--blue-deep);
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
}

#add-fund-btn {
  border: 1px dashed var(--blue); color: var(--blue); background: none;
  border-radius: var(--radius); padding: 9px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
#add-fund-btn:hover { background: #eef1fe; }

.tbl-initials, .drawer-initials, .chip-initials {
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef1fe; color: var(--blue-deep); font-weight: 700; font-size: 11px;
}
.drawer-initials { font-size: 18px; }
.row-gone td b { text-decoration: line-through; text-decoration-color: #ef4444; }
.row-gone .tbl-logo { filter: grayscale(1); opacity: 0.6; }
.gone-tag { background: #fee2e2 !important; color: #b91c1c !important; }
.sub { font-size: 11px; color: var(--muted); }

.status-banner {
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}
.banner-gone { background: #fee2e2; color: #7f1d1d; }
.banner-warn { background: #fef3c7; color: #78350f; }
.status-banner a { color: inherit; }

.drawer-manage { display: flex; gap: 8px; margin-top: 14px; }
.btn-ghost, .btn-danger, .btn-primary {
  border: none; border-radius: 10px; padding: 8px 16px; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.btn-ghost { background: #eef1fe; color: var(--blue-deep); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-primary { background: var(--blue); color: #fff; }

.similar-head {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin: 20px 0 8px;
}
.similar-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 7px 10px; margin-bottom: 6px; cursor: pointer; font-size: 13px;
  text-align: left;
}
.similar-chip:hover { border-color: var(--blue); background: #f6f8ff; }
.similar-chip img, .chip-initials {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.similar-chip .sub { margin-left: auto; white-space: nowrap; }

#modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,14,30,0.5); z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
#modal-backdrop.hidden { display: none; }
#modal {
  background: #fff; border-radius: 16px; padding: 22px; width: 560px;
  max-width: 94vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
#modal h3 { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid input, .form-grid textarea, .form-grid select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; font-family: inherit; color: var(--ink);
}
.form-grid input:focus, .form-grid textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.check-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.chip-picker { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; color: #374151;
}
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- v3: deals + admin ---------- */
.deal-row { border-left: 3px solid #eef1fe; padding: 6px 10px; margin-bottom: 8px; }
.deal-row:hover { border-left-color: var(--blue); }
.deal-company { font-weight: 700; font-size: 13.5px; color: var(--ink); text-decoration: none; }
a.deal-company:hover { color: var(--blue); }
.deal-meta { font-size: 12px; color: var(--muted); margin-left: 6px; }
.deal-desc { font-size: 12px; color: #4b5563; margin-top: 2px; line-height: 1.45; }
.deals-empty, .deals-loading { font-size: 12.5px; color: var(--muted); padding: 4px 0 8px; }
.deals-empty a { color: var(--blue); }

#similar-details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
#similar-details summary {
  cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; list-style: none;
}
#similar-details summary::after { content: " ▾"; }
#similar-details[open] summary::after { content: " ▴"; }
#similar-details .similar-chip:first-of-type { margin-top: 10px; }

/* ---------- admin page ---------- */
.admin-body { overflow: auto; background: var(--bg); }
#admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-header h1 { font-size: 22px; }
.admin-header .spacer { flex: 1; }
#admin-search {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; width: 260px; background: #fff;
}
.admin-pills { display: flex; gap: 6px; }
.admin-pills button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--muted);
}
.admin-pills button.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px;
  overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; text-align: left; vertical-align: middle; }
.admin-table th { background: #fafafa; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.admin-table tbody tr { border-bottom: 1px solid #f1f2f4; }
.admin-table tr.is-hidden td { opacity: 0.45; }
.admin-table tr.deals-open td { background: #f6f8ff; }
.admin-actions { display: flex; gap: 6px; white-space: nowrap; }
.admin-actions button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.admin-actions button:hover { border-color: var(--blue); color: var(--blue); }
.admin-actions button.danger:hover { border-color: #ef4444; color: #ef4444; }

.deals-editor td { background: #f6f8ff; padding: 12px 16px 16px; }
.deals-editor h4 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.deal-edit-row { display: flex; gap: 6px; align-items: center; margin-bottom: 5px; flex-wrap: wrap; }
.deal-edit-row input {
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 12.5px;
}
.deal-edit-row .w-lg { width: 180px; } .deal-edit-row .w-md { width: 120px; } .deal-edit-row .w-sm { width: 96px; }
.deal-edit-row button {
  border: none; background: none; color: #ef4444; cursor: pointer; font-size: 15px;
}
.deal-add-btn {
  border: 1px dashed var(--blue); color: var(--blue); background: none; border-radius: 8px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; margin-top: 4px;
}
.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge.active { background: #dcfce7; color: #157347; }
.badge.gone { background: #fee2e2; color: #b91c1c; }
.badge.warn { background: #fef3c7; color: #92400e; }

/* ---------- v5: timeline view + redesigned sidebar ---------- */
.dpy-row { flex-direction: row; align-items: center; gap: 10px; }
.dpy-row input[type=range] { flex: 1; accent-color: var(--blue); }
.dpy-row output { font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 52px; text-align: right; }
.locked-pill { font-size: 12px; color: var(--muted); font-weight: 500; }
#stats a { color: var(--muted); }
#stats a:hover { color: var(--blue); }

#timeline-view { flex: 1; overflow-y: auto; padding: 66px 26px 40px; background: var(--bg); }
#timeline-view.hidden { display: none; }
.tl-head { max-width: 980px; margin: 0 auto 6px; }
.tl-head h2 { font-size: 19px; }
.tl-head p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.tl-empty { max-width: 980px; margin: 60px auto; text-align: center; color: var(--muted); }
.tl-month { max-width: 980px; margin: 0 auto; display: flex; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.tl-month-label { width: 92px; flex-shrink: 0; padding-top: 6px; }
.tl-month-label span { font-weight: 800; font-size: 13.5px; display: block; }
.tl-month-label small { color: var(--muted); font-size: 11.5px; }
.tl-cards { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.tl-card {
  display: flex; align-items: center; gap: 9px; border: 1px solid var(--line);
  background: #fff; border-radius: 12px; padding: 8px 12px; cursor: pointer;
  text-align: left; font-family: inherit; max-width: 300px;
}
.tl-card:hover { border-color: var(--blue); background: #f6f8ff; }
.tl-card img, .tl-initials {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); flex-shrink: 0;
}
.tl-initials { display: inline-flex; align-items: center; justify-content: center;
  background: #eef1fe; color: var(--blue-deep); font-weight: 700; font-size: 11px; }
.tl-body { display: flex; flex-direction: column; min-width: 0; }
.tl-body b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-body small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-body .tl-fund { color: var(--blue-deep); font-weight: 600; }
.tl-flagged { opacity: 0.6; }
.tl-logos { display: flex; flex-shrink: 0; }
.tl-logos img, .tl-logos .tl-initials { margin-right: -10px; box-shadow: 0 0 0 2px #fff; }
.tl-logos img:last-child, .tl-logos .tl-initials:last-child { margin-right: 0; }

/* ---------- v6: consumer sidebar + methodology tooltip + submissions ---------- */
.side-nav { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.side-card {
  display: flex; gap: 12px; align-items: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  color: var(--ink); background: #fff;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.side-card:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(61,90,241,.12); transform: translateY(-1px); }
.side-card b { display: block; font-size: 13.5px; }
.side-card small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.side-card .sc-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef1fe; color: var(--blue-deep); font-size: 15px; font-weight: 700;
}
.side-card.primary { background: var(--blue); border-color: var(--blue); }
.side-card.primary b, .side-card.primary small { color: #fff; }
.side-card.primary small { opacity: .85; }
.side-card.primary .sc-icon { background: rgba(255,255,255,.18); color: #fff; }
.side-card.primary:hover { box-shadow: 0 6px 18px rgba(61,90,241,.35); }
.side-admin { display: flex; gap: 14px; padding-top: 8px; }
.side-admin .link-btn { text-decoration: none; padding: 0; }

.tl-toolbar { display: flex; align-items: center; gap: 14px; }
.tl-info { position: relative; color: var(--muted); font-size: 12.5px; cursor: help;
  border-bottom: 1px dotted var(--muted); }
.tl-info .tl-tip {
  display: none; position: absolute; top: 22px; left: 0; z-index: 30; width: 310px;
  background: #14181f; color: #e5e7eb; font-size: 12px; line-height: 1.55;
  padding: 12px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.tl-info:hover .tl-tip { display: block; }
.tl-submit { margin-left: auto; background: var(--blue); color: #fff; text-decoration: none;
  font-size: 12.5px; font-weight: 700; padding: 7px 14px; border-radius: 999px; }
.tl-submit:hover { background: var(--blue-deep); }

.submit-verdict { margin-top: 18px; border-radius: 12px; padding: 14px 18px; font-size: 14px; max-width: 720px; }
.submit-verdict.good { background: #dcfce7; color: #14532d; }
.submit-verdict.warn { background: #fef3c7; color: #78350f; }
.submit-verdict.bad { background: #fee2e2; color: #7f1d1d; }
.submit-verdict a { color: inherit; font-weight: 700; }

.deal-pending { background: #fef3c7; border-radius: 8px; padding: 4px 6px; }
.approve-btn { border: 1px solid #f59e0b !important; background: #fff !important;
  color: #92400e !important; border-radius: 8px !important; font-size: 12px !important;
  padding: 4px 10px !important; cursor: pointer; }
.group-label { paint-order: stroke; stroke: var(--blue); stroke-width: 5px; stroke-linejoin: round; }
.tag.micro { background: #fdf2fa; color: #a21caf; }

/* ================= v9: premium polish =================
   Final cascade layer — refined palette, Inter type, deep-ink map canvas,
   glass chrome, softer shadows. Overrides earlier layers deliberately. */
:root {
  --blue: #4f46e5;
  --blue-deep: #3730a3;
  --ink: #0f1222;
  --muted: #666b7e;
  --line: #e7e8ef;
  --bg: #f6f7fb;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15,18,34,.05), 0 4px 14px rgba(15,18,34,.05);
  --shadow-md: 0 2px 6px rgba(15,18,34,.07), 0 12px 32px rgba(15,18,34,.09);
  --glass: rgba(255,255,255,.88);
}
body { font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif; }
.brand h1 { font-size: 17px; letter-spacing: 2.5px; font-weight: 800; }
.byline { font-size: 11px; line-height: 1.5; }

#sidebar { border-right: 1px solid var(--line); padding: 22px 18px; gap: 15px; }
#search {
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s;
}
#search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,70,229,.14); }
.filter-head { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.filter-group { border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.filter-group summary { font-size: 13px; font-weight: 600; }
.filter-group .hint { font-size: 10.5px; }
.side-card { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.side-card.primary { box-shadow: 0 6px 20px rgba(79,70,229,.30); }

/* --- map: deep-ink canvas with soft aurora glows --- */
#map-view {
  background:
    radial-gradient(1100px 700px at 75% 15%, rgba(79,70,229,.28), transparent 60%),
    radial-gradient(900px 650px at 15% 85%, rgba(56,130,246,.16), transparent 60%),
    linear-gradient(160deg, #0e1130 0%, #151a45 55%, #1b2258 100%);
}
.bubble circle.ring {
  fill: #fff; stroke: rgba(255,255,255,.10); stroke-width: 1;
  filter: drop-shadow(0 3px 8px rgba(5,7,25,.35));
  transition: filter .2s;
}
.bubble:hover circle.ring { stroke: #fff; stroke-width: 2; filter: drop-shadow(0 6px 18px rgba(5,7,25,.5)); }
.group-label {
  fill: rgba(255,255,255,.92); font-size: 13px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  stroke: rgba(10,13,38,.45); stroke-width: 4px; paint-order: stroke;
}
#map-tooltip {
  background: rgba(13,16,38,.92); border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 10px; padding: 8px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transition: opacity .15s;
}

/* --- glass chrome over the canvas --- */
#count-pill, .view-toggle, .map-control, #legend {
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(15,18,34,.06); box-shadow: var(--shadow-sm);
}
.view-toggle button { font-weight: 600; transition: color .15s; }
.view-toggle button.active { box-shadow: 0 2px 8px rgba(79,70,229,.35); }

/* --- timeline --- */
#timeline-view { background: var(--bg); }
.tl-head h2 { font-size: 20px; letter-spacing: -.3px; }
.tl-month-label span { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink); }
.tl-month { border-bottom: 1px solid var(--line); }
.tl-card {
  border-radius: 13px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.tl-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: rgba(79,70,229,.35); background: #fff; }
.tl-submit { box-shadow: 0 4px 14px rgba(79,70,229,.3); }

/* --- table, drawer, modal --- */
#table-view table { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
#table-view th { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
#drawer { box-shadow: -16px 0 50px rgba(15,18,34,.16); border-left: 1px solid var(--line); }
#modal { border-radius: 18px; box-shadow: 0 24px 70px rgba(15,18,34,.28); }
.btn-primary { box-shadow: 0 4px 14px rgba(79,70,229,.28); transition: transform .12s, box-shadow .12s; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79,70,229,.36); }
.tag { font-weight: 600; letter-spacing: .1px; }
.fact { border-radius: 12px; }
.similar-chip { border-radius: 12px; transition: border-color .12s, background .12s; }
.empty-note { color: rgba(255,255,255,.75); font-weight: 500; }
.brand-mark { width: 26px; }
.brand-mark .c-mark { width: 26px; height: 26px; color: var(--ink); display: block; }
.curator-card img { border-radius: 10px; border: none; background: #fff; padding: 5px; }
.tag.platform { background: #fef3c7; color: #92400e; }

/* v10: prominent view switcher */
.view-toggle { padding: 5px; gap: 3px; border-radius: 14px; }
.view-toggle button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 700;
  color: #4b5563; letter-spacing: .2px;
}
.view-toggle button:hover { color: var(--ink); background: rgba(79,70,229,.07); }
.view-toggle button.active { background: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(79,70,229,.4); }
.view-toggle .vt-icon { font-size: 12px; opacity: .85; }

/* v11: first-load fit selector + perf (no per-bubble shadow filters) */
.bubble circle.ring { filter: none !important; }
.bubble:hover circle.ring { filter: none !important; stroke: #fff; stroke-width: 2.5; }

#map-intro { position: absolute; inset: 0; z-index: 5; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(800px 500px at 50% 45%, rgba(21,26,69,.35), transparent); }
.mi-card { background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
  border-radius: 22px; padding: 30px 34px; max-width: 620px; width: 100%;
  box-shadow: 0 30px 80px rgba(5,8,30,.45); }
.mi-card h2 { font-size: 24px; letter-spacing: -.4px; }
.mi-card > p { color: var(--muted); font-size: 14px; margin: 6px 0 18px; }
.mi-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.1px; color: var(--muted); margin: 14px 0 8px; }
.mi-label small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.mi-stages { display: flex; gap: 8px; }
.mi-stage { flex: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 12px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: all .12s; }
.mi-stage:hover { border-color: var(--blue); }
.mi-stage.on { background: var(--blue); border-color: var(--blue); color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.mi-sectors { display: flex; flex-wrap: wrap; gap: 6px; max-height: 118px; overflow-y: auto; }
.mi-sector { border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit; color: #374151; }
.mi-sector.on { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
.mi-go { width: 100%; margin-top: 18px; border: none; border-radius: 12px; padding: 13px;
  font-size: 15px; font-weight: 800; cursor: pointer; font-family: inherit;
  background: var(--blue); color: #fff; box-shadow: 0 6px 18px rgba(79,70,229,.35); }
.mi-go:disabled { background: #d6d8e4; color: #8b8fa3; box-shadow: none; cursor: default; }
.mi-all { display: block; margin: 12px auto 0; border: none; background: none;
  color: var(--muted); font-size: 13px; cursor: pointer; font-family: inherit; }
.mi-all:hover { color: var(--blue); }

.fit-toggle { background: var(--glass); backdrop-filter: blur(10px);
  border: 1px solid rgba(15,18,34,.06); box-shadow: var(--shadow-sm);
  border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700;
  color: var(--blue-deep); cursor: pointer; font-family: inherit; margin-right: 8px; }
.fit-toggle:hover { color: var(--blue); }
.fit-toggle.hidden { display: none; }

/* ---------- v14: spotlight halo + mobile layout ---------- */
.halo { fill: none; stroke: rgba(148,141,255,.85); stroke-width: 2.5; pointer-events: none; }

#menu-btn { display: none; }
#menu-backdrop { display: none; }

@media (max-width: 760px) {
  /* sidebar becomes a slide-in filter drawer */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(330px, 88vw);
    z-index: 40; transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: 18px 0 50px rgba(5,8,30,.35);
  }
  body.menu-open #sidebar { transform: none; }
  #menu-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(8,10,28,.45); }
  body:not(.menu-open) #menu-backdrop { display: none; }
  body.menu-open #menu-backdrop { display: block; }

  #menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 12px; border: 1px solid rgba(15,18,34,.06);
    background: var(--glass); backdrop-filter: blur(10px); box-shadow: var(--shadow-sm);
    font-size: 16px; color: var(--ink); cursor: pointer;
  }

  #topbar { left: 10px; right: 10px; top: 10px; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
  .topbar-left { gap: 6px; flex-wrap: wrap; }
  .map-control { display: none; }
  #count-pill { padding: 8px 12px; font-size: 12px; }
  .fit-toggle { padding: 8px 12px; font-size: 12px; margin-right: 0; }
  .view-toggle { padding: 4px; }
  .view-toggle button { padding: 8px 11px; font-size: 12px; gap: 5px; }

  #map-view .group-label { font-size: 10.5px; letter-spacing: .8px; }
  .mi-card { padding: 20px 18px; border-radius: 18px; }
  .mi-card h2 { font-size: 19px; }
  .mi-stage { padding: 10px 6px; font-size: 12.5px; }
  .mi-sectors { max-height: 96px; }
  #map-intro { padding: 70px 12px 16px; align-items: flex-start; }

  #drawer { width: 100vw; max-width: 100vw; padding: 18px; }
  .fact-grid { grid-template-columns: 1fr 1fr; }

  #timeline-view { padding: 104px 12px 32px; }
  .tl-month { flex-direction: column; gap: 8px; padding: 12px 0; }
  .tl-month-label { width: auto; display: flex; gap: 8px; align-items: baseline; padding: 0; }
  .tl-card { max-width: 100%; width: 100%; }
  .tl-head { margin-top: 0; }
  .tl-toolbar { flex-wrap: wrap; gap: 8px; }
  .tl-submit { margin-left: 0; }

  #table-view { padding: 104px 8px 20px; }
  #table-view table { font-size: 12px; min-width: 620px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  #modal { padding: 16px; }
}
@media (max-width: 760px) {
  body:has(#map-intro) .view-toggle, body:has(#map-intro) .fit-toggle { display: none; }
  #map-intro { padding-top: 64px; }
}
@media (max-width: 760px) {
  #map-view { overflow-y: auto; -webkit-overflow-scrolling: touch; }
}
