/* ─── 基础重置 ──────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ─── 导航栏 ──────────────────────────── */
.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
    color: #aaa;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-link.active { color: #fff; background: #e94560; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }

/* ─── 主内容 ──────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ─── 通用组件 ──────────────────────────── */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 16px;
    overflow: hidden;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 18px; }
.text-center { text-align: center; }
.text-muted { color: #999; font-size: 13px; }
.badge {
    background: #e94560;
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

/* ─── 按钮 ──────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 18px; border: none; border-radius: 8px;
    font-size: 14px; cursor: pointer; transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: #e94560; color: #fff; }
.btn-primary:hover { background: #d63851; }
.btn-secondary { background: #eee; color: #333; }
.btn-secondary:hover { background: #ddd; }
.btn-danger { background: #ff4757; color: #fff; }
.btn-danger:hover { background: #e8414a; }
.btn-sm { padding: 4px 10px; font-size: 14px; }
.btn-large { width: 100%; justify-content: center; padding: 14px; font-size: 18px; }
.btn-group { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ─── 表单 ──────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    margin-bottom: 4px; color: #555;
}
.form-input, .form-select {
    width: 100%; padding: 10px 14px; border: 1px solid #ddd;
    border-radius: 8px; font-size: 14px; outline: none;
    background: #fff; transition: border 0.2s;
}
.form-input:focus, .form-select:focus { border-color: #e94560; }
.checkbox-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; color: #333; cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: #e94560; cursor: pointer;
}

/* ─── 表格 ──────────────────────────── */
.table-wrapper { overflow-x: auto; }
.ranking-table {
    width: 100%; border-collapse: collapse; font-size: 14px;
}
.ranking-table th {
    background: #fafafa; text-align: left;
    padding: 10px 12px; font-weight: 600; color: #555;
    border-bottom: 2px solid #eee;
}
.ranking-table td {
    padding: 10px 12px; border-bottom: 1px solid #f0f0f0;
}
.ranking-table tr:hover { background: #fafafa; }
.rank-cell { font-weight: 600; }
.rate-down { color: #2ecc71; font-weight: 600; }  /* 掉秤绿色 */
.rate-up { color: #e74c3c; font-weight: 600; }    /* 增重红色 */
.action-cell { white-space: nowrap; }

/* ─── 称重页 ──────────────────────────── */
.weigh-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.camera-wrapper {
    position: relative; border-radius: 12px; overflow: hidden;
    background: #000; aspect-ratio: 4/3;
}
.camera-wrapper video {
    width: 100%; height: 100%; object-fit: cover;
}
.camera-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
}
.face-guide { text-align: center; }
.face-oval {
    width: 200px; height: 260px; border: 2px dashed rgba(255,255,255,0.5);
    border-radius: 50%; margin: 0 auto 12px;
}
.face-hint { color: rgba(255,255,255,0.8); font-size: 14px; }
.camera-status {
    position: absolute; bottom: 10px; left: 10px;
    display: flex; align-items: center; gap: 6px;
    background: rgba(0,0,0,0.6); padding: 4px 12px;
    border-radius: 20px; color: #fff; font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.running { background: #2ecc71; }
.status-dot.error { background: #e74c3c; }
.status-dot.idle { background: #f39c12; }
/* 活体状态指示器 */
.liveness-status {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.6);
    padding: 4px 12px;
    border-radius: 20px;
    color: #fff;
    font-size: 12px;
}
.liveness-dot { width: 8px; height: 8px; border-radius: 50%; }
.liveness-dot.live { background: #2ecc71; }
.liveness-dot.fake { background: #e74c3c; }
.liveness-dot.disabled { background: #95a5a6; }
.liveness-dot.unknown { background: #f39c12; animation: pulse 2s infinite; }

/* 语音开关按钮 */
.voice-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 20px;
    z-index: 10;
}
.voice-toggle.voice-off { background: #ddd; color: #999; }
.voice-toggle.voice-on { background: #e8f5e9; color: #2e7d32; }
.info-section { position: relative; }
.avatar-large { font-size: 64px; margin-bottom: 8px; }
.avatar-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: 24px; margin-bottom: 4px; }
.user-info { color: #666; font-size: 14px; }
.weight-input-group {
    display: flex; align-items: center; gap: 8px;
}
.weight-input {
    flex: 1; font-size: 28px; font-weight: 700; text-align: center;
    padding: 12px; border: 2px solid #e94560; border-radius: 10px;
    outline: none; width: 100%;
}
.weight-unit { font-size: 20px; color: #666; font-weight: 600; }
.demo-banner {
    background: #fff3cd; color: #856404; padding: 8px 16px;
    border-radius: 8px; font-size: 13px; text-align: center;
}

/* 今日已称重列表 */
.today-list { max-height: 200px; overflow-y: auto; }
.today-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid #f0f0f0;
}
.today-item:last-child { border-bottom: none; }
.today-name { font-weight: 500; }
.today-weight { color: #e94560; font-weight: 600; }

/* ─── 看板页 ──────────────────────────── */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h2 { font-size: 22px; }
.header-controls {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.stats-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.stat-card {
    background: #fff; border-radius: 10px; padding: 16px;
    text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 12px; color: #999; margin-top: 4px; }
.stat-card.best .stat-value { color: #2ecc71; }
.stat-card.avg .stat-value { color: #3498db; }

/* ─── 大屏排名页 ──────────────────────────── */
.leaderboard-container { max-width: 100%; }
.lb-header {
    text-align: center; margin-bottom: 30px;
    display: flex; justify-content: center; align-items: center; gap: 20px;
}
.lb-header h1 { font-size: 32px; }
.lb-select {
    padding: 8px 16px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 16px;
}
.podium {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px; margin-bottom: 24px;
}
.podium-card {
    text-align: center; padding: 24px 16px; border-radius: 16px;
    background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.podium-card.rank-1 { background: linear-gradient(135deg, #ffd700, #ffed4a); }
.podium-card.rank-2 { background: linear-gradient(135deg, #c0c0c0, #e0e0e0); }
.podium-card.rank-3 { background: linear-gradient(135deg, #cd7f32, #e8a860); }
.podium-medal { font-size: 48px; margin-bottom: 8px; }
.podium-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.podium-rate { font-size: 28px; font-weight: 700; color: #2ecc71; }
.podium-weight { font-size: 13px; color: #666; }
.rest-list {
    display: flex; flex-direction: column; gap: 8px;
}
.rest-item {
    display: grid;
    grid-template-columns: 40px 1fr auto 80px;
    align-items: center; gap: 12px;
    background: #fff; padding: 12px 16px; border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.rest-rank { font-weight: 700; color: #999; font-size: 16px; text-align: center; }
.rest-name { font-weight: 500; }
.rest-weight { color: #888; font-size: 13px; }
.rest-rate { font-weight: 700; color: #2ecc71; font-size: 16px; text-align: right; }

/* ─── 弹窗 (Modal) ──────────────────────────── */
.modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-content {
    background: #fff; border-radius: 16px; max-width: 500px;
    width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid #eee;
}
.modal-header h3 { font-size: 18px; }
.modal-close { font-size: 24px; background: none; border: none; cursor: pointer; color: #999; }
.modal-body { padding: 20px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 16px 20px; border-top: 1px solid #eee;
}

/* 人脸录入 */
.face-enroll video {
    width: 100%; border-radius: 8px; background: #000; margin-bottom: 8px;
}
.face-enroll-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.enroll-preview { text-align: center; }
.preview-img { max-width: 200px; border-radius: 8px; margin-bottom: 4px; }

/* ─── 信息表格 ──────────────────────────── */
.info-table { width: 100%; font-size: 13px; }
.info-table td { padding: 6px 8px; border-bottom: 1px solid #f0f0f0; }
.info-table td:first-child { color: #888; width: 100px; }
.info-table code {
    background: #f5f5f5; padding: 2px 6px; border-radius: 4px; font-size: 12px;
    word-break: break-all;
}

/* ─── 响应式: 手机 ──────────────────────────── */
@media (max-width: 768px) {
    .nav-links {
        display: none; width: 100%; flex-direction: column;
        position: absolute; top: 50px; left: 0; background: #1a1a2e;
        padding: 10px; z-index: 99;
    }
    .nav-links.show { display: flex; }
    .nav-toggle { display: block; }
    .weigh-container {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column; align-items: flex-start;
    }
    .podium {
        grid-template-columns: 1fr;
    }
    .podium-card.rank-2 { order: 2; }
    .podium-card.rank-3 { order: 3; }
    .header-controls { width: 100%; }
    .header-controls select, .header-controls input { flex: 1; }
    .main-content { padding: 12px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .lb-header { flex-direction: column; }
}

/* ─── 响应式: 平板 ──────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    .weigh-container {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── 大屏排名页全屏适配 ──────────────────────────── */
@media (min-width: 1920px) {
    .podium-card { padding: 40px 30px; }
    .podium-name { font-size: 32px; }
    .podium-rate { font-size: 36px; }
}

/* ─── 动画 ──────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }
.card, .stat-card, .podium-card { animation: fadeIn 0.3s ease-out; }
@keyframes pulse {
    0%, 100% { opacity: 1; } 50% { opacity: 0.5; }
}
.status-dot.idle { animation: pulse 2s infinite; }

/* ─── 学员管理 ──────────────────────────── */
.admin-container { }


/* ===== 管理端标签页 ===== */
.admin-tabs {
    display: flex;
    gap: 0;
    align-items: flex-end;
}
.admin-tabs .tab {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    color: #666;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: #f5f5f5;
    margin-right: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.admin-tabs .tab:hover {
    background: #e8e8e8;
    color: #333;
}
.admin-tabs .tab.active {
    background: #fff;
    color: #1890ff;
    font-weight: 600;
    border-color: #d9d9d9;
    position: relative;
    top: 1px;
}

/* ─── 电子秤相关样式 ──────────────────────────── */

.scale-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.scale-baudrate {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.scale-baudrate label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.scale-baudrate .form-select {
    width: auto;
    min-width: 100px;
    padding: 6px 10px;
    font-size: 14px;
}

.scale-hint {
    font-size: 12px;
    color: #999;
    text-align: center;
    margin-top: 4px;
}

.scale-hint.connected {
    color: #2ecc71;
    font-weight: 500;
}

.scale-hint.saved {
    color: #e94560;
    font-weight: 600;
}

.scale-hint.unsupported {
    color: #e74c3c;
}

.scale-display {
    text-align: center;
    padding: 16px 0;
    border-top: 1px dashed #eee;
    border-bottom: 1px dashed #eee;
    margin: 12px 0;
}

.weight-realtime {
    font-size: 56px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.weight-unit-label {
    font-size: 18px;
    color: #999;
    margin-top: 4px;
}

.stability-indicator {
    margin: 12px 0;
    padding: 0 4px;
}

.stability-bar {
    width: 100%;
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
}

.stability-progress {
    height: 100%;
    width: 0%;
    border-radius: 5px;
    transition: width 0.3s ease, background-color 0.3s ease;
    background: #3498db;
}

.stability-text {
    font-size: 13px;
    color: #666;
    text-align: center;
    font-weight: 500;
}

/* 稳定性状态样式 */
.stability-indicator.waiting .stability-progress {
    background: #bdc3c7;
    width: 0%;
}

.stability-indicator.waiting .stability-text {
    color: #999;
}

.stability-indicator.stabilizing .stability-progress {
    background: #3498db;
}

.stability-indicator.stabilizing .stability-text {
    color: #3498db;
}

.stability-indicator.stable .stability-progress {
    background: #2ecc71;
    width: 100%;
    animation: pulse-green 1.5s infinite;
}

.stability-indicator.stable .stability-text {
    color: #2ecc71;
    font-weight: 600;
}

.stability-indicator.unstable .stability-progress {
    background: #e74c3c;
    width: 100%;
}

.stability-indicator.unstable .stability-text {
    color: #e74c3c;
}

.stability-indicator.saved .stability-progress {
    background: #e94560;
    width: 100%;
}

.stability-indicator.saved .stability-text {
    color: #e94560;
    font-weight: 600;
}

/* 手动输入切换 */
.manual-input-toggle {
    text-align: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.manual-input-area {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    animation: fadeIn 0.3s ease-out;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 响应式适配 */
@media (max-width: 768px) {
    .weight-realtime {
        font-size: 42px;
    }
    .scale-control {
        gap: 8px;
    }
}
