* { box-sizing: border-box; }
:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --muted-2: #8794a6;
  --border: #dbe3ec;
  --border-strong: #c7d2df;
  --blue: #2563eb;
  --cyan: #1689c9;
  --amber: #e7a400;
  --orange: #d85a24;
  --green: #169b68;
  --shadow: 0 10px 28px rgba(31, 45, 61, 0.07);
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: Arial, Helvetica, sans-serif; -webkit-font-smoothing: antialiased; }
.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 18px 18px 30px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 18px 20px; background: #fff; border: 1px solid var(--border); border-radius: 15px;
  box-shadow: var(--shadow);
}
.page-header h1 { margin: 0; font-size: clamp(21px, 2.4vw, 31px); letter-spacing: -0.025em; }
.page-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.status-badge { flex: 0 0 auto; padding: 8px 11px; border-radius: 999px; background: #eaf7ef; color: #147a53; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 18px; }
.control-panel { position: sticky; top: 12px; padding: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow); }
.control-panel h2, .visual-header h2 { margin: 5px 0 5px; font-size: 18px; letter-spacing: -.015em; }
.section-kicker { color: var(--cyan); font-size: 9px; letter-spacing: .14em; font-weight: 800; }
.panel-help { margin: 0 0 8px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.control-block { padding: 12px 0 6px; border-top: 1px solid #eef2f6; }
.control-block:first-of-type { border-top: 0; }
.control-label { margin-bottom: 9px; color: #334155; font-size: 12px; font-weight: 700; }
.control-hint { margin-top: 7px; color: var(--muted-2); font-size: 9px; line-height: 1.35; }

/* Dash dropdown - light */
.Select-control, .dash-dropdown .Select-control { min-height: 40px; border: 1px solid var(--border-strong) !important; border-radius: 9px !important; background: #fff !important; box-shadow: none !important; }
.Select-value-label, .Select-placeholder, .Select-input > input { color: var(--text) !important; }
.Select-menu-outer { z-index: 2000 !important; border: 1px solid var(--border-strong) !important; border-radius: 9px !important; background: #fff !important; box-shadow: 0 14px 34px rgba(31,45,61,.12) !important; }
.VirtualizedSelectOption { background: #fff !important; color: var(--text) !important; }
.VirtualizedSelectFocusedOption { background: #eef6ff !important; }
.Select-arrow { border-top-color: #64748b !important; }

.mode-control { display: grid !important; grid-template-columns: 1fr 1fr; gap: 7px; }
.mode-control label { display: flex !important; align-items: center; justify-content: center; gap: 6px; margin: 0 !important; min-height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: #f8fafc; color: #475569; font-size: 11px; font-weight: 700; cursor: pointer; }
.mode-control label:has(input:checked) { border-color: #8dc3e3; background: #eaf6fc; color: #0b6fa7; }

.rc-slider { margin: 13px 3px 21px; }
.rc-slider-rail { height: 4px; background: #e7edf3; }
.rc-slider-track { height: 4px; background: var(--cyan); }
.rc-slider-handle { width: 18px; height: 18px; margin-top: -7px; border: 3px solid #fff; background: var(--cyan); box-shadow: 0 0 0 1px #6db6de, 0 2px 7px rgba(22,137,201,.26); opacity: 1; }
.rc-slider-handle:hover, .rc-slider-handle:active, .rc-slider-handle:focus { border-color: #fff; box-shadow: 0 0 0 2px #8ac9e9, 0 2px 10px rgba(22,137,201,.32); }
.rc-slider-mark-text { color: #77869a; font-size: 9px; }
.rc-slider-tooltip-inner { background: #25344a; color: #fff; }
.rc-slider-tooltip-arrow { border-top-color: #25344a !important; }

.warning-card { margin-top: 14px; padding: 12px 13px; border: 1px solid #f1dfaa; border-radius: 10px; background: #fffaf0; }
.warning-title { color: #9a6a00; font-size: 9px; letter-spacing: .12em; font-weight: 800; }
.warning-text { margin-top: 6px; color: #5b4b24; font-size: 10px; line-height: 1.45; }
.warning-note { margin-top: 5px; color: #827456; font-size: 9px; line-height: 1.4; }
.main-panel { min-width: 0; }
.result-banner { display: grid; grid-template-columns: minmax(220px, 330px) minmax(0, 1fr); gap: 18px; align-items: center; padding: 17px 18px; margin-bottom: 12px; background: linear-gradient(110deg,#ffffff,#f6fbfe); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.result-label { color: var(--muted); font-size: 9px; letter-spacing: .12em; font-weight: 800; }
.result-flow { display: inline-block; margin-top: 3px; color: #0a6f9e; font-size: clamp(34px,4vw,50px); line-height: 1; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.result-sub { display: inline-block; margin-left: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.result-delta { margin-top: 4px; color: #a77400; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-config { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.metrics-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-bottom: 12px; }
.metric-card { position: relative; min-width: 0; min-height: 100px; padding: 13px 13px 12px; background: #fff; border: 1px solid var(--border); border-radius: 11px; box-shadow: 0 5px 16px rgba(31,45,61,.045); overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent,var(--cyan)); }
.metric-cyan { --accent: var(--cyan); } .metric-blue { --accent: var(--blue); } .metric-amber { --accent: var(--amber); } .metric-orange { --accent: var(--orange); } .metric-green { --accent: var(--green); }
.metric-label { color: var(--muted); font-size: 10px; }
.metric-value { margin-top: 9px; color: #1e293b; font-size: clamp(18px,1.7vw,23px); font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-subtitle { margin-top: 8px; color: var(--muted-2); font-size: 9px; line-height: 1.3; }
.visual-card { margin-bottom: 12px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.visual-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid #edf1f5; }
.reset-button { appearance: none; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: #435165; padding: 8px 11px; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; }
.reset-button:hover { background: #f5f8fb; border-color: #aebdcc; }
#fig3d, #fig2d { width: 100% !important; max-width: 100% !important; background: #fff; }
#fig3d .js-plotly-plot, #fig3d .plot-container, #fig3d .svg-container { min-height: 570px !important; }
#fig2d .js-plotly-plot, #fig2d .plot-container, #fig2d .svg-container { min-height: 430px !important; }
.visual-note { padding: 9px 16px 12px; border-top: 1px solid #edf1f5; color: var(--muted); font-size: 9px; }
.modebar { opacity: .64; transition: opacity .15s ease; } .modebar:hover { opacity: 1; }
.footer-note { margin-top: 18px; padding: 14px 4px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; line-height: 1.5; }

@media (max-width: 1180px) { .workspace { grid-template-columns: 285px minmax(0,1fr); } .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 820px) {
  .app-shell { padding: 10px 10px 24px; }
  .page-header { padding: 14px; }
  .workspace { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
  .control-panel { position: relative; top: auto; }
  .result-banner { grid-template-columns: 1fr; gap: 12px; }
  #fig3d, #fig3d .js-plotly-plot, #fig3d .plot-container, #fig3d .svg-container { height: 500px !important; min-height: 500px !important; }
  #fig2d, #fig2d .js-plotly-plot, #fig2d .plot-container, #fig2d .svg-container { height: 390px !important; min-height: 390px !important; }
}
@media (max-width: 520px) {
  .page-header { align-items: flex-start; }
  .status-badge { padding: 7px 8px; font-size: 8px; }
  .page-header h1 { font-size: 20px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .metric-card { min-height: 92px; padding: 11px; }
  .metric-value { font-size: 18px; }
  .visual-header { padding: 12px; }
  #fig3d, #fig3d .js-plotly-plot, #fig3d .plot-container, #fig3d .svg-container { height: 440px !important; min-height: 440px !important; }
  #fig2d, #fig2d .js-plotly-plot, #fig2d .plot-container, #fig2d .svg-container { height: 340px !important; min-height: 340px !important; }
}
@media (max-width: 370px) { .metrics-grid { grid-template-columns: 1fr; } }

/* Permanent author branding */
.header-product { min-width: 0; }
.header-eyebrow {
  margin-bottom: 5px;
  color: var(--cyan);
  font-size: 9px;
  line-height: 1;
  letter-spacing: .16em;
  font-weight: 800;
}
.header-brand {
  flex: 0 0 auto;
  min-width: 220px;
  padding: 11px 14px 10px;
  border: 1px solid #cfe0ed;
  border-radius: 11px;
  background: linear-gradient(135deg, #f7fbfe 0%, #edf7fc 100%);
  text-align: right;
}
.author-kicker {
  color: #6c7b8d;
  font-size: 8px;
  line-height: 1.2;
  letter-spacing: .15em;
  font-weight: 800;
}
.author-name {
  margin-top: 3px;
  color: #172033;
  font-size: 17px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.015em;
}

@media (max-width: 620px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .header-brand { width: 100%; min-width: 0; text-align: left; padding: 10px 12px; }
  .author-name { font-size: 16px; }
}
