/* ====== 全局基础 ====== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #2c3e50;
    -webkit-font-smoothing: antialiased;
}
a { color: #667eea; text-decoration: none; }

/* ====== 通用容器 ====== */
.page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    padding: 32px;
    width: 100%;
    max-width: 480px;
}
.card h1 {
    font-size: 22px;
    margin-bottom: 8px;
    text-align: center;
    color: #2c3e50;
}
.card .sub {
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 24px;
}

/* ====== 按钮 ====== */
.btn {
    display: inline-block;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s;
    text-align: center;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(102,126,234,.4); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #ecf0f1; color: #2c3e50; }
.btn.secondary:hover { background: #d5dbdf; box-shadow: none; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #34495e;
    font-weight: 500;
}
.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dcdfe6;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color .15s;
}
.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}

/* ====== 错误提示 ====== */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert.error   { background: #fdecea; color: #c0392b; }
.alert.success { background: #eafaf1; color: #27ae60; }

/* ====== 摄像头预览 ====== */
.camera-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    display: none;
}
.camera-wrap.active { display: block; }
#videoEl, #previewImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.preview-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}
.preview-overlay.hidden { display: none; }

/* ====== 后台头部 ====== */
.topbar {
    background: #fff;
    padding: 14px 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-radius: 12px;
}
.topbar h1 { font-size: 18px; color: #2c3e50; }
.topbar a.logout {
    color: #e74c3c;
    font-size: 14px;
    padding: 6px 14px;
    border: 1px solid #e74c3c;
    border-radius: 6px;
    transition: all .15s;
}
.topbar a.logout:hover { background: #e74c3c; color: #fff; }

/* ====== 照片网格 ====== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.photo-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transition: transform .15s;
}
.photo-card:hover { transform: translateY(-2px); }
.photo-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: #ecf0f1;
    cursor: pointer;
}
.photo-card .meta {
    padding: 10px 12px;
    font-size: 12px;
    color: #7f8c8d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.photo-card .meta a { color: #e74c3c; }

/* ====== 空状态 ====== */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
}
.empty .icon { font-size: 48px; margin-bottom: 12px; }

/* ====== 灯箱 ====== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}
.lightbox.active { display: flex; }
.lightbox img {
    max-width: 95%;
    max-height: 95%;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.lightbox .close {
    position: absolute;
    top: 20px;
    right: 24px;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
}

/* ====== 响应式 ====== */
@media (max-width: 480px) {
    .card { padding: 24px 20px; }
    .card h1 { font-size: 20px; }
}
