body {
    font-family: Arial, sans-serif;
}

/* Status Message Styles */
.status-message {
    margin: 15px 0;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
}

.status-message .loading {
    color: #007bff;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
}

.status-message .success {
    color: #28a745;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.status-message .error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

/* 3D Parameter Space Tab Styles */
.control-group {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.control-group h3 {
    display: block;
    width: 100%;
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.param-row label {
    font-weight: bold;
    min-width: 120px;
    margin: 0;
}

.param-row input[type="number"] {
    width: 80px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.primary-button {
    background-color: var(--accent, #4a7cff);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family, 'Inter', sans-serif);
    transition: background 0.15s;
}

.primary-button:hover {
    background-color: var(--accent-hover, #3a65d4);
}

.primary-button:disabled {
    background-color: var(--text-muted, #8e95a3);
    cursor: not-allowed;
}

.primary-button:disabled:hover {
    background-color: var(--text-muted, #8e95a3);
}

.secondary-button {
    background-color: var(--bg-secondary, #f5f6f8);
    color: var(--text-primary, #1a1d23);
    border: 1px solid var(--border, #e2e5ea);
    padding: 10px 20px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family, 'Inter', sans-serif);
    transition: all 0.15s;
}

.secondary-button:hover {
    border-color: var(--accent, #4a7cff);
    color: var(--accent, #4a7cff);
}

.plot-container {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: white;
}

.plot-container h3 {
    margin-top: 0;
    color: #333;
}

.results-table {
    margin: 20px 0;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.data-table th,
.data-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.data-table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tr:hover {
    background-color: #f5f5f5;
}

.loading {
    color: #007bff;
    font-weight: bold;
    padding: 10px;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 5px;
}

.success {
    color: #28a745;
    font-weight: bold;
    padding: 10px;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
}

.error {
    color: #dc3545;
    font-weight: bold;
    padding: 10px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
}

#paramSpace3DStatus {
    margin: 20px 0;
}

#paramSpace3DPlots {
    margin: 20px 0;
}

#paramSpace3DTable {
    margin: 20px 0;
}

button {
    margin: 0px;
    padding: 10px 20px;
    font-size: 16px;
}

#data-window {
    position:absolute; width:100%; height:100%; background: var(--bg-primary, #fff); border: none; overflow:auto;
}

.popup-container {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

#sliderContainer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin: 20px auto;
}

#sliderContainer label {
    display: block;
    text-align: center;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="range"] {
    /* -webkit-appearance: none; */
    height: 8px;
    background: #d3d3d3;
    border-radius: 5px;
}

input[type="range"]::-webkit-slider-thumb {
    /* -webkit-appearance: none; */
    width: 16px;
    height: 16px;
    /* background: gray; */
    border-radius: 50%;
    cursor: pointer;
}


p {
    margin: 5px;
}

h4 {
    margin: 5px;
}

.popup-content {
    position: relative;
    margin: 10% auto;
    padding: 20px;
    width: 80%;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    margin: 0px;
}

.tabs {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-secondary, #f5f6f8);
    border-bottom: 2px solid var(--border, #e2e5ea);
    padding: 0 var(--space-md, 16px);
    margin-bottom: 0;
    height: 48px;
    font-family: var(--font-family, 'Inter', sans-serif);
    position: relative;
    z-index: 5;
}

.tablink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-lg, 24px);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary, #5f6673);
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

.tablink:hover {
    color: var(--text-primary, #1a1d23);
    background: transparent;
}

.tablink.active {
    color: var(--accent, #4a7cff);
    border-bottom-color: var(--accent, #4a7cff);
    font-weight: 600;
}

.tab-chevron {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.5;
}

.tab-dropdown {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.tab-dropdown.active > .tab-dropdown-trigger {
    color: var(--accent, #4a7cff);
    border-bottom-color: var(--accent, #4a7cff);
    font-weight: 600;
}

.tab-dropdown-trigger {
    padding: 0 var(--space-md, 16px);
}

.tab-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #e2e5ea);
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1));
    padding: var(--space-xs, 4px) 0;
    z-index: 100;
    margin-top: 2px;
    overflow: hidden;
}

.tab-dropdown:hover .tab-dropdown-menu,
.tab-dropdown:focus-within .tab-dropdown-menu {
    display: block;
}

.tab-dropdown-menu .tablink {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--space-sm, 8px) var(--space-md, 16px);
    font-size: 13px;
    font-weight: 400;
    color: var(--text-primary, #1a1d23);
    border-bottom: none;
    margin-bottom: 0;
    border-radius: 0;
    transition: background 0.1s;
}

.tab-dropdown-menu .tablink:hover {
    background: var(--accent-light, rgba(74,124,255,0.08));
    color: var(--accent, #4a7cff);
}

.tab-dropdown-menu .tablink.active {
    color: var(--accent, #4a7cff);
    background: var(--accent-light, rgba(74,124,255,0.08));
    font-weight: 500;
    border-bottom: none;
}

.tab-dropdown-divider {
    height: 1px;
    background: var(--border, #e2e5ea);
    margin: var(--space-xs, 4px) 0;
}

/* Premium (researcher) menu items: visible for everyone, greyed + locked
   until the user has access. Unlocking removes .locked (see unlockResearcherFeatures). */
.tab-dropdown-menu .tablink.premium {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.tab-dropdown-menu .tablink.premium .tab-lock {
    font-size: 11px;
    opacity: 0.75;
    flex: 0 0 auto;
}
.tab-dropdown-menu .tablink.premium:not(.locked) .tab-lock {
    display: none;   /* unlocked → behaves like a normal item */
}
.tab-dropdown-menu .tablink.premium.locked {
    color: var(--text-secondary, #9aa0aa);
    opacity: 0.6;
    cursor: not-allowed;
}
.tab-dropdown-menu .tablink.premium.locked:hover {
    background: transparent;
    color: var(--text-secondary, #9aa0aa);
}

/* Upgrade prompt dialog */
.upgrade-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
}
.upgrade-dialog {
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1d23);
    border-radius: 12px;
    padding: 24px 26px 20px;
    max-width: 440px;
    width: calc(100% - 48px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.22);
    font-family: 'Inter', sans-serif;
}
.upgrade-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent, #4a7cff);
    background: rgba(74,124,255,0.1);
    border: 1px solid rgba(74,124,255,0.3);
    border-radius: 999px;
    padding: 4px 12px;
    margin-bottom: 12px;
}
.upgrade-dialog h3 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
}
.upgrade-dialog p {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary, #5f6673);
}
.upgrade-dialog .upgrade-sub { font-size: 13px; }
.upgrade-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}
.upgrade-actions .button {
    background: var(--accent, #4a7cff);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.upgrade-actions .button:hover { filter: brightness(0.95); }

.tabcontent {
    display: none;
    padding-left: 20px;
    width: 100%;
}

#Canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    padding-left: 0;
}

.tabcontent.active {
    display: block;
}


.rebuildButtonContainer {
    display: none;
}

.chart-wrapper {
    position: relative;
    height: 400px;
    width: 100%;
}

#timeSeriesChart,
#timeSeriesChartSmooth {
    width: 100% !important;
    height: 100% !important;
}

#smoothWindowForm {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

#smoothWindowForm label, #smoothWindowForm input {
    margin: 0;
}

/* Stage 3 controlled structural editor */
#StructuralEdits {
    padding: 0;
    overflow: auto;
    height: calc(100vh - 48px);
}

.se-shell {
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px 28px 72px;
    color: var(--text-primary, #1a1d23);
    font-family: var(--font-family, 'Inter', sans-serif);
}

.se-heading,
.se-pane-heading,
.se-transaction-actions,
.se-path-builder {
    display: flex;
    align-items: center;
}

.se-heading {
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border, #e2e5ea);
}

.se-heading h2,
.se-pane-heading h3 {
    margin: 0;
    letter-spacing: 0;
}

.se-heading h2 { font-size: 20px; }
.se-pane-heading h3 { font-size: 14px; }

.se-graph-summary {
    margin-top: 5px;
    color: var(--text-secondary, #5f6673);
    font-size: 12px;
}

.se-stage-badge,
.se-count,
.se-rule-strip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border, #e2e5ea);
    background: var(--bg-secondary, #f5f6f8);
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
    font-weight: 600;
}

.se-stage-badge { padding: 5px 9px; border-radius: 4px; }
.se-count { min-width: 22px; height: 20px; margin-left: 5px; border-radius: 10px; }

.se-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
    gap: 28px;
    padding: 22px 0;
    border-bottom: 1px solid var(--border, #e2e5ea);
}

.se-pane { min-width: 0; }
.se-pane + .se-pane { border-left: 1px solid var(--border, #e2e5ea); padding-left: 28px; }
.se-pane-heading { justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.se-pane-heading select,
.se-action-fields input,
.se-action-fields select,
.se-safety select,
.se-path-builder select {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--border, #d7dbe2);
    border-radius: 4px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1d23);
    padding: 6px 8px;
    font: inherit;
    font-size: 12px;
}

.se-kind-control {
    display: inline-grid;
    grid-template-columns: repeat(4, auto);
    border: 1px solid var(--border, #d7dbe2);
    border-radius: 4px;
    overflow: hidden;
}

.se-kind-button {
    min-height: 32px;
    padding: 0 9px;
    border: 0;
    border-right: 1px solid var(--border, #d7dbe2);
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #5f6673);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
}

.se-kind-button:last-child { border-right: 0; }
.se-kind-button:hover { color: var(--accent, #4a7cff); }
.se-kind-button.active {
    background: var(--accent, #4a7cff);
    color: #fff;
}
.se-action-fields { min-height: 156px; }
.se-field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.se-field-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.se-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
    font-weight: 600;
}

.se-formula-settings {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border, #e2e5ea);
}

.se-formula-settings summary,
.se-safety summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
}

.se-formula-row {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-top: 9px;
}

.se-formula-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
    font-weight: 600;
}

.se-queue-button { margin-top: 14px; }

.se-text-button,
.se-icon-button,
.se-remove-button {
    border: 0;
    background: transparent;
    color: var(--text-secondary, #5f6673);
    cursor: pointer;
    font: inherit;
}

.se-text-button { font-size: 12px; padding: 5px; }
.se-text-button:hover { color: var(--accent, #4a7cff); }
.se-icon-button,
.se-remove-button { width: 30px; height: 30px; font-size: 18px; }
.se-icon-button { border: 1px solid var(--border, #d7dbe2); border-radius: 4px; flex: 0 0 30px; }
.se-remove-button:hover { color: #c0392b; }

.se-queue {
    max-height: 260px;
    overflow: auto;
    border-top: 1px solid var(--border, #e2e5ea);
}

.se-empty {
    padding: 28px 8px;
    color: var(--text-secondary, #8a9099);
    font-size: 12px;
    text-align: center;
}

.se-queue-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 34px;
    align-items: center;
    min-height: 48px;
    border-bottom: 1px solid var(--border, #e2e5ea);
    font-size: 12px;
}

.se-queue-kind { font-weight: 650; }
.se-queue-detail { color: var(--text-secondary, #5f6673); overflow-wrap: anywhere; }

.se-safety {
    padding: 18px 0;
    border-bottom: 1px solid var(--border, #e2e5ea);
}

.se-rule-strip { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0 16px; }
.se-rule-strip span { padding: 4px 8px; border-radius: 3px; }
.se-safety-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.se-safety select[multiple] { min-height: 116px; padding: 3px; }
.se-safety select[multiple] option { padding: 5px 7px; }
.se-field-label { color: var(--text-secondary, #5f6673); font-size: 11px; font-weight: 600; }
.se-path-builder { gap: 8px; margin-top: 5px; }
.se-path-list { margin-top: 8px; max-height: 72px; overflow: auto; }
.se-path-item { display: flex; align-items: center; justify-content: space-between; min-height: 30px; border-bottom: 1px solid var(--border, #e2e5ea); font-size: 11px; }

.se-transaction-actions { justify-content: flex-end; padding: 18px 0; }
.se-result { border-top: 1px solid var(--border, #e2e5ea); padding-top: 18px; }
.se-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.se-result-heading h3 { margin: 0; font-size: 14px; }
.se-result-status { font-weight: 700; }
.se-result-status--accepted { color: #16854c; }
.se-result-status--rejected { color: #b4453b; }
.se-result-reason { margin: 10px 0 0; color: var(--text-secondary, #5f6673); font-size: 12px; line-height: 1.5; }
.se-result-metrics { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; font-size: 12px; color: var(--text-secondary, #5f6673); }
.se-apply-row { display: flex; justify-content: flex-end; margin-top: 16px; }

@media (max-width: 980px) {
    .se-workspace { grid-template-columns: 1fr; }
    .se-pane + .se-pane { border-left: 0; border-top: 1px solid var(--border, #e2e5ea); padding: 20px 0 0; }
    .se-safety-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .se-shell { padding: 18px 14px 64px; }
    .se-field-grid, .se-field-grid--two { grid-template-columns: 1fr; }
    .se-formula-row { grid-template-columns: 1fr; }
    .se-action-fields { min-height: 0; }
}

/* Stage 4 multi-team workspace */
#TeamSessions {
    height: calc(100vh - 48px);
    padding: 0;
    overflow: auto;
}

/* Shared workspace help panels */
.workspace-title-row {
    display: flex;
    align-items: center;
    gap: 9px;
}

.workspace-help-button {
    width: 25px;
    height: 25px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid var(--border-color, #cfd5df);
    border-radius: 50%;
    background: var(--surface-subtle, #f5f7fa);
    color: var(--text-secondary, #52606d);
    font: 700 14px/1 Inter, sans-serif;
    cursor: pointer;
}

.workspace-help-button:hover,
.workspace-help-button:focus-visible,
.workspace-help-button.is-active {
    border-color: #2f68e5;
    background: #edf3ff;
    color: #2455bd;
    outline: none;
}

.workspace-help-panel {
    position: relative;
    margin: 0 0 18px;
    padding: 18px 20px;
    border: 1px solid #d9e1ec;
    border-left: 3px solid #2f68e5;
    background: #fff;
    box-shadow: 0 8px 24px rgba(22, 34, 51, 0.08);
}

.workspace-help-panel[hidden] { display: none; }

.workspace-help-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.workspace-help-heading h3 { margin: 2px 0 0; font-size: 18px; }

.workspace-help-eyebrow {
    color: #2f68e5;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.workspace-help-close {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #667085;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.workspace-help-close:hover,
.workspace-help-close:focus-visible { color: #172033; outline: none; }

.workspace-help-intro {
    max-width: 900px;
    margin: 0 0 16px;
    color: #475467;
    font-size: 13px;
    line-height: 1.55;
}

.workspace-help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin: 0 0 18px;
    overflow: hidden;
    border: 1px solid #e3e8ef;
    background: #e3e8ef;
}

.workspace-help-grid section {
    min-width: 0;
    padding: 12px 14px;
    background: #f9fafb;
}

.workspace-help-panel h4 {
    margin: 0 0 5px;
    color: #172033;
    font-size: 13px;
}

.workspace-help-panel p,
.workspace-help-panel li,
.workspace-help-table th,
.workspace-help-table td {
    color: #475467;
    font-size: 12px;
    line-height: 1.5;
}

.workspace-help-panel p { margin: 0; }
.workspace-help-panel ul { margin: 5px 0 0; padding-left: 18px; }

.workspace-help-table-wrap {
    margin: 7px 0 18px;
    overflow-x: auto;
    border: 1px solid #e3e8ef;
}

.workspace-help-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.workspace-help-table th,
.workspace-help-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #edf0f4;
    text-align: left;
    vertical-align: top;
}

.workspace-help-table tr:last-child th,
.workspace-help-table tr:last-child td { border-bottom: 0; }
.workspace-help-table th { width: 150px; color: #172033; font-weight: 600; }

.workspace-help-grid--results { margin-bottom: 0; }

.workspace-help-callout {
    margin-top: 10px;
    padding: 9px 10px;
    border-left: 3px solid #d59a24;
    background: #fff8e6;
    color: #684d15;
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 760px) {
    .workspace-help-panel { padding: 16px; }
    .workspace-help-grid { grid-template-columns: 1fr; }
    .workspace-help-table th { width: 120px; }
}

/* Stage 4 multi-team workspace */
.tm-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 28px 72px;
    color: var(--text-primary, #1a1d23);
    font-family: var(--font-family, 'Inter', sans-serif);
}

.tm-shell [hidden] { display: none !important; }

.tm-heading,
.tm-section-heading,
.tm-builder-actions,
.tm-run-row,
.tm-result-heading,
.tm-result-actions,
.tm-simple-balance,
.tm-replay-bar,
.tm-replay-copy,
.tm-structural-import {
    display: flex;
    align-items: center;
}

.tm-heading {
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border, #e2e5ea);
}

.tm-heading h2,
.tm-section-heading h3,
.tm-results h3,
.tm-results h4 {
    margin: 0;
    letter-spacing: 0;
}

.tm-heading h2 { font-size: 20px; }
.tm-graph-summary { margin-top: 5px; color: var(--text-secondary, #5f6673); font-size: 12px; }

.tm-section {
    padding: 20px 0 22px;
    border-bottom: 1px solid var(--border, #e2e5ea);
}

.tm-section-heading { justify-content: space-between; margin-bottom: 14px; }
.tm-section-heading h3 { font-size: 14px; }

.tm-simple-balance {
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    background: #f7f9fc;
    padding: 18px;
}
.tm-simple-balance-copy { min-width: 0; }
.tm-simple-balance h3 { margin: 0; font-size: 14px; letter-spacing: 0; }
.tm-simple-balance p {
    max-width: 880px;
    margin: 6px 0 0;
    color: var(--text-secondary, #5f6673);
    font-size: 12px;
    line-height: 1.5;
}
.tm-simple-balance-status {
    display: block;
    min-height: 16px;
    margin-top: 7px;
    color: #24643f;
    font-size: 11px;
}
.tm-simple-balance .button { flex: 0 0 auto; }
.tm-simple-balance-controls {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    flex: 0 1 520px;
}
.tm-balance-primary {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) auto;
    align-items: end;
    gap: 10px;
}
.tm-simple-balance-controls .se-field { min-width: 0; }
.tm-simple-balance-controls input[type="number"] {
    width: 100%;
    min-height: 34px;
    box-sizing: border-box;
    border: 1px solid var(--border, #d7dbe2);
    border-radius: 4px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1d23);
    padding: 6px 8px;
    font: inherit;
}
.tm-balance-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
}
.tm-balance-options > label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.tm-balance-options input[type="checkbox"] { margin: 0; }
.tm-balance-bounds { flex-basis: 100%; }
.tm-balance-bounds summary {
    width: fit-content;
    cursor: pointer;
    color: var(--text-primary, #1a1d23);
    font-weight: 600;
}
.tm-balance-bounds > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 9px;
}
.tm-balance-preview-summary,
.tm-balance-warnings {
    margin: 8px 0 10px;
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
    line-height: 1.5;
}
.tm-balance-warnings {
    border-left: 3px solid #d7a32f;
    padding-left: 10px;
    color: #6f541b;
}

.tm-builder-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 12px;
}

.tm-role-presets {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border, #e2e5ea);
}
.tm-role-presets-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.tm-role-presets-heading strong { font-size: 12px; }
.tm-role-presets-heading span,
.tm-role-preset-summary {
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
}
.tm-role-preset-buttons {
    display: grid;
    grid-template-columns: repeat(5, minmax(118px, 1fr));
    gap: 7px;
}
.tm-role-preset {
    --tm-role-color: #7b8492;
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 50px;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid var(--border, #d7dbe2);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1d23);
    cursor: pointer;
    font: inherit;
    text-align: left;
}
.tm-role-preset:hover { border-color: var(--tm-role-color); }
.tm-role-preset:focus-visible { outline: 2px solid var(--tm-role-color); outline-offset: 2px; }
.tm-role-preset.is-active {
    border-color: var(--tm-role-color);
    box-shadow: inset 0 0 0 1px var(--tm-role-color);
    background: color-mix(in srgb, var(--tm-role-color) 7%, var(--bg-primary, #fff));
}
.tm-role-preset-swatch {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border: 2px solid color-mix(in srgb, var(--tm-role-color) 78%, #000);
    border-radius: 50%;
    background: var(--tm-role-color);
}
.tm-role-preset-copy { min-width: 0; }
.tm-role-preset-copy strong,
.tm-role-preset-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-role-preset-copy strong { font-size: 12px; }
.tm-role-preset-copy small { margin-top: 2px; color: var(--text-secondary, #5f6673); font-size: 10px; }
.tm-role-preset--green { --tm-role-color: #2f8a5b; }
.tm-role-preset--blue { --tm-role-color: #2f68c8; }
.tm-role-preset--red { --tm-role-color: #c44848; }
.tm-role-preset--black { --tm-role-color: #343941; }
.tm-role-preset-summary { min-height: 16px; margin: 8px 0 0; line-height: 1.45; }

.tm-team-role {
    display: inline-block;
    margin-left: 7px;
    padding: 1px 5px;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.3;
    text-transform: uppercase;
    vertical-align: 1px;
}
.tm-team-role--green { color: #28794f; }
.tm-team-role--blue { color: #285bae; }
.tm-team-role--red { color: #aa3d3d; }
.tm-team-role--black { color: #343941; }

.tm-builder-grid input,
.tm-builder-grid select,
.tm-move-grid input,
.tm-move-grid select,
.tm-run-row input,
.tm-permissions select {
    width: 100%;
    min-height: 34px;
    box-sizing: border-box;
    border: 1px solid var(--border, #d7dbe2);
    border-radius: 4px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1d23);
    padding: 6px 8px;
    font: inherit;
    font-size: 12px;
}

.tm-permissions {
    margin-top: 14px;
    border-top: 1px solid var(--border, #e2e5ea);
    padding-top: 12px;
}

.tm-permissions summary { cursor: pointer; font-size: 12px; font-weight: 650; }
.tm-permission-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 20px; margin-top: 12px; }
.tm-permission-grid fieldset { min-width: 0; margin: 0; border: 0; padding: 0; }
.tm-permission-grid legend { margin-bottom: 6px; color: var(--text-secondary, #5f6673); font-size: 11px; font-weight: 650; }
.tm-permission-grid fieldset label { display: block; margin: 5px 0; color: var(--text-secondary, #5f6673); font-size: 11px; }

.tm-builder-actions { justify-content: flex-end; margin-top: 14px; }
.tm-text-button,
.tm-icon-button,
.tm-remove-button {
    border: 0;
    background: transparent;
    color: var(--text-secondary, #5f6673);
    cursor: pointer;
    font: inherit;
}
.tm-text-button { padding: 5px 7px; font-size: 12px; }
.tm-text-button:hover { color: var(--accent, #4a7cff); }
.tm-remove-button { width: 28px; height: 28px; font-size: 18px; }
.tm-remove-button:hover { color: #b4453b; }

.tm-table-wrap { width: 100%; margin-top: 14px; overflow: auto; border-top: 1px solid var(--border, #e2e5ea); }
.tm-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 12px; }
.tm-table th { color: var(--text-secondary, #5f6673); font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; }
.tm-table th,
.tm-table td { min-height: 42px; padding: 9px 10px; border-bottom: 1px solid var(--border, #e2e5ea); vertical-align: middle; }
.tm-table td small { display: block; margin-top: 3px; color: var(--text-secondary, #8a9099); }
.tm-table td:last-child,
.tm-table th:last-child { width: 34px; text-align: right; }
.tm-empty { padding: 22px !important; color: var(--text-secondary, #8a9099); text-align: center; }

.tm-move-grid { display: grid; grid-template-columns: 180px 190px minmax(0, 1fr); gap: 12px; align-items: end; }
.tm-inline-fields { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; }
.tm-structural-import { min-height: 34px; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border, #e2e5ea); color: var(--text-secondary, #5f6673); font-size: 12px; }
.tm-move-queue { max-height: 230px; margin-top: 14px; overflow: auto; border-top: 1px solid var(--border, #e2e5ea); }
.tm-move-row { display: grid; grid-template-columns: 34px 150px minmax(0, 1fr) 34px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--border, #e2e5ea); font-size: 12px; }
.tm-move-row > span:nth-child(3) { color: var(--text-secondary, #5f6673); overflow-wrap: anywhere; }
.tm-move-sequence { color: var(--text-secondary, #8a9099); font-variant-numeric: tabular-nums; }

.tm-run-row { justify-content: flex-end; gap: 12px; padding: 18px 0; }
.tm-run-row .se-field { width: 110px; }
.tm-results { padding: 18px 0 0; border-top: 1px solid var(--border, #e2e5ea); }
.tm-result-heading { justify-content: space-between; gap: 20px; }
.tm-result-actions { gap: 8px; }
.tm-result-heading h3 { font-size: 15px; }
.tm-result-heading span { display: block; margin-top: 5px; color: var(--text-secondary, #5f6673); font-size: 11px; }
.tm-results h4 { margin-top: 22px; font-size: 12px; }
.tm-learning-summary {
    margin-top: 8px;
    color: var(--text-secondary, #5f6673);
    font-size: 11px;
}
.tm-learning-curve {
    width: 100%;
    min-height: 260px;
    margin-top: 10px;
    border-top: 1px solid var(--border, #e2e5ea);
    border-bottom: 1px solid var(--border, #e2e5ea);
}
.tm-log-wrap { max-height: 330px; }
.tm-status { font-weight: 700; }
.tm-status--accepted { color: #16854c; }
.tm-status--rejected { color: #b4453b; }

.tm-replay-bar {
    position: fixed;
    z-index: 9000;
    top: 58px;
    left: 50%;
    width: min(920px, calc(100vw - 32px));
    min-height: 52px;
    box-sizing: border-box;
    transform: translateX(-50%);
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #cfd4dc;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(20, 26, 36, 0.16);
    color: #1a1d23;
    font-family: var(--font-family, 'Inter', sans-serif);
}
.tm-replay-bar[hidden] { display: none; }
.tm-icon-button { flex: 0 0 32px; width: 32px; height: 32px; border: 1px solid #d7dbe2; border-radius: 4px; }
.tm-icon-button:hover { color: #265bd7; border-color: #9eb4ec; }
.tm-replay-bar input[type="range"] { width: 180px; accent-color: #2f68e5; }
.tm-replay-copy { min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; gap: 2px; }
.tm-replay-copy strong { font-size: 12px; }
.tm-replay-copy span { max-width: 100%; color: #5f6673; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-replay-keep { min-width: 86px; min-height: 32px; padding: 6px 10px; }

@media (max-width: 1080px) {
    .tm-role-preset-buttons { grid-template-columns: repeat(3, minmax(118px, 1fr)); }
    .tm-builder-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
    .tm-permission-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .tm-move-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .tm-inline-fields { grid-column: 1 / -1; }
    .tm-structural-import { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
    .tm-shell { padding: 18px 14px 64px; }
    .tm-role-presets-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
    .tm-role-preset-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tm-builder-grid,
    .tm-permission-grid,
    .tm-move-grid,
    .tm-inline-fields { grid-template-columns: 1fr; }
    .tm-inline-fields { grid-column: auto; }
    .tm-move-row { grid-template-columns: 28px 100px minmax(0, 1fr) 30px; }
    .tm-simple-balance { align-items: stretch; flex-direction: column; gap: 12px; }
    .tm-simple-balance-controls { align-items: stretch; flex-direction: column; }
    .tm-simple-balance-controls .se-field { min-width: 0; }
    .tm-simple-balance .button { align-self: flex-start; }
    .tm-balance-primary,
    .tm-balance-bounds > div { grid-template-columns: 1fr; }
    .tm-result-heading { align-items: flex-start; flex-direction: column; }
    .tm-result-actions { width: 100%; flex-wrap: wrap; }
    .tm-replay-bar { top: 52px; flex-wrap: wrap; }
    .tm-replay-bar input[type="range"] { flex: 1; min-width: 110px; }
    .tm-replay-copy { order: 5; flex-basis: 100%; }
}

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
    pointer-events: none;
}
.toast {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12.5px;
    font-family: 'Menlo', 'Consolas', monospace;
    color: #fff;
    line-height: 1.4;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    opacity: 1;
    transition: opacity 0.35s;
    pointer-events: auto;
    word-break: break-word;
}
.toast.error { background: #c0392b; border-left: 4px solid #96281b; }
.toast.warn  { background: #d35400; border-left: 4px solid #a04000; }
@keyframes toast-in {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
.toast { animation: toast-in 0.2s ease; }

/* Global overlay — only used for Stripe checkout redirect */
#loading-spinner {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 17, 22, 0.55);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* Inline tab loading — reuses the same spinner-ring */
.tab-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
}

.spinner-ring {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #4a7cff;
    animation: spinner-rotate 0.8s linear infinite;
}

.spinner-text {
    font-family: var(--font-family, 'Inter', sans-serif);
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.5px;
}


@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}


.hidden {
	display: none !important;
}

















/* Controls container */
#controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
    margin: 10px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #ffffff;
    width: 90%;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}

/* Heading style */
#controls h3 {
    font-size: 15px;
    font-weight: bold;
    color: #007bff;
    text-align: center;
    margin-bottom: 10px;
}

/* Control groups (analysis sidebar) */
#controls-sidebar .control-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
}

.control-group label {
    font-size: 13px;
    font-weight: bold;
    margin-right: 5px;
    color: #333;
}

.control-group input {
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    width: 70px; /* Compact width for input fields */
    box-sizing: border-box;
}

/* Buttons */
.button-group {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.button-group button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: white;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
}

.button-group button:hover {
    background-color: #0056b3;
}

/* Responsive Design */
@media (max-width: 768px) {
    .control-group {
        flex-direction: column;
        gap: 8px;
    }

    .control-group input {
        width: 100%; /* Full width for smaller screens */
    }

    .button-group {
        flex-direction: column;
        gap: 5px;
    }
}

/* #progressContainer {
    width: 100%;
    background-color: #f3f3f3;
    border-radius: 5px;
    overflow: hidden;
  }
  
  #progressBar {
    width: 0%;
    height: 30px;
    background-color: #4caf50;
    text-align: center;
    line-height: 30px;
    color: white;
  }
   */






/* General Styles for the Node Connections Tab */
#NodeConnections {
    padding: 10px;
    font-family: Arial, sans-serif;
    color: #333;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Section Heading */
#NodeConnections h2 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #0056b3;
    text-align: center;
}

/* Labels for Inputs */
#NodeConnections label {
    font-weight: bold;
    margin-bottom: 2px;
    display: block;
    font-size: 0.9em;
}

/* Text Inputs */
#NodeConnections input[type="text"],
#NodeConnections input[type="number"],
#NodeConnections textarea {
    /* width: 100%; */
    padding: 6px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.9em;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dropdown Select */
#NodeConnections select {
    /* width: 100%; */
    padding: 6px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.9em;
    background-color: #fff;
}

/* Buttons */
#NodeConnections button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#NodeConnections button:hover {
    background-color: #0056b3;
}

#NodeConnections button:disabled {
    background-color: #ddd;
    color: #aaa;
    cursor: not-allowed;
}

/* Output Section */
#NodeConnections pre#output {
    /* padding: 8px; */
    background-color: #e9ecef;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.85em;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 600px) {
    #NodeConnections {
        padding: 8px;
    }

    #NodeConnections input[type="text"],
    #NodeConnections input[type="number"],
    #NodeConnections textarea,
    #NodeConnections select {
        font-size: 0.85em;
    }

    #NodeConnections h2 {
        font-size: 1em;
    }
}







#databaseContent {
    margin-top: 10px;
    overflow-x: auto;
}

#databaseTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

#databaseTable th,
#databaseTable td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    font-size: 0.9em;
}

#databaseTable th {
    background-color: #f2f2f2;
    font-weight: bold;
}

#databaseTable tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

#databaseTable tbody tr:hover {
    background-color: #f1f1f1;
}






/* Table Header */
#graphTableHeader {
    font-family: Arial, sans-serif;
    color: #2c3e50; /* Dark blue for better visibility */
    font-size: 1.2em; /* Smaller font size */
    margin-bottom: 8px;
    text-align: center;
    font-weight: bold;
}

/* Table Styling */
#graphTable {
    width: 90%; /* Slightly smaller width */
    margin: 0 auto; /* Center table */
    border-collapse: collapse;
    font-family: Arial, sans-serif;
    background-color: #ffffff;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.9em; /* Reduce text size for compact look */
}

/* Table Header Row */
#graphTable thead {
    color: #2980b9; /* Stronger blue for visibility */
    text-transform: uppercase;
}

#graphTable th {
    /* padding: 10px; */
    border: 1px solid #ccc;
    text-align: center;
}

#graphTable th, td {
    font-size: small;
}

/* Table Body Rows */
#graphTable tbody tr {
    transition: background-color 0.2s ease-in-out;
}

#graphTable tbody tr:nth-child(even) {
    background-color: #f9f9f9; /* Light grey for zebra striping */
}

#graphTable tbody tr:hover {
    background-color: #ecf6ff; /* Light blue for hover effect */
}

/* Table Cells */
#graphTable td {
    border: 1px solid #ddd;
    text-align: center;
    color: #333;
}

/* Autofill Button */
#graphTable .fillButton {
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#graphTable .fillButton:hover {
    background-color: #0056b3;
    transform: scale(1.03);
}




/* General Styling */
#ViewDatabase {
    font-family: Arial, sans-serif;
    margin: 20px auto;
    max-width: 90%;
    color: #333;
}

#ViewDatabase h2 {
    color: #2c3e50;
    text-align: center;
    font-size: 1.8em;
    margin-bottom: 20px;
}

/* Filter Section Styling */
#ViewDatabase label {
    font-weight: bold;
    margin-right: 8px;
}

#ViewDatabase input[type="text"] {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    width: 200px;
}

#ViewDatabase button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 12px;
    margin: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

#ViewDatabase button:hover {
    background-color: #2980b9;
    transform: scale(1.05);
}

/* Table Styling */
#databaseTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    background-color: #fff;
}

#databaseTable th {
    background-color: #2c3e50;
    color: #fff;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
    text-transform: uppercase;
}

#databaseTable td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
    font-size: 0.9em;
    line-height: 1.5;
}

#databaseTable tbody tr:nth-child(even) {
    background-color: #f9f9f9; /* Light zebra striping */
}

#databaseTable tbody tr:hover {
    background-color: #ecf6ff; /* Light blue highlight */
    cursor: pointer;
}

/* Justification Column Formatting */
#databaseTable td:nth-child(5) {
    max-width: 400px; /* Limit justification width */
    overflow-wrap: break-word; /* Wrap long text */
    font-size: 0.85em;
    color: #555;
    line-height: 1.4;
}

/* Buttons at Bottom */
#ViewDatabase button#refreshDatabaseButton {
    display: block;
    margin: 20px auto 0 auto;
    background-color: #27ae60;
    transition: background-color 0.3s ease;
}

#ViewDatabase button#refreshDatabaseButton:hover {
    background-color: #219150;
}

/* Error and Status Message Styles */
.error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    font-weight: bold;
}

.success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    font-weight: bold;
}

.loading {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    font-weight: bold;
}

/* ── Background simulation bar (above playbar) ─────────────────────────────── */
#sim-iter-bar {
    position: absolute;
    bottom: 97px;
    left: calc(50% - 275px);
    width: 250px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #ccc;
    pointer-events: auto;
    z-index: 10;
}
#sim-iter-bar label { white-space: nowrap; }
#sim-iter-bar input[type="number"] {
    width: 62px;
    background: #444;
    color: #fff;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 12px;
}
.sim-badge {
    margin-left: auto;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.sim-badge--running { background: #6c4a00; color: #ffd; }
.sim-badge--ready   { background: #155724; color: #d4edda; }
.sim-badge--error   { background: #721c24; color: #f8d7da; }

/* ── Analysis tab controls ─────────────────────────────────────────────────── */
.analysis-controls {
    margin: 16px 0 8px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid #333;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.control-row label { color: #ccc; font-size: 13px; white-space: nowrap; min-width: 120px; }
.analysis-controls .button { align-self: flex-start; margin-top: 4px; }
.analysis-controls .hint { font-size: 12px; color: #888; margin: 0; }
.section-divider { border: none; border-top: 1px solid #333; margin: 36px 0; }

/* ── Interactive time series (Plotly) ─────────────────────────────────────── */
.ts-interactive {
    margin: 8px 0 16px;
    border: 1px solid #e2e5ea;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.ts-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 8px 12px;
    background: #f6f7f9;
    border-bottom: 1px solid #e8eaed;
}
.ts-hint {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}
.ts-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.ts-toolbar .tv-text-btn,
.ts-toolbar-actions .tv-text-btn {
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
}
.ts-toolbar .tv-text-btn:hover,
.ts-toolbar-actions .tv-text-btn:hover {
    background: #eef1f6;
    border-color: #b8c0cc;
}
.ts-chart-wrap {
    position: relative;
    width: 100%;
    min-height: 320px;
    padding: 4px 8px 8px;
    box-sizing: border-box;
}
.ts-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}
.ts-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    padding: 8px 12px 0;
}
.ts-range-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 8px 12px 12px;
    border-top: 1px solid #e8eaed;
    background: #fafbfc;
}
.ts-range-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #555;
    flex: 1;
    min-width: 160px;
}
.ts-range-label input[type="range"] {
    flex: 1;
    min-width: 80px;
}
.ts-range-readout {
    font-size: 12px;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ts-fallback {
    padding: 24px;
    color: #888;
    font-size: 13px;
    margin: 0;
}
.ts-classifications ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── Diagram Generator ─────────────────────────────────────────── */
.gen-sub { color: var(--text-secondary, #5f6673); font-size: 14px; max-width: 640px; line-height: 1.5; margin: 4px 0 18px; }
.gen-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; max-width: 640px; }
.gen-field > label { color: var(--text-primary, #1a1d23); font-size: 13px; font-weight: 600; }
.gen-field input[type="password"],
.gen-field input[type="text"],
.gen-field textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #d4d8e0);
    border-radius: 6px;
    color: var(--text-primary, #1a1d23);
    font-size: 14px;
    font-family: inherit;
    padding: 9px 11px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.gen-field textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.gen-field input:focus,
.gen-field textarea:focus {
    outline: none;
    border-color: var(--accent, #4a7cff);
    box-shadow: 0 0 0 3px rgba(74,124,255,0.18);
}
.gen-hint { font-size: 11.5px; color: #8a909c; }

.gen-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; max-width: 640px; }
.gen-ex-label { font-size: 12.5px; color: var(--text-secondary, #5f6673); margin-right: 2px; }
.gen-chip {
    margin: 0;
    padding: 5px 12px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--accent, #4a7cff);
    background: rgba(74,124,255,0.08);
    border: 1px solid rgba(74,124,255,0.35);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.13s;
}
.gen-chip:hover { background: rgba(74,124,255,0.18); }

.gen-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-width: 640px; }
.gen-opt-row { display: flex; align-items: center; gap: 10px; }
.gen-opt-label { color: var(--text-primary, #1a1d23); font-size: 13px; font-weight: 600; min-width: 48px; }
.gen-select {
    flex: 1;
    max-width: 420px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #d4d8e0);
    border-radius: 6px;
    color: var(--text-primary, #1a1d23);
    font-size: 13px;
    font-family: inherit;
    padding: 7px 9px;
    cursor: pointer;
}
.gen-select:focus { outline: none; border-color: var(--accent, #4a7cff); box-shadow: 0 0 0 3px rgba(74,124,255,0.18); }

/* 3D parameter-space: 2D slice preview with axis pickers alongside */
.slice-layout {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.axis-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 150px;
    padding: 12px 14px;
    background: rgba(0,0,0,0.03);
    border: 1px solid var(--border, #e2e5ea);
    border-radius: 8px;
}
.axis-panel-title { font-weight: 600; font-size: 13px; color: var(--text-primary, #1a1d23); }
.axis-panel label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #5f6673);
}
#paramSpace3DSlice {
    flex: 1 1 480px;
    min-width: 340px;
    height: 480px;
}
.axis-select {
    padding: 5px 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary, #1a1d23);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #d4d8e0);
    border-radius: 6px;
    cursor: pointer;
}
.gen-check { display: flex; align-items: center; gap: 8px; color: var(--text-primary, #1a1d23); font-size: 13px; cursor: pointer; }
.gen-check input { margin: 0; }

.gen-status { margin-top: 14px; font-size: 13.5px; line-height: 1.5; min-height: 1.2em; max-width: 640px; }
.gen-status.ok      { color: #1a7f4b; }
.gen-status.error   { color: #c0392b; }
.gen-status.warn    { color: #9a6700; }
.gen-status.loading { color: #3a65d4; }
.gen-spinner {
    display: inline-block;
    width: 13px; height: 13px;
    margin-right: 6px;
    border: 2px solid rgba(74,124,255,0.3);
    border-top-color: var(--accent, #4a7cff);
    border-radius: 50%;
    vertical-align: -2px;
    animation: gen-spin 0.7s linear infinite;
}
@keyframes gen-spin { to { transform: rotate(360deg); } }
