:root {
  --ink: #19221f;
  --muted: #60706a;
  --line: #d9e1dd;
  --paper: #f7f8f6;
  --panel: #ffffff;
  --primary: #b51f35;
  --primary-strong: #8f1728;
  --green: #1f7a5b;
  --amber: #ad6a14;
  --blue: #2f6f9f;
  --shadow: 0 10px 24px rgba(27, 38, 33, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

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

button,
.link-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  min-height: 40px;
  padding: 9px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.primary:hover {
  background: var(--primary-strong);
}

.secondary,
.link-button.secondary {
  background: #e9efec;
  color: var(--ink);
}

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

.danger {
  color: var(--primary);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

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

.brand img {
  width: 128px;
  max-height: 44px;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.main-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px clamp(16px, 4vw, 40px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
}

.tab.active {
  color: var(--primary);
  border-color: #e4b8c0;
  background: #fff5f6;
}

main {
  padding: 22px clamp(16px, 4vw, 40px) 56px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 28px;
  margin: 0 auto 18px;
  max-width: 1180px;
}

.page-head h1 {
  margin: 4px 0 8px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: 0;
}

.page-head p {
  color: var(--muted);
  margin: 0;
  max-width: 680px;
}

.deadline-list {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.deadline-list p {
  color: inherit;
  margin: 0;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.kv-frame {
  flex: 0 0 min(34vw, 360px);
  min-height: 180px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.kv-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kv-frame img.fallback-logo {
  width: 75%;
  height: auto;
  object-fit: contain;
}

.panel,
.admin-console > .panel {
  max-width: 1180px;
  margin: 0 auto 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 3vw, 24px);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title h2,
.section-title h3,
.section-subhead h3 {
  margin: 0;
  font-size: 20px;
}

.section-title p,
.section-subhead p,
.meta-line {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 14px;
}

.compact {
  margin-bottom: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.required-text::after {
  content: " *";
  color: var(--primary);
  font-weight: 700;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  min-height: 40px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.date-select-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.full {
  grid-column: 1 / -1;
}

.hidden {
  display: none !important;
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.track-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  min-height: 58px;
}

.track-option input {
  width: 18px;
  min-height: 18px;
}

.declarations {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfb;
}

.declarations label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
}

.rule-link-row {
  margin: 0 0 2px;
}

.rule-link-row a {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.declarations input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-card {
  margin-top: 12px;
  min-height: 24px;
  color: var(--muted);
}

.result-card.ok {
  color: var(--green);
}

.result-card.error,
.fatal,
.warning {
  color: var(--primary);
}

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

.record-card,
.student-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--green);
  background: #e8f3ee;
  font-size: 12px;
  white-space: nowrap;
}

.item-list,
.file-list,
.payment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.item-list span,
.file-list a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--ink);
  background: #f8faf9;
  font-size: 13px;
  text-decoration: none;
}

.voucher-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  width: 100%;
  align-items: end;
  margin-top: 8px;
}

.offline-payment-panel {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr);
  gap: 14px;
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.offline-payment-copy {
  align-self: start;
}

.offline-payment-copy h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.offline-payment-copy p {
  margin: 0 0 8px;
  color: var(--muted);
}

.offline-payment-qr {
  width: min(100%, 240px);
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.offline-payment-panel .voucher-form {
  grid-column: 1 / -1;
  margin-top: 0;
}

.pay-qr {
  width: 180px;
  height: 180px;
  margin-top: 12px;
  border: 1px solid var(--line);
}

.payment-error {
  margin: 10px 0 0;
  color: var(--primary);
  font-weight: 700;
}

.payment-inline-hint {
  margin: 10px 0 0;
  color: var(--green);
  font-weight: 700;
  line-height: 1.5;
}

.work-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.work-form h3,
.work-form label:nth-of-type(n + 2),
.work-form button {
  grid-column: 1 / -1;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr)) auto auto;
  gap: 10px;
  align-items: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metrics span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: #fbfcfb;
}

.metrics strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
}

.admin-status-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.notice {
  color: var(--blue);
}

.empty {
  color: var(--muted);
  margin: 0;
}

.fatal {
  padding: 10px 16px;
  background: #fff1f2;
  border-bottom: 1px solid #ffd0d6;
}

@media (max-width: 860px) {
  .topbar,
  .page-head,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .with-kv {
    gap: 16px;
  }

  .kv-frame {
    width: 100%;
    flex-basis: auto;
  }

  .inline-form,
  .form-grid,
  .offline-payment-panel,
  .voucher-form,
  .work-form,
  .admin-toolbar,
  .admin-status-row {
    grid-template-columns: 1fr;
  }

  .brand img {
    width: 110px;
  }

  .record-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
