:root {
  --bg: #f6fbff;
  --panel: #ffffff;
  --ink: #14213d;
  --muted: #64748b;
  --line: #d8e3f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --mint: #14b8a6;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --blue: #0ea5e9;
  --shadow: 0 18px 44px rgba(37, 99, 235, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(20, 184, 166, 0.12), transparent 32%),
    var(--bg);
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 32px 22px;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.1), transparent 46%),
    linear-gradient(315deg, rgba(20, 184, 166, 0.14), transparent 38%),
    #f6fbff;
}

.login-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.72fr);
  gap: 22px;
  align-items: stretch;
  min-height: min(720px, calc(100vh - 64px));
}

.login-hero {
  min-height: 620px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 8px;
  padding: 24px;
  color: #10233f;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 22px 60px rgba(15, 35, 68, 0.08);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 18px;
  overflow: hidden;
  position: relative;
}

.login-brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.login-brand-row div {
  display: grid;
  gap: 3px;
}

.login-brand-row strong {
  font-size: 24px;
}

.login-brand-row span,
.login-kicker {
  color: #0f766e;
  font-weight: 700;
}

.login-visual {
  min-height: 330px;
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #e8f3ff;
}

.login-visual img {
  width: 100%;
  height: 100%;
  min-height: 330px;
  display: block;
  object-fit: cover;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(7, 24, 48, 0.66));
}

.login-visual figcaption {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 1;
  color: #fff;
}

.login-visual figcaption strong,
.login-visual figcaption span {
  display: block;
}

.login-visual figcaption strong {
  font-size: 22px;
  line-height: 1.3;
}

.login-visual figcaption span {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
}

.login-hero-copy {
  max-width: 640px;
  position: relative;
  z-index: 1;
}

.login-kicker {
  margin: 0 0 14px;
  font-size: 15px;
}

.login-hero h1 {
  margin: 0;
  max-width: 660px;
  font-size: 42px;
  line-height: 1.16;
  letter-spacing: 0;
}

.login-hero-copy p:last-child {
  max-width: 560px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.login-feature-grid {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  position: relative;
  z-index: 1;
}

.login-feature-grid span {
  min-height: 46px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1e3a8a;
  font-weight: 800;
  font-size: 14px;
}

.login-card {
  align-self: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 60px rgba(15, 35, 68, 0.1);
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
}

.login-card-head {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.login-card-head span {
  color: var(--mint);
  font-size: 14px;
  font-weight: 800;
}

.login-card-head strong {
  font-size: 24px;
  line-height: 1.3;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 20px;
}

.login-error {
  min-height: 22px;
  display: block;
  margin-top: 12px;
  color: var(--rose);
  font-size: 14px;
}

.login-data-status {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.45;
}

.login-data-status[data-status="ready"] {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #0f766e;
}

.login-data-status[data-status="error"] {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #be123c;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #172554;
  color: #eff6ff;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

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

.brand span {
  margin-top: 4px;
  color: #bfdbfe;
  font-size: 13px;
}

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

.nav-tab {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dbeafe;
  background: transparent;
  text-align: left;
}

.nav-tab:hover,
.nav-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
}

.service-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.service-card span,
.service-card p {
  color: #bfdbfe;
}

.service-card strong {
  display: block;
  margin: 8px 0;
  font-size: 38px;
}

.service-card p {
  margin: 0;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-box span {
  color: var(--muted);
  white-space: nowrap;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
  letter-spacing: 0;
}

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

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

.primary-action:hover {
  background: var(--brand-dark);
}

.secondary-action,
.file-button {
  color: var(--brand);
  background: #eef6ff;
  border-color: #c7ddff;
}

.full {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

.metric {
  padding: 18px;
}

.metric span,
.metric small,
.panel p,
label,
th,
.card-meta,
.notice {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 34px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.quick-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.quick-panel {
  box-shadow: none;
}

.quick-form,
.data-stats {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 10px;
  align-items: center;
}

.segment-result {
  display: block;
  margin-top: 12px;
  font-size: 18px;
}

.data-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.data-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbf9;
}

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

.data-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.panel {
  padding: 20px;
}

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

.panel-head p {
  margin-bottom: 0;
}

.with-tools {
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.toolbar input {
  width: min(280px, 100%);
}

.toolbar select {
  width: 140px;
}

.student-list,
.band-list,
.student-cards,
.reco-columns {
  display: grid;
  gap: 12px;
}

.student-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

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

.student-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.student-row strong,
.student-card strong {
  display: block;
  margin-bottom: 5px;
}

.tag {
  min-width: 58px;
  min-height: 30px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.tag.rush {
  background: var(--rose);
}

.tag.steady {
  background: var(--blue);
}

.tag.safe {
  background: var(--mint);
}

.data-gap {
  min-height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 4px 10px;
  color: #92400e;
  background: #fff7d6;
  font-size: 13px;
  font-weight: 800;
}

.band-row {
  display: grid;
  grid-template-columns: 72px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e9efec;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--mint));
}

.table-wrap {
  overflow-x: auto;
}

.school-group-list {
  display: grid;
  gap: 16px;
}

.school-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.school-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.school-card h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

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

.school-summary {
  min-width: 120px;
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 5px;
  color: var(--muted);
}

.school-summary strong {
  color: var(--ink);
  font-size: 18px;
}

.group-rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 14px 16px;
  scroll-snap-type: x proximity;
  border-bottom: 1px solid var(--line);
}

.group-chip {
  flex: 0 0 280px;
  scroll-snap-align: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.group-chip.complete {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.group-chip.partial {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.group-chip.missing {
  border-color: #fde68a;
  background: #fffbeb;
}

.group-chip-head,
.group-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.line-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 10px 0 6px;
  font-weight: 800;
}

.group-chip small {
  display: block;
  color: var(--muted);
  line-height: 1.5;
}

.group-detail-list {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.group-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.group-detail-head {
  justify-content: flex-start;
  padding: 12px;
  background: #f8fbff;
  border-bottom: 1px solid var(--line);
}

.status-pill {
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.complete {
  color: #0f766e;
  background: #ccfbf1;
}

.status-pill.partial {
  color: #0369a1;
  background: #e0f2fe;
}

.status-pill.missing {
  color: #92400e;
  background: #fef3c7;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.source-pill.official {
  background: #dcfce7;
  color: #166534;
}

.compact-table {
  min-width: 980px;
}

.detail-panel {
  margin-top: 18px;
}

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

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 13px;
  background: #f8fbff;
}

.muted,
.table-note {
  color: var(--muted);
  font-size: 13px;
}

.table-note {
  text-align: center;
  background: #f8fbff;
}

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

.form-panel {
  align-self: start;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  font-weight: 700;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.reco-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.reco-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reco-card-title em {
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  text-align: center;
}

.reco-card.rush {
  border-color: #fecdd3;
}

.reco-card.steady {
  border-color: #bae6fd;
}

.reco-card.safe {
  border-color: #99f6e4;
}

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

.plan-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.plan-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: #f8fbff;
  border-bottom: 1px solid var(--line);
}

.plan-item-head strong,
.plan-item-head span {
  display: block;
}

.plan-item-head strong {
  margin-bottom: 5px;
  font-size: 16px;
}

.plan-item-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.plan-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.plan-fields > div {
  min-height: 76px;
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 5px;
  background: #fff;
}

.plan-fields span {
  color: var(--muted);
  font-size: 12px;
}

.plan-fields strong {
  font-size: 15px;
  line-height: 1.35;
}

.rank-gap {
  grid-column: span 2;
}

.rank-gap.ahead {
  background: #fff1f2;
}

.rank-gap.near {
  background: #eff6ff;
}

.rank-gap.behind {
  background: #f0fdfa;
}

.rank-gap.missing {
  background: #fffbeb;
}

.rank-gap small {
  color: var(--muted);
}

.student-cards {
  grid-template-columns: 1fr;
}

.teacher-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 14px;
}

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

.teacher-group-head strong {
  font-size: 18px;
}

.teacher-group-head span {
  color: var(--muted);
  font-size: 14px;
}

.teacher-student-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card-meta {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  font-size: 14px;
}

.import-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px dashed #adc5bb;
  border-radius: 8px;
  padding: 18px;
  background: #f8fbf9;
}

.file-button input {
  display: none;
}

#csvPreview {
  min-height: 180px;
  margin: 14px 0;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.notice {
  border-left: 4px solid var(--amber);
  padding: 12px 14px;
  background: #fff7eb;
  border-radius: 0 8px 8px 0;
}

.beian-footer,
.site-footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.beian-footer {
  margin-top: 10px;
}

.site-footer {
  padding: 16px 0 4px;
}

.beian-footer a,
.site-footer a {
  color: inherit;
  text-decoration: none;
}

.beian-footer a:hover,
.site-footer a:hover {
  color: var(--ink);
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(16, 36, 31, 0.45);
}

.dialog-card {
  width: min(480px, calc(100vw - 32px));
  padding: 22px;
}

.dialog-card textarea {
  min-height: 110px;
  resize: vertical;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

@media (max-width: 1100px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-hero {
    min-height: auto;
    gap: 18px;
  }

  .login-card {
    max-width: 520px;
    margin: 0 auto;
  }

  .metric-grid,
  .teacher-student-list,
  .reco-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .quick-tools,
  .reco-layout,
  .student-editor {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .login-screen {
    min-height: 100vh;
    align-items: start;
    padding: 12px;
  }

  .login-shell {
    gap: 12px;
  }

  .login-hero {
    padding: 14px;
    gap: 12px;
  }

  .login-visual,
  .login-visual img {
    min-height: 210px;
  }

  .login-logo {
    width: 58px;
    height: 58px;
  }

  .login-brand-row strong {
    font-size: 21px;
  }

  .login-hero h1 {
    font-size: 32px;
  }

  .login-hero-copy p:last-child {
    font-size: 15px;
    line-height: 1.6;
  }

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

  .login-feature-grid span {
    min-height: 40px;
  }

  .login-card {
    padding: 22px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .workspace {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .import-box,
  .student-row,
  .school-card-head {
    display: grid;
  }

  .school-summary {
    justify-items: start;
  }

  .group-chip {
    flex-basis: 250px;
  }

  .metric-grid,
  .student-cards,
  .teacher-student-list,
  .reco-columns,
  .quick-form,
  .data-stats,
  .two-col {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .toolbar input,
  .toolbar select,
  .primary-action,
  .secondary-action,
  .file-button {
    width: 100%;
  }
}
