:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-soft: #eef1ef;
  --surface-tint: #f8faf8;
  --text: #202428;
  --muted: #66706d;
  --line: #d9dfdc;
  --accent: #0f6b5f;
  --accent-dark: #0a5148;
  --accent-soft: #e3f0ec;
  --blue: #315f86;
  --bronze: #8a5a22;
  --red: #9f2d20;
  --shadow: 0 18px 48px rgba(32, 36, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(15, 107, 95, 0.08), rgba(49, 95, 134, 0.055) 42%, transparent 42%),
    linear-gradient(180deg, #fbfcfb 0, #f3f5f4 260px),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.summary-band {
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 248, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  box-shadow: var(--shadow);
}

.summary-title,
.panel-heading,
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.summary-title h1,
.panel-heading h2,
.panel-heading h3 {
  margin: 0;
  letter-spacing: 0;
}

.summary-title h1 {
  max-width: 760px;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
  font-weight: 800;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.student-mark {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background:
    linear-gradient(135deg, #202428 0 58%, var(--accent) 58% 100%);
  border: 1px solid rgba(32, 36, 40, 0.16);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  font-weight: 700;
}

.title-subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-heading h2 {
  font-size: 28px;
}

.panel-heading h3 {
  font-size: 18px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--bronze);
  font-size: 12px;
  font-weight: 700;
}

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

.metric {
  min-height: 88px;
  padding: 16px;
  background: var(--surface-tint);
  border: 1px solid var(--line);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--accent-dark);
  font-size: 28px;
  line-height: 1;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-button:hover {
  background: var(--surface-soft);
}

.icon-button.danger {
  color: var(--red);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.text-button {
  min-height: 42px;
  padding: 0 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #bfd9d2;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.text-button:hover {
  border-color: var(--accent);
}

.subject-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.page-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.page-tab {
  min-width: 96px;
  min-height: 40px;
  padding: 0 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 700;
}

.page-tab.active {
  color: #fff;
  background: #202428;
  border-color: #202428;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.tab-button {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 42px;
  padding: 0 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.tab-button.active {
  color: #fff;
  background: #202428;
  border-color: #202428;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.entry-panel,
.charts-panel,
.table-block {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.entry-panel,
.charts-panel {
  padding: 20px;
}

.charts-panel {
  display: flex;
  flex-direction: column;
}

.record-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #bfd9d2;
  font-size: 13px;
  font-weight: 700;
}

.score-form,
.total-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.total-form {
  margin-top: 0;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  outline: none;
}

input,
select {
  height: 42px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

textarea {
  min-height: 260px;
  padding: 12px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.16);
}

.note-custom-input {
  margin-top: 8px;
}

.exam-select {
  position: relative;
  width: 100%;
}

.exam-select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 48px;
  padding: 0 12px 0 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}

.exam-select-button:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.16);
  outline: none;
}

.exam-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: 100%;
  display: none;
  padding: 4px 0;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(32, 36, 40, 0.16);
}

.exam-select.open .exam-select-menu {
  display: block !important;
}

.exam-select-menu button {
  display: flex !important;
  align-items: center;
  width: 100% !important;
  min-height: 46px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}

.exam-select-menu button:last-child {
  border-bottom: 0;
}

.exam-select-menu button:hover {
  color: #fff;
  background: var(--accent);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #bfd9d2;
}

.secondary-button:hover {
  border-color: var(--accent);
}

.rank-totals {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segment {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.segment.active {
  color: #fff;
  background: var(--bronze);
  border-color: var(--bronze);
}

.chart-wrap {
  position: relative;
  margin-top: 16px;
  min-height: 360px;
  flex: 1;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  cursor: crosshair;
  overscroll-behavior: contain;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.empty-state.hidden {
  display: none;
}

.chart-tooltip {
  position: fixed;
  z-index: 5;
  min-width: 130px;
  max-width: 220px;
  padding: 9px 10px;
  color: #fff;
  background: rgba(32, 36, 40, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(32, 36, 40, 0.2);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
  transform: translate(14px, calc(-100% - 10px));
  opacity: 0;
  transition: opacity 120ms ease;
}

.chart-tooltip.visible {
  opacity: 1;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 700;
  color: #d6efe9;
}

.records-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.table-block {
  padding: 18px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  height: 44px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.text-muted {
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.edit-row,
.delete-row {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
}

.edit-row {
  color: var(--accent-dark);
}

.delete-row {
  color: var(--red);
}

.edit-row:hover,
.delete-row:hover {
  background: transparent;
  opacity: 0.72;
}

.edit-row svg,
.delete-row svg {
  width: 16px;
  height: 16px;
}

.hidden {
  display: none !important;
}

.notes-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
}

.note-editor,
.note-list {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
}

.note-editor {
  display: grid;
  gap: 12px;
}

.notes-list-inner {
  display: grid;
  gap: 12px;
}

.note-item {
  padding: 16px;
  background: var(--surface-tint);
  border: 1px solid var(--line);
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.note-date {
  color: var(--bronze);
  font-size: 13px;
  font-weight: 700;
}

.note-item h4 {
  margin: 0 0 8px;
  font-size: 18px;
}

.note-item p {
  margin: 0;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.note-empty {
  padding: 22px;
  color: var(--muted);
  background: var(--surface-tint);
  border: 1px solid var(--line);
}

@media (max-width: 920px) {
  .metric-grid,
  .workspace,
  .records-section,
  .notes-layout {
    grid-template-columns: 1fr;
  }

  .workspace {
    align-items: start;
  }

  .chart-wrap,
  canvas {
    min-height: 360px;
  }

  .summary-title {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .summary-band,
  .entry-panel,
  .charts-panel,
  .table-block {
    padding: 14px;
  }

  .metric-grid {
    gap: 8px;
  }

  .metric {
    min-height: 76px;
  }

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

  .panel-heading {
    align-items: flex-start;
  }

  .summary-title {
    gap: 12px;
  }

  .brand-lockup {
    align-items: flex-start;
    gap: 12px;
  }

  .student-mark {
    width: 52px;
    height: 52px;
    font-size: 28px;
  }

  .title-subtitle {
    font-size: 13px;
  }

  .chart-wrap,
  canvas {
    min-height: 320px;
  }
}
