:root {
  --ink: #172126;
  --muted: #637076;
  --line: #dce4e8;
  --surface: #ffffff;
  --canvas: #f4f7f9;
  --teal: #0281cc;
  --teal-deep: #006ca9;
  --teal-soft: #e8f5fc;
  --coral: #d95f4b;
  --coral-soft: #fbece8;
  --gold: #ca9a0f;
  --gold-soft: #fff5d6;
  --blue: #0281cc;
  --blue-soft: #e8f5fc;
  --danger: #b23a38;
  --shadow: 0 8px 26px rgba(0, 70, 110, .1);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    linear-gradient(180deg, #e8f5fc 0, #f6f9fb 38%, #eef3f6 100%);
}
.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid rgba(2, 129, 204, .18);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}
.login-brand {
  position: relative;
  padding: 30px 26px 26px;
  color: white;
  background: var(--teal-deep);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 6px;
  font-size: 26px;
  font-weight: 800;
}
.login-brand h1 { margin: 0; font-size: 25px; line-height: 1.3; }
.login-brand p { margin: 8px 0 0; color: rgba(255,255,255,.8); }
.login-form { padding: 26px; }
.form-field { margin-bottom: 17px; }
.form-field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; color: #435157; }
.form-field input, .form-field select, .form-field textarea, .search-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd9d7;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  outline: none;
}
.form-field textarea { min-height: 90px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(2,129,204,.14);
}
.primary-btn, .secondary-btn, .danger-btn, .icon-btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 700;
}
.primary-btn { color: white; background: var(--teal); }
.primary-btn:hover { background: var(--teal-deep); }
.secondary-btn { color: var(--teal-deep); background: white; border-color: #9ccfea; }
.danger-btn { color: white; background: var(--danger); }
.wide { width: 100%; }
.demo-accounts { margin-top: 18px; padding: 13px; background: #f5f8f7; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.8; color: var(--muted); }
.demo-account { display: flex; justify-content: space-between; gap: 12px; }

.app-shell { min-height: 100vh; }
.desktop-sidebar { display: none; }
.app-main { min-height: 100vh; padding-bottom: 78px; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 8px 16px;
  color: white;
  background: var(--teal-deep);
  box-shadow: 0 2px 12px rgba(0,108,169,.22);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-mark { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border: 1px solid rgba(255,255,255,.7); border-radius: 5px; font-weight: 800; }
.topbar-title { min-width: 0; }
.topbar-title strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title span { display: block; margin-top: 2px; color: rgba(255,255,255,.68); font-size: 11px; }
.user-button { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.42); border-radius: 50%; color: white; background: transparent; }
.user-button:hover { background: rgba(255,255,255,.1); }
.user-icon { position: relative; display: block; width: 20px; height: 20px; }
.user-icon::before { content: ""; position: absolute; top: 1px; left: 6px; width: 6px; height: 6px; border: 2px solid currentColor; border-radius: 50%; }
.user-icon::after { content: ""; position: absolute; left: 2px; bottom: 1px; width: 14px; height: 7px; border: 2px solid currentColor; border-radius: 9px 9px 3px 3px; }

.content { width: min(1100px, 100%); margin: 0 auto; padding: 16px; }
.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: #6d4b0a;
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  border-radius: 4px;
  font-size: 13px;
}
.notice-label { flex: 0 0 auto; font-weight: 800; }
.notice-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 12px 0 14px; }
.page-heading h2 { margin: 0; font-size: 22px; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.text-link { border: 0; padding: 0; color: var(--teal); background: transparent; font-weight: 700; }

.search-box { display: flex; gap: 8px; margin-bottom: 16px; }
.search-box input { flex: 1; }
.search-box button { flex: 0 0 auto; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.quick-entry {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 3px 12px rgba(0,70,110,.05);
}
.quick-entry:hover { border-color: #7ec3e8; transform: translateY(-1px); }
.quick-glyph { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 10px; border-radius: 5px; color: white; background: var(--teal); font-weight: 800; }
.quick-entry:nth-child(2) .quick-glyph { color: var(--ink); background: var(--gold); }
.quick-entry:nth-child(3) .quick-glyph { background: var(--blue); }
.quick-entry:nth-child(4) .quick-glyph { color: var(--ink); background: var(--gold); }
.quick-entry strong { display: block; }
.quick-entry small { display: block; margin-top: 5px; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 18px; }
.metric { padding: 14px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 6px; font-size: 24px; }
.metric em { font-size: 12px; color: var(--muted); font-style: normal; }
.section { margin-top: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title h3 { margin: 0; font-size: 17px; }

.list { display: grid; gap: 9px; }
.list-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 13px 14px;
  background: white;
  text-align: left;
  color: var(--ink);
}
.list-item:hover { border-color: #7ec3e8; }
.list-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.list-title strong { line-height: 1.45; }
.list-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.list-summary { margin: 9px 0 0; color: #48565b; font-size: 13px; line-height: 1.6; }
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border-radius: 4px; color: var(--teal-deep); background: var(--teal-soft); font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.coral { color: #8d3729; background: var(--coral-soft); }
.badge.gold { color: #73500d; background: var(--gold-soft); }
.badge.gray { color: #4e5a5f; background: #edf1f0; }
.badge.blue { color: #255679; background: var(--blue-soft); }
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip { min-height: 34px; padding: 6px 12px; border: 1px solid #cbd6d4; border-radius: 17px; background: white; color: #435157; white-space: nowrap; }
.filter-chip.active { color: white; background: var(--teal); border-color: var(--teal); }

.detail-card { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 17px; }
.detail-card h2 { margin: 8px 0 12px; font-size: 22px; line-height: 1.4; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.detail-section { padding: 15px 0; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 8px; font-size: 15px; color: var(--teal-deep); }
.detail-section p { margin: 0; white-space: pre-wrap; line-height: 1.8; color: #354247; }
.detail-actions { display: flex; gap: 8px; margin-top: 16px; }
.back-btn { margin-bottom: 12px; }

.exam-card { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 16px; }
.exam-card + .exam-card { margin-top: 10px; }
.exam-card h3 { margin: 0 0 8px; font-size: 17px; }
.exam-info { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0; color: var(--muted); font-size: 12px; }
.exam-toolbar { position: sticky; z-index: 18; top: 62px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -16px -16px 14px; padding: 10px 16px; background: white; border-bottom: 1px solid var(--line); }
.exam-toolbar strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-toolbar .countdown, .exam-toolbar button { flex: 0 0 auto; }
.countdown { font-variant-numeric: tabular-nums; color: var(--danger); font-weight: 800; }
.progress-track { height: 6px; margin-bottom: 14px; overflow: hidden; border-radius: 3px; background: #dfe8e6; }
.progress-bar { height: 100%; background: var(--teal); transition: width .2s; }
.question-card { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 18px; }
.question-index { color: var(--teal); font-weight: 800; }
.question-stem { margin: 10px 0 17px; font-size: 18px; line-height: 1.6; font-weight: 700; }
.option-list { display: grid; gap: 9px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d4dddc;
  border-radius: 6px;
  background: white;
  line-height: 1.55;
}
.option.selected { border-color: var(--teal); background: var(--teal-soft); }
.option input { margin-top: 3px; accent-color: var(--teal); }
.exam-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 14px; }
.exam-nav button:last-child { justify-self: stretch; }
.mark-btn.active { color: #7a5206; background: var(--gold-soft); border-color: #d7b266; }
.answer-sheet { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 14px; }
.answer-cell { height: 38px; border: 1px solid #ccd7d5; border-radius: 5px; background: white; }
.answer-cell.answered { color: white; background: var(--teal); border-color: var(--teal); }
.answer-cell.marked { box-shadow: inset 0 -4px 0 var(--gold); }
.result-score { display: grid; place-items: center; width: 130px; height: 130px; margin: 10px auto 18px; border: 10px solid var(--teal-soft); border-radius: 50%; color: var(--teal-deep); font-size: 34px; font-weight: 800; }
.result-score.failed { color: var(--danger); border-color: var(--coral-soft); }
.review-item { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.review-item + .review-item { margin-top: 9px; }
.review-item.wrong { border-left: 4px solid var(--coral); }
.review-item.correct { border-left: 4px solid var(--teal); }
.review-answer { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.chart { padding: 14px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(74px, 110px) 1fr 46px; align-items: center; gap: 9px; margin: 10px 0; font-size: 12px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; overflow: hidden; border-radius: 4px; background: #e5ebea; }
.bar-fill { height: 100%; background: var(--coral); }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 18px; }
.trend-col { flex: 1; min-width: 34px; text-align: center; }
.trend-bar { width: 100%; min-height: 4px; background: var(--teal); border-radius: 4px 4px 0 0; }
.trend-value { margin-top: -19px; color: var(--teal-deep); font-size: 11px; font-weight: 700; }
.trend-label { margin-top: 7px; color: var(--muted); font-size: 10px; }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #47565b; background: #f3f6f5; font-size: 12px; }
td { font-size: 13px; }

.admin-tabs { display: flex; gap: 7px; margin-bottom: 12px; overflow-x: auto; }
.admin-panel { padding: 16px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.admin-panel h3 { margin: 0 0 14px; }
.admin-stack { display: grid; gap: 14px; }
.panel-heading { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-heading h3 { margin-bottom: 5px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.import-columns { margin-bottom: 10px; padding: 10px 12px; color: var(--teal-deep); background: #f0f8fc; border: 1px solid #c9e6f5; border-radius: 6px; font-size: 12px; line-height: 1.6; }
.form-field .import-textarea { min-height: 132px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row-actions { display: flex; gap: 7px; }
.compact-btn { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.modal-actions { display: grid; gap: 9px; }
.section-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }
.draft-list { display: grid; gap: 12px; }
.draft-card { padding: 15px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.draft-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 700; }
.draft-card .form-field { margin-bottom: 12px; }
.draft-card textarea { min-height: 72px; }
.form-grid { display: grid; gap: 12px; }
.form-grid .form-field { margin: 0; }
.help-text { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  background: white;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(0,70,110,.08);
}
.bottom-nav button { border: 0; background: white; color: #647176; font-size: 12px; font-weight: 700; }
.bottom-nav button.active { color: var(--teal); box-shadow: inset 0 3px 0 var(--teal); }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); background: white; border: 1px dashed #c8d3d1; border-radius: 7px; }
.loading { min-height: 180px; display: grid; place-items: center; color: var(--muted); }
.toast { position: fixed; z-index: 100; left: 50%; top: 18px; transform: translate(-50%, -20px); max-width: calc(100vw - 32px); padding: 10px 14px; color: white; background: #263338; border-radius: 6px; opacity: 0; pointer-events: none; transition: .2s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.modal-backdrop { position: fixed; z-index: 60; inset: 0; display: grid; place-items: end center; background: rgba(12,28,29,.46); padding: 16px; }
.modal { width: min(620px, 100%); max-height: 86vh; overflow: auto; padding: 18px; background: white; border-radius: 8px; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin: 0; }
.close-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: white; font-size: 20px; }

@media (min-width: 760px) {
  .app-shell { display: grid; grid-template-columns: 220px minmax(0,1fr); }
  .desktop-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 20px 14px; color: white; background: var(--teal-deep); }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 7px 22px; border-bottom: 1px solid rgba(255,255,255,.12); }
  .side-brand .topbar-mark { width: 38px; flex-basis: 38px; }
  .side-brand strong { display: block; }
  .side-brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.6); }
  .side-nav { display: grid; gap: 6px; margin-top: 18px; }
  .side-nav button { min-height: 42px; border: 0; border-radius: 5px; padding: 10px 12px; color: rgba(255,255,255,.75); background: transparent; text-align: left; font-weight: 700; }
  .side-nav button.active { color: white; background: rgba(255,255,255,.12); }
  .side-user { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.12); color: rgba(255,255,255,.74); font-size: 12px; line-height: 1.7; }
  .app-main { padding-bottom: 0; }
  .topbar { position: sticky; color: var(--ink); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); box-shadow: none; }
  .topbar-brand { display: none; }
  .user-button { color: var(--teal-deep); border-color: #a9d5ed; margin-left: auto; }
  .user-button:hover { background: #f0f8fc; }
  .bottom-nav { display: none; }
  .content { padding: 24px 28px 42px; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .exam-toolbar { top: 62px; margin: -24px -28px 18px; padding: 10px 28px; }
  .answer-sheet { grid-template-columns: repeat(10, 1fr); }
  .modal-backdrop { place-items: center; }
  .form-grid.two { grid-template-columns: repeat(2, 1fr); }
  .form-grid .span-2 { grid-column: span 2; }
}

@media (max-width: 370px) {
  .content { padding: 13px; }
  .quick-entry { min-height: 96px; padding: 12px; }
  .question-stem { font-size: 17px; }
}
