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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #4f6ef7;
  --accent-hover: #3d5be8;
  --danger: #e05252;
  --success: #3ecf8e;
  --text: #e8eaf0;
  --text-muted: #7b82a0;
  --text-dim: #4a5068;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

/* ─── Typography ─────────────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 24px;
  display: block;
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.5px; text-transform: uppercase; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-success { background: var(--success); color: #000; }
.btn-full    { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-google {
  background: #ffffff;
  color: #1f1f1f;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn-google:hover { background: #f1f1f1; }

.or-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin: 18px 0;
}
.or-divider::before, .or-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.or-divider span { padding: 0 12px; }

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
  border-radius: 7px;
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(224,82,82,0.15); border: 1px solid rgba(224,82,82,0.3); color: #ff8080; }
.alert-success { background: rgba(62,207,142,0.12); border: 1px solid rgba(62,207,142,0.3); color: var(--success); }

/* ─── Top nav ────────────────────────────────────────────────── */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topnav .brand { margin: 0; font-size: 12px; }
.topnav-right { display: flex; align-items: center; gap: 10px; }

/* ─── Admin layout ───────────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - 56px); }
.admin-sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}
.admin-sidebar a {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.admin-sidebar a:hover, .admin-sidebar a.active {
  color: var(--text);
  background: var(--surface2);
  border-left-color: var(--accent);
}
.admin-content { flex: 1; padding: 28px; overflow-y: auto; }

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

/* ─── Tags/badges ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue   { background: rgba(79,110,247,0.18); color: #7b9bff; }
.badge-green  { background: rgba(62,207,142,0.15); color: var(--success); }

/* ─── PDF Grid (user side) ───────────────────────────────────── */
.pdf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.pdf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pdf-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pdf-icon { font-size: 28px; }
.pdf-title { font-weight: 600; font-size: 14px; line-height: 1.4; }
.pdf-level { font-size: 11px; color: var(--text-muted); }

/* ─── Viewer ─────────────────────────────────────────────────── */
.viewer-wrap {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.viewer-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 50px;
  gap: 12px;
  flex-shrink: 0;
}
.viewer-toolbar .title { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-frame-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.viewer-frame-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
#pdfViewer {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  pointer-events: auto;
}
.watermark-overlay {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.07;
}
.watermark-text {
  position: absolute;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-35deg);
  transform-origin: center;
}

/* ─── Upload zone ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: rgba(79,110,247,0.05); }
.upload-zone input { display: none; }

/* ─── Checkbox list ──────────────────────────────────────────── */
.check-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; }
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.check-item:hover { border-color: var(--accent); }
.check-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.check-item label { cursor: pointer; flex: 1; font-size: 13px; }
.check-item .lvl { font-size: 11px; color: var(--text-muted); }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; }
.close-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; line-height: 1; }

/* ─── Section header ─────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }

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

/* ─── Loading ────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center { display: flex; align-items: center; justify-content: center; height: 200px; }

/* ─── Screen capture defense ─────────────────────────────────── */
@media print { body { display: none !important; } }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
