:root {
  --ink: #102033;
  --muted: #657181;
  --line: #d9e2ec;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --blue: #2f6f9f;
  --green: #2f7d5b;
  --amber: #a76713;
  --red: #b42318;
  --soft-blue: #eaf3f8;
  --soft-green: #e8f4ee;
  --soft-amber: #fff3df;
  --shadow: 0 10px 26px rgba(16, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f7;
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-card input {
  width: 100%;
}

.login-error {
  min-height: 20px;
  color: var(--red) !important;
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell[hidden] {
  display: none;
}

.sidebar {
  background: #172433;
  color: #fff;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dfeaf2;
  color: #172433;
  font-weight: 800;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.side-status span,
.panel-head p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar .brand p,
.side-status span {
  color: #b8c5d1;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  padding: 0 12px;
  color: #e7edf4;
  background: transparent;
  cursor: pointer;
}

.nav-btn:hover,
.nav-btn.active {
  background: #2a3b4d;
}

.side-status {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #33475b;
  border-radius: 8px;
  display: grid;
  gap: 5px;
}

.side-status strong {
  font-size: 18px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

.plan-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.date-field.narrow input {
  width: 86px;
}

.resource-line {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.coverage-panel {
  margin-bottom: 16px;
}

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.coverage-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.coverage-grid h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.coverage-grid div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid #edf1f5;
  font-size: 13px;
}

.coverage-grid .ok {
  color: var(--green);
  font-weight: 700;
}

.coverage-grid .risk {
  color: var(--red);
  font-weight: 700;
}

.coverage-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.top-actions,
.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  display: grid;
  gap: 7px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 26px;
}

.metric.warn strong {
  color: var(--amber);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel.wide {
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.primary-btn,
.ghost-btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

.primary-btn {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-btn.full {
  width: 100%;
  margin-bottom: 10px;
}

.ghost-btn.danger {
  color: var(--red);
}

.task-list,
.material-list,
.mistake-list,
.weekly-stats {
  display: grid;
  gap: 10px;
}

.task-item,
.material-item,
.mistake-item,
.stat-item,
.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
}

.task-item input {
  width: 18px;
  height: 18px;
}

.task-meta,
.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: #315066;
  background: var(--soft-blue);
}

.tag.green {
  color: #28654b;
  background: var(--soft-green);
}

.tag.amber {
  color: #7a4b08;
  background: var(--soft-amber);
}

.toolbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 16px;
}

.tag-practice-toolbar {
  align-items: stretch;
  display: grid;
  gap: 12px;
}

.tag-practice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tag-practice-head strong {
  display: block;
  margin-bottom: 4px;
}

.tag-practice-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tag-select-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 156px;
  overflow: auto;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #f8fbfd;
  color: var(--ink);
  cursor: pointer;
}

.tag-option input {
  width: 16px;
  height: 16px;
}

.tag-option:has(input:checked) {
  border-color: var(--blue);
  background: var(--soft-blue);
}

.exam-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.topic-exam-picker {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 120px auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.topic-exam-picker select,
.topic-exam-picker input {
  width: 100%;
}

.exam-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
}

.exam-topline {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #17212b;
  color: #fff;
}

.exam-card {
  min-height: 430px;
}

.exam-options {
  gap: 10px;
}

.exam-controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.exam-answer-sheet {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  align-self: start;
  position: sticky;
  top: 12px;
}

.exam-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin: 10px 0;
}

.exam-nav-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.exam-nav-btn.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.exam-nav-btn.done {
  border-color: var(--green);
  background: var(--soft-green);
  color: #28654b;
}

.exam-nav-btn.active.done {
  background: var(--blue);
  color: #fff;
}

.exam-answer-sheet p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.session-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.quiz-area {
  display: grid;
  gap: 12px;
}

.question-card h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.question-card.answered {
  border-color: #c7d7e4;
  background: #fbfdff;
}

.empty-state {
  box-shadow: none;
}

.options {
  display: grid;
  gap: 7px;
  margin: 10px 0;
}

.option-line {
  display: flex;
  gap: 8px;
  align-items: start;
}

.option-line input {
  width: 16px;
  height: 16px;
  margin-top: 3px;
}

.answer-box {
  width: 100%;
  min-height: 84px;
  padding: 10px;
  resize: vertical;
}

.result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--soft-blue);
  display: none;
}

.result.show {
  display: block;
}

.review-text,
.data-output {
  width: 100%;
  min-height: 360px;
  padding: 12px;
  line-height: 1.6;
  resize: vertical;
}

.data-output {
  min-height: 230px;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.print-sheet {
  background: #fff;
}

.print-sheet table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 22px;
}

.print-sheet th,
.print-sheet td {
  border: 1px solid #9aa8b5;
  min-height: 34px;
  height: 34px;
  padding: 6px;
  text-align: left;
}

.print-sheet th {
  background: #eef3f7;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .content-grid,
  .coverage-grid,
  .exam-shell {
    grid-template-columns: 1fr;
  }

  .exam-answer-sheet {
    position: static;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 700px) {
  .main {
    padding: 14px;
  }

  .sidebar {
    padding: 14px;
    gap: 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .nav-btn {
    min-height: 38px;
    padding: 0 8px;
    text-align: center;
    font-size: 13px;
  }

  .top-actions,
  .toolbar,
  .exam-actions,
  .topic-exam-picker,
  .panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions label,
  .top-actions input,
  .toolbar button,
  .topic-exam-picker button,
  .exam-actions button,
  .panel-actions button,
  .primary-btn,
  .ghost-btn {
    width: 100%;
  }

  .date-field.narrow input {
    width: 100%;
  }

  .tag-practice-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tag-option {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .exam-topline,
  .exam-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .exam-nav-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .topbar h2 {
    font-size: 23px;
  }

  .plan-summary {
    font-size: 12px;
    line-height: 1.5;
  }

  .panel {
    padding: 14px;
  }

  .task-item {
    grid-template-columns: auto 1fr;
  }

  .task-item > span {
    grid-column: 2;
  }

  .metric {
    padding: 13px;
  }

  .metric strong {
    font-size: 22px;
  }

  .question-card h4 {
    font-size: 15px;
    line-height: 1.45;
  }

  .answer-box {
    min-height: 120px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .metrics,
  .toolbar,
  .panel-head button,
  .view:not(.active) {
    display: none !important;
  }

  .app-shell,
  .main,
  .content-grid {
    display: block;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
}
