@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --navy: #0f2b46;
  --navy-light: #1a3d5c;
  --blue: #2563eb;
  --blue-light: #3b82f6;
  --green: #059669;
  --green-light: #10b981;
  --amber: #d97706;
  --purple: #7c3aed;
  --cyan: #0891b2;
  --slate: #64748b;
  --slate-light: #94a3b8;
  --bg: #f0f4f8;
  --white: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(15, 43, 70, 0.08);
  --shadow-lg: 0 8px 40px rgba(15, 43, 70, 0.14);
  --radius: 20px;
  --nav-h: 64px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── NAV ─── */
.nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 12px rgba(15, 43, 70, 0.06);
}
.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.nav-logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
  letter-spacing: -1px; font-style: italic;
}
.nav-logo-text { font-size: 15px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }
.nav-logo-sub { font-size: 10px; font-weight: 500; color: var(--slate); display: block; line-height: 1; margin-top: 1px; }

.nav-actions { display: flex; align-items: center; gap: 6px; }
.nav-actions a {
  text-decoration: none; font-size: 13px; font-weight: 600;
  color: var(--slate); padding: 8px 14px;
  border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-actions a:hover { background: #f1f5f9; color: var(--navy); }
.nav-actions a.primary {
  background: var(--navy); color: #fff;
}
.nav-actions a.primary:hover { background: var(--navy-light); color: #fff; }

/* ─── HERO ─── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 40%, #1e4a7a 70%, #0e3a63 100%);
  padding: 64px 24px 80px;
  position: relative;
  overflow: hidden;
  color: white;
  text-align: center;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 50%, rgba(37, 99, 235, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 30%, rgba(124, 58, 237, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 90%, rgba(5, 150, 105, 0.08) 0%, transparent 60%);
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle 1.5px at 10% 20%, rgba(255, 255, 255, 0.15) 0%, transparent 100%),
    radial-gradient(circle 1px at 90% 15%, rgba(255, 255, 255, 0.1) 0%, transparent 100%),
    radial-gradient(circle 2px at 30% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 100%),
    radial-gradient(circle 1px at 70% 70%, rgba(255, 255, 255, 0.12) 0%, transparent 100%);
  pointer-events: none;
}
.hero-content { max-width: 900px; margin: 0 auto; position: relative; z-index: 1; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 100px;
  padding: 7px 18px;
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,0.85);
  letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 24px;
}
.hero-badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green-light);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.hero h1 {
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 900;
  color: #fff;
  line-height: 1.08;
  letter-spacing: -1.5px;
  margin-bottom: 14px;
}
.hero p {
  font-size: clamp(14px, 2.2vw, 18px);
  color: rgba(255,255,255,0.75);
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.7;
  font-weight: 500;
}

/* ─── SECTION ─── */
.section {
  max-width: 1400px;
  margin: -40px auto 40px;
  padding: 0 24px;
  position: relative;
  z-index: 2;
}
.card {
  background: white;
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.card + .card { margin-top: 24px; }
.card h2 {
  color: var(--navy);
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}
.card-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: 8px;
}

/* ─── MERMAID (large, readable, but capped) ─── */
.mermaid-wrap {
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
  border-radius: 14px;
  padding: 28px 16px;
  border: 1px solid var(--border);
  overflow-x: auto;
}
/* Default cap: most diagrams should not exceed ~900px wide */
.mermaid {
  text-align: center;
  min-height: 240px;
  max-width: 900px;
  margin: 0 auto;
}
.mermaid svg {
  max-width: 100% !important;
  height: auto !important;
  font-family: 'Inter', sans-serif !important;
}
/* Wider cap for architecture / gantt / sequence that need horizontal room */
.mermaid-wrap.wide .mermaid { max-width: 1100px; }
/* Tighter cap for quadrant / sankey / xychart that explode visually */
.mermaid-wrap.narrow .mermaid { max-width: 760px; }
.mermaid text,
.mermaid .nodeLabel,
.mermaid .edgeLabel,
.mermaid .taskText,
.mermaid .titleText,
.mermaid .quadrantTitle,
.mermaid .quadrant-point-text {
  font-family: 'Inter', sans-serif !important;
}

/* ─── TABLES ─── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 20px;
}
.tbl th, .tbl td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.tbl th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--navy);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.tbl tr:hover td { background: #fafbfc; }
.tbl tr.highlight { background: #f0f9ff; font-weight: 600; }

/* ─── PHASE TAGS ─── */
.phase-p1, .ph1 { color: var(--green); font-weight: 700; }
.phase-p2, .ph2 { color: var(--blue); font-weight: 700; }
.phase-p3, .ph3 { color: var(--purple); font-weight: 700; }

.phase-header {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}
.phase-header.p1 { color: var(--green); border-color: var(--green); }
.phase-header.p2 { color: var(--blue); border-color: var(--blue); }
.phase-header.p3 { color: var(--purple); border-color: var(--purple); }

/* ─── BADGES ─── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-high { background: #fee2e2; color: #991b1b; }
.badge-mid { background: #fef3c7; color: #92400e; }
.badge-low { background: #d1fae5; color: #065f46; }

/* ─── STAT GRID ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.stat-box {
  background: #f0f9ff;
  border-left: 4px solid var(--blue);
  padding: 18px 20px;
  border-radius: 10px;
}
.stat-box-label {
  font-size: 11px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.stat-box-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--navy);
  margin-top: 4px;
  letter-spacing: -0.3px;
}

/* ─── NOTES ─── */
.note {
  padding: 16px 20px;
  border-radius: 12px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.7;
  border-left: 4px solid;
}
.note-info { background: #f0f9ff; border-color: var(--blue); color: #1e3a8a; }
.note-warn { background: #fef3c7; border-color: var(--amber); color: #92400e; }
.note-ok { background: #d1fae5; border-color: var(--green); color: #064e3b; }

/* ─── LIST ─── */
.bullet-list {
  list-style: none;
  padding: 0;
  margin-top: 20px;
  display: grid;
  gap: 10px;
}
.bullet-list li {
  background: #f8fafc;
  border-left: 3px solid var(--blue);
  padding: 13px 18px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
}
.bullet-list li b { color: var(--navy); }
.bullet-list.green li { border-color: var(--green); }
.bullet-list.amber li { border-color: var(--amber); }

/* ─── RELATED DIAGRAMS NAV ─── */
.related-nav {
  background: white;
  padding: 28px;
  border-radius: var(--radius);
  margin-top: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.related-nav-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--slate);
  font-weight: 700;
  margin-bottom: 14px;
}
.related-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.related-nav-grid a {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}
.related-nav-grid a:hover {
  border-color: var(--blue);
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}
.related-nav-grid a.current {
  background: var(--navy); color: white; border-color: var(--navy);
  pointer-events: none;
}
.related-nav-grid a .ico { font-size: 16px; }

/* ─── FOOTER ─── */
.footer {
  background: var(--navy);
  color: rgba(255,255,255,0.7);
  padding: 32px 24px;
  text-align: center;
  margin-top: 60px;
}
.footer-logo {
  font-size: 18px; font-weight: 800; color: #fff;
  letter-spacing: -0.5px;
}
.footer-tagline {
  font-size: 13px; margin: 6px 0 14px;
}
.footer-meta {
  font-size: 12px;
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  align-items: center;
}
.footer-meta a { color: rgba(255,255,255,0.85); text-decoration: none; }
.footer-meta a:hover { color: white; text-decoration: underline; }
.footer-divider { opacity: 0.4; }
.footer-meta strong { color: rgba(255,255,255,0.95); }

/* ─── BACK TO TOP ─── */
.back-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(15, 43, 70, 0.3);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
}
.back-top.visible { opacity: 1; pointer-events: auto; }
.back-top:hover { transform: translateY(-2px); }

/* ─── PHASE COLUMNS (HTML alternative to wide mermaid) ─── */
.phase-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 4px;
}
.phase-col {
  background: white;
  border: 2px solid;
  border-radius: 14px;
  padding: 20px;
  position: relative;
}
.phase-col.p1 { border-color: var(--green); background: #ecfdf5; }
.phase-col.p2 { border-color: var(--blue); background: #eff6ff; }
.phase-col.p3 { border-color: var(--purple); background: #fdf4ff; }
.phase-col-head {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.2px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed currentColor;
  display: flex; align-items: center; gap: 8px;
}
.phase-col.p1 .phase-col-head { color: var(--green); }
.phase-col.p2 .phase-col-head { color: var(--blue); }
.phase-col.p3 .phase-col-head { color: var(--purple); }
.phase-col ul {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 6px;
}
.phase-col li {
  background: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--navy);
  font-weight: 500;
  border: 1px solid rgba(15, 43, 70, 0.08);
}
.phase-trigger {
  text-align: center;
  margin: 18px 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.phase-trigger::before, .phase-trigger::after {
  content: ''; flex: 1; height: 1px; background: var(--border); max-width: 80px;
}

/* ─── FUNNEL CASCADE (HTML alternative for market funnel) ─── */
.funnel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 16px 0;
}
.funnel-step {
  width: 100%;
  max-width: 520px;
  border-radius: 14px;
  padding: 16px 20px;
  text-align: center;
  border: 2px solid;
  margin-bottom: 0;
}
.funnel-step + .funnel-arrow {
  font-size: 20px;
  color: var(--slate);
  margin: 8px 0;
}
.funnel-step.l1 { max-width: 600px; background: #dbeafe; border-color: #1e40af; color: #1e3a8a; }
.funnel-step.l2 { max-width: 540px; background: #bfdbfe; border-color: #1e40af; color: #1e3a8a; }
.funnel-step.l3 { max-width: 480px; background: #d1fae5; border-color: var(--green); color: #064e3b; }
.funnel-step.l4 { max-width: 440px; background: #93c5fd; border-color: var(--blue); color: #1e3a8a; }
.funnel-step.l5 { max-width: 400px; background: #c4b5fd; border-color: var(--purple); color: #1e1b4b; }
.funnel-step b { font-size: 15px; display: block; margin-bottom: 4px; }
.funnel-step span { font-size: 13px; opacity: 0.85; }

/* ─── ZOOM BUTTON ─── */
.card { position: relative; }
.zoom-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px; height: 38px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  z-index: 5;
  color: var(--slate);
  transition: all 0.15s;
  padding: 0;
}
.zoom-btn:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(15, 43, 70, 0.18);
}
.zoom-btn svg { width: 18px; height: 18px; }

/* ─── ZOOM MODAL ─── */
.diagram-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 43, 70, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: dmFade 0.18s ease-out;
}
.diagram-modal.open { display: flex; }
@keyframes dmFade { from { opacity: 0; } to { opacity: 1; } }

.dm-stage {
  background: white;
  border-radius: 18px;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.dm-canvas {
  width: 100%;
  height: 100%;
  overflow: auto;
  cursor: grab;
  padding: 32px;
  background:
    linear-gradient(rgba(15,43,70,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,43,70,0.04) 1px, transparent 1px);
  background-size: 20px 20px;
}
.dm-canvas.dragging { cursor: grabbing; }
.dm-canvas > * {
  display: inline-block;
  transform-origin: top left;
  user-select: none;
  -webkit-user-select: none;
  vertical-align: top;
}
.dm-canvas .mermaid svg,
.dm-canvas .funnel,
.dm-canvas .phase-cols {
  max-width: none !important;
}

.dm-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  background: white;
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 10;
  align-items: center;
}
.dm-toolbar button {
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--slate);
  font-family: inherit;
  display: inline-flex; align-items: center; gap: 4px;
  transition: background 0.15s, color 0.15s;
}
.dm-toolbar button:hover {
  background: #f1f5f9;
  color: var(--navy);
}
.dm-toolbar button.danger:hover {
  background: #fee2e2;
  color: #991b1b;
}
.dm-level {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  min-width: 56px;
  text-align: center;
  padding: 0 8px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.dm-title {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 43, 70, 0.9);
  color: white;
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
  letter-spacing: 0.5px;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.diagram-modal.hint-fade .dm-title { opacity: 0; }
.dm-title kbd {
  background: rgba(255,255,255,0.18);
  padding: 1px 6px;
  border-radius: 4px;
  margin: 0 2px;
  font-family: inherit;
  font-size: 11px;
}

@media (max-width: 768px) {
  .diagram-modal { padding: 12px; }
  .dm-canvas { padding: 16px; }
  .dm-toolbar { padding: 2px; top: 8px; gap: 2px; }
  .dm-toolbar button { padding: 6px 8px; font-size: 13px; }
  .zoom-btn { top: 10px; right: 10px; width: 34px; height: 34px; }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .hero { padding: 48px 18px 64px; }
  .card { padding: 24px 18px; }
  .nav-inner { padding: 0 16px; gap: 8px; }
  .nav-actions a { padding: 6px 10px; font-size: 12px; }
  .nav-logo-sub { display: none; }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .related-nav-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
