:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --primary: #2f6feb;
  --primary-hover: #1f57c9;
  --success: #16a34a;
  --success-bg: #ecfdf3;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

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

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.topbar .brand img {
  height: 28px;
  width: auto;
  display: block;
}

.login-card .brand-logo {
  display: block;
  height: 48px;
  width: auto;
  margin-bottom: 12px;
}

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.login-card p.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  background: var(--surface);
  color: var(--text);
}

input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover, .btn:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f0f1f3; }

.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

h1.page-title { font-size: 22px; margin: 0 0 20px; }

.module-list, .unit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.module-card, .unit-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.module-card .title, .unit-row .title { font-weight: 600; font-size: 15px; }
.module-card .desc { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-review { background: var(--warning-bg); color: var(--warning); }
.badge-locked { background: #f1f2f4; color: var(--text-muted); }
.badge-done { background: var(--success-bg); color: var(--success); }

.progress-track {
  height: 6px;
  background: #eef0f2;
  border-radius: 999px;
  overflow: hidden;
  width: 100px;
}
.progress-fill { height: 100%; background: var(--primary); }

.unit-row.locked { opacity: 0.55; }
.unit-row.locked .title::before { content: "🔒 "; }
.unit-row.done .title::before { content: "✅ "; }

.content-md {
  font-size: 15px;
}
.content-md h1 { font-size: 20px; }
.content-md h2 { font-size: 17px; margin-top: 24px; }
.content-md blockquote {
  border-left: 3px solid var(--warning);
  background: var(--warning-bg);
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}
.content-md code { background: #f1f2f4; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.content-md ul, .content-md ol { padding-left: 22px; }

.question-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface);
}
.question-block .q-text { font-weight: 600; margin-bottom: 10px; }
.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.option-row:hover { background: #f7f8fa; }
.option-row.correct { background: var(--success-bg); }
.option-row.incorrect { background: var(--danger-bg); }

.result-banner {
  padding: 16px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-weight: 600;
}
.result-banner.pass { background: var(--success-bg); color: var(--success); }
.result-banner.fail { background: var(--danger-bg); color: var(--danger); }

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table.admin-table th { color: var(--text-muted); font-weight: 600; font-size: 13px; }

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: #d1d5db;
  border-radius: 999px;
  transition: 0.2s;
}
.slider::before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}
input:checked + .slider { background-color: var(--success); }
input:checked + .slider::before { transform: translateX(18px); }

.muted { color: var(--text-muted); font-size: 13px; }
.mt-16 { margin-top: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
