:root {
    --ink: #17212f;
    --muted: #667384;
    --surface: #ffffff;
    --surface-subtle: #f7f9fa;
    --border: #d9e0e7;
    --accent: #126f68;
    --accent-soft: #eaf6f4;
    --warning: #9a6419;
    --danger: #a63a46;
    color: #18212f;
    background: #f3f5f7;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    margin: 0;
    background: #f3f5f7;
    font-variant-numeric: tabular-nums;
}

a { color: #116c65; }

.nav-link {
    padding: 8px 6px;
    color: #4c5969;
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
}

.nav-link:hover { color: #116c65; }

.feedback-trigger {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 15;
    box-shadow: 0 4px 14px rgba(24, 33, 47, 0.14);
}

.feedback-dialog,
.save-dialog {
    width: min(440px, calc(100% - 32px));
    padding: 0;
    border: 1px solid #d8dee5;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(20, 28, 39, 0.22);
}

.feedback-dialog::backdrop,
.save-dialog::backdrop { background: rgba(20, 28, 39, 0.45); }

.feedback-dialog form,
.save-dialog form { display: grid; gap: 16px; padding: 22px; }

.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; font-size: 19px; }
.icon-button { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: #edf1f4; color: #344153; font-size: 22px; }

.feedback-dialog label,
.save-dialog label,
.stack-form label { display: grid; gap: 7px; color: #344153; font-size: 13px; font-weight: 700; }

textarea { min-height: 110px; resize: vertical; }
textarea,
.stack-form input,
.feedback-dialog select,
.save-dialog input {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid #cbd3dc;
    border-radius: 6px;
    background: #fff;
    color: #18212f;
    font: inherit;
}

.form-status { min-height: 20px; margin: 0; color: #596779; font-size: 13px; }

.auth-shell { display: grid; min-height: calc(100vh - 180px); place-items: center; }
.auth-panel { width: min(480px, 100%); padding: 28px; border: 1px solid #d8dee5; border-radius: 8px; background: #fff; box-shadow: 0 4px 18px rgba(24, 33, 47, 0.06); }
.auth-panel h1 { margin-bottom: 24px; font-size: 30px; }
.stack-form { display: grid; gap: 14px; }
.stack-form p { display: grid; gap: 6px; margin: 0; color: #465365; font-size: 13px; font-weight: 650; }
.stack-form .helptext, .stack-form ul { color: #75808e; font-size: 12px; font-weight: 400; line-height: 1.45; }
.stack-form ul { margin: 0; padding-left: 18px; }
.stack-form .errorlist { color: #b42318; }
.auth-copy { margin: 0 0 22px; color: #5f6c7c; line-height: 1.65; }
.verification-waiting { display: flex; margin: -4px 0 22px; align-items: center; gap: 8px; color: #526172; font-size: 13px; font-weight: 700; }
.auth-help { display: flex; margin: 16px 0; justify-content: space-between; gap: 12px; font-size: 13px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.dashboard-main, .dashboard-side { border: 1px solid #d8dee5; border-radius: 8px; background: #fff; }
.dashboard-main { padding: 20px; }
.dashboard-side { padding: 20px; }
.dashboard-side h2 { margin: 0 0 8px; font-size: 17px; }
.dashboard-side hr { margin: 22px 0; border: 0; border-top: 1px solid #e2e7ec; }
.project-list { display: grid; }
.project-row { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #e5e9ed; }
.project-row:last-child { border-bottom: 0; }
.project-row > div { display: grid; gap: 5px; }
.project-row a { color: #243142; text-decoration: none; }
.project-row span { color: #77818f; font-size: 12px; }
.empty-state { padding: 70px 20px; color: #667282; text-align: center; }
.empty-state h2 { color: #263445; font-size: 19px; }

.access-status { color: #526172; font-size: 12px; font-weight: 750; white-space: nowrap; }
.result-upgrade-link { display: inline-flex; margin-left: 12px; }
.account-list { display: grid; margin: 0 0 22px; }
.account-list div { display: flex; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid #e5e9ed; }
.account-list dt { color: #6a7685; }
.account-list dd { margin: 0; font-weight: 700; }
.account-actions { display: flex; align-items: center; justify-content: space-between; }
.feedback-row { display: grid; grid-template-columns: 60px 1fr auto; gap: 14px; padding: 13px 0; border-bottom: 1px solid #e5e9ed; }
.policy-page { max-width: 760px; margin: 0 auto; }
.policy-page h1 { margin-bottom: 30px; }
.policy-page p { color: #5f6c7c; line-height: 1.7; }
.policy-intro { margin: -18px 0 24px; }
.policy-disclosures { overflow: hidden; border-top: 1px solid #dce2e8; }
.policy-disclosures details { border-bottom: 1px solid #dce2e8; background: #ffffff; }
.policy-disclosures summary { padding: 17px 46px 17px 18px; }
.policy-disclosures details > p { margin: 0; padding: 0 46px 18px 18px; }

@media (max-width: 760px) {
    .app-header-inner { width: min(100% - 24px, 1240px); align-items: flex-start; padding: 12px 0; }
    .page-nav { flex-wrap: wrap; justify-content: flex-end; }
    .nav-link { font-size: 12px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .feedback-row { grid-template-columns: 50px 1fr; }
    .feedback-row small { grid-column: 2; }
}

button,
input,
select {
    font: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid #dfe3e8;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
}

.app-header-inner {
    display: flex;
    width: min(1240px, calc(100% - 40px));
    min-height: 64px;
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #18212f;
    font-size: 16px;
    font-weight: 750;
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: #16766f;
    color: #ffffff;
    font-size: 12px;
    letter-spacing: 0;
}

.page-shell {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 36px 0 56px;
}

.page-nav {
    display: flex;
    gap: 8px;
}

.language-switcher {
    margin: 0;
}

.language-switcher select {
    min-height: 36px;
    width: auto;
    padding: 6px 28px 6px 10px;
    border-color: var(--border);
    background-color: var(--surface);
    font-size: 0.875rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.upload-panel,
.result-layout {
    width: 100%;
}

.workspace-intro,
.result-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: #16766f;
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: #141c27;
    font-size: 36px;
    line-height: 1.15;
    letter-spacing: 0;
}

.intro {
    max-width: 440px;
    margin: 0 0 3px;
    color: #657080;
    font-size: 15px;
    line-height: 1.55;
    text-align: right;
}

.input-workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.trust-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
    overflow: hidden;
    border: 1px solid #d7dfe5;
    border-radius: 8px;
    background: #ffffff;
}

.trust-disclosure {
    min-width: 0;
    border-right: 1px solid #e1e6eb;
}

.trust-disclosure:last-child {
    border-right: 0;
}

.trust-disclosure summary,
.policy-disclosures summary,
.integrity-banner summary {
    position: relative;
    list-style: none;
    color: #263445;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.trust-disclosure summary {
    padding: 15px 42px 15px 17px;
}

.trust-disclosure summary::-webkit-details-marker,
.policy-disclosures summary::-webkit-details-marker,
.integrity-banner summary::-webkit-details-marker {
    display: none;
}

.trust-disclosure summary::after,
.policy-disclosures summary::after,
.integrity-banner summary::after {
    position: absolute;
    top: 50%;
    right: 16px;
    color: #16766f;
    content: "+";
    font-size: 18px;
    font-weight: 500;
    transform: translateY(-50%);
}

.trust-disclosure[open] summary::after,
.policy-disclosures details[open] summary::after,
.integrity-banner[open] summary::after {
    content: "-";
}

.trust-disclosure summary:focus-visible,
.policy-disclosures summary:focus-visible,
.integrity-banner summary:focus-visible {
    outline: 3px solid rgba(22, 118, 111, 0.22);
    outline-offset: -3px;
}

.trust-disclosure > p {
    margin: 0;
    padding: 0 17px 15px;
    color: #697585;
    font-size: 12px;
    line-height: 1.5;
}

.input-card {
    border: 1px solid #d9dee5;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(24, 33, 47, 0.04);
}

.upload-card {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.source-heading {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}

.source-heading h2,
.table-card-header h2 {
    margin: 0;
    color: #202a38;
    font-size: 17px;
    line-height: 1.3;
}

.step-number {
    display: inline-flex;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    align-items: center;
    justify-content: center;
    border: 1px solid #b7d9d5;
    border-radius: 50%;
    background: #ecf7f5;
    color: #11645e;
    font-size: 13px;
    font-weight: 750;
}

.help-text,
.note {
    margin: 2px 0 0;
    color: #6c7684;
    font-size: 13px;
    line-height: 1.45;
}

.file-dropzone {
    display: grid;
    min-height: 154px;
    padding: 22px 16px;
    align-content: center;
    justify-items: center;
    gap: 7px;
    border: 1px dashed #aeb7c3;
    border-radius: 8px;
    background: #f8fafb;
    color: #344153;
    text-align: center;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.file-dropzone:hover,
.file-dropzone.is-dragging {
    border-color: #16766f;
    background: #f0f8f7;
    box-shadow: inset 0 0 0 1px #16766f;
}

.file-dropzone.has-file {
    border-style: solid;
    border-color: #7cb7b1;
    background: #edf8f6;
}

.file-dropzone-title {
    max-width: 100%;
    color: #243142;
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.file-dropzone-meta {
    color: #7a8491;
    font-size: 12px;
}

.file-dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

button,
.secondary-link,
.secondary-button,
.danger-button,
.danger-secondary-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid #18212f;
    border-radius: 7px;
    padding: 0 15px;
    background: #18212f;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled),
.secondary-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(24, 33, 47, 0.12);
}

button:focus-visible,
.secondary-link:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(22, 118, 111, 0.22);
    outline-offset: 2px;
}

.secondary-link,
.secondary-button {
    border-color: #d4dae2;
    background: #ffffff;
    color: #344153;
}

.danger-button {
    border-color: #c83d4b;
    background: #c83d4b;
}

.danger-secondary-button {
    border-color: #efc4c8;
    background: #fff7f7;
    color: #ad2f3d;
}

.danger-secondary-button:hover:not(:disabled) {
    border-color: #e79ba3;
    background: #ffebed;
}

.compact-primary {
    width: 100%;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
    transform: none;
    box-shadow: none;
}

.table-card {
    min-width: 0;
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.workspace-toolbar {
    min-height: 70px;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e6eb;
}

.table-actions,
.plot-toolbar,
.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.table-actions {
    justify-content: flex-end;
}

.table-actions button,
.plot-toolbar button,
.page-nav > * {
    min-height: 34px;
    padding: 0 11px;
    font-size: 13px;
}

.table-edit-status {
    min-height: 34px;
    margin: 0;
    padding: 9px 16px;
    border-bottom: 1px solid #e6e9ed;
    background: #fafbfc;
    color: #687383;
    font-size: 12px;
}

.data-table-wrap {
    max-height: 430px;
    overflow: auto;
    border: 1px solid #d9dee5;
    border-radius: 7px;
    background: #ffffff;
}

.table-card > .data-table-wrap {
    border: 0;
    border-radius: 0;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

.data-table th,
.data-table td {
    min-width: 145px;
    border-right: 1px solid #e4e8ed;
    border-bottom: 1px solid #e4e8ed;
    padding: 0;
}

.data-table th:last-child,
.data-table td:last-child {
    border-right: 0;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 44px;
    padding: 0 12px;
    background: #f0f3f6;
    color: #354153;
    font-size: 13px;
    text-align: left;
}

.data-table .row-selector-header,
.data-table .row-selector-cell {
    width: 68px;
    min-width: 68px;
    max-width: 68px;
}

.row-selector-header,
.row-selector-cell {
    text-align: center;
}

.row-selector-header input,
.row-selector-cell input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #16766f;
    cursor: pointer;
}

.row-selector-cell {
    position: relative;
    height: 44px;
    background: #f7f9fa;
}

.row-selector-cell .row-select-checkbox {
    position: absolute;
    top: 14px;
    left: 10px;
}

.row-number {
    display: block;
    padding-left: 23px;
    color: #798391;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.data-table tr.is-selected td {
    background: #eef8f6;
}

.data-table tr.is-selected .row-selector-cell {
    background: #deefec;
}

.variable-header {
    display: flex;
    min-height: 43px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.variable-header > span {
    display: grid;
    gap: 1px;
}

.variable-header small {
    color: #75808e;
    font-size: 10px;
    font-weight: 600;
}

.variable-header .type-status-binary {
    color: #147066;
}

.column-delete-button {
    width: 28px;
    min-width: 28px;
    min-height: 28px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0;
    background: transparent;
    color: #707b89;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

.column-delete-button:hover:not(:disabled) {
    border-color: #efc4c8;
    background: #ffebed;
    color: #ad2f3d;
}

.data-table input,
.data-table select {
    width: 100%;
    height: 44px;
    border: 0;
    border-radius: 0;
    padding: 0 12px;
    background: #ffffff;
    color: #18212f;
}

.data-table input:hover,
.data-table select:hover {
    background: #fafcfc;
}

.data-table .row-select-checkbox {
    width: auto;
}

.data-table .row-select-checkbox {
    width: 16px;
    height: 16px;
    border: 0;
    padding: 0;
}

.data-table input:focus,
.data-table select:focus {
    position: relative;
    z-index: 1;
    outline: 2px solid #16766f;
    outline-offset: -2px;
    background: #ffffff;
}

.data-table select {
    cursor: pointer;
}

.table-footer {
    display: flex;
    min-height: 68px;
    padding: 13px 16px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid #e2e6eb;
}

.messages {
    margin-bottom: 18px;
}

.message {
    margin: 0 0 10px;
    border: 1px solid #d8dee6;
    border-radius: 7px;
    padding: 12px 14px;
    background: #ffffff;
}

.message-error,
.field-errors {
    color: #9c2734;
}

.message-error {
    border-color: #efc4c8;
    background: #fff4f5;
}

.result-header {
    align-items: center;
    margin-bottom: 18px;
}

.workspace-subtitle {
    max-width: 620px;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.workspace-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.workspace-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 2px 10px rgba(23, 33, 47, 0.035);
}

.workspace-summary > div {
    min-width: 0;
    padding: 12px 15px;
    border-right: 1px solid #e8ecf0;
}

.workspace-summary > div:last-child { border-right: 0; }
.workspace-summary span { display: block; color: #778291; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.workspace-summary strong { display: block; margin-top: 5px; color: var(--ink); font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }

.export-menu { position: relative; }
.export-menu > summary {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    border: 1px solid #d4dae2;
    border-radius: 7px;
    padding: 0 34px 0 14px;
    background: #fff;
    color: #344153;
    font-size: 14px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu > summary::after { position: absolute; right: 13px; content: "▾"; color: #6a7584; }
.export-menu[open] > summary { border-color: #7eb5b0; box-shadow: 0 0 0 3px rgba(18, 111, 104, 0.12); }
.export-menu-panel {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 12;
    display: grid;
    width: 250px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(23, 33, 47, 0.16);
}
.menu-button { justify-content: flex-start; border: 0; border-bottom: 1px solid #edf0f3; border-radius: 0; background: #fff; color: #344153; font-size: 13px; }
.menu-button:last-child { border-bottom: 0; }
.menu-button:hover:not(:disabled) { background: #f3f8f7; box-shadow: none; transform: none; }

.exclude-button {
    border-color: #d5a34d;
    background: #fff8e9;
    color: #76501c;
}
.exclude-button:hover:not(:disabled) { border-color: #bd8326; background: #ffefc9; }

.integrity-banner {
    margin-bottom: 14px;
    border-left: 3px solid #c38a20;
    background: #fff9eb;
    color: #5c4a29;
    font-size: 13px;
    line-height: 1.45;
}

.integrity-banner summary {
    padding: 11px 44px 11px 14px;
    color: #5c4a29;
}

.integrity-banner > p {
    margin: 0;
    padding: 0 44px 12px 14px;
    color: #725f3a;
}

.dataset-count {
    margin-bottom: 4px;
    border: 1px solid #d5dbe2;
    border-radius: 999px;
    padding: 7px 11px;
    background: #ffffff;
    color: #536071;
    font-size: 13px;
    font-weight: 650;
}

.plot-toolbar {
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #d9dee5;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    padding: 10px;
    background: #ffffff;
}

.toolbar-group-secondary {
    justify-content: flex-end;
}

.selection-bar {
    display: flex;
    min-height: 34px;
    align-items: center;
    gap: 8px;
    border-right: 1px solid #d9dee5;
    border-left: 1px solid #d9dee5;
    padding: 0 13px;
    background: #f8fafb;
    flex-wrap: wrap;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #16766f;
}

.selection-status {
    color: #596576;
    font-size: 13px;
    font-weight: 650;
}

.chart-sample-notice {
    flex: 1 1 100%;
    padding: 0 0 8px 15px;
    color: #6d7785;
    font-size: 12px;
}

.chart-zoom-controls {
    display: flex;
    margin-left: auto;
    gap: 4px;
}

.chart-zoom-button {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 17px;
    line-height: 1;
}

.chart-wrap {
    overflow-x: auto;
    border: 1px solid #d9dee5;
    border-radius: 0 0 8px 8px;
    background: #ffffff;
}

.interactive-chart {
    position: relative;
    width: 100%;
}

.chart-legend {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 13px;
    border: 1px solid rgba(217, 224, 231, 0.9);
    border-radius: 7px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #526071;
    font-size: 11px;
    pointer-events: auto;
}
.chart-legend span,
.chart-legend label { display: inline-flex; align-items: center; gap: 5px; cursor: default; }
.chart-legend label { cursor: pointer; }
.chart-legend input { width: 14px; height: 14px; margin: 0 1px 0 0; accent-color: var(--accent); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.legend-included { background: #0f766e; }
.legend-excluded { border: 1.5px solid #9aa5b1; background: #fff; }
.legend-line { display: inline-block; width: 19px; border-top: 3px solid #c2413b; }

canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

#selectionCanvas {
    position: absolute;
    inset: 0;
    cursor: crosshair;
    pointer-events: auto;
}

.arrays {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.arrays > div {
    min-width: 0;
}

.arrays h2 {
    margin: 0 0 7px;
    color: #344153;
    font-size: 13px;
}

pre {
    min-height: 76px;
    max-height: 140px;
    margin: 0;
    overflow: auto;
    border: 1px solid #d9dee5;
    border-radius: 7px;
    padding: 13px;
    background: #ffffff;
    color: #344153;
    font-size: 12px;
    line-height: 1.55;
}

.data-quality-summary {
    display: flex;
    flex-wrap: wrap;
    margin-top: 14px;
    align-items: center;
    gap: 7px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 14px;
    background: #fff;
    color: #647181;
    font-size: 12px;
}
.data-quality-summary strong { color: #2f3d4e; }
.data-quality-summary span::before { margin-right: 6px; color: #1c8077; content: "✓"; font-weight: 800; }

.note {
    margin-top: 14px;
}

.renewed-table-section,
.results-section,
.history-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid #d9dee5;
}

.renewed-table-section h2,
.results-section h2,
.history-section h2,
.analysis-subsection h2 {
    margin: 0;
    font-size: 18px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.section-kicker {
    margin: 0 0 4px;
    color: #16766f;
    font-size: 10px;
    font-weight: 750;
    text-transform: uppercase;
}

.history-list {
    display: grid;
    gap: 8px;
    margin-top: 11px;
}

.history-item {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid #d9dee5;
    border-radius: 7px;
    padding: 10px 12px;
    background: #ffffff;
}

.history-item > div {
    display: grid;
    gap: 3px;
}

.history-item strong {
    color: #273446;
    font-size: 13px;
}

.history-item span {
    color: #707b89;
    font-size: 12px;
}

.history-item button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
}

.renewed-table-wrap,
.regression-table-wrap {
    margin-top: 11px;
}

#renewedTable td,
.regression-table td {
    height: 40px;
    padding: 0 12px;
    color: #243142;
    font-variant-numeric: tabular-nums;
}

.regression-table th:nth-child(7),
.regression-table td:nth-child(7) {
    min-width: 210px;
}

.confidence-control {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #465365;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.result-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.result-message {
    margin-top: 12px;
    border: 1px solid #ebc7a5;
    border-radius: 7px;
    padding: 11px 13px;
    background: #fff8ef;
    color: #7b4b1f;
    font-size: 13px;
    line-height: 1.5;
}

.analysis-section-nav {
    display: flex;
    margin-top: 16px;
    overflow-x: auto;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}
.analysis-section-nav a {
    border-bottom: 2px solid transparent;
    padding: 9px 11px;
    color: #5f6c7d;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.analysis-section-nav a:hover { border-bottom-color: var(--accent); color: var(--accent); }
#coefficientResults,
#comparisonSection,
#influenceSection,
#methodGuide { scroll-margin-top: 86px; }

.confidence-control select {
    min-height: 34px;
    border: 1px solid #c8d0d9;
    border-radius: 7px;
    padding: 0 28px 0 9px;
    background: #ffffff;
    color: #18212f;
}

.significance-note {
    margin-top: 9px;
    font-size: 12px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.model-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.analysis-subsection {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid #d9dee5;
}

.comparison-metrics {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.analysis-result-table th,
.analysis-result-table td {
    min-width: 160px;
    height: 48px;
    padding: 10px 14px;
    white-space: nowrap;
}

.analysis-result-table th:first-child,
.analysis-result-table td:first-child {
    min-width: 150px;
    font-weight: 750;
}

.analysis-result-table tbody th {
    position: sticky;
    top: auto;
    left: 0;
    z-index: 1;
    background: inherit;
    color: #243142;
    font-size: inherit;
    letter-spacing: normal;
    text-transform: none;
}

.analysis-scroll-table {
    max-height: 430px;
    overflow: auto;
    overscroll-behavior: contain;
}

.analysis-scroll-table .data-table {
    min-width: 1080px;
}

.analysis-scroll-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.method-guide {
    margin-top: 28px;
    border: 1px solid #d9dee5;
    border-radius: 7px;
    background: #ffffff;
}

.method-guide summary {
    padding: 14px 16px;
    color: #273446;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid #e2e6eb;
}

.method-grid > div {
    display: grid;
    gap: 4px;
    padding: 13px 16px;
    border-right: 1px solid #e8ebef;
    border-bottom: 1px solid #e8ebef;
}

.method-grid > div:nth-child(2n) {
    border-right: 0;
}

.method-grid strong {
    color: #344153;
    font-size: 12px;
}

.method-grid span {
    color: #6b7685;
    font-size: 12px;
    line-height: 1.5;
}

.result-metric {
    border: 1px solid #d9dee5;
    border-radius: 7px;
    padding: 13px;
    background: #ffffff;
}

.result-metric span {
    display: block;
    color: #727d8b;
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
}

.result-metric strong {
    display: block;
    margin-top: 7px;
    color: #18212f;
    font-size: 20px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

@media (max-width: 960px) {
    .input-workspace {
        grid-template-columns: 1fr;
    }

    .upload-card {
        grid-template-columns: minmax(180px, 0.6fr) minmax(260px, 1.4fr) auto;
        align-items: center;
    }

    .file-dropzone {
        min-height: 92px;
    }
}

@media (max-width: 720px) {
    .app-header-inner,
    .page-shell {
        width: min(100% - 24px, 1240px);
    }

    .app-header-inner {
        min-height: 0;
        padding: 12px 0;
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .page-nav {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
    }

    .page-nav > * {
        display: flex;
        min-width: 0;
        padding-right: 6px;
        padding-left: 6px;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .page-shell {
        padding: 24px 0 40px;
    }

    .workspace-intro,
    .result-header {
        display: block;
    }

    .workspace-header-actions { margin-top: 14px; justify-content: flex-start; flex-wrap: wrap; }
    .workspace-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .workspace-summary > div { border-bottom: 1px solid #e8ecf0; }
    .workspace-summary > div:nth-child(2n) { border-right: 0; }
    .export-menu-panel { right: auto; left: 0; }

    .trust-panel,
    .method-grid {
        grid-template-columns: 1fr;
    }

    .trust-disclosure,
    .method-grid > div,
    .method-grid > div:nth-child(2n) {
        border-right: 0;
        border-bottom: 1px solid #e1e6eb;
    }

    .trust-disclosure:last-child {
        border-bottom: 0;
    }

    h1 {
        font-size: 30px;
    }

    .intro {
        margin-top: 8px;
        text-align: left;
    }

    .upload-card {
        grid-template-columns: 1fr;
    }

    .workspace-toolbar,
    .table-card-header,
    .table-footer,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .integrity-banner,
    .history-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-item button {
        width: 100%;
    }

    .result-controls {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .table-actions,
    .table-actions > button,
    .table-footer > button {
        width: 100%;
    }

    .table-actions > button {
        flex: 1 1 140px;
    }

    .plot-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar-group button {
        width: 100%;
        white-space: normal;
    }

    .toolbar-group-secondary .access-status {
        grid-column: 1 / -1;
        width: 100%;
        padding: 6px 8px;
        border-radius: 5px;
        background: #f3f6f8;
        text-align: center;
        white-space: normal;
    }

    .arrays,
    .results-grid,
    .model-summary-grid {
        grid-template-columns: 1fr;
    }

    .chart-legend { position: static; border-width: 1px 0 0; border-radius: 0; }

    .dataset-count {
        display: inline-block;
        margin-top: 10px;
    }
}

/* Refined analysis workspace: progressive disclosure and warmer visual hierarchy. */
:root {
    --ink: #173a35;
    --muted: #697670;
    --surface-subtle: #f5f3ed;
    --border: #dedfd8;
    --accent: #2d7668;
    --accent-soft: #e8f1ee;
}

body { background: #f4f2ec; color: #253631; }

.app-header {
    border-bottom: 0;
    background: #173a35;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.app-header-inner { min-height: 60px; }
.app-header .brand { color: #fffdfa; font-family: Georgia, "Songti SC", serif; font-size: 18px; }
.app-header .brand-mark { border: 1px solid rgba(255, 255, 255, 0.5); background: transparent; color: #fff; }
.app-header .nav-link { color: rgba(255, 255, 255, 0.76); }
.app-header .nav-link:hover { color: #fff; }
.app-header .secondary-link { border-color: rgba(255, 255, 255, 0.26); background: rgba(255, 255, 255, 0.1); color: #fff; }
.app-header .language-switcher select { border-color: rgba(255, 255, 255, 0.24); background-color: #254c46; color: #fff; }

.page-shell { padding-top: 30px; }
.result-layout h1,
.result-layout h2 { font-family: Georgia, "Songti SC", serif; letter-spacing: -0.012em; }
.result-header h1 { color: #173a35; font-size: clamp(30px, 3.4vw, 42px); }
.result-header { margin-bottom: 22px; }
.result-header .eyebrow { letter-spacing: 0.13em; }
.workspace-header-actions { flex-wrap: wrap; }

.workspace-summary {
    border-color: #dedfd8;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(23, 58, 53, 0.045);
}
.workspace-summary > div { padding: 14px 17px; border-right-color: #e8e7e1; }
.workspace-summary span { color: #7c837e; font-size: 10px; letter-spacing: 0.08em; }
.workspace-summary strong { color: #173a35; font-family: Georgia, serif; font-size: 21px; }

.analysis-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 18px 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #dedfd8;
    border-radius: 12px;
    background: rgba(255, 253, 250, 0.75);
    list-style: none;
}
.analysis-flow li {
    position: relative;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-right: 1px solid #e5e4de;
    color: #78817c;
}
.analysis-flow li:last-child { border-right: 0; }
.analysis-flow li > span {
    display: grid;
    width: 27px;
    height: 27px;
    place-items: center;
    border: 1px solid #d4d6d0;
    border-radius: 50%;
    background: #fff;
    color: #858b87;
    font-size: 11px;
    font-weight: 800;
}
.analysis-flow li div { display: grid; gap: 3px; min-width: 0; }
.analysis-flow strong { color: #44524d; font-size: 12px; }
.analysis-flow small { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.analysis-flow li.is-active { background: #fff; box-shadow: inset 0 -3px #e9755b; }
.analysis-flow li.is-active > span { border-color: #e9755b; background: #e9755b; color: #fff; }
.analysis-flow li.is-active strong { color: #173a35; }
.analysis-flow li.is-complete > span { border-color: #2d7668; background: #2d7668; color: #fff; }

.analysis-stage {
    overflow: hidden;
    border: 1px solid #dedfd8;
    border-radius: 14px;
    background: #fffdfa;
    box-shadow: 0 14px 38px rgba(23, 58, 53, 0.07);
}
.stage-heading {
    display: flex;
    min-height: 86px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 17px 20px;
    border-bottom: 1px solid #ebe9e3;
}
.stage-heading h2 { margin: 0; color: #173a35; font-size: 21px; }
.stage-heading > div > p:last-child,
.section-description { margin: 6px 0 0; color: #6f7974; font-size: 12px; line-height: 1.55; }
.stage-heading .integrity-banner { width: min(390px, 46%); margin: 0; border: 1px solid #eadbbd; border-left: 3px solid #d79a37; border-radius: 8px; }
.plot-toolbar { border: 0; border-radius: 0; padding: 11px 14px; background: #f8f7f2; }
.selection-bar { border-right: 0; border-left: 0; border-top: 1px solid #ebe9e3; background: #fffdfa; }
.analysis-stage .chart-wrap { border: 0; border-top: 1px solid #ebe9e3; border-radius: 0; }
.primary-result-button { border-color: #173a35; background: #173a35; box-shadow: 0 4px 12px rgba(23, 58, 53, 0.14); }
.refresh-button { border-color: transparent; background: transparent; }

.data-quality-summary {
    margin-top: 16px;
    border-color: #d9e5e0;
    border-radius: 10px;
    background: #f8fbf9;
}
.source-data-details {
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid #dedfd8;
    border-radius: 10px;
    background: #fffdfa;
}
.source-data-details > summary,
.advanced-diagnostics > summary {
    position: relative;
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 48px 12px 16px;
    list-style: none;
    cursor: pointer;
}
.source-data-details > summary::-webkit-details-marker,
.advanced-diagnostics > summary::-webkit-details-marker { display: none; }
.source-data-details > summary::after,
.advanced-diagnostics > summary::after {
    position: absolute;
    top: 50%;
    right: 18px;
    color: #2d7668;
    content: "+";
    font-size: 22px;
    transform: translateY(-50%);
}
.source-data-details[open] > summary::after,
.advanced-diagnostics[open] > summary::after { content: "−"; }
.source-data-details > summary span { display: grid; gap: 3px; }
.source-data-details > summary strong { color: #293a35; font-size: 13px; }
.source-data-details > summary small { color: #7b847f; font-size: 11px; }
.source-data-details > summary b { color: #65736e; font-size: 12px; }
.source-data-details[open] > summary { border-bottom: 1px solid #e7e6df; background: #f8f7f2; }
.source-data-details .arrays { margin: 0; padding: 16px; }
.source-data-details .renewed-table-section { margin: 0; padding: 0 16px 18px; border: 0; }

.results-section {
    margin-top: 28px;
    border: 1px solid #dedfd8;
    border-radius: 14px;
    padding: 24px;
    background: #fffdfa;
    box-shadow: 0 14px 38px rgba(23, 58, 53, 0.06);
}
.results-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.results-heading h2 { margin: 0 0 6px; color: #173a35; font-size: 25px; }
.result-settings { position: relative; }
.result-settings > summary {
    min-height: 38px;
    border: 1px solid #d9ddd7;
    border-radius: 7px;
    padding: 9px 30px 9px 12px;
    background: #fff;
    color: #52615b;
    font-size: 12px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}
.result-settings > summary::after { position: absolute; right: 11px; content: "⌄"; }
.result-settings .result-controls {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 6;
    display: grid;
    width: 300px;
    padding: 14px;
    border: 1px solid #d9ddd7;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 16px 36px rgba(23, 58, 53, 0.14);
}
.analysis-section-nav { margin-top: 20px; gap: 8px; }
.analysis-section-nav a { padding: 10px 12px; border-radius: 7px 7px 0 0; }
.analysis-section-nav a:first-child { color: #2d7668; }
.model-summary-grid { margin-top: 18px; }
.result-metric { border-color: #e0e2dc; border-radius: 9px; background: #f8f7f2; }
.result-metric span { color: #747e78; font-size: 10px; letter-spacing: 0.06em; }
.result-metric strong { color: #173a35; font-family: Georgia, serif; font-size: 21px; }
.coefficient-section { margin-top: 22px; }
.coefficient-section .section-description { max-width: 680px; }

.data-table-wrap { border: 1px solid #e0e2dc; border-radius: 9px; }
.data-table thead th { background: #f2f1eb; color: #53615c; font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; }
.data-table tbody tr:nth-child(even) { background: #faf9f5; }
.data-table tbody tr:hover { background: #f0f7f4; }
.analysis-result-table th:not(:first-child),
.analysis-result-table td:not(:first-child) { text-align: right; }
.analysis-result-table thead th:first-child,
.analysis-result-table tbody td:first-child { position: sticky; left: 0; z-index: 1; background: inherit; }
.diagnostic-flagged { box-shadow: inset 3px 0 #e9755b; }
.diagnostic-flagged td:last-child { color: #a34f3f; font-weight: 750; }

.advanced-diagnostics {
    overflow: hidden;
    border: 1px solid #dedfd8;
    border-radius: 10px;
    padding: 0;
    background: #f8f7f2;
}
.advanced-diagnostics > summary { background: #f8f7f2; }
.advanced-diagnostics > summary h2 { margin: 0; font-size: 17px; }
.advanced-diagnostics > summary .selection-status { max-width: 410px; margin-left: auto; text-align: right; }
.advanced-diagnostics > .section-description,
.advanced-diagnostics > .data-table-wrap,
.advanced-diagnostics > .note { margin-right: 16px; margin-left: 16px; }
.advanced-diagnostics > .section-description { margin-top: 0; padding-top: 3px; }
.advanced-diagnostics > .note { margin-bottom: 16px; }
.method-guide { border-radius: 10px; }

@media (max-width: 860px) {
    .analysis-flow { grid-template-columns: 1fr; }
    .analysis-flow li { border-right: 0; border-bottom: 1px solid #e5e4de; }
    .analysis-flow li:last-child { border-bottom: 0; }
    .stage-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    .stage-heading .integrity-banner { width: 100%; }
    .results-heading { flex-direction: column; }
    .result-settings { width: 100%; }
    .result-settings > summary { width: 100%; }
    .result-settings .result-controls { position: static; width: 100%; margin-top: 7px; box-shadow: none; }
}

@media (max-width: 720px) {
    .app-header .page-nav { border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 10px; }
    .app-header .language-switcher select { width: 100%; }
    .analysis-flow small { white-space: normal; }
    .analysis-stage { border-radius: 10px; }
    .stage-heading { padding: 15px; }
    .results-section { border-radius: 10px; padding: 17px 14px; }
    .advanced-diagnostics > summary { align-items: flex-start; flex-direction: column; }
    .advanced-diagnostics > summary .selection-status { margin-left: 0; text-align: left; }
}
.diagnostic-guidance {
    margin: 14px 0 18px;
    padding: 14px 16px;
    border: 1px solid #cfe4df;
    border-radius: 10px;
    background: #f3faf8;
    color: #223c38;
}

.diagnostic-guidance p {
    margin: 6px 0 0;
    color: #536a66;
}
