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

:root {
  --sidebar-w: 220px;
  --sidebar-bg: #0d2137;
  --sidebar-hover: #1a3a5c;
  --sidebar-active: #1e6fc4;
  --header-h: 60px;
  --primary: #1e6fc4;
  --primary-dark: #155ba0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --bg: #f0f4f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body { font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .3px;
}
.sidebar-logo .logo-icon { font-size: 22px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section { padding: 16px 16px 4px; color: rgba(255,255,255,.35); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  text-decoration: none;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(30,111,196,.25); color: #fff; border-left-color: var(--sidebar-active); }
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,.07);
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.user-info-sidebar { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta { color: rgba(255,255,255,.45); font-size: 11px; }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  transition: all .15s;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }

.page-body { flex: 1; padding: 24px; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d2137 0%, #1e3a5f 60%, #0d5490 100%);
}
.login-card {
  width: 400px;
  background: var(--card);
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 8px; }
.login-logo .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.login-logo .icon { font-size: 40px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,111,196,.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; width: 100%; justify-content: center; }
.btn-icon { padding: 6px 8px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 600; padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.tier-S  { background: #ede9fe; color: #5b21b6; }
.tier-Ap { background: #dbeafe; color: #1d4ed8; }
.tier-A  { background: #e0f2fe; color: #0369a1; }
.tier-Am { background: #cffafe; color: #0e7490; }
.tier-Bp { background: #d1fae5; color: #065f46; }
.tier-B  { background: #fef3c7; color: #92400e; }
.tier-Bm { background: #fee2e2; color: #991b1b; }
.badge-locked { background: #f1f5f9; color: #94a3b8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-item {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Alerts / Toast ──────────────────────────────────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  min-width: 260px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slide-in .2s ease;
}
.toast-success { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.toast-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card);
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { font-size: 20px; cursor: pointer; color: var(--text-muted); background: none; border: none; line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-lg { max-width: 720px; }

/* ── Video Player ────────────────────────────────────────────────────────── */
.video-player-wrap {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16/9;
}
.video-player-wrap video { width: 100%; height: 100%; display: block; }

/* ── File cards ──────────────────────────────────────────────────────────── */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.file-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s; }
.file-card:hover { box-shadow: var(--shadow-md); }
.file-card.locked { opacity: .65; }
.file-card-top { display: flex; align-items: flex-start; gap: 12px; }
.file-icon { font-size: 28px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; line-height: 1.3; word-break: break-word; }
.file-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.file-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.file-actions { display: flex; gap: 8px; margin-top: auto; }

/* ── Stats grid ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 4px; }
.stat-icon { font-size: 24px; float: right; opacity: .2; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── FAQ ─────────────────────────────────────────────────────────────────── */
.faq-item { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.faq-q { padding: 14px 16px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; }
.faq-q:hover { background: #fafbff; }
.faq-q .arrow { transition: transform .2s; color: var(--text-muted); font-size: 12px; }
.faq-item.open .faq-q .arrow { transform: rotate(180deg); }
.faq-a { display: none; padding: 14px 16px; background: #f8fafc; border-top: 1px solid var(--border); line-height: 1.6; font-size: 13.5px; color: var(--text); white-space: pre-wrap; }
.faq-item.open .faq-a { display: block; }
.faq-pending-item { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; }

/* ── Upload progress ─────────────────────────────────────────────────────── */
.upload-progress { display: none; margin-top: 12px; }
.upload-progress.show { display: block; }
.progress-bar { height: 6px; border-radius: 3px; background: #e2e8f0; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; width: 0%; }
.upload-status { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Checkbox list ───────────────────────────────────────────────────────── */
.check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.check-item input { cursor: pointer; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-danger { color: var(--danger); }
.font-600 { font-weight: 600; }
.w-full { width: 100%; }
