.mfo-workflow-shell {
  --mfo-sidebar-bg-1: #f8f9fa;
  --mfo-sidebar-bg-2: #f1f3f5;
  --mfo-sidebar-edge: rgba(0, 0, 0, 0.1);
  --mfo-sidebar-width: clamp(270px, 20vw, 330px);
  --mfo-panel-bg: #ffffff;
  --mfo-panel-border: #dee2e6;
  --mfo-panel-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
  --mfo-text-dark: #212529;
  --mfo-text-soft: #6c757d;
  /* Status tokens (mirror FORTRAN_COLORS warning_/success_/
               danger_ in visual_branding.py). Banner text is always
               --mfo-text-dark. --mfo-danger-1/-2 below are separate —
               the Run button's red gradient. */
  --mfo-warning-bg: #fef9c3;
  --mfo-warning-edge: #eab308;
  --mfo-success-bg: #d7f0d3;
  --mfo-success-edge: #3C7F38;
  --mfo-danger-bg: #fee2e2;
  --mfo-danger-edge: #dc2626;
  --mfo-danger-1: #dc3545;
  --mfo-danger-2: #c82333;
  width: 100%;
  box-sizing: border-box;
  /* The Voila output is a fixed viewport. The content panel below owns
             scrolling, so the shell must not grow the notebook output. */
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  /* Visual frame removed — content sits directly on the page
             background. CSS variables above are still consumed by inner
             components (panel cards, sub-tab bar, etc.), so we keep them
             defined here. */
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden !important;
}

.mfo-workflow-shell > .widget-vbox {
  height: 100%;
  min-height: 0;
  overflow: hidden !important;
}

.mfo-workflow-shell .mfo-top-bar {
  flex-shrink: 0 !important;
  overflow: visible !important;
}

.mfo-workflow-shell .mfo-content-container {
  gap: 0 !important;
}

.mfo-workflow-shell .mfo-panel-card {
  min-height: 0 !important;
}

.mfo-workflow-shell .mfo-step-content {
  min-height: 0 !important;
  max-height: none !important;
}

.mfo-workflow-shell .widget-box,
.mfo-workflow-shell .jupyter-widgets.widget-box {
  box-sizing: border-box;
}

.mfo-caption {
  font-size: 0.85rem;
  color: #456148;
}

.mfo-count-number {
  font-size: 1.15rem;
  font-weight: 700;
  color: #112214;
}

.mfo-notice {
  font-size: 0.95rem;
  line-height: 1.4;
  font-weight: 700;
  border-left: 4px solid;
  border-radius: 4px;
  padding: 10px 12px;
}

.mfo-notice--warning {
  color: #7c2d12;
  background: #fff7ed;
  border-left-color: #f59e0b;
}

.mfo-notice--success {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #166534;
  background: #f0fdf4;
  border-left-color: #15803d;
}

/* Plain ipywidgets buttons size to their text instead of clipping
           with an ellipsis. */
.mfo-workflow-shell .jupyter-widgets.jupyter-button {
  min-width: max-content;
}

.mfo-workflow-shell .mfo-objective-slider,
.mfo-workflow-shell .mfo-objective-slider .widget-box,
.mfo-workflow-shell .mfo-objective-slider .jupyter-widgets.widget-box {
  width: 100% !important;
}

.mfo-workflow-shell .mfo-objective-slider .widget-inline-hbox,
.mfo-workflow-shell .mfo-objective-slider .widget-hbox {
  justify-content: flex-start !important;
  align-items: center !important;
}

.mfo-workflow-shell .mfo-objective-slider .widget-label {
  text-align: left !important;
  justify-content: flex-start !important;
  white-space: normal !important;
  padding-right: 10px;
}

.mfo-workflow-shell .mfo-objective-slider .widget-readout {
  text-align: left !important;
  min-width: 64px;
}

.mfo-workflow-shell .mfo-step-content {
  min-width: 0;
  height: auto !important;
  background: var(--mfo-panel-bg);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--mfo-panel-border);
  box-shadow: var(--mfo-panel-shadow);
}

/* Keep controls inside the card and prevent horizontal scrolling. */
.mfo-workflow-shell .mfo-info-card .widget-inline-hbox,
.mfo-workflow-shell .mfo-info-card .widget-toggle-buttons {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  box-sizing: border-box;
}

/* --- Two-level navigation: layout/box rules ---------------------
           Button styles live in main.css, written on the button element
           (`.x` and `.x.widget-button`); a descendant selector matches
           nothing. The rules below target VBox/HBox elements. */
.mfo-workflow-shell .mfo-panel-card {
  /* Hex mirrors FORTRAN_COLORS["neutral_100"] — keep in sync. */
  background: #edf7e8;
  border: 1px solid var(--mfo-panel-border);
  /* No top border: keeps the page from reading as top-heavy. */
  border-top-width: 0;
  border-radius: 14px;
  box-shadow: var(--mfo-panel-shadow);
  overflow: hidden;
  /* Override the .widget-vbox 10px gap so the sub-tab bar sits
               flush against step_content. */
  gap: 0 !important;
}

.mfo-workflow-shell .mfo-panel-card .mfo-step-content {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #edf7e8;
  /* Self-scrolling: only the page content scrolls; top bar and the
               sub-tab bar above stay visible. The active step panel is
               forced to keep its natural height (flex-shrink:0) and full
               horizontal width (width:100%) so it overflows into the
               scrollbar instead of being squished or cramped to one side. */
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  overflow-x: hidden;
  /* Chart and map updates must not trigger automatic scroll anchoring. */
  overflow-anchor: none;
}

.mfo-workflow-shell .mfo-panel-card .mfo-step-content>* {
  flex-shrink: 0 !important;
  width: 100% !important;
}

/* Per-h4-group card. Single source of truth for card look. */
.mfo-workflow-shell .mfo-info-card {
  background: #ffffff;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--mfo-panel-border);
}

/* Plan selection: fill each column with up to three clickable items. */
.mfo-workflow-shell .mfo-compare-selection-title {
  margin: 8px 0 6px 12px;
  font-weight: 600;
  color: #365331;
}

.mfo-workflow-shell .mfo-compare-selection {
  display: grid;
  grid-template-rows: repeat(3, max-content);
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
  overflow-x: auto;
  min-width: 0;
  width: calc(100% - 12px);
  margin: 0 0 4px 12px;
  padding: 6px;
  gap: 4px 8px;
  border: 1px solid #dbe5d7;
  border-radius: 8px;
  background: #f6f8f4;
}

.mfo-workflow-shell .mfo-compare-selection .widget-checkbox {
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 36px;
  margin: 0;
}

.mfo-workflow-shell .mfo-compare-selection .widget-label-basic {
  --mfo-selection-border: #d6d6d6;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 2px solid var(--mfo-selection-border);
  border-radius: 5px;
  color: var(--mfo-text-dark);
  font-weight: 600;
  cursor: pointer;
}

.mfo-workflow-shell .mfo-compare-selection .widget-label-basic:hover {
  background: #eaf0e6;
}

.mfo-workflow-shell .mfo-compare-selection .widget-label-basic:has(input:checked) {
  --mfo-selection-border: var(--mfo-success-edge);
  background: #e3efde;
  color: #2d5427;
}

.mfo-workflow-shell .mfo-compare-selection .widget-label-basic:focus-within {
  outline: 2px solid var(--mfo-selection-border);
  outline-offset: -2px;
}

.mfo-workflow-shell .mfo-compare-selection input[type="checkbox"]:checked + span::before {
  border-right-color: var(--mfo-success-edge);
  border-bottom-color: var(--mfo-success-edge);
}

.mfo-workflow-shell .mfo-compare-selection .widget-label-basic > span {
  height: auto;
  white-space: normal;
  line-height: 1.45;
}

/* Loading overlay. Apply .mfo-loading on any element to dim
           its content and show a centered CSS spinner. Toggled by
           _schedule_with_loading around deferred renders. */
.mfo-workflow-shell .mfo-loading {
  position: relative;
}

.mfo-workflow-shell .mfo-loading>* {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.mfo-workflow-shell .mfo-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border: 4px solid rgba(42, 82, 37, 0.15);
  border-top-color: #2A5225;
  border-radius: 50%;
  animation: mfo-loading-spin 800ms linear infinite;
  z-index: 2;
}

@keyframes mfo-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.mfo-workflow-shell .mfo-subtab-container {
  width: 100%;
  flex-shrink: 0 !important;
}

/* Keep the tab strip outside the content scroller. */
.mfo-workflow-shell .mfo-subtab-bar {
  overflow: visible !important;
  flex-shrink: 0 !important;
}

/* Sub-tab bar: a tab strip on the top edge of the card. */
.mfo-workflow-shell .mfo-subtab-bar {
  width: 100%;
  gap: 4px;
  padding: 6px 10px 0 10px;
  border-bottom: 1px solid var(--mfo-panel-border);
  background: var(--mfo-sidebar-bg-1);
}
