/* ================================ 基础样式 ================================ */

:root {
    --bg-primary: #FAF9F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F5F4F2;
    --text-primary: #1A1A1A;
    --text-secondary: #6B6B6B;
    --text-muted: #9B9B9B;
    --border-color: #E5E5E5;
    --accent-primary: #D97706;
    --accent-secondary: #92400E;
    --success: #059669;
    --warning: #D97706;
    --error: #DC2626;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ================================ 认证界面 ================================ */

.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 360px;
}

.auth-card h1 {
    font-size: 48px;
    margin-bottom: 16px;
}

.auth-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.auth-card input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.error-text {
    color: var(--error);
    font-size: 14px;
    margin-top: 12px;
}

/* ================================ 主界面 ================================ */

.main-screen {
    padding-bottom: 40px;
}

/* 头部 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.btn-icon {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-icon:active {
    transform: scale(0.95);
}

/* 状态卡片 */
.status-section {
    margin-bottom: 24px;
}

.status-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.status-item {
    text-align: center;
}

.status-item .label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-item .value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.status-item .value.gap {
    color: var(--success);
}

.status-item .value.gap.warning {
    color: var(--warning);
}

.status-item .value.gap.error {
    color: var(--error);
}

.status-time {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* 操作按钮 */
.actions-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-secondary);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.btn-icon-left {
    margin-right: 8px;
}

/* 结果展示 */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.results-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.results-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.results-status.success {
    background: #D1FAE5;
    color: var(--success);
}

.results-status.error {
    background: #FEE2E2;
    color: var(--error);
}

.results-summary {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.table-container {
    overflow-x: auto;
    margin: 0 -20px;
    padding: 0 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    font-variant-numeric: tabular-nums;
}

td:first-child {
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-icon {
    font-size: 16px;
}

.match-icon.success {
    color: var(--success);
}

.match-icon.error {
    color: var(--error);
}

.results-duration {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(250, 249, 247, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-content p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ================================ 响应式 ================================ */

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .status-card {
        padding: 20px 16px;
        gap: 12px;
    }
    
    .status-item .value {
        font-size: 18px;
    }
    
    .actions-section {
        grid-template-columns: 1fr;
    }
    
    .btn {
        padding: 18px 20px;
    }
    
    th, td {
        padding: 10px 6px;
        font-size: 13px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1A1A1A;
        --bg-secondary: #2D2D2D;
        --bg-tertiary: #3D3D3D;
        --text-primary: #F5F5F5;
        --text-secondary: #A0A0A0;
        --text-muted: #707070;
        --border-color: #404040;
    }
    
    .loading-overlay {
        background: rgba(26, 26, 26, 0.9);
    }
}
