/* ── CSS Variables ── */
:root {
  --bg:       #0a0c10;
  --surface:  #111520;
  --surface2: #161b2a;
  --border:   #1e2740;
  --accent:   #00e5a0;
  --accent2:  #3b7aff;
  --warn:     #f59e0b;
  --text:     #c9d1e0;
  --muted:    #4a5568;
  --white:    #eef2ff;
  --radius:   12px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: clip;
}

/* ── Noise texture overlay ── */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Grid background ── */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ══════════════════════════════
   HEADER
══════════════════════════════ */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,12,16,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  color: var(--bg);
  box-shadow: 0 0 16px rgba(0,229,160,0.4);
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.5px;
}

.logo-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
}

.header-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ══════════════════════════════
   HERO
══════════════════════════════ */
.hero {
  padding: 80px 24px 60px;
  text-align: center;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 300px;
  background: radial-gradient(ellipse, rgba(0,229,160,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  border: 1px solid rgba(0,229,160,0.3);
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 24px;
  background: rgba(0,229,160,0.05);
  animation: fadeDown 0.6s ease both;
}

.hero-label::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: blink 1.4s ease infinite;
}

@keyframes blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

.hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(42px, 7vw, 80px);
  font-weight: 800;
  color: var(--white);
  line-height: 1;
  letter-spacing: -2px;
  animation: fadeUp 0.7s ease both 0.1s;
}

.hero h1 .hl {
  color: var(--accent);
  text-shadow: 0 0 40px rgba(0,229,160,0.4);
}

.hero p {
  margin-top: 20px;
  font-size: 16px;
  color: var(--text);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
  font-weight: 300;
  animation: fadeUp 0.7s ease both 0.2s;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════
   SECTION / CARD
══════════════════════════════ */
main { padding: 0 0 40px; }

.section {
  padding: 0 24px;
  margin-bottom: 32px;
}

.spacer { height: 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 20px 28px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header-line {
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
}

.card-body {
  padding: 24px 28px 28px;
}

/* ══════════════════════════════
   OVERVIEW
══════════════════════════════ */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 640px) {
  .overview-grid { grid-template-columns: 1fr; }
}

.overview-text p {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 12px;
}

.overview-text p strong {
  color: var(--white);
  font-weight: 500;
}

.analogy-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 18px;
  margin-top: 4px;
}

.analogy-box .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.analogy-box p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}

.observe-list {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.observe-list .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.observe-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}

.observe-item:last-child { margin-bottom: 0; }

.observe-item .dot {
  width: 5px; height: 5px;
  background: var(--accent2);
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

/* ══════════════════════════════
   CONTROLS / BUTTONS
══════════════════════════════ */
.controls-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 24px rgba(0,229,160,0.25), 0 4px 12px rgba(0,0,0,0.4);
}

.btn-primary:hover {
  background: #00ffc3;
  box-shadow: 0 0 36px rgba(0,229,160,0.45), 0 6px 20px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,229,160,0.05);
}

/* ══════════════════════════════
   LEGEND
══════════════════════════════ */
.hidden { display: none !important; }

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 700px) {
  .legend-grid { grid-template-columns: 1fr; }
}

.legend-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.legend-card h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.legend-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.legend-row:last-child { margin-bottom: 0; }

.legend-key {
  font-family: 'JetBrains Mono', monospace;
  color: var(--white);
  font-size: 12px;
  min-width: 80px;
  flex-shrink: 0;
}

.legend-val { color: var(--text); line-height: 1.5; }

.steps-list { counter-reset: step; }

.step-item {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
  align-items: flex-start;
}

.step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent2);
  background: rgba(59,122,255,0.12);
  border: 1px solid rgba(59,122,255,0.25);
  border-radius: 4px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.decision-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid;
}

.chip-green { color: var(--accent);  border-color: rgba(0,229,160,0.3);  background: rgba(0,229,160,0.06); }
.chip-blue  { color: var(--accent2); border-color: rgba(59,122,255,0.3); background: rgba(59,122,255,0.06); }
.chip-warn  { color: var(--warn);    border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.06); }
.chip-gray  { color: var(--muted);   border-color: var(--border);        background: transparent; }

/* ══════════════════════════════
   RESULTS PLACEHOLDER
══════════════════════════════ */
.results-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 80px 24px;
  text-align: center;
}

.results-placeholder .icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.results-placeholder h2 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  color: var(--white);
  margin-bottom: 8px;
}

.results-placeholder p {
  font-size: 14px;
  color: var(--muted);
  max-width: 340px;
  margin: 0 auto;
  line-height: 1.6;
}

.results-placeholder p b { color: var(--accent); font-weight: 500; }

.cursor::after {
  content: '_';
  animation: blink 1.2s step-start infinite;
  color: var(--accent);
}

/* ══════════════════════════════
   FOOTER
══════════════════════════════ */
footer {
  margin-top: 60px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--muted);
}

.footer-name span { color: var(--accent); font-weight: 700; }

.footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-links a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-links a:hover { color: var(--accent); }
.divider { color: var(--border); }


/* ══════════════════════════════
   RENDERER STYLES
   Used by: summaryRenderer.js
            ganttRenderer.js
            tableRenderer.js
══════════════════════════════ */

/* ── Shared renderer card ── */
.r-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.r-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.r-card-line {
  width: 3px; height: 18px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.r-card-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.r-card-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

.r-card-body {
  padding: 24px;
}

/* ── Summary ── */
.r-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.r-summary::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 400px; height: 200px;
  background: radial-gradient(ellipse, rgba(0,229,160,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.r-summary-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.r-summary-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 32px;
}

.r-summary-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
}

.r-stat-card { flex: 1; min-width: 160px; padding: 0 24px; }

.r-stat-divider {
  width: 1px;
  height: 60px;
  background: var(--border);
  flex-shrink: 0;
}

.r-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
  text-shadow: 0 0 30px rgba(0,229,160,0.35);
}

.r-stat-value.accent2 {
  color: var(--accent2);
  text-shadow: 0 0 30px rgba(59,122,255,0.35);
}

.r-stat-label {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.r-stat-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

/* ─────────────────────────────
   GANTT CHART (Responsive + Scrollable)
───────────────────────────── */

/* Scroll wrapper (wrap .g-chart + .g-axis inside this) */
.g-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px; /* space for scrollbar */
}

/* Optional custom scrollbar (matches table style) */
.g-scroll::-webkit-scrollbar {
  height: 6px;
}

.g-scroll::-webkit-scrollbar-track {
  background: var(--surface);
}

.g-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Chart row */
.g-chart {
  display: flex;
  height: 52px;
  min-width: 700px; /* prevents timeline compression */
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface2);
}

/* Individual block */
.g-block {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(0,0,0,0.2);
  transition: filter 0.15s ease;
  cursor: default;
  min-width: 2px;
  position: relative;
}

.g-block:hover {
  filter: brightness(1.15);
}

.g-block:last-child {
  border-right: none;
}

/* Block label */
.g-block-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(9px, 1vw, 11px);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  pointer-events: none;
}

/* Time axis */
.g-axis {
  position: relative;
  height: 24px;
  min-width: 700px; /* must match .g-chart */
  margin-top: 6px;
}

/* Tick marks */
.g-tick {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(9px, 1vw, 10px);
  color: var(--muted);
  transform: translateX(-50%);
  top: 4px;
  white-space: nowrap;
}

/* ── Process Table ── */
.t-scroll {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.t-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.t-scroll::-webkit-scrollbar-track { background: var(--surface); }
.t-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.t-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.t-th {
  background: var(--surface2);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  transition: color 0.15s;
  user-select: none;
}

.t-th:hover { color: var(--accent); }

.t-sort-icon { opacity: 0.4; font-size: 10px; }
.t-th:hover .t-sort-icon { opacity: 1; }

.t-row { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.t-row:hover { background: var(--surface2); }
.t-row-alt { background: rgba(255,255,255,0.015); }

.t-td {
  padding: 10px 16px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.t-pid { color: var(--white); font-weight: 700; }
.t-tat { color: var(--warn); }
.t-wt  { color: var(--accent); }

/* =====================================================
   RESPONSIVE SYSTEM
===================================================== */


/* ---------- GLOBAL SCALING ---------- */

html {
  font-size: clamp(14px, 0.9vw, 16px);
  width: 100%;
  overflow-x: clip;
}

img,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

/* Prevent horizontal overflow */
.wrap,
.header-inner,
.footer-inner {
  width: 100%;
  padding-inline: clamp(16px, 4vw, 24px);
}

/* Tables scroll instead of breaking layout */
.t-table {
  min-width: 600px;
}


/* =====================================================
   TABLET
===================================================== */
@media (max-width: 1024px) {

  .hero {
    padding: 60px 20px 40px;
  }

  .r-summary-stats {
    flex-wrap: wrap;
  }

  .r-stat-card {
    min-width: 140px;
  }

}


/* =====================================================
   LARGE PHONES
===================================================== */
@media (max-width: 768px) {

  /* HEADER */
  .header-inner {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .header-tag {
    display: none;
  }

  /* HERO */
  .hero {
    padding: 48px 16px;
  }

  .hero h1 {
    line-height: 1.1;
  }

  /* CARD SPACING */
  .card-body {
    padding: 20px;
  }

  /* SUMMARY STATS STACK */
  .r-summary-stats {
    flex-direction: column;
    gap: 24px;
  }

  .r-stat-divider {
    display: none;
  }

  /* LEGEND GRID */
  .legend-grid {
    grid-template-columns: 1fr;
  }

  /* FOOTER */
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  /* BUTTON STACK */
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

}


/* =====================================================
   SMALL PHONES
===================================================== */
@media (max-width: 480px) {

  .logo-text {
    font-size: 16px;
  }

  .hero h1 {
    font-size: clamp(32px, 9vw, 42px);
  }

  .hero p {
    font-size: 14px;
  }

  .section {
    padding: 0 16px;
  }

}

/* ===== MOBILE OVERFLOW FINAL FIX ===== */

.wrap,
.header-inner,
.footer-inner,
.section {
  max-width: 100%;
}