:root {
  color-scheme: light;
  --navy-950: #071c2f;
  --navy-900: #0b2b47;
  --navy-800: #123f64;
  --navy-700: #1a527c;
  --blue-600: #176fa8;
  --blue-100: #e2eef5;
  --paper: #f2f5f6;
  --surface: #ffffff;
  --surface-muted: #e9eff2;
  --surface-raised: #f9fbfc;
  --ink: #122532;
  --ink-soft: #354a58;
  --muted: #61727d;
  --line: #d6e0e5;
  --line-strong: #b9c8d0;
  --red: #b33b32;
  --red-dark: #882b25;
  --red-soft: #fff2ef;
  --amber: #99631a;
  --amber-soft: #fff7e8;
  --green: #287557;
  --green-soft: #eaf6f0;
  --shadow-sm: 0 1px 2px rgba(7, 28, 47, 0.06), 0 8px 20px rgba(7, 28, 47, 0.05);
  --shadow-md: 0 16px 40px rgba(7, 28, 47, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --font-display: "Notice Serif", "Songti SC", "SimSun", serif;
  --transition: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@font-face {
  font-family: "Notice Serif";
  src: url("../assets/fonts/NotoSerifSC-DisplaySubset.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
  scrollbar-color: #94a8b3 var(--surface-muted);
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

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

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--blue-600);
  text-underline-offset: 3px;
}

::selection {
  color: #fff;
  background: var(--navy-700);
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: var(--surface-muted);
}

::-webkit-scrollbar-thumb {
  background: #94a8b3;
  border: 3px solid var(--surface-muted);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #778f9c;
}

:focus-visible {
  outline: 3px solid rgba(23, 111, 168, 0.32);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: var(--navy-950);
  background: #fff;
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform var(--transition);
}

.skip-link:focus {
  transform: translateY(0);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-header {
  color: #fff;
  background: var(--navy-950);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1280px, calc(100% - 48px));
  min-height: 78px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.brand-copy {
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  margin: 1px 0 0;
  color: #b9cfdd;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #c9dce8;
  font-size: 13px;
}

.header-date {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}

.public-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 10px;
  color: #e8f5ff;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 12px;
}

.public-badge::before {
  width: 6px;
  height: 6px;
  content: "";
  background: #6bc2a2;
  border-radius: 50%;
}

.shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 44px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  color: var(--navy-950);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-description {
  max-width: 68ch;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.view-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.tab-button {
  min-height: 38px;
  padding: 7px 15px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
  transition: color var(--transition), background var(--transition), box-shadow var(--transition);
}

.tab-button:hover {
  color: var(--navy-900);
  background: rgba(255, 255, 255, 0.62);
}

.tab-button[aria-selected="true"] {
  color: var(--navy-900);
  background: #fff;
  box-shadow: 0 1px 3px rgba(7, 28, 47, 0.1);
}

.workspace {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.workspace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.week-navigation {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.week-current {
  min-width: 220px;
}

.week-label {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.week-subtitle {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.button:hover:not(:disabled) {
  color: var(--navy-900);
  background: var(--surface-raised);
  border-color: #9fb2bc;
  box-shadow: var(--shadow-sm);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  color: #8a979f;
  background: #f3f5f6;
  border-color: var(--line);
  opacity: 0.75;
}

.button-primary {
  color: #fff;
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.button-primary:hover:not(:disabled) {
  color: #fff;
  background: var(--navy-700);
  border-color: var(--navy-700);
}

.button-danger {
  color: var(--red-dark);
  background: var(--red-soft);
  border-color: #ebc4be;
}

.button-danger:hover:not(:disabled) {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.button-quiet {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.button-quiet:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-muted);
  border-color: transparent;
  box-shadow: none;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
}

.button.is-loading .icon {
  animation: spin 650ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  caret-color: var(--blue-600);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: #9db0ba;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 0;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(23, 111, 168, 0.14);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--red);
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.search-field {
  position: relative;
  min-width: 230px;
}

.search-field .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field .input {
  padding-left: 38px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0 22px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}

.metric {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-height: 66px;
  padding: 14px 20px;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric:first-child {
  padding-left: 0;
}

.metric-value {
  order: 1;
  color: var(--navy-900);
  font-size: 24px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.metric-value.is-warning {
  color: var(--red);
}

.metric-label {
  order: 2;
  color: var(--muted);
  font-size: 12px;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  padding: 12px 16px;
  color: var(--muted);
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #e7edf0;
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: #f8fafb;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tr.is-highlighted {
  background: var(--red-soft);
}

.data-table tr.is-highlighted:hover {
  background: #ffece8;
}

.cell-rank {
  width: 62px;
}

.rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  color: var(--ink-soft);
  background: var(--surface-muted);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 750;
}

.is-highlighted .rank-number {
  color: #fff;
  background: var(--red);
}

.student-cell {
  min-width: 175px;
}

.student-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.student-id {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.attention-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 2px 8px;
  color: var(--red-dark);
  background: #fff;
  border: 1px solid #e7bcb6;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
}

.attention-badge::before {
  width: 5px;
  height: 5px;
  content: "";
  background: var(--red);
  border-radius: 50%;
}

.score-cell {
  min-width: 90px;
}

.score-value {
  color: var(--ink);
  font-size: 18px;
  font-weight: 750;
}

.is-highlighted .score-value {
  color: var(--red-dark);
}

.score-unit {
  margin-left: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.count-cell {
  color: var(--ink-soft);
  white-space: nowrap;
}

.reason-cell {
  max-width: 340px;
  color: var(--ink-soft);
}

.reason-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.cell-action {
  width: 110px;
  text-align: right;
}

.row-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  color: var(--blue-600);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 650;
}

.row-link:hover {
  color: var(--navy-900);
  text-decoration: underline;
}

.row-link .icon {
  width: 14px;
  height: 14px;
}

.zero-state {
  color: var(--muted);
}

.empty-state,
.error-state {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 42px 24px;
  text-align: center;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  color: var(--navy-700);
  background: var(--blue-100);
  border-radius: 50%;
}

.state-icon .icon {
  width: 22px;
  height: 22px;
}

.empty-state h3,
.error-state h3 {
  margin: 0;
  font-size: 17px;
}

.empty-state p,
.error-state p {
  max-width: 46ch;
  margin: 7px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: #e8eef1;
  border-radius: 5px;
}

.skeleton::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(255, 255, 255, 0.5);
  transform: translateX(-100%);
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.skeleton-table {
  padding: 18px 22px 24px;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 44px 1.2fr 0.6fr 0.5fr 1.7fr 90px;
  gap: 22px;
  align-items: center;
  min-height: 62px;
  border-bottom: 1px solid #edf1f3;
}

.skeleton-row span {
  height: 12px;
}

.skeleton-row span:first-child {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: var(--muted);
  font-size: 12px;
}

.footer-note {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mode-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
}

.mode-dot.is-local {
  background: var(--amber);
}

dialog {
  width: min(680px, calc(100% - 32px));
  max-height: min(82vh, 760px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(7, 28, 47, 0.58);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 17px;
  border-bottom: 1px solid var(--line);
}

.dialog-title {
  margin: 0;
  font-size: 19px;
}

.dialog-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.dialog-body {
  max-height: 58vh;
  overflow-y: auto;
  padding: 20px 22px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 22px;
  background: var(--surface-raised);
  border-top: 1px solid var(--line);
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-item {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid #e9eef1;
}

.detail-item:last-child {
  border-bottom: 0;
}

.detail-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.detail-reason {
  margin: 0;
  color: var(--ink-soft);
}

.detail-score {
  color: var(--red-dark);
  font-size: 16px;
  font-weight: 750;
  white-space: nowrap;
}

.toast-region {
  position: fixed;
  z-index: 80;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100% - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  color: #fff;
  background: var(--navy-900);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease-out;
}

.toast.is-error {
  background: var(--red-dark);
}

.toast.is-success {
  background: #1f654d;
}

.toast p {
  margin: 0;
  font-size: 13px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Admin */
.admin-header .header-inner {
  min-height: 70px;
}

.admin-main {
  padding-top: 24px;
}

.admin-heading {
  align-items: center;
}

.admin-status {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sync-state::before {
  width: 7px;
  height: 7px;
  content: "";
  background: var(--green);
  border-radius: 50%;
}

.sync-state.is-busy::before {
  background: var(--amber);
}

.sync-state.is-error::before {
  background: var(--red);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel-sticky {
  position: sticky;
  top: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
}

.panel-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.entry-form {
  display: grid;
  gap: 17px;
  padding: 18px 20px 20px;
}

.edit-mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #eed8b2;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.roster-search-row {
  display: grid;
  gap: 8px;
}

.roster-picker {
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  scrollbar-color: #a7b8c1 transparent;
  scrollbar-width: thin;
}

.roster-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}

.roster-option:hover {
  background: #eef4f7;
}

.roster-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--navy-700);
}

.roster-option-name {
  flex: 1;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.roster-option-id {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.selected-count {
  color: var(--navy-800);
  font-weight: 700;
}

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

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

.quick-button {
  min-width: 41px;
  min-height: 30px;
  padding: 4px 9px;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
}

.quick-button:hover {
  color: var(--navy-800);
  background: var(--blue-100);
  border-color: #b9d0de;
}

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

.reason-chip {
  min-height: 28px;
  padding: 3px 9px;
  color: var(--ink-soft);
  background: var(--surface-muted);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
}

.reason-chip:hover {
  color: var(--navy-800);
  background: var(--blue-100);
  border-color: #c4d9e5;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding-top: 2px;
}

.form-message {
  min-height: 18px;
  margin: -8px 0 0;
  color: var(--red);
  font-size: 12px;
}

.ledger-panel {
  min-width: 0;
  overflow: hidden;
}

.ledger-toolbar {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 165px 165px;
  gap: 10px;
}

.ledger-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.result-count {
  color: var(--muted);
  font-size: 12px;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.export-actions .button {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 11px;
}

.record-table th {
  padding-top: 10px;
  padding-bottom: 10px;
}

.record-table td {
  padding-top: 11px;
  padding-bottom: 11px;
}

.record-student {
  min-width: 135px;
}

.record-student strong {
  display: block;
}

.record-student span {
  color: var(--muted);
  font-size: 11px;
}

.record-reason {
  max-width: 260px;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.mini-button:hover {
  color: var(--navy-800);
  background: var(--blue-100);
}

.mini-button.is-danger:hover {
  color: var(--red-dark);
  background: var(--red-soft);
}

.mini-button .icon {
  width: 15px;
  height: 15px;
}

.storage-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  color: var(--ink-soft);
  background: var(--surface-raised);
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.storage-notice .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: var(--muted);
}

.gate-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr);
  min-height: 100vh;
  background: #fff;
}

.gate-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: clamp(36px, 6vw, 82px);
  color: #fff;
  background: var(--navy-950);
}

.gate-brand .brand {
  align-self: flex-start;
}

.gate-statement {
  max-width: 580px;
}

.gate-statement h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 66px);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.gate-statement p {
  max-width: 46ch;
  margin: 20px 0 0;
  color: #bed0dc;
  font-size: 15px;
}

.gate-footer {
  color: #8fb0c4;
  font-size: 12px;
}

.gate-form-wrap {
  display: grid;
  place-items: center;
  padding: 36px;
}

.login-panel {
  width: min(390px, 100%);
}

.login-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  color: var(--navy-800);
  background: var(--blue-100);
  border-radius: 50%;
}

.login-mark .icon {
  width: 22px;
  height: 22px;
}

.login-panel h2 {
  margin: 0;
  color: var(--navy-950);
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.02em;
}

.login-panel > p {
  margin: 8px 0 25px;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 13px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.login-submit {
  width: 100%;
}

.login-security {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.login-security .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
}

@media (max-width: 1040px) {
  .admin-grid {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }
}

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

  .panel-sticky {
    position: static;
  }

  .gate-screen {
    grid-template-columns: 1fr;
  }

  .gate-brand {
    min-height: 280px;
    padding: 32px;
  }

  .gate-statement h1 {
    margin-top: 52px;
    font-size: 40px;
  }

  .gate-statement p {
    margin-top: 12px;
  }

  .gate-footer {
    display: none;
  }

  .gate-form-wrap {
    min-height: calc(100vh - 280px);
  }
}

@media (max-width: 760px) {
  .header-inner,
  .shell,
  .page-footer {
    width: min(100% - 28px, 1280px);
  }

  .header-inner {
    min-height: 70px;
  }

  .admin-header .header-inner {
    flex-wrap: wrap;
    gap: 9px;
    padding: 10px 0;
  }

  .admin-header .header-meta {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .admin-header .header-meta .button {
    min-height: 34px;
    padding: 5px 8px;
  }

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

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

  .brand-subtitle {
    font-size: 11px;
  }

  .header-date {
    display: none;
  }

  .page-heading {
    display: grid;
    gap: 15px;
    margin-bottom: 16px;
  }

  .page-title {
    font-size: 25px;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .tab-button {
    padding-inline: 8px;
  }

  .workspace-top {
    display: grid;
    gap: 15px;
    padding: 16px;
  }

  .week-navigation {
    justify-content: space-between;
  }

  .week-current {
    min-width: 0;
    flex: 1;
    text-align: center;
  }

  .week-label {
    font-size: 14px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .search-field {
    min-width: 0;
  }

  .metric-strip {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .metric {
    min-height: 51px;
    padding: 9px 0;
  }

  .metric + .metric {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .metric-value {
    width: 72px;
    font-size: 20px;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .data-table tbody tr {
    padding: 12px 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
  }

  .data-table tbody tr.is-highlighted {
    background: var(--red-soft);
    border-color: #ecc5bf;
  }

  .data-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 15px;
    min-height: 30px;
    padding: 4px 0;
    border: 0;
    text-align: right;
  }

  .data-table td::before {
    flex: 0 0 auto;
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 650;
    text-align: left;
  }

  .data-table td.cell-rank {
    justify-content: flex-start;
    width: auto;
    padding-bottom: 9px;
  }

  .data-table td.cell-rank::before,
  .data-table td.student-cell::before {
    display: none;
  }

  .data-table td.student-cell {
    min-width: 0;
    text-align: left;
  }

  .student-name {
    font-size: 16px;
  }

  .score-cell,
  .count-cell,
  .reason-cell,
  .cell-action {
    max-width: none;
  }

  .reason-text {
    -webkit-line-clamp: 3;
  }

  .cell-action {
    padding-top: 7px !important;
  }

  .data-table td.cell-action::before {
    display: none;
  }

  .data-table td.cell-action {
    justify-content: flex-end;
  }

  .row-link {
    margin-left: auto;
  }

  .page-footer {
    display: grid;
    gap: 6px;
    padding-bottom: 20px;
  }

  .skeleton-table {
    padding: 12px;
  }

  .skeleton-row {
    grid-template-columns: 34px 1fr 64px;
    gap: 12px;
    min-height: 58px;
  }

  .skeleton-row span:nth-child(4),
  .skeleton-row span:nth-child(5),
  .skeleton-row span:nth-child(6) {
    display: none;
  }

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

  .detail-time {
    grid-column: 1 / -1;
  }

  .admin-heading {
    display: grid;
    align-items: start;
  }

  .admin-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    justify-content: flex-start;
    justify-items: start;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .search-field {
    grid-column: auto;
  }

  .ledger-meta {
    display: grid;
  }

  .export-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .score-row {
    grid-template-columns: 1fr 1fr;
  }

  .gate-brand {
    min-height: 245px;
    padding: 24px;
  }

  .gate-statement h1 {
    margin-top: 38px;
    font-size: 33px;
  }

  .gate-statement p {
    display: none;
  }

  .gate-form-wrap {
    min-height: calc(100vh - 245px);
    padding: 30px 24px;
  }
}

@media (max-width: 460px) {
  .score-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .form-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #fff;
    font-size: 12px;
  }

  .site-header {
    color: var(--ink);
    background: #fff;
    border-bottom: 2px solid var(--navy-900);
  }

  .brand-subtitle,
  .header-meta,
  .view-tabs,
  .toolbar-actions,
  .page-footer,
  .cell-action {
    display: none !important;
  }

  .shell {
    width: 100%;
    padding-top: 20px;
  }

  .workspace {
    border: 1px solid #aab8c0;
    box-shadow: none;
  }

  .tab-panel[hidden] {
    display: none !important;
  }

  .data-table tr {
    break-inside: avoid;
  }
}
