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

/* ==========================================================================
   DESIGN TOKENS
   --------------------------------------------------------------------------
   ACCENT LOCK: cobalt (--accent) is the ONE accent colour on this site.
   It is the only colour used for emphasis, links, active nav, primary CTAs
   and chart series. Purple / cyan / teal decoration has been removed.

   The --state-* colours below are NOT accents. They encode real inventory
   status (stock safe / approaching reorder point / reorder now) and appear
   only on alert banners and status badges. Never use them for decoration.

   SHAPE LOCK: three radii, applied consistently.
     --radius      12px  cards, panels, plot frames
     --radius-sm    8px  inputs, buttons, badges, small tiles
     --radius-pill  999px  pills and status chips only
   ========================================================================== */

:root {
  /* Surfaces: light, low-chroma greys. Cards sit above the page ground. */
  --bg-primary:    #f6f7f9;   /* page ground */
  --bg-secondary:  #eef1f5;   /* raised surface, table headers, inputs */
  --bg-card:       #ffffff;   /* cards and panels */
  --bg-sidebar:    #ffffff;   /* sidebar */

  /* THE accent */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   rgba(37, 99, 235, 0.08);
  --accent-line:   rgba(37, 99, 235, 0.28);
  --accent-text:   #1d4ed8;   /* darkened so accent text passes contrast on light */

  /* Semantic state only. Not decoration. Dark enough to read on light tints. */
  --state-safe:    #047857;
  --state-warn:    #9a4508;
  --state-danger:  #b91c1c;

  /* Type */
  --text-primary:  #14171c;
  --text-secondary:#4b5563;
  --text-muted:    #646c79;

  --border-color:  #e4e8ee;
  --border-hover:  #c6cdd8;

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-pill:   999px;

  /* Shadows tinted to the surface hue, never pure black (Section 4.4) */
  --shadow:        0 1px 3px rgba(20, 23, 28, 0.06), 0 4px 16px rgba(20, 23, 28, 0.05);
  --shadow-lg:     0 2px 6px rgba(20, 23, 28, 0.07), 0 12px 32px rgba(20, 23, 28, 0.09);
  --transition:    all 0.2s ease;

  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Legacy aliases. Older rules and inline styles still reference these names;
   they all resolve to the locked accent so no stray hues can reappear. */
:root {
  --accent-blue:   var(--accent);
  --accent-cyan:   var(--accent);
  --accent-purple: var(--accent);
  --accent-orange: var(--state-warn);
  --accent-green:  var(--state-safe);
  --accent-danger: var(--state-danger);
}

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

html { 
  scroll-behavior: smooth; 
  font-size: 15px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1400;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; 
  left: 0; 
  bottom: 0;
  z-index: 1500;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 40px; 
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: 1.2rem;
  color: #ffffff;
  flex-shrink: 0;
}

.brand-text { line-height: 1.2; }
.brand-name { 
  font-size: 1rem; 
  font-weight: 700; 
  color: var(--text-primary);
}
.brand-sub { 
  font-size: 0.7rem;  
  color: var(--text-muted); 
}

.sidebar-nav { 
  flex: 1; 
  padding: 1rem 0.75rem; 
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
}

.nav-item { 
  margin-bottom: 0.25rem; 
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
}

.nav-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  font-weight: 600;
  border-left: 3px solid var(--accent-blue);
}

.nav-link .nav-icon { 
  font-size: 1.1rem; 
  width: 20px; 
  text-align: center;
  color: var(--text-muted);
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  color: var(--accent-blue);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.academic-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 600;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  background: var(--bg-primary);
}

.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.top-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-toggle {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
}

.header-title-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.header-actions { 
  display: flex; 
  align-items: center; 
  gap: 1rem; 
}

.page-content {
  flex: 1;
  padding: 1.75rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-accent {
  border-left: 4px solid var(--accent-blue);
}

.card-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-primary { 
  color: var(--accent-blue); 
}

.card-body { 
  padding: 1.25rem; 
}

.bg-card-dark {
  background: var(--bg-secondary) !important;
}

.grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.bg-primary-light { background: rgba(59, 130, 246, 0.15); }
.bg-success-light { background: rgba(16, 185, 129, 0.15); }
.bg-warning-light { background: rgba(249, 115, 22, 0.15); }
.bg-danger-light  { background: rgba(239, 68, 68, 0.15); }
.bg-info-light    { background: rgba(6, 182, 212, 0.15); }

.text-primary { color: var(--accent-blue) !important; }
.text-success { color: var(--accent-green) !important; }
.text-warning { color: var(--accent-orange) !important; }
.text-danger  { color: var(--accent-danger) !important; }
.text-info    { color: var(--accent-cyan) !important; }
.text-accent  { color: var(--accent-purple) !important; }

.stat-details h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.stat-details p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hero-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-tag {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.hero-text h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.hero-text p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.mini-stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mini-stat-card i {
  font-size: 1.4rem;
}

.mini-stat-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.mini-stat-card p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
}

.tech-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem 0.85rem;
  text-align: center;
}

.tech-icon {
  font-size: 1.8rem;
  color: var(--accent-blue);
  margin-bottom: 0.4rem;
}

.tech-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.tech-card p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.step-card {
  flex: 1;
  min-width: 160px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--accent-blue);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  margin: 0 auto 0.5rem;
}

.step-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.step-card p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.step-arrow {
  color: var(--accent-blue);
  font-size: 1.1rem;
}

.styled-list {
  list-style: none;
  padding: 0;
}

.styled-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.styled-list li:last-child { 
  border-bottom: none; 
}

.styled-list li i {
  color: var(--accent-green);
  margin-top: 3px;
  flex-shrink: 0;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table, .info-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.data-table thead th {
  background: var(--bg-secondary);
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.data-table td {
  padding: 0.65rem 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table code {
  font-family: var(--font-mono);
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.info-table th {
  padding: 0.65rem 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  width: 45%;
  border-bottom: 1px solid var(--border-color);
}

.info-table td {
  padding: 0.65rem 0.85rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-primary { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge-warning { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }
.badge-danger  { background: rgba(239, 68, 68, 0.15);  color: var(--accent-danger); }
.badge-info    { background: rgba(6, 182, 212, 0.15);  color: var(--accent-cyan); }
.badge-accent  { background: var(--accent-soft); color: var(--accent-text); }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 180px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  font-family: inherit;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: var(--bg-card);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-block {
  width: 100%;
}

.formula-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0.85rem 0;
  font-size: 1.05rem;
}

.math-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-blue);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 0.85rem 0;
}

.math-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-blue);
  margin-bottom: 0.4rem;
}

.math-formula {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0.4rem 0;
}

.math-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  line-height: 1.5;
}

.derivation-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.derivation-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
}

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert-success { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); color: var(--state-safe); }
.alert-warning { background: rgba(249, 115, 22, 0.1); border-color: rgba(249, 115, 22, 0.3); color: var(--state-warn); }
.alert-danger  { background: rgba(239, 68, 68, 0.1);  border-color: rgba(239, 68, 68, 0.3);  color: var(--state-danger); }
.alert-info    { background: rgba(59, 130, 246, 0.1);  border-color: rgba(59, 130, 246, 0.3);  color: var(--accent-text); }

.img-responsive {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
}

.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.25rem !important; }
.mb-4 { margin-bottom: 1.25rem !important; }
.m-0  { margin: 0 !important; }

@media (max-width: 992px) {
  .sidebar { 
    transform: translateX(-100%); 
  }
  .sidebar.open { 
    transform: translateX(0); 
  }
  .sidebar-overlay.active {
    display: block;
  }
  .main-wrapper { 
    margin-left: 0; 
    width: 100%;
  }
  .mobile-toggle { 
    display: flex; 
  }
  .top-header { 
    padding: 0 1rem; 
  }
  .page-content { 
    padding: 1rem; 
  }
}

@media (max-width: 576px) {
  .grid-2col { 
    grid-template-columns: 1fr; 
  }
  .pipeline-steps { 
    flex-direction: column; 
  }
  .step-arrow { 
    display: none; 
  }
  .step-card { 
    width: 100%; 
  }
}

/* ==========================================================================
   Compatibility layer
   --------------------------------------------------------------------------
   The Differencing / ACF-PACF / ARIMA / Evaluation / Upload / About pages were
   originally written against Bootstrap 5. Rather than loading Bootstrap (which
   would fight this dark theme), the handful of grid and component classes those
   templates rely on are re-implemented here in the project's own design tokens.
   ========================================================================== */

/* --- minimal 12-column grid shim ---------------------------------------- */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -0.5rem;
  margin-right: -0.5rem;
}
.row > [class*="col-"] {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  min-width: 0;
}
.col-md-2  { flex: 0 0 16.6667%; max-width: 16.6667%; }
.col-md-4  { flex: 0 0 33.3333%; max-width: 33.3333%; }
.col-md-6  { flex: 0 0 50%;      max-width: 50%; }
.col-md-8  { flex: 0 0 66.6667%; max-width: 66.6667%; }
.col-lg-5  { flex: 0 0 41.6667%; max-width: 41.6667%; }
.col-lg-7  { flex: 0 0 58.3333%; max-width: 58.3333%; }

.g-1 { row-gap: 0.25rem; }
.g-3 { margin-bottom: -1rem; }
.g-3 > [class*="col-"] { margin-bottom: 1rem; }
.g-4 { margin-bottom: -1.5rem; }
.g-4 > [class*="col-"] { margin-bottom: 1.5rem; }

.h-100 { height: 100%; }
.w-100 { width: 100%; }
.mb-3 { margin-bottom: 1rem; }
.float-end { float: right; }
.align-items-end { align-items: flex-end; }

@media (max-width: 900px) {
  .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
}

/* --- page headings ------------------------------------------------------ */
.page-header { margin-bottom: 1.5rem; }
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}
.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 70ch;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- metric / KPI cards ------------------------------------------------- */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: 100%;
  transition: var(--transition);
}
.metric-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.metric-name {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.metric-formula {
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 0.6rem;
  margin-top: 0.6rem;
  line-height: 1.6;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
}
.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.kpi-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }

/* --- plot containers ---------------------------------------------------- */
.plot-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.plot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.plot-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.plot-container { padding: 1rem; }
.plot-container img, .plot-card img { width: 100%; border-radius: var(--radius-sm); display: block; }

/* --- badges, verdicts, monospace ---------------------------------------- */
.order-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-weight: 600;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.35);
  color: var(--accent-blue);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
}
.mono { font-family: var(--font-mono); font-size: 0.85rem; }
.verdict-stationary,
.verdict-nonstationary {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}
.verdict-stationary {
  background: rgba(16,185,129,0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16,185,129,0.35);
}
.verdict-nonstationary {
  background: rgba(249,115,22,0.15);
  color: var(--accent-orange);
  border: 1px solid rgba(249,115,22,0.35);
}

/* --- form + button aliases ---------------------------------------------- */
.form-label-custom {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-control-custom {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
}
.form-control-custom:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.btn-primary-custom,
.btn-outline-custom,
.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: var(--transition);
}
.btn-primary-custom { background: var(--accent-blue); color: #fff; }
.btn-primary-custom:hover { background: #2563eb; transform: translateY(-1px); }
.btn-outline-custom {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-hover);
}
.btn-outline-custom:hover { color: var(--text-primary); border-color: var(--accent-blue); }
.btn-download {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-color: var(--border-color);
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
}
.btn-download:hover { color: var(--accent-blue); border-color: var(--accent-blue); }

/* --- alerts ------------------------------------------------------------- */
.alert-custom {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  border: 1px solid transparent;
}
.alert-custom.alert-success { background: rgba(16,185,129,0.1);  border-color: rgba(16,185,129,0.3);  color: var(--state-safe); }
.alert-custom.alert-warning { background: rgba(249,115,22,0.1);  border-color: rgba(249,115,22,0.3);  color: var(--state-warn); }
.alert-custom.alert-danger  { background: rgba(239,68,68,0.1);   border-color: rgba(239,68,68,0.3);   color: var(--state-danger); }
.alert-custom.alert-info    { background: rgba(59,130,246,0.1);  border-color: rgba(59,130,246,0.3);  color: var(--accent-text); }

/* --- dark data table ---------------------------------------------------- */
.table-dark-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.table-dark-custom th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table-dark-custom td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}
.table-dark-custom tbody tr:hover { background: rgba(59,130,246,0.05); }

/* --- entry animation ---------------------------------------------------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.fade-in, .fade-in-1, .fade-in-2, .fade-in-3, .fade-in-4 {
  animation: fadeInUp 0.45s ease both;
}
.fade-in-1 { animation-delay: 0.05s; }
.fade-in-2 { animation-delay: 0.10s; }
.fade-in-3 { animation-delay: 0.15s; }
.fade-in-4 { animation-delay: 0.20s; }

@media (prefers-reduced-motion: reduce) {
  .fade-in, .fade-in-1, .fade-in-2, .fade-in-3, .fade-in-4 { animation: none; }
}

/* ==========================================================================
   NARRATIVE PAGES (Home, About, Conclusion)
   --------------------------------------------------------------------------
   These are the presentation surfaces of the project, so they get composed
   layouts rather than the card grid used by the data pages. Every section
   below uses a different layout family on purpose, so the page does not read
   as the same block repeated.

   Motion level is deliberately low: hover and focus transitions only. This is
   a server-rendered Jinja app with no animation runtime, so nothing here
   claims motion it cannot deliver.
   ========================================================================== */

/* --- Hero: asymmetric split ---------------------------------------------- */
.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3.5rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border-color);
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  margin-bottom: 1.25rem;
}

.home-hero-title {
  font-size: clamp(1.9rem, 3.4vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.home-hero-lede {
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 46ch;
  margin-bottom: 1.75rem;
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.home-hero-figure {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow);
}
.home-hero-figure img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
}
.home-hero-figure figcaption {
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 0.7rem 0.4rem 0.2rem;
  line-height: 1.5;
}

.home-hero-fallback {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}
.home-hero-fallback i {
  font-size: 2rem;
  color: var(--accent-text);
  margin-bottom: 0.75rem;
  display: block;
}
.home-hero-fallback p { margin-bottom: 1rem; font-size: 0.9rem; }

/* --- Results strip -------------------------------------------------------- */
.result-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 2.5rem 0;
}
.result-item {
  background: var(--bg-card);
  padding: 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.result-item-accent { background: var(--accent-soft); }
.result-value {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.result-item-accent .result-value { color: var(--accent-text); }
.result-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.result-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* --- Shared section scaffolding ------------------------------------------ */
.section-block { padding: 2.75rem 0; border-bottom: 1px solid var(--border-color); }
.section-block:last-child { border-bottom: 0; }

.section-heading {
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}
.section-lede {
  font-size: 0.93rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 62ch;
  margin-bottom: 1.75rem;
}

/* --- Pipeline flow -------------------------------------------------------- */
.flow {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1.5rem;
  padding: 0;
}
.flow-step {
  background: var(--bg-card);
  padding: 1.35rem 1.15rem;
  transition: var(--transition);
}
.flow-step:hover { background: var(--bg-secondary); }
.flow-step-accent { background: var(--accent-soft); }
.flow-step-accent:hover { background: rgba(37, 99, 235, 0.18); }
.flow-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--bg-primary);
  border: 1px solid var(--border-hover);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
}
.flow-step-accent .flow-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.flow-step h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.flow-step p {
  font-size: 0.79rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* --- Asymmetric split section -------------------------------------------- */
.split-asym {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.8fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.decision-list { display: grid; gap: 1.1rem; }
.decision-list dt {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.decision-list dd {
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0;
  padding-left: 0.9rem;
  border-left: 2px solid var(--border-hover);
}

.formula-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem 0.5rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
}
.formula-card-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.side-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-text);
  text-decoration: none;
  margin-top: 0.5rem;
  transition: var(--transition);
}
.side-link:hover { gap: 0.7rem; color: var(--text-primary); }

/* --- Tech stack row ------------------------------------------------------- */
.stack-row {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 0;
}
.stack-row li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  transition: var(--transition);
}
.stack-row li:hover { border-color: var(--accent-line); }
.stack-row i { font-size: 1.05rem; color: var(--accent-text); margin-bottom: 0.3rem; }
.stack-row span { font-size: 0.86rem; font-weight: 600; color: var(--text-primary); }
.stack-row small { font-size: 0.73rem; color: var(--text-muted); }

/* --- Ghost button (secondary CTA) ---------------------------------------- */
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

/* --- Mobile collapse (explicit, per Section 4.7) -------------------------- */
@media (max-width: 1100px) {
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .home-hero,
  .split-asym { grid-template-columns: 1fr; }
  .home-hero { padding-top: 1rem; gap: 2rem; }
  .home-hero-title { font-size: clamp(1.8rem, 7vw, 2.4rem); }
}
@media (max-width: 560px) {
  .flow,
  .result-strip { grid-template-columns: 1fr; }
  .stack-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-block { padding: 2rem 0; }
}

/* --- Statement block (About / Conclusion openers) ------------------------ */
.statement {
  padding: clamp(1.5rem, 4vw, 3rem) 0 2.25rem;
  border-bottom: 1px solid var(--border-color);
  max-width: 72ch;
}
.statement-title {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 0.9rem;
}
.statement-body {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 62ch;
}

/* --- Findings: numbered vertical list, hairlines between, not cards ------ */
.finding-list {
  list-style: none;
  counter-reset: finding;
  margin-top: 1.5rem;
  padding: 0;
}
.finding-list > li {
  counter-increment: finding;
  position: relative;
  padding: 1.5rem 0 1.5rem 3.4rem;
  border-top: 1px solid var(--border-color);
}
.finding-list > li:last-child { border-bottom: 1px solid var(--border-color); }
.finding-list > li::before {
  content: counter(finding, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-text);
}
.finding-list h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
  letter-spacing: -0.01em;
}
.finding-list p {
  font-size: 0.87rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 70ch;
}

/* --- Two-column reference split ------------------------------------------ */
.limits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}
.limit-list { list-style: none; padding: 0; margin-top: 1.25rem; }
.limit-list li {
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--text-secondary);
  padding: 0.7rem 0 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}
.limit-list li:first-child { border-top: 1px solid var(--border-color); }
.limit-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.35rem;
  width: 4px;
  height: 1px;
  background: var(--border-hover);
}
.limit-list strong { color: var(--text-primary); font-weight: 600; }

/* --- Closing action row --------------------------------------------------- */
.closing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding: 1.5rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}
.closing-row p { font-size: 0.93rem; color: var(--text-secondary); margin: 0; }

/* --- Project-structure panel (About) -------------------------------------- */
.tree-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.tree-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.tree {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.85;
  color: var(--text-secondary);
  white-space: pre;
  overflow-x: auto;
  margin: 0;
}

/* --- Nine-stage pipeline list (About) ------------------------------------- */
.stage-list {
  list-style: none;
  padding: 0;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}
.stage-item {
  background: var(--bg-card);
  padding: 1.15rem 1.15rem 1.25rem;
  display: flex;
  gap: 0.85rem;
  transition: var(--transition);
}
.stage-item:hover { background: var(--bg-secondary); }
.stage-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-text);
  flex-shrink: 0;
  padding-top: 0.1rem;
}
.stage-name {
  display: block;
  font-size: 0.89rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 0.3rem;
  transition: var(--transition);
}
.stage-name:hover { color: var(--accent-text); }
.stage-body p {
  font-size: 0.775rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* --- Mobile collapse ------------------------------------------------------ */
@media (max-width: 1100px) {
  .stage-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .limits { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stage-list { grid-template-columns: 1fr; }
  .finding-list > li { padding-left: 2.6rem; }
  .closing-row { flex-direction: column; align-items: flex-start; }
}
