/* ===== 基础 ===== */
* { box-sizing: border-box; }
body {
    margin: 0;
    background: #f3f4f6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1f2937;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== 认证页 ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e0e7ff, #f0f9ff);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
}
.auth-title { font-size: 28px; font-weight: 700; margin: 0 0 4px; color: #1f2937; }
.auth-subtitle { color: #6b7280; margin: 0 0 24px; font-size: 14px; }
.auth-switch { text-align: center; margin-top: 12px; font-size: 14px; color: #6b7280; }
.auth-switch a { color: #3b82f6; text-decoration: none; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 4px; }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.form-group textarea { resize: vertical; }

/* ===== 按钮 ===== */
.btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
}
.btn-block { width: 100%; padding: 12px; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1px solid #d1d5db; color: #374151; }
.btn-outline:hover { background: #f3f4f6; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ===== 顶部栏 ===== */
.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { font-size: 20px; font-weight: 700; color: #1f2937; }
.user-email { font-size: 13px; color: #6b7280; }
.renew-label { font-size: 13px; color: #6b7280; }
.days { font-weight: 600; font-size: 18px; }
.days.green { color: #16a34a; }
.days.orange { color: #f59e0b; }
.days.red { color: #dc2626; }
.threshold-select { padding: 4px 8px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 13px; }

/* ===== 只读横幅 ===== */
.readonly-banner {
    background: #fef2f2;
    border-bottom: 2px solid #fca5a5;
    padding: 10px 24px;
    text-align: center;
    color: #991b1b;
    font-size: 14px;
    font-weight: 500;
}

/* ===== 工具栏 ===== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    align-items: center;
}
.search-input { flex: 1; min-width: 150px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }
.search-input:focus { outline: none; border-color: #3b82f6; }
.filter-select, .sort-select { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; background: #fff; }

/* ===== 卡片列表 ===== */
.card-list {
    padding: 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.empty-state { grid-column: 1/-1; text-align: center; color: #9ca3af; padding: 40px 0; }

/* ===== 卡片 ===== */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s;
    cursor: pointer;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-2px); }
.card.readonly { opacity: 0.6; pointer-events: none; }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.card-meta { font-size: 13px; color: #6b7280; margin: 4px 0 8px; }
.card-email { font-size: 12px; color: #9ca3af; }

/* ===== 徽章 ===== */
.badge {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    background: #e5e7eb;
    color: #374151;
}
.badge.sent { background: #d1fae5; color: #065f46; }
.badge.unsent { background: #fef3c7; color: #92400e; }

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: 16px;
    max-width: 560px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-sm { max-width: 400px; }
.modal-title { font-size: 20px; font-weight: 600; margin: 0 0 16px; }
.modal-hint { color: #6b7280; font-size: 14px; margin: 0 0 16px; }
.modal-input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.modal-input:focus { outline: none; border-color: #3b82f6; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.text-danger { color: #dc2626; }

/* ===== 详情 ===== */
.detail-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.detail-content {
    font-size: 15px;
    color: #374151;
    white-space: pre-wrap;
    padding: 12px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    min-height: 60px;
}
.detail-file { margin-top: 12px; font-size: 13px; color: #6b7280; }
.detail-email { margin-top: 12px; font-size: 13px; color: #9ca3af; }

/* ===== 文件上传 ===== */
.file-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}
.file-upload-area:hover { border-color: #3b82f6; background: #f8fafc; }
.file-upload-area.has-file { border-color: #22c55e; background: #f0fdf4; }

/* ===== 恢复码 ===== */
.recovery-label { font-size: 13px; font-weight: 600; color: #065f46; margin: 0; }
.recovery-code {
    font-size: 20px;
    font-weight: 700;
    color: #16a34a;
    margin: 4px 0;
    letter-spacing: 2px;
    font-family: monospace;
}
.recovery-hint { font-size: 12px; color: #065f46; margin: 0; }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    .topbar { flex-direction: column; gap: 8px; align-items: stretch; }
    .topbar-right { justify-content: center; }
    .toolbar { flex-direction: column; }
    .search-input { min-width: 100%; }
    .card-list { grid-template-columns: 1fr; padding: 12px; }
}
