/* Space Peptides 花名册 · 全局样式 */
/* 设计原则：大色块、大字号、留白舒适、移动友好 */

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

:root {
    --primary: #1f6feb;
    --primary-dark: #1158c7;
    --bg: #f5f7fb;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --text-soft: #666;
    --text-faint: #999;
    --border: #e5e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============== 顶栏 ============== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 28px; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: var(--text-faint); font-size: 12px; }

nav { display: flex; gap: 8px; }
nav a {
    padding: 8px 16px;
    color: var(--text-soft);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
}
nav a:hover { background: var(--bg); }
nav a.active { color: var(--primary); background: rgba(31, 111, 235, 0.08); }

.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .me { color: var(--text-soft); font-size: 14px; }

/* ============== 主体 ============== */
main { max-width: 1200px; margin: 0 auto; padding: 32px; min-height: calc(100vh - 140px); }

/* ============== 登录页 ============== */
.login-body {
    background: linear-gradient(135deg, #1f6feb 0%, #6f42c1 100%);
    min-height: 100vh;
}
.login-main { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .logo-big { font-size: 48px; display: block; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; margin-bottom: 8px; }
.login-header p { color: var(--text-soft); font-size: 14px; }

.qr-wrap { text-align: center; margin-bottom: 24px; }
.qr-img {
    width: 220px;
    height: 220px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: white;
}
.qr-status { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; color: var(--text-soft); font-size: 13px; }
.dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--success);
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.qr-status.is-fail { color: var(--danger); }
.qr-status.is-fail .dot { background: var(--danger); animation: none; }
.qr-status.is-ok { color: var(--success); }
.qr-status.is-ok .dot { background: var(--success); animation: none; }

/* 登录失败提示块（电脑端与手机端同时可见） */
.login-error {
    display: none;
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    white-space: pre-line;
    line-height: 1.7;
}
.login-error.show { display: block; }
.login-error .btn-retry {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 14px;
    background: var(--danger);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 12px;
}
.pre-line { white-space: pre-line; }

.login-tips { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border); }
.step { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-soft); }
.step .num {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: bold;
}

.qr-fallback { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-soft); }
.qr-fallback summary { cursor: pointer; }
.qr-fallback ol { padding-left: 20px; margin-top: 8px; }

.login-footer { margin-top: 16px; text-align: center; color: var(--text-faint); font-size: 11px; }
.login-footer .muted { color: var(--text-faint); }
.login-footer .debug-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    color: var(--warning);
    border: 1px dashed rgba(245, 158, 11, 0.5);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 12px;
    transition: all 0.2s;
}
.login-footer .debug-link:hover { background: rgba(245, 158, 11, 0.08); border-style: solid; }

/* ============== 主区 ============== */
.hero-section { margin-bottom: 32px; }
.hero-section h1 { font-size: 28px; margin-bottom: 8px; }
.hero-section p { color: var(--text-soft); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-top: 24px; }
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 4px;
}
.stat-card .num { font-size: 32px; font-weight: 600; color: var(--primary); }
.stat-card .label { color: var(--text-soft); font-size: 13px; }

/* ============== 工具栏 ============== */
.toolbar {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.search-row { display: flex; flex-wrap: wrap; gap: 8px; }
.search-row input, .search-row select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: white;
    flex: 1; min-width: 120px;
}
.search-row input { flex: 2; min-width: 200px; }
.search-row input:focus, .search-row select:focus { outline: none; border-color: var(--primary); }

/* ============== 按钮 ============== */
.btn-primary, .btn-ghost {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

/* ============== 员工列表 ============== */
.employee-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.emp-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
}
.emp-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.emp-card .head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.emp-card .avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6f42c1);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold;
}
.emp-card .name { font-size: 16px; font-weight: 600; }
.emp-card .meta { color: var(--text-soft); font-size: 13px; margin-bottom: 4px; }
.emp-card .tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    font-size: 11px;
}
.emp-card .tag.probation { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.emp-card .tag.leave { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.empty { text-align: center; padding: 48px; color: var(--text-faint); }

/* ============== 组织架构 ============== */
.org-tree { display: flex; flex-direction: column; gap: 16px; }
.org-company { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.org-name { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.org-name strong { font-size: 18px; }
.org-name small { color: var(--text-faint); }

.org-dept { padding: 12px 0; border-top: 1px solid var(--border); }
.org-dept:first-of-type { border-top: none; }
.dept-name { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--text-soft); }
.dept-name .count { color: var(--text-faint); font-size: 12px; }
.emp-row { display: flex; flex-wrap: wrap; gap: 8px; }
.emp-mini {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px 4px 4px;
    background: var(--bg);
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
}
.emp-mini:hover { background: rgba(31, 111, 235, 0.08); }
.avatar-mini {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6f42c1);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
}

/* ============== 设置 ============== */
.page-section h1 { font-size: 24px; margin-bottom: 4px; }
.page-section > p { color: var(--text-soft); margin-bottom: 24px; }
.settings-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.settings-card h3 { font-size: 16px; margin-bottom: 4px; }
.settings-card .hint { color: var(--text-faint); font-size: 13px; margin-bottom: 12px; }
.settings-card .row { display: flex; align-items: center; gap: 8px; }
.settings-card .row label { color: var(--text-soft); font-size: 14px; }
.settings-card .row input { width: 80px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.settings-card code { background: var(--bg); padding: 2px 8px; border-radius: 4px; font-size: 12px; }

.reminder-row {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.reminder-row:last-child { border-bottom: none; }
.reminder-row .rlabel { flex: 0 0 120px; }
.threshold-input { flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 13px; }

/* ============== 弹窗 ============== */
.modal {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    position: relative;
}
.modal-close {
    position: absolute; top: 12px; right: 12px;
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--text-faint);
}
.modal-content h2 { margin-bottom: 8px; }
.modal-content p { color: var(--text-soft); margin: 4px 0; }

/* ============== 底栏 ============== */
.bottombar {
    text-align: center;
    padding: 16px;
    color: var(--text-faint);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

/* ============== 响应式 ============== */
@media (max-width: 768px) {
    .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    nav { order: 3; width: 100%; justify-content: space-around; }
    main { padding: 16px; }
    .login-card { padding: 32px 24px; }
    .qr-img { width: 180px; height: 180px; }
    .hero-section h1 { font-size: 22px; }
    .stat-card .num { font-size: 24px; }
}