:root {
  --bg: #f0f0f5;
  --fg: #1a1a2e;
  --surface: #ffffff;
  --border: #d1d5db;
  --primary: #dc2626;
  --accent: #0e6680;
  --accent-glow: rgba(34, 211, 238, 0.2);
  --text: #1a1a2e;
  --text2: #4a5568;
  --text3: #566274;
  --surface-base: #f0f0f5;
  --surface-raised: #ffffff;
  --surface-overlay: #f5f5f5;
  --shadow-subtle: 0 1px 2px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.05);
  --shadow-medium: 0 4px 12px rgba(0,0,0,0.15);
  --font-display: 'Segoe UI', Arial, sans-serif;
  --font-mono: 'Cascadia Mono', Consolas, monospace;
  --transition: 200ms ease-out;
}

.dark-mode {
  --bg: #0a0a0a;
  --fg: #e0e0e0;
  --surface: #141414;
  --border: #2a2a2a;
  --primary: #dc2626;
  --accent: #22d3ee;
  --accent-glow: rgba(34, 211, 238, 0.15);
  --text: #e8eaf6;
  --text2: #b3bdd3;
  --text3: #94a3b8;
  --surface-base: #0a0a0a;
  --surface-raised: #141414;
  --surface-overlay: #1e1e1e;
  --shadow-subtle: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-medium: 0 4px 12px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
}

.dark-mode .status-operational,
.dark-mode .status-near-completion,
.dark-mode .cat-fiber,
.dark-mode .compat-excellent,
.dark-mode .badge-commercial,
.dark-mode .source-verified { color: #34d399; }
.dark-mode .status-construction,
.dark-mode .cat-fuel,
.dark-mode .badge-construction,
.dark-mode .source-plausible { color: #fbbf24; }
.dark-mode .status-commissioning,
.dark-mode .cat-polymer { color: #c4b5fd; }
.dark-mode .cat-rubber { color: #fb923c; }
.dark-mode .cat-other,
.dark-mode .cat-balance { color: #cbd5e1; }

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

.skip-link {
  position: fixed;
  left: 12px;
  top: -48px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
}
.skip-link:focus { top: 12px; }

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 300ms ease, color 300ms ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.input-error {
  border-color: #ef4444 !important;
  animation: shake 300ms ease-in-out;
}

.field-error {
  margin-top: 7px;
  padding: 8px 10px;
  border-left: 3px solid #dc2626;
  border-radius: 4px;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.08);
  font-size: 12px;
  line-height: 1.45;
}
.dark-mode .field-error { color: #fca5a5; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--surface-overlay); transform: translateY(-1px); }

.app-container { max-width: 1600px; margin: 0 auto; padding: 20px; }

.app-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; }
.logo h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
}
.logo-accent { color: var(--primary); }

.subtitle {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-left: auto;
  padding-right: 94px;
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(7, minmax(135px, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-base);
  scrollbar-width: thin;
}

.nav-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text2);
  min-height: 48px;
  padding: 11px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all var(--transition);
}
.nav-btn:hover { background: var(--surface-overlay); color: var(--text); border-color: color-mix(in srgb, var(--primary) 38%, var(--border)); }
.nav-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 5px 13px color-mix(in srgb, var(--primary) 28%, transparent), inset 0 -3px 0 rgba(90, 0, 0, .38);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeInUp 300ms ease-out; }

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

.main-grid {
  display: grid;
  grid-template-columns: 320px 1fr 480px;
  gap: 20px;
}

@media (max-width: 1366px) {
  .main-grid { grid-template-columns: 280px 1fr 400px; }
}
@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; }
}

.left-panel, .right-panel, .center-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel-section {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-subtle);
}

.panel-section h2 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.section-num { color: var(--primary); margin-right: 6px; }

.select-group { margin-bottom: 12px; }
.select-group label {
  display: block;
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.select-group select,
.input-row input,
.input-row select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color var(--transition);
}
.select-group select:focus,
.input-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.select-group select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.input-row select { width: 140px; }

.specs-card, .tech-info-card, .compat-card {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
}

.spec-row, .info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.spec-row:last-child, .info-row:last-child { border-bottom: none; }

.spec-label, .info-label { color: var(--text2); }
.spec-value, .info-value { color: var(--text); font-weight: 600; }

#gas-specs .spec-row {
  align-items: flex-start;
  gap: 10px;
}

#gas-specs .spec-label {
  flex: 0 0 34%;
}

#gas-specs .spec-value {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.compat-empty {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 12px;
}

.compat-good { color: #10b981; }
.compat-moderate { color: #f59e0b; }
.compat-poor { color: #ef4444; }

.compat-rating {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.compat-card.excellent { border-color: #10b981; }
.compat-card.good { border-color: #22d3ee; }
.compat-card.poor { border-color: #ef4444; }

/* Rankings */
.rankings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 8px;
}

.rankings-toolbar label {
  color: var(--text3);
  font: 11px var(--font-mono);
  letter-spacing: 0.65px;
}

.rankings-toolbar select {
  min-height: 36px;
  max-width: 190px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 28px 6px 8px;
  color: var(--text);
  background: var(--surface-base);
  font: 10px var(--font-mono);
}

.rankings-card {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-top: 4px;
}

.ranking-objective-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 2px 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  font: 700 11px var(--font-mono);
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.ranking-objective-heading:first-child { margin-top: 0; }
.ranking-objective-heading small { color: var(--text3); font-size: 10px; font-weight: 400; letter-spacing: 0; }

.rankings-empty {
  text-align: center;
  color: var(--text3);
  font-size: 11px;
  padding: 10px;
}

.ranking-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 4px;
  padding: 7px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 11px;
  border: 1px solid transparent;
  transition: all 150ms ease;
  cursor: pointer;
  min-height: 44px;
}
.ranking-row:hover {
  background: var(--surface-overlay);
  border-color: var(--border);
}
.ranking-row:last-child { margin-bottom: 0; }

.ranking-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.ranking-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.ranking-name {
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 6px;
  flex-shrink: 0;
}

.economic-badge,
.economic-verdict {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.45px;
  line-height: 1.2;
  padding: 3px 7px;
  text-transform: uppercase;
}

.econ-attractive { color: #059669 !important; background: rgba(16, 185, 129, 0.11); }
.econ-viable { color: #0891b2 !important; background: rgba(34, 211, 238, 0.11); }
.econ-marginal { color: #d97706 !important; background: rgba(245, 158, 11, 0.11); }
.econ-uneconomic,
.econ-deeply-uneconomic { color: #dc2626 !important; background: rgba(239, 68, 68, 0.10); }
.econ-downstream-required,
.econ-not-evaluated { color: #64748b !important; background: rgba(100, 116, 139, 0.10); }

.ranking-excellent { background: rgba(16, 185, 129, 0.12); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.25); }
.ranking-good { background: rgba(34, 211, 238, 0.12); color: var(--accent); border: 1px solid rgba(34, 211, 238, 0.35); }
.ranking-conditional { background: rgba(245, 158, 11, 0.12); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.25); }
.ranking-specialized { background: rgba(167, 139, 250, 0.12); color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.25); }
.ranking-poor { background: rgba(239, 68, 68, 0.12); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.25); }

.ranking-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--text3);
  font-size: 10px;
  line-height: 1.35;
}

.ranking-detail span {
  white-space: nowrap;
}

.ranking-note {
  font-size: 10px;
  color: var(--text2);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

.ranking-selected {
  background: rgba(34, 211, 238, 0.08);
  border-color: var(--accent);
}

:where(button, input, select, a, [role="button"]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

.actions { display: flex; flex-direction: column; gap: 8px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #b91c1c; transform: translateY(-1px); box-shadow: var(--shadow-medium); }

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

.flow-container {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-subtle);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 440px;
}

#flow-svg { width: 100%; height: auto; }

.flow-node { transition: opacity 400ms ease; }

@keyframes glowPulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.5; }
}

@keyframes flowDash {
  to { stroke-dashoffset: -30; }
}

.flow-active { animation: flowDash 1.2s linear infinite; }

.reactor-glow { animation: glowPulse 2s ease-in-out infinite; }

.chart-wrapper {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#yield-chart {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
}

.chart-tooltip {
  position: absolute;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text);
  pointer-events: none;
  z-index: 100;
  box-shadow: var(--shadow-medium);
  white-space: nowrap;
}

.results-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.results-table td, .results-table th { padding: 4px 3px; white-space: nowrap; }
.results-table td:first-child { min-width: 118px; max-width: 180px; white-space: normal; }
.results-table th { font-size: 10px; padding-right: 10px; }
#profit-breakdown td, #profit-breakdown th { padding: 2px 3px; font-size: 10px; white-space: nowrap; }
#profit-breakdown > div { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.price-override { box-sizing: border-box; }

.price-deck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-base);
}

.price-deck-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.price-deck-copy strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.price-deck-copy span {
  margin-top: 2px;
  color: var(--text3);
  font-size: 10px;
  line-height: 1.3;
}

.price-scenario-group {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-overlay);
}

.price-scenario-btn {
  min-height: 44px;
  min-width: 72px;
  border: 0;
  border-radius: 5px;
  padding: 8px 12px;
  color: var(--text3);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.price-scenario-btn:hover { color: var(--text); }
.price-scenario-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.price-editor-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.price-override.is-custom {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.08);
}

.price-custom-label {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.35px;
}

.unpriced-value {
  color: var(--text3);
  font-size: 10px;
  font-style: italic;
}

.results-product-name {
  display: inline-flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.35;
}

.results-category-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.dot-chemical { color: var(--accent); }
.dot-polymer { color: #a78bfa; }
.dot-fuel { color: #f59e0b; }
.dot-rubber { color: #f97316; }
.dot-fiber { color: #34d399; }
.dot-other { color: #6b7280; }
.dot-balance { color: #64748b; }

.category-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.35px;
  line-height: 1.2;
  text-transform: uppercase;
}

.category-badge-chemical { color: #0891b2; background: rgba(34, 211, 238, 0.12); }
.category-badge-polymer { color: #7c3aed; background: rgba(167, 139, 250, 0.12); }
.category-badge-fuel { color: #b45309; background: rgba(245, 158, 11, 0.12); }
.category-badge-rubber { color: #c2410c; background: rgba(249, 115, 22, 0.12); }
.category-badge-fiber { color: #047857; background: rgba(52, 211, 153, 0.12); }
.category-badge-other { color: #475569; background: rgba(107, 114, 128, 0.12); }
.category-badge-balance { color: #475569; background: rgba(100, 116, 139, 0.12); }

.non-saleable-price {
  color: var(--text3);
  font-weight: 700;
}

.results-table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.results-table thead,
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.results-table th,
.data-table th {
  background: var(--surface-overlay);
  color: var(--text2);
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  cursor: default;
  user-select: none;
  transition: color 150ms ease;
  position: relative;
  padding-right: 18px;
}

.results-table th[data-sort-bound="true"]:hover,
.data-table th[data-sort-bound="true"]:hover {
  color: var(--accent);
}

.results-table th[data-sort-bound="true"],
.data-table th[data-sort-bound="true"] {
  cursor: pointer;
  min-height: 44px;
}

.results-table th[data-sort-bound="true"]:not(.sort-asc):not(.sort-desc)::after,
.data-table th[data-sort-bound="true"]:not(.sort-asc):not(.sort-desc)::after {
  content: '↕';
  position: absolute;
  right: 6px;
  color: var(--text3);
  font-size: 11px;
}

.results-table th.sort-asc::after,
.data-table th.sort-asc::after {
  content: '▲';
  position: absolute;
  right: 6px;
  font-size: 10px;
  color: var(--accent);
}

.results-table th.sort-desc::after,
.data-table th.sort-desc::after {
  content: '▼';
  position: absolute;
  right: 6px;
  font-size: 10px;
  color: var(--accent);
}

.results-table td,
.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.results-table tbody tr:hover,
.data-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.05);
}

.empty-results {
  text-align: center;
  color: var(--text3);
  padding: 20px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-base);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.metric-label {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

#economics-section .metric-item {
  align-items: flex-start;
}

#economics-section .metric-label {
  max-width: 48%;
  line-height: 1.35;
}

#economics-section .metric-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.metric-primary {
  white-space: nowrap;
}

.metric-per-feed {
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.25;
  white-space: normal;
}

.economics-disclaimer {
  margin-top: 9px;
  padding: 8px;
  border-left: 2px solid var(--text3);
  border-radius: 0 4px 4px 0;
  color: var(--text3);
  background: var(--surface-base);
  font-size: 10px;
  line-height: 1.5;
}

.economic-context {
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 5px;
  color: var(--text2);
  background: rgba(34, 211, 238, 0.05);
  font-size: 11px;
  line-height: 1.55;
}

.revenue-breakdown-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.revenue-breakdown-heading h4 {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.9px;
}

.revenue-breakdown-heading p {
  margin-top: 2px;
  color: var(--text3);
  font-size: 10px;
  line-height: 1.35;
}

.revenue-breakdown-heading button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  background: var(--surface-overlay);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}

.revenue-breakdown-heading button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.revenue-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.revenue-breakdown-table {
  min-width: 520px;
  font-size: 10px;
}

.revenue-breakdown-table td,
.revenue-breakdown-table th {
  padding: 5px 4px !important;
}

.revenue-breakdown-table td:nth-child(n+2),
.revenue-breakdown-table th:nth-child(n+2) {
  text-align: right;
}

.revenue-product-note {
  display: block;
  margin-top: 1px;
  color: var(--text3);
  font-size: 10px;
}

.non-revenue-row {
  opacity: 0.65;
}

.revenue-share {
  display: grid;
  grid-template-columns: minmax(42px, 1fr) 34px;
  align-items: center;
  gap: 5px;
  min-width: 84px;
}

.revenue-share-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.16);
}

.revenue-share-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
}

.revenue-share strong {
  color: var(--text2);
  font-size: 10px;
  text-align: right;
}

@media (max-width: 520px) {
  .price-deck-bar { align-items: stretch; flex-direction: column; }
  .price-scenario-group { justify-content: stretch; }
  .price-scenario-btn { flex: 1; }
}

.tab-content {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow-subtle);
}

.tab-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.tab-context {
  font-size: 12px;
  color: var(--text2);
  margin: -8px 0 16px;
  line-height: 1.6;
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.tech-card {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: all var(--transition);
}
.tech-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.tech-card h3 {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.tech-card .tech-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tech-card .badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.badge-commercial { background: rgba(16, 185, 129, 0.15); color: #047857; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-construction { background: rgba(245, 158, 11, 0.15); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-pilot { background: rgba(34, 211, 238, 0.15); color: var(--accent); border: 1px solid rgba(34, 211, 238, 0.3); }
.badge-direct { background: rgba(220, 38, 38, 0.15); color: #dc2626; border: 1px solid rgba(220, 38, 38, 0.3); }
.badge-integrated { background: rgba(167, 139, 250, 0.15); color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.3); }

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}
.source-verified { background: rgba(16, 185, 129, 0.12); color: #059669; border: 1px solid rgba(16, 185, 129, 0.28); }
.source-plausible { background: rgba(245, 158, 11, 0.12); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.28); }
.source-needs-source { background: rgba(239, 68, 68, 0.12); color: #dc2626; border: 1px solid rgba(239, 68, 68, 0.28); }

.tech-card p {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

.tech-econ-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.tech-econ-row span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text2);
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-overlay);
}

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; border: 1px solid var(--border); }

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.compare-case {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.compare-case h3 {
  font-family: var(--font-display);
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.compare-run-btn {
  width: min(260px, 100%);
  margin-bottom: 16px;
}

.compare-output {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-base);
}

.compare-empty {
  color: var(--text3);
  text-align: center;
  padding: 24px;
  font-size: 12px;
}

.compare-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.compare-summary > div {
  background: var(--surface-raised);
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
}

.compare-summary span {
  color: var(--text2);
}

.compare-header-row,
.compare-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.compare-header-row {
  background: var(--surface-overlay);
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.compare-row:last-child { border-bottom: none; }
.compare-product { font-weight: 700; }

.compare-bar-cell {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.compare-bar-cell span {
  font-family: var(--font-mono);
  color: var(--text2);
  font-size: 11px;
  text-align: right;
}

.compare-bar-track {
  height: 8px;
  background: var(--surface-overlay);
  border-radius: 999px;
  overflow: hidden;
}

.compare-bar {
  height: 100%;
  border-radius: 999px;
}

.compare-a { background: #22d3ee; }
.compare-b { background: #f59e0b; }

.status-operational { color: #047857; font-weight: 600; }
.status-construction { color: #b45309; font-weight: 600; }
.status-planned { color: var(--accent); font-weight: 600; }
.status-reassessed { color: #ef4444; font-weight: 600; }
.status-commissioning { color: #7c3aed; font-weight: 600; }
.status-near-completion { color: #047857; font-weight: 600; }

.cat-polymer { color: #7c3aed; }
.cat-chemical { color: var(--accent); }
.cat-fuel { color: #b45309; }
.cat-rubber { color: #c2410c; }
.cat-fiber { color: #047857; }
.cat-other { color: #475569; }
.cat-balance { color: #475569; }

.app-footer {
  text-align: center;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
.app-footer p {
  font-size: 11px;
  color: var(--text3);
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

.countries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

@media (max-width: 640px) {
  .theme-toggle {
    position: static;
    display: block;
    width: max-content;
    margin: 12px 12px 0 auto;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 11px;
  }
  .app-container {
    padding: 12px;
  }
  .app-header {
    gap: 12px;
    padding: 8px 0 12px;
    margin-bottom: 12px;
  }
  .logo {
    min-width: 0;
  }
  .logo-icon {
    font-size: 24px;
  }
  .logo h1 {
    font-size: 23px;
    letter-spacing: 0;
  }
  .subtitle {
    width: 100%;
    margin-left: 0;
    font-size: 10px;
    letter-spacing: 1.5px;
  }
  .app-nav {
    gap: 6px;
    grid-template-columns: repeat(7, minmax(132px, 1fr));
    padding: 6px;
  }
  .nav-btn {
    min-height: 48px;
    padding: 10px 8px;
    font-size: 12px;
    letter-spacing: 0.8px;
  }
  .main-grid,
  .tab-content,
  .panel-section,
  .compare-case,
  .tech-card,
  .country-card {
    min-width: 0;
  }
  .panel-section,
  .tab-content {
    padding: 14px;
  }
  .feed-toggle-btn {
    min-width: 0;
    padding: 10px 8px;
    font-size: 11px;
  }
  .input-row > * {
    min-width: 0;
  }
  .flow-container {
    min-height: 260px;
    padding: 8px;
  }
  .chart-wrapper {
    height: 180px;
  }
  .results-table-wrapper,
  .table-wrapper {
    margin-left: -2px;
    margin-right: -2px;
  }
  .countries-grid { grid-template-columns: 1fr; }
  .tech-grid { grid-template-columns: 1fr; }
  .view-toggle { flex-wrap: wrap; width: 100%; }
  .toggle-btn { flex: 1 1 auto; }
  .compare-grid,
  .compare-summary {
    grid-template-columns: 1fr;
  }
  .compare-header-row,
  .compare-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .compare-bar-cell {
    grid-template-columns: 52px 1fr;
  }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .countries-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1025px) and (max-width: 1440px) {
  .countries-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1441px) {
  .countries-grid { grid-template-columns: repeat(4, 1fr); }
}

.country-card {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.country-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.country-flag {
  font-size: 40px;
  margin-bottom: 10px;
  line-height: 1;
}

.country-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.country-meta {
  display: inline-block;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  margin-bottom: 10px;
}

.country-project-list {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.5;
}

.country-projects {
  animation: fadeInUp 300ms ease-out;
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.projects-header .tab-title {
  margin-bottom: 0;
}

.view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  padding: 8px 16px;
  background: var(--surface-base);
  border: none;
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.toggle-btn:hover {
  background: var(--surface-overlay);
  color: var(--text);
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.feed-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.feed-crude { background: rgba(220, 38, 38, 0.15); color: #dc2626; border: 1px solid rgba(220, 38, 38, 0.3); }
.feed-gas { background: rgba(34, 211, 238, 0.15); color: var(--accent); border: 1px solid rgba(34, 211, 238, 0.3); }
.feed-naphtha { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.feed-mixed { background: rgba(167, 139, 250, 0.15); color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.3); }
.feed-coal { background: rgba(75, 85, 99, 0.2); color: #9ca3af; border: 1px solid rgba(107, 114, 128, 0.4); }

.feed-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
}
.feed-toggle-btn {
  flex: 1;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
}
.feed-toggle-btn:first-child { border-radius: 6px 0 0 6px; }
.feed-toggle-btn:last-child { border-radius: 0 6px 6px 0; }
.feed-toggle-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.feed-toggle-btn:not(.active):hover {
  background: var(--surface-overlay);
  color: var(--text);
}

.data-table tbody tr {
  cursor: pointer;
}
.data-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.08);
}
.crude-group-header td {
  background: var(--surface-overlay);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text);
  padding: 12px 10px;
  cursor: pointer;
  user-select: none;
  border-bottom: 2px solid var(--border);
  transition: background var(--transition);
}
.crude-group-header:hover td {
  background: var(--surface-base);
}
.group-arrow {
  display: inline-block;
  margin-right: 8px;
  transition: transform 200ms ease;
  font-size: 14px;
}
.group-arrow.collapsed {
  transform: rotate(-90deg);
}
.compat-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-right: 4px;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.compat-excellent {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.compat-good {
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.25);
}
/* Tech card compatibility heatmap */
.tech-fit-label {
  margin-top: 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tech-compat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.compat-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 4px;
  border-radius: 3px;
  color: #fff;
  letter-spacing: 0;
  line-height: 1.2;
  min-width: 22px;
}
.compat-dot.compat-excellent { border: 1px solid rgba(16, 185, 129, 0.5); }
.compat-dot.compat-good { border: 1px solid rgba(34, 211, 238, 0.5); }
.compat-dot.compat-poor { border: 1px solid rgba(239, 68, 68, 0.5); }

.tech-flow-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text2);
  margin-top: 6px;
  letter-spacing: 0.5px;
  padding: 4px 6px;
  background: var(--surface-overlay);
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tech-project-count {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.25);
  margin-left: 4px;
}
.tech-project-count.no-projects {
  background: rgba(107, 114, 128, 0.12);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.25);
  font-size: 10px;
}

.tech-card {
  cursor: pointer;
}
.tech-card.expanded {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.yield-bar-mini {
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-overlay);
  height: 16px;
}
.yield-bar-mini-inner {
  display: flex;
  height: 100%;
  width: 100%;
}
.yield-bar-mini-segment {
  height: 100%;
  transition: width 300ms ease;
}
.yield-bar-mini-label {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size: 10px;
}
.yield-label-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text2);
}
.yield-label-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-pill {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-base);
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-pill:hover {
  background: var(--surface-overlay);
  color: var(--text);
  border-color: var(--text3);
}

.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.cat-dot {
  font-size: 10px;
  margin-right: 4px;
}

.cat-dot-chemical { color: #22d3ee; }
.cat-dot-polymer { color: #a78bfa; }
.cat-dot-fuel { color: #f59e0b; }
.cat-dot-rubber { color: #f97316; }
.cat-dot-fiber { color: #34d399; }
.cat-dot-other { color: #6b7280; }
.cat-dot-balance { color: #9ca3af; }

.product-detail td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
  background: var(--surface-base);
}

.product-detail-content {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  animation: slideDown 200ms ease-out;
}

.product-detail-content strong {
  color: var(--text);
  margin-right: 6px;
}

.tech-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  background: rgba(220, 38, 38, 0.12);
  color: var(--primary);
  border: 1px solid rgba(220, 38, 38, 0.3);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-right: 6px;
}

.data-table tbody tr.expanded {
  background: rgba(34, 211, 238, 0.08);
}

.data-table tbody tr[data-category] {
  cursor: pointer;
  transition: background var(--transition);
}

.data-table tbody tr[data-category]:hover {
  background: rgba(34, 211, 238, 0.05);
}

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

.ds-subtitle {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 20px;
  line-height: 1.7;
}

#tab-downstream .tab-content {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
}

#tab-downstream .tab-title { font-size: 26px; }

/* Connected-chain pilot */
.cc-panel {
  margin: 18px 0 34px;
  padding: 26px;
  border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--border));
  border-radius: 12px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 42%),
    var(--surface-raised);
  box-shadow: var(--shadow-medium);
}

.cc-panel-heading,
.cc-result-title-row,
.ds-catalog-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.cc-panel-heading h3,
.ds-catalog-heading h3 {
  margin: 4px 0 7px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: .2px;
}

.cc-panel-heading p {
  max-width: 860px;
  color: var(--text2);
  font-size: 14px;
  line-height: 1.65;
}

.cc-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.cc-pilot-badge,
.cc-mini-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--border));
  border-radius: 999px;
  color: color-mix(in srgb, var(--accent) 85%, var(--text));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .7px;
}

.cc-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.cc-stage-cost-fields { display: contents; }

.cc-assumption-warning {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #f59e0b;
  border-radius: 5px;
  color: var(--text2);
  background: color-mix(in srgb, #f59e0b 8%, transparent);
  font: 11px/1.55 var(--font-mono);
}

.cc-assumption-warning ul { margin: 6px 0 0 16px; padding: 0; }
.cc-assumption-warning li + li { margin-top: 3px; }

.cc-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.cc-field-wide { min-width: 190px; grid-column: span 2; }

.cc-field > span {
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .65px;
  text-transform: uppercase;
}

.cc-field input,
.cc-field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-overlay);
  color: var(--text);
  font: 14px var(--font-mono);
}

.cc-field input:focus,
.cc-field select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.cc-field small {
  min-height: 12px;
  color: var(--text3);
  font-size: 10px;
}

.cc-scenario-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 7px;
  color: var(--text2);
  font-size: 12px;
}

.cc-scenario-buttons { display: flex; gap: 6px; }

.cc-scenario-btn {
  min-height: 44px;
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  font: 750 12px/1.2 var(--font-mono);
}

.cc-scenario-btn:hover,
.cc-scenario-btn.active {
  border-color: var(--accent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.cc-scenario-btn.active { box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--accent) 70%, #0e7490); }

.cc-auto-note { margin-left: auto; color: var(--accent); }

.cc-judgments {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.cc-judgment {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-overlay);
}

.cc-judgment:nth-child(1) { border-top: 3px solid #10b981; }
.cc-judgment:nth-child(2) { border-top: 3px solid #f59e0b; }
.cc-judgment:nth-child(3) { border-top: 3px solid #22d3ee; }

.cc-judgment-label {
  color: var(--text3);
  font-size: 11px;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.cc-judgment-value {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
}

.cc-judgment-detail { display: block; margin-top: 6px; color: var(--text2); font-size: 11px; line-height: 1.55; }
.cc-tone-good { color: #10b981; }
.cc-tone-warn { color: #f59e0b; }
.cc-tone-bad { color: #ef4444; }
.cc-tone-neutral { color: var(--accent); }

.cc-message {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  background: color-mix(in srgb, #f59e0b 8%, var(--surface));
  color: var(--text2);
  font-size: 12px;
  line-height: 1.55;
}

.cc-results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .85fr);
  gap: 12px;
}

.cc-result-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.cc-result-card h4 {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: .4px;
}

.cc-stage-block { margin-top: 13px; }
.cc-stage-block + .cc-stage-block { padding-top: 13px; border-top: 1px dashed var(--border); }
.cc-stage-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cc-stage-name { font-size: 13px; font-weight: 800; }
.cc-stage-input { color: var(--accent); font-size: 10px; line-height: 1.5; text-align: right; }
.cc-stage-meta { margin-top: 8px; color: var(--text3); font-size: 10px; line-height: 1.55; }
.cc-price-input {
  width: 82px;
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-overlay);
  color: var(--text);
  font: 11px var(--font-mono);
}

.cc-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.cc-stream-table,
.cc-sensitivity-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.cc-stream-table { min-width: 356px; }
.cc-stream-table th,
.cc-stream-table td,
.cc-sensitivity-table th,
.cc-sensitivity-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: right; }
.cc-stream-table th:first-child,
.cc-stream-table td:first-child,
.cc-sensitivity-table th:first-child,
.cc-sensitivity-table td:first-child { text-align: left; }
.cc-stream-table th,
.cc-sensitivity-table th { color: var(--text3); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.cc-stream-role { color: var(--text3); }
.cc-stream-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; vertical-align: 1px; }
.cc-stream-dot.saleable { background: #22d3ee; }
.cc-stream-dot.intermediate { background: #a78bfa; }
.cc-stream-dot.credit { background: #f59e0b; }
.cc-stream-dot.waste { background: #64748b; }
.cc-stream-dot.balance { background: #94a3b8; }

.cc-metric-list { margin-top: 11px; }
.cc-metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.cc-metric-row span:first-child { color: var(--text2); }
.cc-metric-row strong { text-align: right; }
.cc-metric-row.cc-total { margin-top: 6px; padding-top: 13px; font-size: 15px; }
.cc-driver-list { margin: 12px 0 0 18px; color: var(--text2); font-size: 11px; line-height: 1.8; }

.cc-waterfall { margin-top: 15px; }
.cc-waterfall-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(110px, 1.35fr) 88px;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: var(--text2);
  font-size: 10px;
}
.cc-waterfall-row strong { color: var(--text); text-align: right; }
.cc-waterfall-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-overlay); }
.cc-waterfall-bar { height: 100%; border-radius: inherit; }
.cc-waterfall-bar.positive { background: #22d3ee; }
.cc-waterfall-bar.negative { background: #f59e0b; }
.cc-waterfall-bar.net-positive { background: #10b981; }
.cc-waterfall-bar.net-negative { background: #ef4444; }

.cc-sensitivity-card { margin-top: 12px; }
.cc-sensitivity { margin-top: 12px; overflow-x: auto; }
.cc-sensitivity-note { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--text2); font-size: 11px; }
.cc-sensitivity-verdict { font-size: 10px; line-height: 1.5; }
.cc-sensitivity-cell { border-radius: 3px; font-weight: 700; }
.cc-sensitivity-cell.good { background: color-mix(in srgb, #10b981 16%, var(--surface)); color: #10b981; }
.cc-sensitivity-cell.warn { background: color-mix(in srgb, #f59e0b 14%, var(--surface)); color: #d97706; }
.cc-sensitivity-cell.bad { background: color-mix(in srgb, #ef4444 12%, var(--surface)); color: #ef4444; }

.cc-basis-note {
  margin-top: 13px;
  color: var(--text3);
  font-size: 11px;
  line-height: 1.55;
}

.ds-catalog-heading { margin: 0 0 14px; padding-top: 8px; border-top: 1px solid var(--border); }
.ds-catalog-heading h3 { font-size: 18px; }

@media (max-width: 1100px) {
  .cc-controls { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .cc-field-wide { grid-column: span 2; }
  .cc-results-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .cc-panel { padding: 16px; }
  .cc-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cc-results-grid { grid-template-columns: 1fr; }
  .cc-judgments { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .cc-panel-heading { flex-direction: column; }
  .cc-controls { grid-template-columns: 1fr; }
  .cc-field-wide { grid-column: auto; }
  .cc-scenario-row { align-items: flex-start; flex-direction: column; }
  .cc-scenario-buttons { width: 100%; }
  .cc-scenario-btn { flex: 1; padding-left: 5px; padding-right: 5px; }
  .cc-auto-note { margin-left: 0; }
  .cc-price-input { min-height: 44px; }
  .cc-waterfall-row { grid-template-columns: minmax(0, 1fr) 70px 76px; }
}

.ds-chains {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ds-chain {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.ds-chain:hover {
  border-color: var(--accent);
}

.ds-chain.ds-expanded {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.ds-chain-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}

.ds-chain-header:hover {
  background: var(--surface-overlay);
}

.ds-chain-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.ds-chain-title-wrap {
  flex: 1;
  min-width: 0;
}

.ds-chain-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.ds-chain-feed {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ds-chain-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ds-stage-count {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.25);
  font-weight: 600;
}

.ds-product-count {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 600;
}

.ds-expand-arrow {
  font-size: 14px;
  color: var(--text3);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.ds-chain.ds-expanded .ds-expand-arrow {
  transform: rotate(90deg);
}

.ds-chain-body {
  display: none;
  padding: 0 20px 20px 20px;
}

.ds-chain.ds-expanded .ds-chain-body {
  display: block;
  animation: slideDown 200ms ease-out;
}

.ds-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--surface-overlay);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.ds-stages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ds-stage {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--transition);
}

.ds-stage:hover {
  border-color: rgba(34, 211, 238, 0.4);
}

.ds-stage.ds-stage-expanded {
  border-color: var(--accent);
}

.ds-stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px 12px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-subtle);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}

.ds-stage-header:hover {
  border-color: var(--accent);
  background: var(--surface-overlay);
  transform: translateY(-1px);
}

.ds-stage-header:focus-visible { border-color: var(--accent); }

.ds-stage-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.ds-stage-conditions {
  font-size: 10px;
  color: var(--text3);
  display: flex;
  gap: 10px;
}

.ds-stage-conditions span {
  background: var(--surface-overlay);
  padding: 2px 8px;
  border-radius: 4px;
}

.ds-stage-arrow {
  font-size: 18px;
  color: var(--accent);
  transition: transform var(--transition);
}

.ds-stage-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  background: var(--surface-overlay);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.ds-stage.ds-stage-expanded .ds-stage-arrow {
  transform: rotate(90deg);
}

.ds-stage-body {
  display: none;
  padding: 0 16px 14px 16px;
}

.ds-stage.ds-stage-expanded .ds-stage-body {
  display: block;
  animation: slideDown 200ms ease-out;
}

.ds-input-line {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.ds-input-line strong {
  color: var(--accent);
}

.ds-products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.ds-product-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-overlay);
  border-radius: 6px;
  font-size: 12px;
}

.ds-product-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.ds-product-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ds-product-name {
  width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 600;
}

.ds-product-pct {
  width: 40px;
  text-align: right;
  font-weight: 600;
  font-family: var(--font-mono);
}

.ds-cat-chemical .ds-product-bar { background: #22d3ee; }
.ds-cat-chemical .ds-product-pct { color: var(--accent); }
.ds-cat-fuel .ds-product-bar { background: #f59e0b; }
.ds-cat-fuel .ds-product-pct { color: #f59e0b; }
.ds-cat-polymer .ds-product-bar { background: #a78bfa; }
.ds-cat-polymer .ds-product-pct { color: #a78bfa; }
.ds-cat-rubber .ds-product-bar { background: #f97316; }
.ds-cat-rubber .ds-product-pct { color: #f97316; }
.ds-cat-fiber .ds-product-bar { background: #34d399; }
.ds-cat-fiber .ds-product-pct { color: #34d399; }
.ds-cat-other .ds-product-bar { background: #6b7280; }
.ds-cat-other .ds-product-pct { color: #6b7280; }

.ds-chart-container {
  margin-top: 8px;
}

.ds-chart-container canvas {
  width: 100%;
  height: 180px;
  border-radius: 6px;
}

@media (max-width: 1024px) {
  .ds-products-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .ds-chain-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
  }
  .ds-chain-badges {
    width: 100%;
  }
  .ds-stage-conditions {
    display: none;
  }
}

.ds-search-row {
  position: relative;
  margin-bottom: 16px;
}

.ds-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.ds-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.ds-search::placeholder {
  color: var(--text3);
}

.ds-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-medium);
}

.ds-search-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.ds-search-item:last-child {
  border-bottom: none;
}

.ds-search-item:hover {
  background: var(--surface-overlay);
}

.ds-search-item-product {
  font-weight: 600;
  color: var(--text);
}

.ds-search-item-stage {
  color: var(--text2);
  font-size: 11px;
}

.ds-search-item-chain {
  color: var(--text3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ds-search-item-yield {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  float: right;
}

.ds-highlight {
  background: rgba(34, 211, 238, 0.2);
  border-radius: 2px;
  padding: 0 2px;
}

.donut-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  padding: 8px 0;
}

.donut-wrapper canvas {
  width: 120px !important;
  height: 120px !important;
  flex-shrink: 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  min-width: 0;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-label {
  color: var(--text2);
}

.donut-legend-pct {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  margin-left: auto;
}

.ds-flow-connector {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.ds-flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text3);
  font-size: 11px;
  gap: 0;
}

.ds-flow-arrow-line {
  width: 2px;
  height: 12px;
  background: var(--border);
}

.ds-flow-arrow-head {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text3);
}

.ds-flow-arrow-label {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--surface-overlay);
  border-radius: 3px;
  color: var(--text3);
  white-space: nowrap;
  margin-top: -2px;
}

.price-label {
  padding: 8px 12px;
  background: var(--surface-overlay);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-weight: 600;
}

.map-wrapper {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}

#map-svg {
  background: #0a1628;
}

.map-country {
  fill: #16213e;
  stroke: #2a3a5e;
  stroke-width: 0.3;
  transition: fill 200ms ease;
}

.map-country:hover {
  fill: #1a2a4e;
}

.map-project-dot {
  cursor: pointer;
  transition: r 200ms ease, opacity 200ms ease;
}

.map-project-dot:hover {
  filter: url(#mapGlow);
}

.map-tooltip {
  line-height: 1.5;
}

.map-tooltip-name {
  font-weight: 700;
  color: var(--accent);
  font-size: 12px;
}

.map-tooltip-detail {
  color: var(--text2);
}

.map-tooltip-status {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

/* Value Chains explorer */
.vc-explorer {
  margin: 18px 0 42px;
}

.vc-section-heading,
.vc-family-heading,
.vc-economics-heading,
.vc-advanced-heading,
.vc-projects-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.vc-section-heading h3,
.vc-family-heading h3,
.vc-economics-heading h3 {
  margin: 4px 0 7px;
  font-family: var(--font-display);
  font-size: 24px;
}

.vc-section-heading p,
.vc-family-heading p,
.vc-economics-heading p {
  max-width: 860px;
  color: var(--text2);
  font-size: 14px;
  line-height: 1.65;
}

.vc-boundary-badge,
.vc-status-badge {
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 999px;
  color: color-mix(in srgb, var(--accent) 88%, var(--text));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .65px;
}

.vc-boundary-badge { padding: 6px 10px; }
.vc-status-badge { padding: 3px 9px; }

.vc-overview-labels,
.vc-lane {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.vc-overview-labels {
  margin: 18px 0 7px;
  padding: 0 14px;
  color: var(--text3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.vc-overview-map {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

.vc-lane {
  transition: opacity var(--transition), filter var(--transition);
}

.vc-lane-muted { opacity: .58; filter: saturate(.7); }

.vc-lane-cell {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 72px;
  align-items: center;
  gap: 8px;
  padding: 10px 22px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-overlay);
}

.vc-lane[data-vc-lane="crude"] .vc-lane-cell:first-child { border-left: 3px solid #f59e0b; }
.vc-lane[data-vc-lane="gas"] .vc-lane-cell:first-child { border-left: 3px solid #22d3ee; }
.vc-lane[data-vc-lane="coal"] .vc-lane-cell:first-child { border-left: 3px solid #94a3b8; }

.vc-lane-cell strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.vc-stage-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font: 700 10px var(--font-mono);
}

.vc-lane-arrow {
  position: absolute;
  right: -13px;
  z-index: 2;
  color: var(--accent);
  font-size: 16px;
}

.vc-filter-panel {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.2fr);
  gap: 18px;
  margin: 18px 0 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-raised);
}

.vc-filter-group { min-width: 0; }
.vc-filter-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .75px;
  text-transform: uppercase;
}

.vc-filter-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.vc-filter-btn {
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-overlay);
  color: var(--text2);
  font: 750 12px var(--font-mono);
  cursor: pointer;
}

.vc-filter-btn:hover { border-color: var(--accent); color: var(--text); }
.vc-filter-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--accent) 24%, transparent), inset 0 -3px 0 #0891b2;
}
.dark-mode .vc-filter-btn.active { color: #082f49; }

.vc-finder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.vc-finder-row .ds-search-row { margin: 0; }
.vc-finder-row .ds-search { min-height: 48px; font-size: 14px; }
.vc-print-btn { min-height: 44px; white-space: nowrap; }

.vc-product-trace {
  position: relative;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 58%), var(--surface-raised);
}

.vc-product-trace[hidden] { display: none; }
.vc-trace-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text2);
  font-size: 24px;
  cursor: pointer;
}

.vc-trace-title { display: flex; align-items: center; gap: 9px; padding-right: 42px; }
.vc-trace-title h3 { margin: 3px 0 0; font-size: 20px; }
.vc-trace-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 12px; }
.vc-trace-grid > div { padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-overlay); }
.vc-trace-grid span { display: block; margin-bottom: 5px; color: var(--text3); font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.vc-trace-grid strong { color: var(--text); font-size: 12px; line-height: 1.55; }

.vc-family-heading {
  align-items: flex-end;
  margin: 26px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.vc-family-heading p { margin: 0; text-align: right; }
.vc-family-heading p strong { color: var(--text); font-size: 13px; }

.ds-chains {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.ds-chain { min-width: 0; }
.ds-chain.ds-expanded { grid-column: 1 / -1; }
.vc-card-art { padding: 10px 10px 0; }
.vc-equipment-art { display: block; width: 100%; height: 150px; }
.vc-equipment-lines,
.vc-ground { fill: none; stroke: color-mix(in srgb, var(--accent) 76%, var(--text)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vc-ground { stroke: var(--border); }
.vc-equipment-art text { fill: color-mix(in srgb, var(--accent) 76%, var(--text)); font: 700 13px var(--font-mono); }
.vc-art-label { letter-spacing: 1px; }

.ds-chain-header { min-height: 68px; padding: 12px 18px 5px; }
.ds-chain-header:hover { background: transparent; }
.ds-chain-name { font-size: 20px; }
.ds-expand-arrow {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 22px;
}
.ds-chain.ds-expanded .ds-expand-arrow { transform: rotate(45deg); }

.vc-card-summary { padding: 4px 18px 18px; }
.vc-card-summary > p { min-height: 62px; margin: 5px 0 12px; color: var(--text2); font-size: 13px; line-height: 1.65; }
.vc-mini-flow { display: flex; align-items: center; gap: 6px; overflow: hidden; margin-bottom: 12px; color: var(--text2); font-size: 10px; }
.vc-mini-flow span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-mini-flow b { color: var(--accent); }
.vc-key-outputs { display: flex; min-height: 58px; flex-wrap: wrap; align-content: flex-start; gap: 6px; margin-bottom: 12px; }
.vc-output-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--text2); background: var(--surface-overlay); font-size: 10px; }
.ds-chain-badges { gap: 5px; }
.vc-card-summary .ds-stage-count,
.vc-card-summary .ds-product-count { font-size: 11px; padding: 5px 10px; }

.ds-chain-body { padding: 0 18px 20px; }
.vc-explain-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 8px 0 16px; }
.vc-explain-grid section { padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-overlay); }
.vc-explain-grid section.vc-explain-wide { grid-column: span 3; }
.vc-explain-grid p,
.vc-explain-grid ul { margin: 7px 0 0; color: var(--text2); font-size: 13px; line-height: 1.65; }
.vc-explain-grid ul { padding-left: 17px; }
.vc-explain-label { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .8px; }
.vc-audit-note { border-left: 3px solid #f59e0b !important; }

.vc-projects-heading { align-items: baseline; margin: 18px 0 8px; }
.vc-projects-heading small { color: var(--text3); font-size: 10px; }
.vc-projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.vc-project { padding: 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-raised); }
.vc-project strong,
.vc-project span,
.vc-project small { display: block; }
.vc-project strong { color: var(--text); font-size: 13px; }
.vc-project span { margin: 5px 0; color: var(--text2); font-size: 11px; }
.vc-project small { color: var(--text3); font-size: 10px; }
.vc-empty-note { color: var(--text3); font-size: 12px; }

.vc-advanced-heading { align-items: flex-end; margin: 20px 0 10px; padding-top: 16px; border-top: 1px dashed var(--border); }
.vc-advanced-heading h4 { margin: 4px 0 0; color: var(--text); font-size: 17px; }
.vc-advanced-heading > span { color: var(--text3); font-size: 11px; }

.ds-product-row { min-height: 44px; cursor: pointer; }
.ds-product-row:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.vc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 14px 0 0; color: var(--text2); font-size: 10px; }
.vc-legend-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #64748b; }
.vc-legend-dot.chemical { background: #22d3ee; }
.vc-legend-dot.fuel { background: #f59e0b; }
.vc-legend-dot.polymer { background: #a78bfa; }
.vc-legend-dot.fiber { background: #34d399; }
.vc-legend-dot.rubber { background: #f97316; }
.vc-legend-dot.intermediate { background: #8b5cf6; }
.vc-legend-dot.other { background: #64748b; }
.vc-legend-dot.balance { background: #94a3b8; box-shadow: 0 0 0 1px var(--text3); }

.vc-economics-heading { margin-top: 34px; padding-top: 24px; border-top: 2px solid var(--border); }
.vc-economics-heading p { margin: 0; }
.vc-economics-heading + .cc-panel { margin-top: 14px; }

#tab-downstream .ds-chain-feed { font-size: 12px; color: var(--text2); }
#tab-downstream .ds-desc { font-size: 13px; line-height: 1.7; }
#tab-downstream .ds-stage-name { font-size: 14px; }
#tab-downstream .ds-stage-conditions { font-size: 11px; }
#tab-downstream .ds-input-line { font-size: 12px; line-height: 1.55; }
#tab-downstream .ds-product-row { font-size: 13px; }
#tab-downstream .ds-search-item { font-size: 13px; }
#tab-downstream .ds-search-item-stage { font-size: 12px; }
#tab-downstream .ds-search-item-chain { font-size: 11px; }
.ds-related-note { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 12px; color: var(--text2); font-size: 11px; line-height: 1.5; text-align: center; }
.ds-related-note::before,
.ds-related-note::after { content: ''; flex: 1; max-width: 80px; border-top: 1px solid var(--border); }
.ds-related-label { padding: 3px 7px; border-radius: 999px; color: var(--text2); background: var(--surface-overlay); font-weight: 800; text-transform: uppercase; letter-spacing: .45px; }

@media (max-width: 1100px) {
  .ds-chains { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vc-trace-grid { grid-template-columns: repeat(2, 1fr); }
  .vc-overview-labels { display: none; }
  .vc-lane { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vc-lane-cell:nth-child(3) .vc-lane-arrow { display: none; }
}

@media (max-width: 760px) {
  .vc-section-heading,
  .vc-family-heading,
  .vc-economics-heading { flex-direction: column; align-items: flex-start; }
  .vc-family-heading p { text-align: left; }
  .vc-filter-panel { grid-template-columns: 1fr; }
  .vc-lane { grid-template-columns: 1fr; }
  .vc-lane-cell { min-height: 58px; }
  .vc-lane-arrow { right: 50%; bottom: -16px; transform: rotate(90deg); }
  .vc-lane-cell:nth-child(3) .vc-lane-arrow { display: block; }
  .ds-chains { grid-template-columns: 1fr; }
  .vc-explain-grid { grid-template-columns: 1fr; }
  .vc-explain-grid section.vc-explain-wide { grid-column: auto; }
  .vc-projects { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .vc-finder-row { grid-template-columns: 1fr; }
  .vc-print-btn { width: 100%; }
  .vc-trace-grid { grid-template-columns: 1fr; }
  .vc-filter-btn { flex: 1 1 calc(50% - 6px); }
  .vc-equipment-art { height: 130px; }
  .vc-advanced-heading { flex-direction: column; align-items: flex-start; }
}

/* Whole-project interaction affordances */
.tech-card,
.project-row,
.products-table tbody tr[role="button"],
.country-card {
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition), background var(--transition);
}

.tech-card:hover,
.tech-card:focus-visible,
.country-card:hover,
.country-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.tech-card-action,
.country-card-action {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  background: var(--surface-overlay);
  font-size: 11px;
  font-weight: 800;
}

.tech-card.expanded .tech-card-chevron { transform: rotate(90deg); }
.tech-card-chevron { font-size: 18px; transition: transform var(--transition); }

.project-row[role="button"],
.products-table tbody tr[role="button"] { cursor: pointer; }
.project-row[role="button"]:hover,
.project-row[role="button"]:focus-visible,
.products-table tbody tr[role="button"]:hover,
.products-table tbody tr[role="button"]:focus-visible {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  box-shadow: inset 3px 0 0 var(--accent);
  outline-offset: -2px;
}

.expand-label {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .3px;
}
.expand-arrow { display: inline-block; min-width: 15px; color: var(--accent); font-size: 15px; }

#export-csv-btn {
  float: right;
  min-width: 52px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  background: var(--surface-overlay);
  font: 700 10px var(--font-mono);
  cursor: pointer;
}
#export-csv-btn:hover { border-color: var(--accent); color: var(--accent); }

.price-override {
  min-width: 72px;
  min-height: 36px;
  padding: 6px 8px;
  font: 12px var(--font-mono) !important;
}

.table-scroll-hint {
  display: none;
  margin: 0 0 7px;
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 820px) {
  .table-scroll-hint { display: block; }
  .ds-stage-header { align-items: flex-start; flex-wrap: wrap; }
  .ds-stage-conditions { order: 3; width: 100%; flex-wrap: wrap; }
  .ds-stage-action { margin-left: auto; }
}

@media print {
  @page { margin: 12mm; }
  .theme-toggle, .app-nav, .actions, .app-footer, .filter-bar, .vc-filter-panel, .ds-search-row, .ds-search-results, #ds-print-btn, .compare-run-btn, .vc-trace-close, .table-scroll-hint { display: none !important; }
  body { background: white !important; color: black !important; font-size: 11pt; }
  .tab-panel { display: block !important; }
  .panel-section, .tab-content, .compare-case, .compare-output { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }
  .main-grid, .compare-grid, .compare-summary { display: block !important; }
  .flow-container, .chart-wrapper { min-height: auto !important; break-inside: avoid; }
  .table-wrapper, .results-table-wrapper { overflow: visible !important; }
  .results-table th, .data-table th, .results-table td, .data-table td { color: black !important; background: white !important; }
  .detail-row { display: none !important; }
  .ds-chain-body { display: block !important; }
  .ds-stage-body { display: block !important; }
  .ds-chain { break-inside: avoid; }
  .ds-chains { display: block !important; }
  .ds-chain { margin-bottom: 12px; }
}
