* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #0a1628;
    --text-color: #e8e8e8;
    --header-bg: #1a2a4a;
    --accent-color: #2d8cf0;
    --status-normal: #52c41a;
    --status-delay: #faad14;
    --status-early: #13c2c2;
    --status-checkin: #f5222d;
    --border-color: rgba(255,255,255,0.08);
    --row-hover: rgba(255,255,255,0.03);
    --font-size-base: 16px;
    --font-size-title: 28px;
    --font-size-header: 14px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: var(--font-size-base);
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 设置面板 - 右侧弹出 */
.settings-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    max-width: 100vw;
    height: 100%;
    height: -webkit-fill-available;
    background: #1a1a2e;
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}

.settings-panel.active {
    right: 0;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.settings-overlay.active {
    display: block;
}

.settings-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #aaa;
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    background: #0f0f23;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-danger {
    background: #ff4d4f;
    color: white;
}

/* 主容器 */
.main-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: padding 0.3s;
}

/* 顶部信息栏 */
.top-bar {
    background: var(--header-bg);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-color);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.station-name {
    font-size: var(--font-size-title);
    font-weight: 700;
    letter-spacing: 2px;
}

.top-info {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 14px;
}

.current-time {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.date-info {
    opacity: 0.8;
    font-size: 20px;
}

/* 表格区域 */
.board-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 表头固定 */
.table-header-wrapper {
    flex-shrink: 0;
    background: var(--bg-color);
    z-index: 10;
}

/* 置顶检票信息区域 */
.pinned-checkin-wrapper {
    flex-shrink: 0;
    background: rgba(245, 34, 45, 0.05);
    border-bottom: 2px solid var(--status-checkin);
    max-height: 30vh;
    overflow-y: auto;
    z-index: 9;
}

.pinned-checkin-wrapper .board-table {
    background: transparent;
}

.pinned-checkin-wrapper .board-table td {
    background: rgba(245, 34, 45, 0.08);
    border-bottom: 1px solid rgba(245, 34, 45, 0.2);
}

.pinned-checkin-wrapper .board-table tr:hover {
    background: rgba(245, 34, 45, 0.15);
}

.board-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.board-table th {
    background: rgba(0,0,0,0.3);
    padding: 12px 16px;
    text-align: left;
    font-size: var(--font-size-header);
    font-weight: 500;
    color: #aaa;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 列宽定义 - 统一使用百分比 */
.board-table th:nth-child(1),
.board-table td:nth-child(1) { width: 12%; }
.board-table th:nth-child(2),
.board-table td:nth-child(2) { width: 10%; }
.board-table th:nth-child(3),
.board-table td:nth-child(3) { width: 10%; }
.board-table th:nth-child(4),
.board-table td:nth-child(4) { width: 15%; }
.board-table th:nth-child(5),
.board-table td:nth-child(5) { width: 40%; }
.board-table th:nth-child(6),
.board-table td:nth-child(6) { width: 13%; }

/* 滚动模式下隐藏行底部边框 */
.scroll-mode-container .board-table td {
    border-bottom: none;
}

.board-table tbody tr:hover {
    background: var(--row-hover);
}

.train-no {
    font-weight: 700;
    color: var(--accent-color);
    font-size: calc(var(--font-size-base) + 2px);
}

.destination {
    font-weight: 500;
}

.depart-time {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

.check-info {
    opacity: 0.8;
    font-size: calc(var(--font-size-base) - 1px);
}

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: calc(var(--font-size-base) - 2px);
    font-weight: 500;
}

.status-normal {
    color: var(--status-normal);
    background: rgba(82, 196, 26, 0.1);
}

.status-delay {
    color: var(--status-delay);
    background: rgba(250, 173, 20, 0.1);
}

.status-early {
    color: var(--status-early);
    background: rgba(19, 194, 194, 0.1);
}

.status-checkin {
    color: var(--status-checkin);
    background: rgba(245, 34, 45, 0.1);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 表格内容区域 */
.table-body-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* 翻页模式 */
.page-mode-container {
    height: 100%;
    overflow: auto;
}

/* 滚动模式容器 */
.scroll-mode-container {
    height: 100%;
    overflow: hidden;
    position: relative;
}

.scroll-content {
    position: absolute;
    width: 100%;
    will-change: transform;
}

/* 内容区域工具栏 */
.content-toolbar {
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.content-toolbar-left {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.content-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tool-btn {
    padding: 6px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.tool-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent-color);
}

.page-indicator {
    font-size: 13px;
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
}

/* 底部信息栏 */
.bottom-bar {
    background: var(--header-bg);
    padding: 10px 20px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--border-color);
}

/* iOS Safari 底部安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-bar {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}

/* 站名可点击样式 */
.station-name {
    font-size: var(--font-size-title);
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.2s;
}

.station-name:hover {
    opacity: 0.8;
}

.station-name:active {
    opacity: 0.6;
}



.bottom-bar-left,
.bottom-bar-right {
    flex: 1;
}

.bottom-bar-center {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.scroll-hint {
    opacity: 0.6;
}

.countdown {
    font-variant-numeric: tabular-nums;
    color: var(--accent-color);
}

/* 全屏样式 - 隐藏底部控制按钮 */
.fullscreen .bottom-bar-center {
    display: none;
}

/* 全屏时隐藏内容工具栏 */
.fullscreen .content-toolbar {
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.fullscreen:hover .content-toolbar {
    opacity: 1;
    pointer-events: auto;
}

/* 加载状态 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 14px;
    opacity: 0.6;
}

.error-msg {
    text-align: center;
    padding: 40px;
    opacity: 0.7;
}

/* 铺满模式 - 均匀分布行 */
.auto-fill .board-table {
    height: 100%;
}

.auto-fill .board-table tbody {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.auto-fill .board-table tbody tr {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 0;
}

.auto-fill .board-table tbody tr td {
    flex: 1;
    display: flex;
    align-items: center;
    border-bottom: none;
}

/* 手机端适配 */
@media (max-width: 768px) {
    :root {
        --font-size-base: 14px;
        --font-size-title: 20px;
        --font-size-header: 12px;
    }

    .top-bar {
        padding: 10px 12px;
    }

    .station-name {
        letter-spacing: 1px;
    }

    .top-info .date-info{
        gap: 10px;
        font-size: 12px;
    }

    .current-time {
        font-size: 16px;
    }

    .content-toolbar {
        padding: 6px 12px;
    }

    .board-table th,
    .board-table td {
        padding: 10px 8px;
    }

    /* 隐藏部分列 */
    .board-table th:nth-child(3),
    .board-table td:nth-child(3) {
        display: none;
    }

    .board-table th:nth-child(1),
    .board-table td:nth-child(1) { width: 18%; }
    .board-table th:nth-child(2),
    .board-table td:nth-child(2) { width: 25%; }
    .board-table th:nth-child(4),
    .board-table td:nth-child(4) { width: 20%; }
    .board-table th:nth-child(5),
    .board-table td:nth-child(5) { width: 22%; }
    .board-table th:nth-child(6),
    .board-table td:nth-child(6) { width: 15%; }

    .check-info {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .settings-panel {
        width: 100%;
        right: -100%;
        height: 100%;
        height: -webkit-fill-available;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .bottom-bar {
        padding: 8px 12px;
        flex-direction: column;
        gap: 6px;
    }

    .bottom-bar-left,
    .bottom-bar-right,
    .bottom-bar-center {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .board-table th:nth-child(5),
    .board-table td:nth-child(5) {
        display: none;
    }

    .board-table th:nth-child(1),
    .board-table td:nth-child(1) { width: 22%; }
    .board-table th:nth-child(2),
    .board-table td:nth-child(2) { width: 30%; }
    .board-table th:nth-child(4),
    .board-table td:nth-child(4) { width: 25%; }
    .board-table th:nth-child(6),
    .board-table td:nth-child(6) { width: 23%; }
}

/* 提示消息 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 2000;
    transition: transform 0.3s;
    border: 1px solid var(--border-color);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}
