:root {
  --bg: #f4f2ed;
  --paper: #fffdf9;
  --ink: #282a2d;
  --muted: #74716a;
  --line: #ded9cf;
  --teal: #167c73;
  --teal-soft: #dcefeb;
  --coral: #df634e;
  --coral-soft: #f8e3de;
  --yellow: #eeb844;
  --yellow-soft: #fff0c9;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.eyebrow { color: var(--teal); font-size: 12px; font-weight: 800; }
.brand-mark { position: relative; width: 38px; height: 38px; flex: 0 0 38px; overflow: hidden; display: inline-block; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.brand-mark::before { content: ""; position: absolute; right: 7px; top: 7px; width: 8px; height: 8px; background: var(--yellow); border-radius: 50%; }
.brand-mark::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 7px; height: 8px; background: var(--teal); border-radius: 50%; transform: rotate(-7deg); }
.brand-mark i { position: absolute; left: 8px; right: 13px; bottom: 18px; height: 6px; background: var(--coral); border-radius: 50%; transform: rotate(8deg); }
.login-view { min-height: 100vh; padding: 42px; display: grid; grid-template-columns: minmax(280px, 440px); align-content: center; justify-content: center; background: var(--bg); }
.login-brand { margin-bottom: 28px; display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 850; }
.login-panel { padding: 36px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 16px 40px rgba(40,42,45,.09); }
.login-panel h1 { margin: 8px 0 10px; font-size: 30px; }
.login-panel p { margin: 0 0 28px; color: var(--muted); line-height: 1.6; }
.login-panel label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 750; }
.login-panel input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 7px; background: white; outline: none; }
.login-panel input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,124,115,.12); }
.login-panel > .button { width: 100%; margin-top: 18px; }
.login-panel small { display: block; margin-top: 16px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.login-field + .login-field { margin-top: 16px; }
.auth-tabs { height: 42px; margin-bottom: 20px; padding: 3px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; background: #ebe8e1; border-radius: 7px; }
.auth-tabs button { border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.auth-tabs button.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(40,42,45,.1); }
.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px 18px; display: flex; flex-direction: column; background: var(--ink); color: white; }
.sidebar-brand { padding: 0 8px 25px; display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 850; border-bottom: 1px solid #484a4d; }
.sidebar-brand small { display: block; margin-top: 3px; color: #aaa8a3; font-size: 10px; font-weight: 500; }
.sidebar nav { display: grid; gap: 5px; margin-top: 22px; }
.sidebar nav button { position: relative; min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 7px; background: transparent; color: #c9c7c2; text-align: left; font-size: 13px; font-weight: 650; }
.sidebar nav button span { width: 20px; color: #aaa8a3; font-size: 18px; text-align: center; }
.sidebar nav button:hover, .sidebar nav button.active { background: #3a3c3f; color: white; }
.sidebar nav button.active::before { content: ""; position: absolute; left: -16px; width: 4px; height: 24px; background: #70c5ba; }
.sidebar nav button b { margin-left: auto; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; background: var(--coral); border-radius: 7px; color: white; font-size: 10px; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid #484a4d; color: #aaa8a3; font-size: 10px; }
.sidebar-foot button { padding: 0; border: 0; background: transparent; color: #ddd9d2; font-size: 11px; }
.main-area { min-width: 0; }
.main-header { min-height: 92px; padding: 20px clamp(24px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.main-header h1 { margin: 4px 0 0; font-size: 24px; }
.admin-identity { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.admin-identity i { width: 34px; height: 34px; display: grid; place-items: center; background: var(--yellow-soft); border-radius: 50%; color: #765816; font-style: normal; font-weight: 850; }
.content { padding: 30px clamp(24px, 4vw, 54px) 60px; }
.loading, .empty { padding: 54px 24px; color: var(--muted); text-align: center; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { min-height: 124px; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.stat-head { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.stat-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; font-size: 17px; }
.stat-icon.teal { background: var(--teal-soft); color: var(--teal); }
.stat-icon.coral { background: var(--coral-soft); color: var(--coral); }
.stat-icon.yellow { background: var(--yellow-soft); color: #765816; }
.stat-icon.ink { background: #e9e7e2; color: var(--ink); }
.stat strong { display: block; margin-top: 17px; font-size: 30px; }
.stat small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.section-grid { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 18px; }
.section { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.section.spaced { margin-top: 18px; }
.section-header { min-height: 58px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.section-header h2 { margin: 0; font-size: 15px; }
.section-header span { color: var(--muted); font-size: 11px; }
.task-row, .audit-row { min-height: 67px; padding: 13px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.task-row:last-child, .audit-row:last-child { border-bottom: 0; }
.task-score { width: 42px; height: 42px; display: grid; place-items: center; background: var(--teal-soft); border-radius: 7px; color: var(--teal); font-weight: 850; }
.task-main, .audit-main { flex: 1; min-width: 0; }
.task-main strong, .task-main span, .audit-main strong, .audit-main span { display: block; }
.task-main strong, .audit-main strong { font-size: 12px; }
.task-main span, .audit-main span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.subject-chip, .status-chip { display: inline-flex; min-height: 24px; padding: 0 8px; align-items: center; border-radius: 5px; font-size: 10px; font-weight: 800; }
.subject-chip.english { background: var(--teal-soft); color: var(--teal); }
.subject-chip.math { background: var(--coral-soft); color: #a94433; }
.subject-chip.chinese { background: var(--yellow-soft); color: #765816; }
.status-chip.draft { background: #e9e7e2; color: #625f59; }
.status-chip.review, .status-chip.pending, .status-chip.correction { background: var(--yellow-soft); color: #765816; }
.status-chip.published, .status-chip.reviewed { background: var(--teal-soft); color: var(--teal); }
.status-chip.disabled { background: var(--coral-soft); color: #a94433; }
.toolbar { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.toolbar.spaced { margin-top: 22px; }
.toolbar.more-spaced { margin-top: 28px; }
.toolbar-copy h2 { margin: 0; font-size: 18px; }
.toolbar-copy p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.filters.spaced-bottom { margin-bottom: 14px; }
.field, .select { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--ink); outline: none; }
.field:focus, .select:focus, .textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,124,115,.1); }
.field.search { width: min(280px, 100%); }
.button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); font-size: 12px; font-weight: 750; }
.button:hover { border-color: var(--teal); }
.button.primary { border-color: var(--teal); background: var(--teal); color: white; }
.button.danger { border-color: var(--coral); color: var(--coral); }
.button.small { min-height: 32px; padding: 0 10px; font-size: 10px; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8f6f1; color: var(--muted); font-size: 10px; font-weight: 750; white-space: nowrap; }
td { font-size: 11px; }
tr:last-child td { border-bottom: 0; }
.question-cell { min-width: 320px; }
.question-cell strong, .question-cell span { display: block; }
.question-cell strong { font-size: 12px; line-height: 1.5; }
.question-cell span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.modal-backdrop { position: fixed; z-index: 50; inset: 0; padding: 32px; display: grid; place-items: center; background: rgba(40,42,45,.48); }
.modal-panel { width: min(760px, 100%); max-height: calc(100vh - 64px); overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 70px rgba(40,42,45,.22); }
.modal-header { position: sticky; z-index: 2; top: 0; min-height: 66px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 17px; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; background: var(--bg); font-size: 21px; }
.modal-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: grid; gap: 7px; margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { color: var(--muted); font-size: 10px; font-weight: 750; }
.form-group .field, .form-group .select { width: 100%; }
.textarea { width: 100%; min-height: 92px; padding: 11px 12px; resize: vertical; border: 1px solid var(--line); border-radius: 7px; background: white; outline: none; line-height: 1.55; }
.form-actions { padding-top: 14px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.answer-review { padding: 16px 0; border-bottom: 1px solid var(--line); }
.answer-review:last-child { border-bottom: 0; }
.answer-review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.answer-review-head strong { font-size: 12px; line-height: 1.5; }
.answer-pair { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.answer-box { padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
.answer-box small, .answer-box b { display: block; }
.answer-box small { color: var(--muted); font-size: 9px; }
.answer-box b { margin-top: 4px; font-size: 11px; overflow-wrap: anywhere; }
.answer-box.correct b { color: var(--teal); }
.explanation { margin-top: 8px; padding: 12px; background: var(--teal-soft); border-left: 4px solid var(--teal); font-size: 10px; line-height: 1.6; }
.checkbox-line { min-height: 40px; display: flex; align-items: center; gap: 8px; font-size: 11px; }
.checkbox-line input { width: 17px; height: 17px; accent-color: var(--teal); }
.review-form { margin-top: 20px; }
.toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; background: var(--ink); border-radius: 7px; color: white; font-size: 11px; box-shadow: 0 12px 30px rgba(40,42,45,.2); }
@media (max-width: 980px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .section-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar-brand { padding-bottom: 13px; }
  .sidebar nav { grid-template-columns: repeat(5, 1fr); margin-top: 12px; gap: 4px; }
  .sidebar nav button { padding: 6px 4px; justify-content: center; flex-direction: column; gap: 2px; font-size: 9px; text-align: center; }
  .sidebar nav button.active::before, .sidebar-foot { display: none; }
  .main-header { min-height: 76px; padding: 14px 18px; }
  .content { padding: 20px 16px 42px; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .form-grid, .answer-pair { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 12px; }
  .modal-panel { max-height: calc(100vh - 24px); }
}
@media (max-width: 440px) {
  .login-view { padding: 24px 16px; }
  .login-panel { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr; }
  .admin-identity span { display: none; }
}
