:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --ink: #18201c;
  --muted: #68736d;
  --line: #dfe4df;
  --green: #176b4d;
  --green-soft: #e5f3ec;
  --amber: #9a5b08;
  --amber-soft: #fff1d8;
  --red: #a6382f;
  --red-soft: #fce9e6;
  --blue: #285d84;
  --blue-soft: #e7f0f7;
  --shadow: 0 18px 50px rgb(24 32 28 / 8%);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e4eee7 0, transparent 34%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgb(255 255 255 / 92%); box-shadow: var(--shadow); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; background: var(--green); color: white; font: 700 24px/1 "Songti SC", serif; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; }
.eyebrow { margin: 24px 0 6px; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 38px); letter-spacing: -.03em; }
h2 { margin-bottom: 5px; font-size: 19px; }
h3 { margin: 0 0 12px; font-size: 14px; }
.muted { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 17px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #46504b; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #ccd4ce; border-radius: 10px; background: white; color: var(--ink); padding: 11px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(23 107 77 / 12%); }
textarea { resize: vertical; }
.form-error { min-height: 18px; margin: -3px 0; color: var(--red); font-size: 13px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; color: inherit; background: transparent; font-weight: 650; font-size: 13px; text-decoration: none; transition: transform .1s, background .15s; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: #115c41; }
.button.secondary { border-color: var(--line); background: var(--surface); }
.button.secondary:hover, .button.ghost:hover { background: #eef1ee; }
.button.danger-quiet { color: var(--red); }
.button.danger-quiet:hover { background: var(--red-soft); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 max(24px, calc((100vw - 1280px) / 2)); border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 92%); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand span { display: block; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.admin-email { color: var(--muted); font-size: 12px; }
.sync-pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 6px 10px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; }
.sync-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync-pill.error { color: var(--red); background: var(--red-soft); }

.content { width: min(1280px, calc(100% - 48px)); margin: 0 auto; padding: 38px 0 64px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.page-heading .eyebrow { margin-top: 0; }
.operations-health { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 22px; padding: 16px 18px; border: 1px solid #b9d7c9; border-radius: 14px; background: var(--green-soft); }
.operations-health.warning { border-color: #e7c88e; background: var(--amber-soft); }
.operations-health.critical { border-color: #e1a59f; background: var(--red-soft); }
.operations-health strong { display: block; font-size: 14px; }
.operations-health p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.operations-status-list { display: grid; gap: 13px; }
.operations-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.health-badge { white-space: nowrap; border-radius: 999px; padding: 6px 9px; background: rgb(255 255 255 / 70%); color: var(--green); font-size: 11px; font-weight: 750; }
.health-badge.attention { color: var(--red); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; margin: 28px 0 30px; }
.summary-card { min-height: 120px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 4px 16px rgb(24 32 28 / 3%); }
.summary-card strong { display: block; margin-top: 16px; font-size: 32px; line-height: 1; }
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card.attention { border-color: #edd6ae; background: linear-gradient(145deg, #fff, #fff9ef); }

.tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.tab { padding: 12px 16px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.tab.active { border-color: var(--green); color: var(--green); }
.count-badge { display: inline-grid; min-width: 20px; height: 20px; place-items: center; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 11px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 0 16px 16px 16px; background: var(--surface); box-shadow: 0 8px 28px rgb(24 32 28 / 4%); }
.panel-heading { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.button-row, .section-title { display: flex; align-items: center; gap: 8px; }
.section-title { justify-content: space-between; }
.section-title h3 { margin: 0; }
.file-button { cursor: pointer; }
.compact-label { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.compact-label select { width: auto; min-width: 190px; padding: 8px 10px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 16px; background: #fafbf9; color: var(--muted); text-align: left; font-size: 11px; letter-spacing: .04em; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid #edf0ed; vertical-align: middle; }
.teacher-name strong, .teacher-name span { display: block; }
.teacher-name span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status.on-time, .status.confirmed { color: var(--green); background: var(--green-soft); }
.status.late, .status.pending { color: var(--amber); background: var(--amber-soft); }
.status.missing, .status.ignored { color: var(--muted); background: #edf0ee; }
.status.auto { color: var(--blue); background: var(--blue-soft); }
.pending-number { color: var(--amber); font-weight: 750; }
.line-list { display: grid; gap: 3px; min-width: 180px; }
.line-list span { overflow-wrap: anywhere; }
.empty { padding: 52px 20px; color: var(--muted); text-align: center; }

.review-list { display: grid; }
.review-row { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(180px, .9fr) minmax(200px, 1fr) auto; align-items: center; gap: 18px; padding: 18px 22px; border-bottom: 1px solid #edf0ed; cursor: pointer; }
.review-row:last-child { border-bottom: 0; }
.review-row:hover { background: #fafbf9; }
.review-primary strong, .review-primary span { display: block; }
.review-primary span, .review-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; max-width: 190px; overflow: hidden; padding: 4px 7px; border-radius: 6px; background: #f0f2ef; color: #56615b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 90px rgb(10 20 14 / 26%); }
.dialog::backdrop { background: rgb(15 24 19 / 48%); backdrop-filter: blur(3px); }
.dialog-shell { display: grid; gap: 22px; max-height: calc(100vh - 40px); overflow: auto; padding: 26px; }
.dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog header .eyebrow { margin: 0 0 5px; }
.dialog h2 { font-size: 22px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eef1ee; color: #4c5751; cursor: pointer; font-size: 24px; line-height: 1; }
.metadata-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metadata-item { padding: 12px; border-radius: 10px; background: #f6f7f5; }
.metadata-item span, .metadata-item strong { display: block; overflow-wrap: anywhere; }
.metadata-item span { margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.metadata-item strong { font-size: 13px; }
.attachment-list, .teacher-choice-list { display: grid; gap: 8px; }
.attachment { display: flex; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.attachment span:last-child { color: var(--muted); }
.teacher-choice { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.teacher-choice:has(input:checked) { border-color: #79ad98; background: var(--green-soft); }
.teacher-choice input, .check-row input { width: 16px; height: 16px; margin: 0; }
.teacher-choice div { flex: 1; }
.teacher-choice strong, .teacher-choice span { display: block; }
.teacher-choice span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.required-mark { flex: 0 !important; border-radius: 999px; padding: 3px 7px; background: #edf0ee; color: var(--muted); font-size: 10px; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-column { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: 9px; background: #f6f7f5; font-weight: 500; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }
.notice { margin: -8px 0 0; padding: 11px 13px; border-radius: 9px; background: var(--amber-soft); color: #704404; font-size: 12px; line-height: 1.6; }
.compact-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 260px; overflow: auto; }
.preview-table { max-height: 320px; border: 1px solid var(--line); border-radius: 10px; }
.import-errors { display: grid; gap: 6px; max-height: 150px; overflow: auto; }
.import-error { margin: 0; padding: 8px 10px; border-radius: 7px; background: var(--red-soft); color: var(--red); font-size: 12px; }
.spacer { flex: 1; }
.compact-dialog { width: min(600px, calc(100% - 28px)); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 20px 24px; border-left: 1px solid var(--line); }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.timeline li:last-child { border-left-color: transparent; }
.timeline strong, .timeline span { display: block; }
.timeline span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 360px; transform: translateY(20px); opacity: 0; pointer-events: none; border-radius: 10px; padding: 12px 16px; background: #19251f; color: white; box-shadow: var(--shadow); transition: .2s; font-size: 13px; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .review-row { grid-template-columns: 1fr auto; }
  .review-row > :nth-child(2), .review-row > :nth-child(3) { grid-column: 1; }
  .admin-email { display: none; }
  .three-column { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .brand span, .sync-pill { display: none; }
  .content { width: calc(100% - 24px); padding-top: 24px; }
  .page-heading { align-items: flex-start; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 100px; padding: 15px; }
  .summary-card strong { font-size: 28px; }
  .review-heading { align-items: flex-start; flex-direction: column; }
  .metadata-grid, .option-grid, .two-column, .compact-choices { grid-template-columns: 1fr; }
  .management-heading { align-items: flex-start; flex-direction: column; }
  .operations-health { align-items: flex-start; flex-direction: column; }
  .operations-badges { justify-content: flex-start; }
  .dialog-shell { padding: 20px; }
  .dialog-actions .button { flex: 1; }
}
