:root {
  --navy: #17324d;
  --navy-2: #234d70;
  --blue: #3277a8;
  --blue-soft: #eaf3f9;
  --ink: #203247;
  --muted: #708196;
  --line: #e2e9ef;
  --surface: #ffffff;
  --background: #f5f7fa;
  --green: #287b63;
  --green-soft: #eaf6f1;
  --red: #b64d4d;
  --red-soft: #fff0ef;
  --amber: #a47427;
  --shadow: 0 8px 28px rgba(25, 51, 76, .06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--background); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 15px; line-height: 1.65; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, .9fr); background: var(--surface); }
.login-hero { padding: 72px clamp(44px, 7vw, 110px); color: #fff; background: linear-gradient(145deg, #142d47 0%, #245777 100%); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 650; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.35); border-radius: 11px; color: #fff; font-family: Georgia, serif; font-size: 23px; }
.login-hero h1 { margin: 0 0 22px; max-width: 550px; font-size: clamp(36px, 4vw, 54px); line-height: 1.2; font-weight: 600; letter-spacing: -.02em; }
.login-hero p { max-width: 520px; color: #c8d8e4; font-size: 17px; }
.hero-points { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.hero-points span { padding: 7px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 20px; color: #dce8f0; font-size: 13px; }
.login-foot { color: #9eb8ca; font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(400px, 100%); }
.login-card h2 { margin: 0 0 8px; font-size: 28px; font-weight: 600; }
.login-card > p { margin: 0 0 30px; color: var(--muted); }
.demo-accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.demo-account { padding: 12px; text-align: left; color: var(--ink); background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.demo-account:hover { border-color: #91b6d0; background: var(--blue-soft); }
.demo-account strong, .demo-account span { display: block; }
.demo-account span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.demo-note { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.form-field { display: grid; gap: 7px; margin-bottom: 16px; }
.form-field label, .field-label { color: #43566c; font-size: 13px; font-weight: 550; }
input[type="text"], input[type="password"], input[type="number"], select, textarea { width: 100%; min-height: 43px; padding: 9px 12px; color: var(--ink); background: #fff; border: 1px solid #d7e0e8; border-radius: 8px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #6299bc; box-shadow: 0 0 0 3px rgba(50,119,168,.12); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; color: #4e6175; font-size: 14px; }

.btn { min-height: 40px; padding: 8px 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 550; transition: background .15s, border-color .15s, transform .15s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--navy-2); }
.btn-primary:hover:not(:disabled) { background: #193e5b; }
.btn-secondary { color: var(--navy-2); background: #fff; border-color: #cddae4; }
.btn-secondary:hover:not(:disabled) { background: #f2f7fa; }
.btn-soft { color: #285e83; background: var(--blue-soft); }
.btn-danger { color: var(--red); background: #fff; border-color: #edcccc; }
.btn-block { width: 100%; }
.btn-sm { min-height: 33px; padding: 5px 11px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 11px 22px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 232px; display: flex; flex-direction: column; padding: 27px 18px 20px; color: #d9e4ec; background: var(--navy); }
.sidebar .brand { padding: 0 8px 24px; color: #fff; }
.sidebar .brand-mark { width: 34px; height: 34px; font-size: 20px; }
.nav { display: grid; gap: 5px; }
.nav-button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 13px; text-align: left; color: #b9ccda; background: transparent; border: 0; border-radius: 8px; }
.nav-button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-button.active { color: #fff; background: #2b5676; }
.nav-index { width: 19px; color: #789bb3; font-size: 11px; text-align: center; }
.nav-button.active .nav-index { color: #d9edf9; }
.sidebar-bottom { margin-top: auto; padding: 17px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.user-name { color: #fff; font-weight: 550; }
.user-role { color: #8faec2; font-size: 12px; }
.logout { margin-top: 10px; padding: 4px 0; color: #a9bfce; background: none; border: 0; font-size: 13px; }
.main { min-height: 100vh; margin-left: 232px; }
.topbar { height: 75px; display: flex; align-items: center; justify-content: space-between; padding: 0 36px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); }
.topbar-title { font-size: 15px; font-weight: 600; }
.demo-badge { padding: 4px 9px; color: #56748b; background: #edf3f7; border-radius: 12px; font-size: 11px; }
.content { width: min(1240px, 100%); margin: 0 auto; padding: 34px 36px 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.page-heading h1 { margin: 0 0 4px; font-size: 27px; line-height: 1.35; font-weight: 600; }
.page-heading p { margin: 0; color: var(--muted); }

.card { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.card-title { margin: 0 0 5px; font-size: 17px; font-weight: 600; }
.card-subtitle { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 22px; }
.stat-card { padding: 19px 20px; background: #fff; border: 1px solid var(--line); border-radius: 11px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin-top: 6px; color: var(--navy); font-size: 29px; line-height: 1.25; font-weight: 600; }
.stat-extra { margin-top: 4px; color: #8292a3; font-size: 12px; }
.two-column { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }
.three-column { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.section-gap { margin-top: 22px; }
.empty { padding: 38px 20px; color: var(--muted); text-align: center; background: #fafcfd; border: 1px dashed #d4dfe7; border-radius: 10px; }
.divider { height: 1px; margin: 18px 0; background: var(--line); }

.category-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 23px; }
.category-option { position: relative; }
.category-option input { position: absolute; opacity: 0; pointer-events: none; }
.category-option span { display: grid; place-items: center; min-height: 75px; padding: 12px; color: #435a6f; background: #fafcfd; border: 1px solid #dce5ec; border-radius: 10px; font-weight: 550; transition: all .15s; }
.category-option input:checked + span { color: #245c84; background: var(--blue-soft); border-color: #74a5c4; box-shadow: inset 0 0 0 1px #74a5c4; }
.category-option small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.difficulty-grid { display: flex; flex-wrap: wrap; gap: 9px; }
.difficulty-option input { position: absolute; opacity: 0; }
.difficulty-option span { display: block; padding: 8px 15px; color: #536a7e; background: #fff; border: 1px solid #d9e2e9; border-radius: 8px; }
.difficulty-option input:checked + span { color: #fff; background: var(--navy-2); border-color: var(--navy-2); }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.available-count { color: var(--muted); font-size: 13px; }
.available-count strong { color: var(--navy-2); font-size: 20px; }

.tag-search { display: flex; gap: 10px; }
.tag-search input { flex: 1; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tag-chip { display: inline-flex; align-items: center; padding: 4px 9px; color: #4e6f86; background: #edf4f8; border: 0; border-radius: 5px; font-size: 12px; font-weight: 400; }
button.tag-chip:hover { background: #dcebf4; }
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.result-row:last-child { border-bottom: 0; }
.result-title { font-weight: 550; }
.result-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }

.practice-shell { min-height: 100vh; background: #f4f7f9; }
.practice-top { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 12px 30px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.practice-title { font-weight: 600; }
.practice-progress { color: var(--muted); font-size: 13px; }
.practice-body { width: min(1000px, 100%); margin: 0 auto; padding: 28px 24px 60px; }
.question-card { padding: clamp(20px, 3vw, 34px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.question-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.source-label { margin-right: auto; color: var(--navy-2); font-weight: 600; }
.question-content { padding: 10px 0 20px; overflow-x: auto; }
.question-image, .solution-image { display: block; max-width: 100%; height: auto; margin: 0 auto 8px; object-fit: contain; }
.solution-image { margin: 10px auto; }
.answer-area { padding-top: 21px; border-top: 1px solid var(--line); }
.answer-label { display: block; margin-bottom: 9px; font-weight: 550; }
.answer-input { max-width: 220px; height: 52px; font-size: 23px; letter-spacing: .12em; text-align: center; }
.answer-hint { margin-top: 7px; color: var(--muted); font-size: 12px; }
.feedback { margin-top: 22px; padding: 18px; border-radius: 10px; }
.feedback.correct { color: #205f4d; background: var(--green-soft); }
.feedback.wrong { color: #854141; background: var(--red-soft); }
.feedback h3 { margin: 0 0 4px; font-size: 19px; }
.feedback p { margin: 4px 0; }
.solution-block { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.solution-block h3 { margin: 0 0 10px; font-size: 16px; }
.practice-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 25px; }

.paper-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 17px; }
.paper-card { position: relative; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.paper-year { color: #7c91a3; font-size: 12px; letter-spacing: .08em; }
.paper-card h2 { margin: 7px 0; font-size: 23px; font-weight: 600; }
.paper-info { display: flex; gap: 16px; margin: 16px 0 20px; color: var(--muted); font-size: 13px; }
.paper-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.score-pill { padding: 5px 9px; color: var(--green); background: var(--green-soft); border-radius: 6px; font-size: 12px; }

.exam-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 14px 26px; background: #fff; border-bottom: 1px solid var(--line); }
.timer { padding: 7px 13px; color: #9b4b38; background: #fff3ed; border-radius: 7px; font-size: 20px; font-weight: 600; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 245px; gap: 20px; width: min(1220px, 100%); margin: 0 auto; padding: 26px 24px 50px; }
.answer-sheet { position: sticky; top: 94px; align-self: start; }
.answer-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 15px 0; }
.answer-number { aspect-ratio: 1; padding: 0; color: #5f7183; background: #fff; border: 1px solid #d8e1e8; border-radius: 6px; font-size: 13px; }
.answer-number.answered { color: #fff; background: #387aa2; border-color: #387aa2; }
.answer-number.marked { box-shadow: inset 0 0 0 2px #d2a44f; }
.answer-number.current { outline: 2px solid #173f61; outline-offset: 2px; }
.sheet-legend { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 11px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; background: #fff; border: 1px solid #cbd8e2; border-radius: 2px; }
.legend-dot.done { background: #387aa2; border-color: #387aa2; }

.report-hero { padding: 28px; color: #fff; background: linear-gradient(135deg, #173650, #2e6b8e); border-radius: 13px; }
.report-hero h1 { margin: 0 0 6px; font-size: 26px; }
.report-hero p { margin: 0; color: #cadde9; }
.report-score { margin-top: 20px; font-size: 48px; line-height: 1; font-weight: 600; }
.report-score small { font-size: 19px; font-weight: 400; opacity: .7; }
.report-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.report-stat { padding: 16px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.report-stat strong { display: block; color: var(--navy); font-size: 23px; }
.report-stat span { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: #607589; background: #f7fafc; font-size: 12px; font-weight: 550; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; padding: 3px 8px; border-radius: 5px; font-size: 11px; }
.status.ok { color: var(--green); background: var(--green-soft); }
.status.bad { color: var(--red); background: var(--red-soft); }
.status.neutral { color: #607589; background: #edf2f6; }

.wrong-item { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 19px 0; border-bottom: 1px solid var(--line); }
.wrong-item:last-child { border-bottom: 0; }
.wrong-item h3 { margin: 0 0 6px; font-size: 15px; }
.filter-bar { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; margin-bottom: 20px; }
.filter-bar .form-field { margin: 0; }
.knowledge-card { height: 100%; }
.knowledge-category { color: var(--blue); font-size: 12px; }
.knowledge-card h3 { margin: 6px 0 13px; }
.knowledge-card ul { margin: 0 0 16px; padding-left: 20px; color: #4d6174; }
.knowledge-card li { margin: 7px 0; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; max-width: calc(100% - 32px); padding: 10px 17px; color: #fff; background: rgba(23,50,77,.94); border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(15,33,50,.45); }
.modal-card { width: min(460px, 100%); padding: 25px; background: #fff; border-radius: 13px; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.modal-card h2 { margin: 0 0 10px; font-size: 21px; }
.modal-card p { color: #5f7184; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .three-column { grid-template-columns: repeat(2, 1fr); }
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 310px; padding: 36px 28px; }
  .login-hero h1 { margin-top: 50px; font-size: 36px; }
  .login-foot { display: none; }
  .login-panel { padding: 36px 24px; }
  .sidebar { position: static; width: 100%; padding: 14px 16px 10px; }
  .sidebar .brand { padding: 0 3px 12px; }
  .nav { display: flex; overflow-x: auto; gap: 5px; padding-bottom: 3px; }
  .nav-button { flex: 0 0 auto; width: auto; padding: 8px 11px; white-space: nowrap; }
  .nav-index, .sidebar-bottom { display: none; }
  .main { margin-left: 0; }
  .topbar { height: 54px; padding: 0 20px; }
  .content { padding: 24px 18px 45px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .paper-grid { grid-template-columns: 1fr; }
  .exam-layout { grid-template-columns: 1fr; padding: 18px 14px 40px; }
  .answer-sheet { position: static; order: -1; }
  .answer-grid { grid-template-columns: repeat(15, 1fr); gap: 4px; }
  .answer-number { font-size: 11px; }
  .sheet-legend, .answer-sheet .card-subtitle { display: none; }
  .exam-top { padding: 10px 14px; }
  .exam-top .practice-title { font-size: 13px; }
  .timer { font-size: 17px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .report-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .stats-grid, .three-column { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 15px; }
  .stat-value { font-size: 25px; }
  .card { padding: 17px; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .category-option span { min-height: 62px; }
  .form-footer, .practice-actions { align-items: stretch; flex-direction: column; }
  .form-footer .btn, .practice-actions .btn { width: 100%; }
  .tag-search { flex-direction: column; }
  .paper-footer { align-items: flex-start; flex-direction: column; }
  .wrong-item { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
  .practice-top { padding: 10px 14px; }
  .practice-body { padding: 17px 12px 40px; }
  .question-card { padding: 17px; }
  .source-label { width: 100%; margin-bottom: 5px; }
  .report-hero { padding: 22px; }
}

@media print {
  .sidebar, .topbar, .button-row, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .report-hero { box-shadow: none; }
}
