/* Extracted styles from index.html */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #1f2933;
    background-color: #f8fafc;
}

body {
    display: flex;
    flex-direction: column;
}

.header {
    flex: 0 0 8%;
    min-height: 60px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 32px;
    font-size: 1.6rem;
    letter-spacing: 0.05em;
}

.header span {
    font-weight: 600;
}

.logout-btn {
    margin-left: auto;
    background: #dc2626;
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(220, 38, 38, .35);
    transition: background .2s, box-shadow .2s, transform .15s;
}

.logout-btn svg {
    pointer-events: none;
}

.logout-btn:hover {
    background: #b91c1c;
    box-shadow: 0 8px 18px rgba(185, 28, 28, .45);
    transform: translateY(-2px);
}

.logout-btn:active {
    transform: translateY(0);
}

.logout-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .45);
}

.main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    flex: 0 0 14%;
    min-width: 200px;
    background-color: #e2e8f0;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-item {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    text-align: left;
    background-color: #fff;
    color: #1f2933;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.menu-item:hover,
.menu-item:focus {
    background-color: #cbd5f5;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    outline: none;
}

.menu-item.active {
    background-color: #1d4ed8;
    color: #fff;
    box-shadow: 0 6px 18px rgba(29, 78, 216, 0.35);
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.filters {
    flex: 0 0 auto;
    min-height: 80px;
    background-color: #fff;
    border-bottom: 1px solid #d1d9e6;
    padding: 16px 32px;
    display: flex;
    align-items: flex-start;
    overflow-y: auto;
}

.filters-panel {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
    row-gap: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    color: #475569;
    min-width: 88px;
    text-align: right;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid #cbd5f5;
    border-radius: 6px;
    background-color: #f8fafc;
    font-size: 0.95rem;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.filter-button {
    padding: 10px 18px;
    border: 1px solid #1d4ed8;
    border-radius: 8px;
    background-color: #fff;
    color: #1d4ed8;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.filter-button:hover,
.filter-button:focus {
    background-color: #e0e7ff;
    box-shadow: 0 6px 18px rgba(29, 78, 216, 0.25);
    outline: none;
}

.filter-button.primary {
    background-color: #1d4ed8;
    color: #fff;
}

.filter-button.primary:hover,
.filter-button.primary:focus {
    background-color: #1e40af;
}

.filter-button.accent {
    border-color: #0f766e;
    color: #0f766e;
}

.filter-button.accent:hover,
.filter-button.accent:focus {
    background-color: #ccfbf1;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1000;
    padding: 24px;
}

.modal.active {
    display: flex;
}

.modal-dialog {
    width: min(760px, 100%);
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    overflow: hidden;
}

.modal-header {
    padding: 20px 28px 12px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #0f172a;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #475569;
}

.modal-body {
    padding: 12px 28px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-row.single {
    flex-direction: column;
}

.form-field {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 0.9rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 4px;
}

.required {
    color: #dc2626;
}

.form-control,
.form-select,
.form-textarea {
    padding: 10px 14px;
    border: 1px solid #cbd5f5;
    border-radius: 8px;
    background-color: #f8fafc;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    outline: none;
    background-color: #fff;
}

.form-textarea {
    min-height: 96px;
    resize: vertical;
}

.modal-footer {
    padding: 16px 28px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #e2e8f0;
    flex: 0 0 auto;
    background: #fff;
}

.modal-action {
    padding: 10px 22px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.modal-action.cancel {
    background-color: #fff;
    border-color: #cbd5f5;
    color: #475569;
}

.modal-action.cancel:hover {
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.modal-action.submit {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.modal-action.submit:hover {
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
    transform: translateY(-1px);
}

.data {
    flex: 1 1 auto;
    padding: 28px 32px;
    display: flex;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.data-panel {
    flex: 1 0 100%;
    width: 100%;
    display: none;
    overflow: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 72px;
}

.data-panel:not([hidden]) {
    display: block;
}

.pagination {
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.pagination-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-label {
    font-size: 0.85rem;
    color: #475569;
}

.pagination-select,
.pagination-button {
    border-radius: 6px;
    border: 1px solid #cbd5f5;
    background-color: #f8fafc;
    padding: 6px 10px;
    font-size: 0.85rem;
    color: #1f2937;
}

.pagination-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    outline: none;
    background-color: #fff;
}

.pagination-button {
    border-color: #2563eb;
    background-color: #2563eb;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.pagination-button:hover,
.pagination-button:focus {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
    outline: none;
}

table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    table-layout: auto;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
}

thead {
    background-color: #f1f5f9;
    color: #0f172a;
}

tbody tr:hover {
    background-color: #f8fafc;
}

.empty-state {
    color: #64748b;
    font-size: 1rem;
    text-align: center;
    padding: 48px 0;
}

[hidden] {
    display: none !important;
}

th.status-running,
td.status-running {
    color: #059669;
    font-weight: 600;
}

th.status-completed,
td.status-completed {
    color: #111827;
    font-weight: 600;
}

/* 序号列加粗并居中，去掉省略 */
th.col-seq,
td.col-seq {
    font-weight: 600;
    text-align: center;
    text-overflow: initial;
}

.col-seq {
    width: 56px;
}

.col-status {
    width: 80px;
}

.col-scheme {
    width: 160px;
}

.col-trial-number {
    width: 160px;
}

.col-name {
    width: 280px;
    max-width: 20ch;
}

.col-volunteer {
    width: 130px;
}

.col-trial-category {
    width: 130px;
}

.col-specialty {
    width: 170px;
}

.col-disease {
    width: 170px;
}

.col-actions {
    width: 150px;
}

/* 人员表格列宽定义 */
.col-people-seq {
    width: 60px;
}

.col-people-name {
    width: 70px;
}

.col-people-gender {
    width: 60px;
}

.col-people-ethnicity {
    width: 60px;
}

.col-people-age {
    width: 60px;
}

.col-people-birthdate {
    width: 120px;
}

.col-people-address {
    width: 22%;
    min-width: 170px;
}

.col-people-idcard {
    width: 16%;
    min-width: 150px;
}

.col-people-trialname {
    width: 20%;
    min-width: 160px;
    max-width: 20ch;
}

.col-people-phone {
    width: 12%;
    min-width: 120px;
}

.col-people-actions {
    width: 15%;
    min-width: 150px;
}

/* 人员表格序号列居中加粗 */
th.col-people-seq,
td.col-people-seq {
    font-weight: 600;
    text-align: center;
}

/* 人员表格文本溢出处理 */
th.col-people-address,
td.col-people-address,
th.col-people-idcard,
td.col-people-idcard,
th.col-people-trialname,
td.col-people-trialname,
th.col-people-phone,
td.col-people-phone {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 优化操作按钮样式，便于压缩列宽 */
.action-btn {
    padding: 6px 10px;
    margin: 0 6px 0 0;
    font-size: 0.8rem;
    border: 1px solid #2563eb;
    background: #fff;
    color: #2563eb;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
}

.action-btn:last-child {
    margin-right: 0;
}

.action-btn:hover,
.action-btn:focus {
    background: #2563eb;
    color: #fff;
    outline: none;
}

td.col-people-actions {
    white-space: normal;
}

.col-people-actions .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.col-people-actions .action-btn:last-child {
    margin-bottom: 0;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 添加：试验名称单元格文本溢出处理（单行省略号） */
th.col-name,
td.col-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === 修正：使长表单可滚动，底部提交按钮固定可见 === */
#experiment-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#people-add-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-dialog {
    height: auto;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 移动端/窄屏优化 */
@media (max-width: 640px) {
    .modal-dialog {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-body {
        padding: 12px 16px 20px;
    }

    .modal-footer {
        padding: 12px 16px 20px;
    }
}

/* 低矮视口高度优化 */
@media (max-height: 700px) {
    .modal-dialog {
        max-height: 96vh;
    }
}

/* 低矮视口：筛选区限制高度，出现滚动条，保证下方数据区域可见 */
@media (max-height: 700px) {
    .filters {
        max-height: 40vh;
    }
}

/* 可选：滚动条样式改善 */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== 详情弹窗表格样式 ========== */
/* 大尺寸模态框 */
.modal-dialog-large {
    width: min(900px, 95%);
}

/* 详情部分间距 */
.detail-section {
    margin-bottom: 28px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

/* 详情表格样式 */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    margin-top: 12px;
    table-layout: auto;
}

.detail-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.detail-table tbody tr:last-child {
    border-bottom: none;
}

.detail-table tbody tr:hover {
    background-color: #f8fafc;
}

.detail-table td {
    padding: 14px 20px;
    font-size: 0.95rem;
    vertical-align: top;
}

/* 详情标签样式（左侧列） */
.detail-table .detail-label {
    width: 160px;
    min-width: 140px;
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-align: right;
    border-right: 2px solid #e2e8f0;
    white-space: nowrap;
}

/* 详情值样式（右侧列） */
.detail-table .detail-value {
    color: #1f2937;
    background-color: #fff;
    padding-left: 24px;
    word-break: break-word;
    line-height: 1.6;
    overflow-wrap: break-word;
}

/* 试验名称特殊处理：确保长文本可以完全显示 */
.detail-table #detail-trialName,
.detail-table #people-detail-trialName {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: none;
}

/* 空值显示 */
.detail-table .detail-value:empty::before {
    content: '—';
    color: #94a3b8;
    font-style: italic;
}

/* 状态值特殊样式 - 通过 JavaScript 添加 class 来实现 */
.detail-table .detail-value.status-running {
    color: #059669;
    font-weight: 600;
}

.detail-table .detail-value.status-completed {
    color: #111827;
    font-weight: 600;
}

/* 详情表格响应式优化 */
@media (max-width: 768px) {
    .modal-dialog-large {
        width: 95%;
    }

    .detail-table td {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .detail-table .detail-label {
        width: 120px;
        min-width: 100px;
        font-size: 0.85rem;
    }
}

/* 详情表格在移动端堆叠显示 */
@media (max-width: 640px) {

    .detail-table,
    .detail-table tbody,
    .detail-table tr,
    .detail-table td {
        display: block;
        width: 100%;
    }

    .detail-table tbody tr {
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
        background-color: #fff;
    }

    .detail-table .detail-label {
        width: 100%;
        text-align: left;
        background-color: transparent;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 8px;
        margin-bottom: 8px;
        font-size: 0.85rem;
        color: #64748b;
    }

    .detail-table .detail-value {
        width: 100%;
        padding-left: 0;
        padding-top: 8px;
    }
}

/* 成功消息提示样式 */
.toast-message {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 280px;
    max-width: 400px;
    padding: 14px 20px;
    background-color: #10b981;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.35);
    font-size: 0.95rem;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease-out, fadeOut 0.3s ease-in 2.7s;
    animation-fill-mode: both;
}

.toast-message::before {
    content: '✓';
    font-size: 1.2rem;
    font-weight: bold;
    flex-shrink: 0;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}