/* ── Flood Optimization panel (CRMT) ── */
#flood-opt-panel.flood-opt-wrap {
    position: absolute;
    z-index: 5200;
    top: 56px;
    right: 93px;
    bottom: auto;
    width: min(52vw, 920px);
    height: min(72vh, 760px);
    min-width: 640px;
    min-height: 420px;
    padding: 4px 12px 12px 6px;
    display: none;
    flex-direction: column;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #e2e8f0;
    background:
        linear-gradient(180deg, rgba(30, 41, 59, 0.72) 0%, rgba(15, 23, 42, 0.86) 100%),
        rgba(11, 17, 28, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.25);
    backdrop-filter: blur(18px) saturate(1.25);
    overflow: hidden;
}

#flood-opt-panel .plot-resize-handle {
    z-index: 6;
    pointer-events: auto;
}

#flood-opt-panel.flood-opt-open {
    display: flex;
}

#flood-opt-panel .flood-opt-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    align-items: start;
    margin: 0 -12px 4px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.10), rgba(148, 163, 184, 0));
    cursor: move;
}

#flood-opt-panel .flood-opt-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#flood-opt-panel .flood-opt-btn--icon.flood-opt-btn--danger:hover:not(:disabled) {
    border-color: rgba(248, 113, 113, 0.55);
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
}

#flood-opt-panel .flood-opt-btn--icon:disabled {
    opacity: 0.35;
    cursor: default;
}

#flood-opt-panel .flood-opt-header-body {
    min-width: 0;
}

#flood-opt-panel.flood-opt-analysis-whole .flood-opt-header,
#flood-opt-panel.flood-opt-analysis-phase .flood-opt-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    cursor: move;
}

#flood-opt-panel.flood-opt-analysis-whole .flood-opt-header-actions,
#flood-opt-panel.flood-opt-analysis-phase .flood-opt-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
}

#flood-opt-panel.flood-opt-analysis-whole .flood-opt-title,
#flood-opt-panel.flood-opt-analysis-phase .flood-opt-title {
    display: block;
    max-width: 100%;
}

#flood-opt-panel.flood-opt-mode-advanced #flood-opt-mode-toggle.is-active {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
}

#flood-opt-panel .flood-opt-mode-toggle {
    width: 88px;
    min-width: 88px;
    max-width: 88px;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(148, 163, 184, 0.12);
    color: #e2e8f0;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-sizing: border-box;
}

#flood-opt-panel .flood-opt-mode-toggle:hover {
    background: rgba(148, 163, 184, 0.22);
}

#flood-opt-panel.flood-opt-mode-advanced .flood-opt-mode-toggle {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
}

#flood-opt-panel .flood-opt-btn--icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
    line-height: 0;
}

/* Match DCA save / icon buttons: explicit SVG box so the glyph does not collapse. */
#flood-opt-panel .flood-opt-btn--icon svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    display: block;
    flex-shrink: 0;
    fill: currentColor;
}

#flood-opt-panel #flood-opt-phase-save svg {
    width: 16px;
    height: 16px;
}

#flood-opt-panel .flood-opt-phase-step-nav {
    /* ADR 010: title may change length; buttons stay in a fixed right column. */
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 8px;
    margin: 2px 0 6px;
    width: 100%;
    flex: 0 0 auto;
    min-height: 28px;
}

#flood-opt-panel .flood-opt-phase-step-title {
    min-width: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #dbe4ee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    text-align: left;
}

#flood-opt-panel .flood-opt-phase-step-nav-btns {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    /* Fixed footprint so disabled opacity never changes click geometry. */
    width: calc(28px + 4px + 28px);
    justify-content: flex-end;
}

#flood-opt-panel .flood-opt-phase-step-nav .flood-opt-btn--icon:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Step title lives in the toolbar; keep <summary> for a11y only. */
#flood-opt-panel .flood-opt-phase-step > summary.flood-opt-phase-step-summary-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Info uses the same rounded square icon button as save/refresh; letter i inside. */
#flood-opt-panel #flood-opt-phase-info {
    font-family: inherit;
    font-style: normal;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
}

#flood-opt-panel .flood-opt-btn--icon.is-active,
#flood-opt-panel .flood-opt-btn--icon[aria-pressed="true"] {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
}

#flood-opt-panel.flood-opt-mode-simple .flood-opt-advanced-only {
    display: none !important;
}

#flood-opt-panel.flood-opt-mode-simple .flood-opt-body {
    grid-template-columns: minmax(0, 1fr);
}

#flood-opt-panel .flood-opt-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #dbe4ee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#flood-opt-panel .flood-opt-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}

#flood-opt-panel .flood-opt-close {
    border: none;
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
}

#flood-opt-panel .flood-opt-close:hover {
    background: rgba(248, 113, 113, 0.25);
    color: #fecaca;
}

#flood-opt-panel .flood-opt-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 4px 0 6px;
    font-size: 12px;
}

#flood-opt-panel .flood-opt-ctl--slider {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#flood-opt-panel .flood-opt-ctl--slider input[type="range"] {
    width: 110px;
    accent-color: #38bdf8;
}

#flood-opt-panel .flood-opt-btn {
    padding: 4px 12px;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.15);
    color: #e0f2fe;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

#flood-opt-panel .flood-opt-btn:hover {
    background: rgba(56, 189, 248, 0.28);
}

#flood-opt-panel .flood-opt-btn--toggle {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
}

#flood-opt-panel .flood-opt-btn--toggle.is-on {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.15);
    color: #e0f2fe;
}

#flood-opt-panel .flood-opt-ctl--bg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#flood-opt-panel .flood-opt-ctl--bg input[type="number"] {
    width: 64px;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.65);
    color: #e2e8f0;
    font-size: 12px;
}

#flood-opt-panel .flood-opt-bg-unit {
    font-size: 10px;
    color: #94a3b8;
}

#flood-opt-panel .flood-opt-ctl--forecast {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    font-size: 12px;
    color: #cbd5e1;
}

#flood-opt-panel .flood-opt-forecast-field {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#flood-opt-panel .flood-opt-forecast-field input[type="number"] {
    width: 72px;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.65);
    color: #e2e8f0;
    font-size: 12px;
}

#flood-opt-panel .flood-opt-forecast-field input#flood-opt-fc-months {
    width: 48px;
}

#flood-opt-panel .flood-opt-chart-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

#flood-opt-panel .flood-opt-unit-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

#flood-opt-panel .flood-opt-unit-chip {
    border: 1px solid color-mix(in srgb, var(--chip-color, #94a3b8) 55%, transparent);
    background: color-mix(in srgb, var(--chip-color, #94a3b8) 18%, transparent);
    color: var(--chip-color, #94a3b8);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 1px 7px;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1.4;
}

#flood-opt-panel .flood-opt-unit-chip.is-hidden {
    opacity: 0.35;
    text-decoration: line-through;
}

#flood-opt-panel .flood-opt-warnings {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

#flood-opt-panel .flood-opt-warn {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
}

#flood-opt-panel .flood-opt-warn--error {
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.15);
    color: #fecaca;
    font-weight: 600;
}

#flood-opt-panel .flood-opt-warn--info {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
}

#flood-opt-panel .flood-opt-status {
    font-size: 11px;
    color: #94a3b8;
    /* ADR 010: reserve two lines so step/status updates never shift Field/Phases or < >. */
    line-height: 1.35;
    min-height: calc(2 * 1.35em);
    max-height: calc(2 * 1.35em);
    padding-bottom: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
}

#flood-opt-panel .flood-opt-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.9fr);
    gap: 10px;
}

#flood-opt-panel .flood-opt-chart-block {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#flood-opt-panel .flood-opt-chart-block--history {
    flex: 1 1 auto;
}

#flood-opt-panel .flood-opt-chart-title {
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 2px;
}

#flood-opt-panel .flood-opt-canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 180px;
}

#flood-opt-panel .flood-opt-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

#flood-opt-panel .flood-opt-plot-grid {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) 14px;
    grid-template-rows: minmax(0, 1fr) 14px;
    flex: 1 1 auto;
    min-height: 180px;
    min-width: 0;
}

#flood-opt-panel .flood-opt-canvas-host {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    min-height: 0;
    min-width: 0;
}

#flood-opt-panel .flood-opt-canvas-host canvas {
    width: 100% !important;
    height: 100% !important;
}

#flood-opt-panel .flood-opt-y-wrap {
    grid-row: 1;
    display: flex;
    width: 14px;
    min-width: 14px;
    min-height: 0;
}

#flood-opt-panel #flood-opt-scrollbar-y-oil-wrap {
    grid-column: 1;
}

#flood-opt-panel #flood-opt-scrollbar-y-inj-wrap {
    grid-column: 3;
}

#flood-opt-panel #flood-opt-scrollbar-x-wrap {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    height: 14px;
    min-height: 14px;
    width: 100%;
}

#flood-opt-panel .flood-opt-corner-bl {
    grid-column: 1;
    grid-row: 2;
}

#flood-opt-panel .flood-opt-corner-br {
    grid-column: 3;
    grid-row: 2;
}

#flood-opt-panel .flood-opt-fit-window-readout {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
}

#flood-opt-panel .flood-opt-side {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow: auto;
}

#flood-opt-panel #flood-opt-heat-canvas {
    width: 100%;
    max-width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

#flood-opt-panel .flood-opt-heat-legend {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
}

#flood-opt-panel .flood-opt-diag {
    font-size: 11px;
    color: #cbd5e1;
}

#flood-opt-panel .flood-opt-diag-title {
    font-weight: 600;
    margin-bottom: 4px;
}

#flood-opt-panel .flood-opt-diag-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 6px;
}

#flood-opt-panel .flood-opt-diag-table th,
#flood-opt-panel .flood-opt-diag-table td {
    text-align: left;
    padding: 2px 4px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    font-weight: 400;
}

#flood-opt-panel .flood-opt-diag-table th {
    color: #94a3b8;
    width: 3.2rem;
}

#flood-opt-panel .flood-opt-diag-line {
    margin-bottom: 2px;
    line-height: 1.35;
}

#flood-opt-panel .flood-opt-diag-line.muted {
    color: #64748b;
    font-size: 10px;
}

@media (max-width: 900px) {
    #flood-opt-panel .flood-opt-body {
        grid-template-columns: 1fr;
    }
}

#flood-opt-panel .flood-opt-alerts-panel,
#flood-opt-panel .flood-opt-settings-panel {
    margin: 0 0 6px;
    padding: 8px 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.72);
    max-height: 220px;
    overflow: auto;
}

#flood-opt-panel .flood-opt-settings-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    font-size: 11px;
}

#flood-opt-panel .flood-opt-settings-grid .flood-opt-ctl input[type="number"] {
    width: 64px;
    margin-left: 4px;
}

#flood-opt-panel .flood-opt-alert-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 7px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    line-height: 14px;
    text-align: center;
    font-weight: 700;
}

#flood-opt-panel #flood-opt-alerts-btn {
    position: relative;
}

#flood-opt-panel #flood-opt-alerts-btn.has-alerts {
    border-color: rgba(248, 113, 113, 0.7);
    color: #fecaca;
}

#flood-opt-panel .flood-opt-alert-icon {
    font-weight: 800;
    font-size: 13px;
}

#flood-opt-panel .flood-opt-controls,
#flood-opt-panel .flood-opt-econ-controls,
#flood-opt-panel .flood-opt-chart-block--econ,
#flood-opt-panel .flood-opt-diag-plots {
    display: none !important;
}

/* ── Phase (cohort) workspace ── */
#flood-opt-panel .flood-opt-analysis-mode {
    display: flex;
    gap: 6px;
    margin: 4px 0 6px;
}

#flood-opt-panel .flood-opt-analysis-mode .flood-opt-btn--toggle.is-active {
    border-color: rgba(56, 189, 248, 0.55);
    background: rgba(56, 189, 248, 0.2);
    color: #e0f2fe;
}

#flood-opt-panel .flood-opt-phase-workspace {
    max-height: 42%;
    overflow: auto;
    margin-bottom: 6px;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.45);
}

#flood-opt-panel .flood-opt-phase-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

#flood-opt-panel .flood-opt-phase-run-picker {
    position: relative;
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 320px;
}

#flood-opt-panel .flood-opt-phase-run-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 28px;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}

#flood-opt-panel .flood-opt-phase-run-trigger:hover {
    border-color: rgba(148, 163, 184, 0.55);
}

#flood-opt-panel .flood-opt-phase-run-trigger-label {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

#flood-opt-panel .flood-opt-phase-run-trigger-prefix {
    flex: 0 0 auto;
}

#flood-opt-panel .flood-opt-phase-run-trigger-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

#flood-opt-panel .flood-opt-phase-run-trigger-name.is-renamable {
    cursor: text;
    text-decoration: underline dotted rgba(148, 163, 184, 0.55);
    text-underline-offset: 2px;
}

#flood-opt-panel .flood-opt-phase-run-rename-input {
    width: 100%;
    min-width: 0;
    padding: 0 2px;
    margin: 0;
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
    font: inherit;
    line-height: 1.3;
}

#flood-opt-panel .flood-opt-phase-run-trigger-caret {
    flex: 0 0 auto;
    opacity: 0.75;
}

#flood-opt-panel .flood-opt-phase-run-select[hidden] {
    display: none !important;
}

/* Fixed + high z so the list is not clipped by panel overflow */
.flood-opt-phase-run-menu {
    margin: 0;
    padding: 4px 0;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.flood-opt-phase-run-menu[hidden] {
    display: none !important;
}

.flood-opt-phase-run-option {
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.35;
    cursor: pointer;
}

.flood-opt-phase-run-option:hover,
.flood-opt-phase-run-option:focus {
    background: rgba(56, 189, 248, 0.18);
    outline: none;
}

.flood-opt-phase-run-option.is-selected {
    background: rgba(56, 189, 248, 0.28);
}

#flood-opt-panel .flood-opt-phase-banner {
    margin: 4px 0 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fde68a;
    font-size: 11px;
}

#flood-opt-panel .flood-opt-phase-warn {
    font-size: 11px;
    color: #cbd5e1;
    margin: 2px 0;
}

#flood-opt-panel .flood-opt-phase-step {
    margin: 6px 0;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    padding: 4px 8px;
    background: rgba(30, 41, 59, 0.35);
}

#flood-opt-panel .flood-opt-phase-step > summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
    color: #e2e8f0;
}

#flood-opt-panel .flood-opt-phase-step.is-locked {
    opacity: 0.55;
    pointer-events: none;
}

#flood-opt-panel .flood-opt-phase-step2-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

#flood-opt-panel .flood-opt-phase-step2-controls .flood-opt-ctl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#flood-opt-panel .flood-opt-phase-step2-controls input[type="number"] {
    width: 4.2em;
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    padding: 2px 4px;
}

#flood-opt-panel .flood-opt-ctl-unit {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

#flood-opt-panel .flood-opt-phase-step2-status {
    font-size: 11px;
    color: #cbd5e1;
    margin-bottom: 6px;
}

#flood-opt-panel .flood-opt-phase-well-list {
    margin: 8px 0;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.35);
}

#flood-opt-panel .flood-opt-phase-well-list > summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    padding: 4px 0;
}

#flood-opt-panel .flood-opt-phase-summary-host,
#flood-opt-panel .flood-opt-phase-map-legend {
    margin: 4px 0 8px;
}

#flood-opt-panel .flood-opt-phase-summary-line {
    font-size: 12px;
    font-weight: 650;
    color: #e2e8f0;
    margin-bottom: 6px;
}

#flood-opt-panel .flood-opt-phase-summary-note {
    margin-top: 6px;
    font-size: 11px;
    color: #fbbf24;
}

#flood-opt-panel .flood-phase-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #e2e8f0;
    cursor: pointer;
    font-family: inherit;
}

#flood-opt-panel .flood-phase-chip:hover {
    border-color: rgba(148, 163, 184, 0.55);
    background: rgba(148, 163, 184, 0.2);
}

#flood-opt-panel .flood-phase-chip.is-active {
    border-color: rgba(56, 189, 248, 0.7);
    background: rgba(56, 189, 248, 0.15);
}

#flood-opt-panel .flood-opt-phase-step4-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

#flood-opt-panel .flood-opt-phase-step4-status {
    font-size: 11px;
    color: #cbd5e1;
    margin-bottom: 6px;
}

#flood-opt-panel .flood-phase-fit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 4px;
}

#flood-opt-panel .flood-phase-fit-table th,
#flood-opt-panel .flood-phase-fit-table td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    padding: 3px 4px;
    text-align: left;
}

#flood-opt-panel .flood-phase-fit-table tr.is-warn td {
    color: #fbbf24;
}

#flood-opt-panel .flood-phase-fit-table tr.flood-phase-fit-row {
    cursor: pointer;
}

#flood-opt-panel .flood-phase-fit-table tr.flood-phase-fit-row:hover td {
    background: rgba(148, 163, 184, 0.08);
}

#flood-opt-panel .flood-phase-fit-table tr.flood-phase-fit-row.is-active td {
    background: rgba(59, 130, 246, 0.18);
}


#flood-opt-panel .flood-phase-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin: 6px 0;
}

#flood-opt-panel .flood-phase-table th,
#flood-opt-panel .flood-phase-table td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    padding: 3px 4px;
    text-align: left;
    vertical-align: top;
}

#flood-opt-panel .flood-phase-table input,
#flood-opt-panel .flood-phase-table select {
    width: 100%;
    max-width: 110px;
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    font-size: 11px;
}

#flood-opt-panel .flood-phase-signals {
    color: #94a3b8;
    max-width: 160px;
}

#flood-opt-panel .flood-phase-legend {
    font-size: 11px;
    color: #e2e8f0;
}

#flood-opt-panel .flood-phase-legend-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
}

#flood-opt-panel .flood-phase-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

#flood-opt-panel .flood-phase-swatch--unclassified {
    background: #9aa0a6;
    border: 1px dashed #cfd8dc;
}

#flood-opt-panel.flood-opt-analysis-phase {
    /* Size comes from JS (positionPanelForCompactMode / user resize). Do not lock
       width/height with !important — that made corner grips only move the panel. */
    min-width: 280px;
    min-height: 180px;
    max-width: min(92vw, 980px);
    max-height: min(90vh, 860px);
}

#flood-opt-panel.flood-opt-analysis-whole {
    min-width: 280px;
    min-height: 180px;
    max-width: min(92vw, 980px);
    max-height: min(90vh, 860px);
}

#flood-opt-panel.flood-opt-analysis-phase .flood-opt-body,
#flood-opt-panel.flood-opt-analysis-phase .flood-opt-side,
#flood-opt-panel.flood-opt-analysis-phase .flood-opt-advanced-only,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-optimize,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-shutin,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-diag-toggle,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-mode-toggle,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-legend-btn,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-alerts-btn,
#flood-opt-panel.flood-opt-analysis-phase #flood-opt-settings-btn {
    display: none !important;
}

/* Field compact: hide in-panel HM chart; keep Optimize / Shut-in / Diagnostics / Settings */
#flood-opt-panel.flood-opt-analysis-whole .flood-opt-advanced-only,
#flood-opt-panel.flood-opt-analysis-whole .flood-opt-body,
#flood-opt-panel.flood-opt-analysis-whole .flood-opt-side,
#flood-opt-panel.flood-opt-analysis-whole #flood-opt-legend-btn {
    display: none !important;
}

#flood-opt-panel.flood-opt-analysis-whole .flood-opt-field-workspace {
    max-height: none;
    flex: 1 1 auto;
    overflow: auto;
    padding-bottom: 8px;
}

#flood-opt-panel.flood-opt-analysis-whole .flood-opt-status {
    font-size: 11px;
    line-height: 1.35;
    min-height: calc(2 * 1.35em);
    max-height: calc(2 * 1.35em);
    margin: 2px 0 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

#flood-opt-panel .flood-opt-field-metrics {
    margin-top: 6px;
    font-size: 12px;
    color: #e2e8f0;
}

#flood-opt-panel .flood-opt-field-metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
}

#flood-opt-panel.flood-opt-analysis-phase .flood-opt-phase-workspace {
    max-height: none;
    flex: 1 1 auto;
    overflow: auto;
    padding-bottom: 8px;
}

#flood-opt-panel.flood-opt-analysis-phase .flood-opt-status {
    font-size: 11px;
    line-height: 1.35;
    min-height: calc(2 * 1.35em);
    max-height: calc(2 * 1.35em);
    margin: 2px 0 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

#flood-opt-panel.flood-opt-analysis-phase .flood-opt-header {
    padding-bottom: 4px;
}

#flood-opt-panel.flood-opt-analysis-phase .flood-opt-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #dbe4ee;
    line-height: 1.25;
}

#flood-opt-panel .flood-opt-phase-info-panel {
    margin: 4px 0 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.25);
    max-height: 160px;
    overflow: auto;
    font-size: 11px;
}

#flood-opt-panel .flood-opt-phase-info-line {
    margin-bottom: 4px;
    color: #cbd5e1;
}

#flood-opt-panel #flood-opt-phase-info.is-active {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
}

#flood-opt-panel .flood-opt-phase-step[hidden] {
    display: none !important;
}

#flood-opt-panel .flood-phase-legend-note {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 10px;
}

/* Map canvas phase names (not inside the flood panel) — clickable → history plot. */
.flood-phase-map-label {
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
}
