/* ============================================================
 * 临床试验生存分析工具 — 学术编辑风样式
 * 设计语言：暖米白底 + 深墨文字 + 深松绿点缀（临床研究的克制与可信）
 * 注意：所有类名与 JS 依赖保持兼容（hidden/missing/step-item 等）
 * ============================================================ */

:root {
    --bg: #F5F3EE;            /* 暖米白页面底 */
    --surface: #FFFFFF;       /* 卡片/表面 */
    --surface-2: #FAF8F4;     /* 次级表面（表头/输入底） */
    --ink: #22302F;           /* 深墨色主文字 */
    --ink-2: #5C6B68;         /* 次级文字 */
    --ink-3: #8A958F;         /* 弱化文字/占位 */
    --line: #E4DED2;          /* 暖灰细边框 */
    --line-strong: #C9C0B0;   /* 强调边框 */
    --accent: #1F5E54;        /* 深松绿主色 */
    --accent-2: #17463F;      /* 主色深（hover） */
    --accent-soft: #E8EFEB;   /* 主色浅底 */
    --danger: #A44534;        /* 砖红（缺失/显著） */
    --danger-soft: #F6E7E3;
    --warn: #8A5A1F;
    --warn-soft: #F5EDDA;
    --ok: #2F6B4F;
    --ok-soft: #E6F0E9;
    --font-serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
    --font-sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-num: 'Noto Sans SC', 'Segoe UI', sans-serif;
    --shadow-card: 0 1px 2px rgba(34, 48, 47, 0.04), 0 4px 16px rgba(34, 48, 47, 0.04);
}

/* ========== Base ========== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    background: var(--bg) !important;
    color: var(--ink) !important;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========== Header ========== */
header {
    background: rgba(255, 255, 255, 0.86) !important;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line) !important;
}
header h1 {
    font-family: var(--font-serif);
    color: var(--ink) !important;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.back-toolkit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff !important;
    background: var(--accent);
    border: 1px solid var(--accent-2);
    border-radius: 8px;
    padding: 6px 12px;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(31, 94, 84, 0.25);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.back-toolkit:hover {
    background: var(--accent-2);
    box-shadow: 0 4px 12px rgba(31, 94, 84, 0.32);
    transform: translateY(-1px);
}
.back-toolkit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========== Step Indicator ========== */
.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    max-width: 100px;
}
.step-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-serif);
    background: var(--surface);
    color: var(--ink-3);
    border: 1.5px solid var(--line-strong);
    transition: all 0.3s ease;
}
.step-label {
    font-size: 0.75rem;
    color: var(--ink-3);
    text-align: center;
    letter-spacing: 0.04em;
    transition: color 0.3s ease;
}
.step-item.active .step-circle {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
    box-shadow: 0 0 0 4px rgba(34, 48, 47, 0.08);
}
.step-item.active .step-label {
    color: var(--ink);
    font-weight: 600;
}
.step-item.completed .step-circle {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.step-item.completed .step-label {
    color: var(--accent);
}
.step-line {
    height: 1.5px;
    flex: 1;
    background: var(--line);
    margin: 0 4px;
    margin-bottom: 24px;
}

/* ========== Card ========== */
.card {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
    padding: 28px;
    border: 1px solid var(--line);
}
.card-title {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.card-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 40px;
    height: 2px;
    background: var(--accent);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    letter-spacing: 0.01em;
}
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-2);
    border-color: var(--accent-2);
}
.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--ink-3);
}
.btn-outline {
    background: var(--surface);
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline:hover:not(:disabled) {
    background: var(--accent-soft);
}

/* ========== Tables ========== */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    background: var(--surface);
}
.data-table thead {
    background: var(--surface-2);
}
.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr:hover {
    background: var(--surface-2);
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Missing cell highlight */
.data-table td.missing {
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 500;
}

/* Missing summary row (results table) */
.data-table.results-table tr.missing-row td {
    color: var(--danger);
    font-weight: 600;
    background: var(--danger-soft);
}

/* Results table special styling */
.data-table.results-table {
    font-size: 0.8125rem;
}
.data-table.results-table thead th {
    background: var(--ink);
    color: #F3F1EA;
    padding: 10px 14px;
    font-weight: 600;
    border-color: var(--ink);
    letter-spacing: 0.03em;
}
.data-table.results-table tbody td {
    padding: 6px 14px;
    vertical-align: top;
    border-color: var(--line);
}
.data-table.results-table .var-header {
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
}
.data-table.results-table .stat-label {
    color: var(--ink-2);
    font-size: 0.75rem;
    padding-left: 8px;
}
.data-table.results-table .stat-value {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
}
.data-table.results-table .p-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.data-table.results-table .p-significant {
    color: var(--danger);
}
.data-table.results-table .p-ns {
    color: var(--ink);
}
.data-table.results-table .method-cell {
    font-size: 0.75rem;
    color: var(--ink-2);
}
.data-table.results-table .group-header {
    background: var(--surface-2);
}

/* Survival table group separator */
.data-table tr.group-sep td {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--accent);
    padding: 6px 12px;
    border-top: 1px solid var(--line);
}

/* ========== Radio / Select ========== */
.radio-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 6px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    transition: all 0.15s ease;
    background: var(--surface);
    color: var(--ink-2);
}
.radio-inline:hover {
    border-color: var(--ink-3);
}
.radio-inline:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.radio-inline input[type='radio'] {
    accent-color: var(--accent);
}
.radio-inline input[type='checkbox'] {
    accent-color: var(--accent);
}

.select-input {
    width: 100%;
    max-width: 320px;
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select-input:hover {
    border-color: var(--ink-3);
}
.select-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 94, 84, 0.12);
}

/* Text inputs in chart config */
input[type='text'], input[type='number'] {
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type='text']:focus, input[type='number']:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 94, 84, 0.12);
}
input[type='color'] {
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 0;
    background: var(--surface);
    cursor: pointer;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(34, 48, 47, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
/* 覆盖组件层 display：JS 用 class hidden 开关弹层/步骤 */
.hidden { display: none !important; }
.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 32px;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(34, 48, 47, 0.18);
    border: 1px solid var(--line);
}

/* ========== Loader ========== */
.loader {
    width: 44px;
    height: 44px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== Drop Zone ========== */
.drop-zone {
    border: 1.5px dashed var(--line-strong);
    border-radius: 10px;
    padding: 28px 24px;
    text-align: center;
    background: var(--surface-2);
    transition: all 0.2s ease;
    cursor: default;
}
.drop-zone:hover {
    border-color: var(--ink-3);
}
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.drop-zone-icon {
    display: inline-flex;
    opacity: 0.85;
    color: var(--ink-3);
}
.drop-zone-icon svg {
    width: 38px;
    height: 38px;
}
.drop-zone-text {
    font-size: 0.8125rem;
    color: var(--ink-2);
    margin: 0;
}
.step-panel {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== Chart Panel ========== */
.chart-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    aspect-ratio: 16 / 9;
    box-sizing: border-box;
    min-height: 260px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.chart-panel canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ========== Missing Badge ========== */
.missing-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.missing-badge.ok {
    background: var(--ok-soft);
    color: var(--ok);
}
.missing-badge.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

/* ========== Notes ========== */
.footnote-item {
    padding: 4px 0;
    border-bottom: 1px dashed var(--line);
    color: var(--ink-2);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #F3F1EA;
    padding: 10px 26px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 2000;
    box-shadow: 0 8px 24px rgba(34, 48, 47, 0.2);
    animation: toastIn 0.3s ease;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }

/* ========== Variable Checkbox ========== */
.var-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}
.data-table td.text-center {
    text-align: center;
    vertical-align: middle;
}

/* ========== 语义化文本 / 组件工具类（替代 tailwind 配色类） ========== */
.label-text { color: var(--ink); }
.hint-text { color: var(--ink-2); }
.ok-text { color: var(--ok); }
.sig-text { color: var(--danger); }
.warn-text { color: var(--warn); }

.paste-area {
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 12px;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.paste-area:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 94, 84, 0.12);
}

.info-card {
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.error-box {
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 0.875rem;
}

.footnote-box {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 0.75rem;
    color: var(--ink-2);
}
.footnote-title {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}

.summary-total td {
    background: var(--surface-2);
    font-weight: 600;
}

.export-icon {
    width: 32px;
    height: 32px;
}

.modal-warn-icon {
    width: 26px;
    height: 26px;
    color: var(--warn);
    flex-shrink: 0;
}

.header-icon {
    width: 24px;
    height: 24px;
    color: var(--accent);
    flex-shrink: 0;
}

.btn-sub {
    opacity: 0.72;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .card { padding: 16px; }
    .step-item { max-width: 70px; }
    .step-circle { width: 30px; height: 30px; font-size: 0.75rem; }
    .step-label { font-size: 0.625rem; }
    .modal-content { padding: 24px; }
}
