/* Data Strategy — Briefing Console
   Executive-grade dark theme. Restrained palette. High information density.
*/

:root {
  --bg-0: #0b1014;
  --bg-1: #11181f;
  --bg-2: #182029;
  --bg-3: #1f2832;
  --bg-4: #2a3540;
  --line: #2d3845;
  --line-soft: #1d2731;
  --text-0: #e6edf3;
  --text-1: #b8c4d1;
  --text-2: #8896a6;
  --text-3: #5d6b7a;
  --accent: #6ea8ff;
  --accent-2: #4ea0a0;
  --warn: #d39b3b;
  --good: #5ec27b;
  --bad: #d3585b;

  /* Category colours */
  --cat-strategy: #6ea8ff;
  --cat-architecture: #b58bff;
  --cat-governance: #5ec27b;
  --cat-industry: #d39b3b;
  --cat-leadership: #e98a8a;
  --cat-utilities-specific: #4ec0c0;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 4px 14px rgba(0,0,0,0.35);
  --radius: 6px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-0);
  color: var(--text-0);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#root { min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

/* ───── App shell ───── */

.app-header {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-0);
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav button {
  padding: 8px 14px;
  color: var(--text-2);
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: var(--bg-3); color: var(--text-0); }
.nav button.active {
  background: var(--bg-4);
  color: var(--text-0);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ───── Page headers ───── */
.page-header {
  padding: 22px 28px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.page-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.page-sub { font-size: 13px; color: var(--text-2); margin: 0; max-width: 720px; }

/* ───── Common: badges, chips ───── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--line);
}
.badge.foundational { color: #9bc5ff; border-color: #2a4060; }
.badge.intermediate { color: #d39b3b; border-color: #4a3a1f; }
.badge.advanced { color: #e98a8a; border-color: #4f2828; }

.util-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.util-dot.low { background: #4a5562; }
.util-dot.medium { background: #d39b3b; }
.util-dot.high { background: #5ec27b; }

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-1);
  text-transform: uppercase;
}
.cat-tag::before {
  content: '';
  width: 9px; height: 9px;
  border-radius: 2px;
  background: var(--cat-strategy);
}
.cat-tag.strategy::before { background: var(--cat-strategy); }
.cat-tag.architecture::before { background: var(--cat-architecture); }
.cat-tag.governance::before { background: var(--cat-governance); }
.cat-tag.industry::before { background: var(--cat-industry); }
.cat-tag.leadership::before { background: var(--cat-leadership); }
.cat-tag.utilities-specific::before { background: var(--cat-utilities-specific); }

/* ───── Learning Hub ───── */

.hub-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.hub-search {
  flex: 1;
  min-width: 240px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-0);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.hub-search:focus { outline: none; border-color: var(--accent); }

.filter-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-2);
}
.filter-chip.active { background: var(--bg-4); color: var(--text-0); border-color: var(--accent); }
.filter-chip:hover { color: var(--text-0); }

.progress-pill {
  font-size: 11px;
  color: var(--text-2);
  background: var(--bg-2);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.hub-body {
  padding: 18px 28px 60px;
}
.cat-section { margin-bottom: 28px; }
.cat-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cat-section h2 .count {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0;
  text-transform: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.topic-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.topic-card:hover { border-color: var(--accent); background: var(--bg-3); }
.topic-card.viewed::after {
  content: '✓';
  position: absolute;
  top: 10px; right: 12px;
  color: var(--good);
  font-size: 12px;
}
.topic-card h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-0); padding-right: 18px; }
.topic-card p { margin: 0; font-size: 12.5px; color: var(--text-1); }
.topic-card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ───── Detail panel ───── */
.detail-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 11, 0.6);
  backdrop-filter: blur(2px);
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}
.detail-panel {
  width: min(720px, 100%);
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  position: sticky;
  top: 0;
  background: var(--bg-1);
  z-index: 1;
}
.detail-head h2 { margin: 0 0 8px; font-size: 18px; }
.detail-head .meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.close-btn {
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
}
.close-btn:hover { background: var(--bg-3); color: var(--text-0); }
.detail-body { padding: 18px 24px 40px; }
.detail-body h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin: 22px 0 8px;
}
.detail-body p, .detail-body li { color: var(--text-1); }
.detail-body .markdown h1,
.detail-body .markdown h2,
.detail-body .markdown h3,
.detail-body .markdown h4 {
  color: var(--text-0);
  font-weight: 600;
  margin-top: 18px;
  margin-bottom: 6px;
  letter-spacing: 0;
  text-transform: none;
}
.detail-body .markdown h2 { font-size: 15px; }
.detail-body .markdown h3 { font-size: 13px; }
.detail-body .markdown p { font-size: 13.5px; line-height: 1.65; }
.detail-body .markdown ul { padding-left: 20px; }
.detail-body .markdown li { font-size: 13.5px; line-height: 1.6; margin-bottom: 4px; }
.detail-body .markdown code {
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: #c8d4e1;
}
.detail-body .markdown strong { color: var(--text-0); }

.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.related-pill {
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-1);
  cursor: pointer;
}
.related-pill:hover { border-color: var(--accent); color: var(--text-0); }

/* ───── Knowledge Map ───── */
.map-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-toolbar {
  padding: 12px 28px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.map-svg-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(110,168,255,0.04), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(78,160,160,0.04), transparent 50%),
    var(--bg-0);
}
.map-svg-wrap svg { display: block; width: 100%; height: 100%; }
.map-svg-wrap svg .node { cursor: pointer; }
.map-svg-wrap svg .node circle { transition: r 0.15s, stroke-width 0.15s; }
.map-svg-wrap svg .node:hover circle { stroke-width: 3; }
.map-svg-wrap svg .node.selected circle { stroke: #fff; stroke-width: 3; }
.map-svg-wrap svg .node text {
  fill: var(--text-1);
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
  text-anchor: middle;
}
.map-svg-wrap svg .node text.node-label-full {
  fill: var(--text-0);
  font-size: 13px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.85);
  stroke-width: 4px;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.map-svg-wrap svg .edge {
  stroke: var(--line);
  stroke-width: 1;
  fill: none;
}
.map-svg-wrap svg .edge.highlight { stroke: var(--accent); stroke-width: 2; }
.map-svg-wrap svg .edge-label {
  fill: var(--text-3);
  font-size: 9px;
  pointer-events: none;
}
.map-svg-wrap svg .node.dim { opacity: 0.18; }
.map-svg-wrap svg .edge.dim { opacity: 0.08; }

.map-zoom-controls {
  position: absolute;
  top: 14px; right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
}
.map-zoom-controls button {
  width: 30px; height: 30px;
  color: var(--text-1);
  border-radius: 4px;
}
.map-zoom-controls button:hover { background: var(--bg-3); color: var(--text-0); }

.map-side-panel {
  position: absolute;
  top: 14px; bottom: 14px; right: 60px;
  width: 360px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.map-side-panel header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.map-side-panel header h3 { margin: 0 0 6px; font-size: 15px; }
.map-side-panel .body { padding: 14px 16px; overflow-y: auto; }
.map-side-panel .body p { font-size: 12.5px; color: var(--text-1); margin: 0 0 12px; }
.map-side-panel .body h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin: 14px 0 6px;
}
.map-side-panel .body ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-1); }

/* Legend */
.map-legend {
  position: absolute;
  bottom: 14px; left: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-legend .leg-row { display: flex; align-items: center; gap: 6px; }
.map-legend .leg-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ───── Scenario Explorer ───── */
.sc-list {
  padding: 18px 28px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.sc-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.sc-card:hover { border-color: var(--accent); background: var(--bg-3); }
.sc-card h3 { margin: 0 0 6px; font-size: 15px; }
.sc-card p { margin: 0; font-size: 13px; color: var(--text-1); }

.sc-run {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px;
}
.sc-run h2 { font-size: 20px; margin: 0 0 8px; }
.sc-run .situation {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-1);
  border-radius: 4px;
  margin: 14px 0 22px;
  line-height: 1.65;
}

.branch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.branch-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-0);
  transition: border-color 0.15s, background 0.15s;
}
.branch-btn:hover { border-color: var(--accent); background: var(--bg-3); }
.branch-btn.selected { border-color: var(--accent); background: var(--bg-3); }

.sc-outcome {
  margin-top: 22px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.sc-outcome h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin: 0 0 6px;
}
.sc-outcome .commentary {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--text-1);
  line-height: 1.65;
}

.sc-actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
}
.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--line);
  font-size: 13px;
}
.btn:hover { background: var(--bg-4); color: var(--text-0); }
.btn.primary { background: var(--accent); color: #0b1014; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #8db9ff; color: #0b1014; }

/* ───── Pattern Library ───── */
.pl-toolbar {
  padding: 14px 28px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.pl-grid {
  padding: 18px 28px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}
.pattern-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pattern-card h3 { margin: 0; font-size: 15px; }
.pattern-card .tagline { font-size: 12.5px; color: var(--text-2); margin: 0; }
.pattern-card .diagram {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 12px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pattern-card .util-fit {
  font-size: 12.5px;
  background: linear-gradient(180deg, rgba(94,194,123,0.08), rgba(94,194,123,0.02));
  border: 1px solid rgba(94,194,123,0.25);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-1);
}
.pattern-card .util-fit strong { color: var(--good); }
.pattern-card .pat-row {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}

.pattern-card details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
  list-style: none;
}
.pattern-card details summary::-webkit-details-marker { display: none; }
.pattern-card details summary::before { content: '▸ '; }
.pattern-card details[open] summary::before { content: '▾ '; }
.pattern-card details p, .pattern-card details ul { font-size: 13px; color: var(--text-1); }
.pattern-card details ul { padding-left: 18px; }

.compare-toggle {
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-1);
}
.compare-toggle.active { background: var(--accent); color: #0b1014; border-color: var(--accent); }

.pattern-card.compare-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.compare-view {
  padding: 20px 28px 60px;
}
.compare-grid {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.compare-grid > div {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--text-1);
}
.compare-grid > .lbl {
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  border-right: 1px solid var(--line-soft);
}
.compare-grid > .head {
  background: var(--bg-3);
  color: var(--text-0);
  font-size: 14px;
  font-weight: 600;
}

/* Diagram SVG styles */
.diag-box {
  fill: var(--bg-3);
  stroke: var(--line);
  stroke-width: 1;
  rx: 4;
}
.diag-box.accent { fill: #1d2a3a; stroke: var(--accent); }
.diag-box.warm { fill: #2a2218; stroke: var(--warn); }
.diag-box.good { fill: #1c2a22; stroke: var(--good); }
.diag-text { fill: var(--text-0); font-size: 10px; text-anchor: middle; font-family: 'Inter', sans-serif; }
.diag-text.small { font-size: 9px; fill: var(--text-2); }
.diag-arrow { stroke: var(--text-2); stroke-width: 1.5; fill: none; marker-end: url(#arrow); }

/* Utility */
.row { display: flex; gap: 8px; align-items: center; }
.gap-12 { gap: 12px; }
.muted { color: var(--text-3); font-size: 12px; }
.empty {
  padding: 60px 28px;
  text-align: center;
  color: var(--text-3);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line); }

@media (max-width: 760px) {
  .app-header { flex-direction: column; align-items: flex-start; padding: 12px 16px; }
  .page-header, .hub-toolbar, .hub-body, .sc-list, .pl-grid, .pl-toolbar, .map-toolbar { padding-left: 16px; padding-right: 16px; }
  .map-side-panel { right: 14px; width: auto; left: 14px; }
}

/* Sources panel in TopicDetail */
.sources-list { list-style: none; padding: 0; margin: 8px 0 16px 0; }
.sources-list li { padding: 10px 12px; border: 1px solid var(--surface-3); border-radius: 6px; margin-bottom: 8px; background: var(--surface-2); }
.sources-list .src-quote { margin-top: 6px; font-style: italic; color: var(--text-2); border-left: 2px solid var(--accent-1); padding-left: 10px; font-size: 13px; line-height: 1.5; }

.sc-role {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent, #2266cc);
  background: rgba(34, 102, 204, 0.08);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.pl-group { margin-bottom: 36px; }
.pl-group-header { margin: 10px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.pl-group-header h2 { margin: 0 0 4px; font-size: 18px; }
.pl-group-header .muted { margin: 0; font-size: 13px; }
