/* Exact Tkinter UI Replication */
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: transparent; margin: 0; padding: 0; font-size: 13px; color: #000; }
.app-shell {
    max-width: 1400px;
    margin: 12px auto;
    padding: 24px 30px 40px;
    background:
        linear-gradient(165deg, rgba(248, 251, 255, 0.92) 0%, rgba(233, 240, 249, 0.9) 50%, rgba(227, 235, 246, 0.88) 100%),
        radial-gradient(1200px 420px at 10% -20%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 65%);
    box-shadow: 0 24px 60px rgba(8, 23, 53, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.38);
    border: 1px solid rgba(168, 186, 216, 0.35);
    border-radius: 14px;
    overflow: hidden;
    min-height: calc(100vh - 24px);
    position: relative;
    backdrop-filter: blur(2px);
}

/* Header Layout */
.top-header { display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start; margin-bottom: 16px; margin-top: 0;}
.corner-logo {
    position: static;
    z-index: 1;
    pointer-events: none;
    margin-bottom: 4px;
    line-height: 0;
}
.corner-logo img {
    max-width: 250px;
    width: 100%;
    height: auto;
    display: block;
    opacity: 1;
    filter: url(#logo-color-filter);
}
.stages-box { background-color: #003A40; padding: 12px 20px; border: 1px solid #003A40; border-radius: 4px; color: rgba(255,255,255,0.92); font-size: 12px; line-height: 1.6; box-shadow: 0 8px 20px rgba(0, 58, 64, 0.25); }
.stages-box strong { font-weight: bold; color: #ffffff; font-size: 13px; display: block; margin: 2px 0; }
.stages-box { margin-top: 0; }

.title-h1 { font-size: 20px; font-weight: bold; margin: 0 0 5px 0; }
.subtitle { font-size: 11px; font-style: italic; margin: 0 0 20px 0; color: #555; }

/* Tabs */
.tabs-header { display: flex; border-bottom: 1px solid #ccc; margin-bottom: 15px; }
.tab-btn { padding: 8px 16px; cursor: pointer; border: 1px solid #003A40; background: #003A40; font-size: 14px; color: #fff; border-radius: 8px 8px 0 0; }
.tab-btn:hover { filter: brightness(1.08); }
.tab-btn.active { background: #005159; border-color: #005159; margin-bottom: -1px; font-weight: bold; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Fieldsets & Inputs */
fieldset { border: 1px solid rgba(122, 142, 172, 0.45); border-radius: 6px; padding: 12px 15px; margin: 0 0 15px 0; background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(250,252,255,0.3)); }
legend { font-weight: bold; font-size: 13px; color: #000; padding: 0 5px; background: transparent;}

.row { display: flex; align-items: center; margin-bottom: 8px; }
.row label { width: 350px; flex-shrink: 0; }
.row input[type="text"], .row select { flex-grow: 1; padding: 4px 6px; border: 1px solid #a0a0a0; font-family: 'Segoe UI', sans-serif; font-size: 13px; box-sizing: border-box; }

.btn-calc { padding: 4px 12px; background: #003A40; border: 1px solid #003A40; border-radius: 8px; font-size: 13px; color: #fff; cursor: pointer; }
.btn-calc:hover { filter: brightness(1.08); }
.btn-calc:disabled { background: #f0f0f0; color: #a0a0a0; border-color: #ccc; cursor: not-allowed; }
.btn-back {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 20;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #003A40;
    background: #003A40;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 58, 64, 0.36);
    transition: transform 0.18s ease, filter 0.18s ease;
}
.btn-back:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* Dynamic Grids */
.pcp-grid { display: grid; grid-template-columns: 80px 1fr 1fr 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 5px; }
.pcp-grid.opt { grid-template-columns: 80px 1fr 1fr 1fr 1fr; } /* 5 columns for optimization (center is auto-computed) */
.pcp-grid label { font-weight: bold; font-size: 12px; margin-bottom: 2px; }
.pcp-grid input { width: 100%; padding: 4px; border: 1px solid #a0a0a0; box-sizing: border-box; }

.run-grid { display: grid; grid-template-columns: 120px 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 5px; }
.run-grid label { font-weight: bold; font-size: 12px; margin-bottom: 2px; }
.run-grid input { width: 100%; padding: 4px; border: 1px solid #a0a0a0; box-sizing: border-box; }

/* Reproducibility Subject ID / PMP grid */
.pcp-grid-repro-pmp { display: grid; gap: 8px; align-items: center; margin-bottom: 5px; }
.pcp-grid-repro-pmp label { font-weight: bold; font-size: 12px; margin-bottom: 2px; }
.pcp-grid-repro-pmp input { width: 100%; padding: 4px; border: 1px solid #a0a0a0; box-sizing: border-box; }
.pmp-header-cell { display: flex; flex-direction: column; gap: 4px; }
.pmp-header-cell input { font-size: 11px; padding: 3px; }

/* Textareas and Canvas */
textarea { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #a0a0a0; font-family: 'Segoe UI', Tahoma, sans-serif; font-size: 13px; resize: vertical; background: #fff; line-height: 1.4; outline: none; }
textarea[readonly] { background: #f9f9f9; color: #333; cursor: default; }

.bottom-split { display: flex; gap: 15px; align-items: stretch; margin-top: 5px; }
.bottom-split textarea { flex: 2; height: 280px; }
.canvas-container { flex: 1; background: #fff; border: 1px solid #a0a0a0; padding: 0; min-width: 440px; display: flex; justify-content: center; align-items: center;}
canvas { background: transparent; width: 100%; max-width: 720px; }

/* Alert Banner */
.alert-banner { margin: 0 0 15px; padding: 12px 40px 12px 14px; border-radius: 4px; position: relative; font-size: 13px; line-height: 1.5; display: none; }
.alert-error { background: #fdecea; border: 1px solid #f3a6a0; color: #7a1f1a; }
.alert-banner strong { display: block; margin-bottom: 4px; }
.alert-close { position: absolute; top: 6px; right: 8px; background: #003A40; border: 1px solid #003A40; color: #fff; border-radius: 8px; font-size: 16px; line-height: 1; padding: 2px 6px; cursor: pointer; }

.link-text { color: #1f5fbf; cursor: pointer; text-decoration: underline; }

.page-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(7, 18, 44, 0.72), rgba(16, 35, 77, 0.62));
    backdrop-filter: blur(2px);
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.page-loading-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.page-loading-card {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(191, 206, 228, 0.5);
    background: rgba(20, 22, 58, 0.78);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.page-loading-overlay.page-loading-error .page-loading-card {
    flex-direction: column;
    text-align: center;
    max-width: 360px;
    gap: 8px;
    padding: 18px 22px;
    border-color: rgba(240, 179, 160, 0.6);
    background: rgba(58, 22, 22, 0.85);
}
.page-loading-error-icon {
    font-size: 28px;
    color: #ff8a80;
}
.page-loading-reload-btn {
    margin-top: 4px;
}
.loading-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(191, 206, 228, 0.35);
    border-top-color: #bfcee4;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.svg-defs { position: absolute; }
.landing-backdrops-fixed { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; }
.plain-link { text-decoration: none; }

.stage-select-note { margin: 5px 0; }
.stage-heading { margin: 0 0 5px 0; font-size: 16px; }
.stage-heading-spacious { margin-bottom: 10px; }
.stage-subtitle-note { font-size: 11px; margin-bottom: 15px; }
.lead-bold-tight { font-weight: bold; margin-bottom: 5px; }
.paragraph-spacious { margin-bottom: 15px; }

.note-muted-normal { color: #555; font-weight: normal; }
.variability-help-text { font-size: 11px; color: #555; margin: -5px 0 10px 0; }

.inline-controls { display: flex; gap: 10px; align-items: center; }
.inline-controls-grow { display: flex; gap: 10px; align-items: center; flex-grow: 1; }

#entry_repro_pct,
#entry_repro_count { max-width: 100px; }

.btn-top-gap { margin-top: 5px; }
.btn-bottom-gap { margin-bottom: 10px; }
.hidden-item { display: none; }

#repro_stats_label { margin-bottom: 5px; }
#repro_status_label { font-weight: bold; font-size: 14px; margin-bottom: 10px; }
.repro-canvas-container { height: 280px; }
#repro_variability_help { display: none; margin-top: 15px; }

#entry_pcp_count,
#entry_opt_k { width: 80px; }

#combo_doe_type { width: 250px; flex-grow: 0; }
.hint-muted { color: #4d4d4d; font-size: 12px; }
.hint-text { font-size: 12px; margin-bottom: 10px; }
.action-row { display: flex; gap: 8px; margin-bottom: 15px; }
.fieldset-spacious-top { margin-top: 15px; }
.btn-rank-hidden { margin-top: 10px; display: none; }

.paragraph-compact { margin-bottom: 10px; }
.paragraph-muted { color: #555; margin-bottom: 10px; }
.paragraph-muted-alt { color: #4d4d4d; margin-bottom: 15px; }
.paragraph-muted-zero-top { color: #555; margin-top: 0; }

#entry_opt_center { max-width: 80px; }

#opt_summary_label { color: #2f855a; margin-top: 10px; white-space: pre-wrap; }
#opt_keyset_label { color: #1f4e79; font-weight: bold; font-size: 14px; margin-top: 5px; white-space: pre-wrap; }

.pcp-grid-repro { grid-template-columns: 120px 1fr; }

/* Dual-objective and factor-type controls */
#row_moi2_name, #row_moi2_objective { display: none; }
.repro-pct2-label { display: none; margin-left: 20px; width: auto; flex-shrink: 0; }
.repro-pct2-input { display: none; max-width: 100px; }
#repro_inputs_container2_wrap { display: none; }
#repro_canvas2_wrap { display: none; }
#pareto_frame2_wrap { display: none; }
#row_opt_moi_weight { display: none; }
#repro_stats_label2 { margin-bottom: 5px; }
#repro_status_label2 { font-weight: bold; font-size: 14px; margin-bottom: 10px; }
#row_opt_moi_weight input { max-width: 100px; }
#row_opt_actions { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; margin: 10px 0; }
.opt-action-col { flex: 1 1 300px; min-width: 260px; }
.opt-action-col p.paragraph-muted-zero-top { margin-top: 0; margin-bottom: 6px; }
#col_adaptive_axial { border-left: 1px solid #dcdcdc; padding-left: 24px; }

.repro-correlation-canvas-container,
.stage4-viz-canvas-container { min-width: 100%; }
.correlation-stats-text { font-size: 12px; color: #444; margin-bottom: 8px; line-height: 1.4; }

#result_box_opt, #result_box_scr {
    font-family: "Consolas", "Courier New", monospace;
    white-space: pre;
    overflow-x: auto;
}


