:root {
  color-scheme: light;
  --ink: #10201b;
  --muted: #5e6d68;
  --bg: #f3f6f4;
  --panel: #ffffff;
  --green: #0b8a61;
  --green-dark: #0f5f48;
  --red: #c13b32;
  --line: #d8e4dc;
  --soft-line: #ecf1ee;
  --sidebar: #10201b;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(135deg, rgba(11, 138, 97, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(34, 82, 145, 0.1), transparent 34%),
    var(--bg);
}

.qr-stage {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.qr-board {
  display: grid;
  gap: 14px;
  width: min(78vmin, 720px);
}

.qr-title {
  min-height: 54px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(28px, 5vmin, 46px);
  line-height: 1.15;
  font-weight: 900;
  text-align: center;
}

.qr-title[hidden] {
  display: none !important;
}

.qr-box {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(16, 32, 27, 0.16);
  padding: clamp(18px, 4vmin, 34px);
}

.qr-box svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-loading {
  width: 100%;
  height: 100%;
}

.qr-unavailable {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: clamp(22px, 5vmin, 42px);
  font-weight: 900;
  text-align: center;
}

.qr-status {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.scan-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
}

.scan-card {
  width: min(420px, 100%);
  min-height: 310px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 22px 56px rgba(16, 32, 27, 0.14);
  padding: 30px;
  text-align: center;
}

.scan-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  color: var(--green);
  background: rgba(11, 138, 97, 0.12);
  font-size: 42px;
  font-weight: 900;
}

.scan-card.error .scan-mark {
  color: var(--red);
  background: rgba(193, 59, 50, 0.12);
}

.scan-card h1 {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

.scan-card p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.silent-scan-page {
  min-height: 100vh;
  background: transparent;
}

.scan-form-page {
  min-height: 100vh;
  background: var(--bg);
}

.scan-form-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

.scan-form-shell[hidden] {
  display: none !important;
}

.scan-form {
  display: grid;
  gap: 16px;
  width: min(100%, 420px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 46px rgba(16, 32, 27, 0.12);
}

.scan-form[hidden] {
  display: none !important;
}

.scan-result {
  width: min(100%, 420px);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 26px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 46px rgba(16, 32, 27, 0.12);
  text-align: center;
}

.scan-result[hidden] {
  display: none !important;
}

.scan-result-mark {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  color: var(--green);
  background: rgba(11, 138, 97, 0.12);
  font-size: 36px;
  font-weight: 900;
}

.scan-result.error .scan-result-mark {
  color: var(--red);
  background: rgba(193, 59, 50, 0.12);
}

.scan-result h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.scan-result p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
}

.scan-status {
  width: min(100%, 420px);
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 12px 30px rgba(16, 32, 27, 0.1);
}

.scan-status.error {
  color: var(--red);
}

.scan-extra-fields {
  display: grid;
  gap: 16px;
}

.scan-field span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.scan-field input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 18px;
  outline: none;
}

.scan-field input:focus {
  border-color: rgba(11, 138, 97, 0.72);
  box-shadow: 0 0 0 4px rgba(11, 138, 97, 0.12);
}

.scan-submit {
  height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  font-size: 17px;
  font-weight: 900;
}

.scan-submit:disabled {
  opacity: 0.72;
}

.admin-page {
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.admin-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  margin-bottom: 14px;
  padding: 0 6px;
}

.admin-eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-hero h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
}

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

.admin-actions[hidden],
.login-panel[hidden],
.dashboard[hidden] {
  display: none !important;
}

.ghost-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.ghost-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

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

.login-panel {
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 50px rgba(25, 41, 36, 0.1);
}

.admin-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-field input {
  width: 100%;
  height: 54px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.admin-field input:focus {
  border-color: rgba(11, 138, 97, 0.75);
  box-shadow: 0 0 0 4px rgba(11, 138, 97, 0.12);
}

.admin-field.compact input {
  height: 44px;
}

.admin-textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  outline: none;
}

.admin-textarea:focus {
  border-color: rgba(11, 138, 97, 0.75);
  box-shadow: 0 0 0 4px rgba(11, 138, 97, 0.12);
}

.admin-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.admin-message.error {
  color: var(--red);
}

.admin-message.success {
  color: var(--green);
}

.dashboard {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.admin-tabs {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(16, 32, 27, 0.08);
  border-radius: 8px;
  background: var(--sidebar);
  box-shadow: 0 18px 45px rgba(16, 32, 27, 0.14);
}

.admin-tab {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.admin-tab:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.admin-tab.is-active {
  border-color: rgba(255, 255, 255, 0.14);
  background: var(--green);
  color: #ffffff;
}

.admin-section {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.admin-section[hidden] {
  display: none;
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(160px, 200px) minmax(170px, 220px) minmax(220px, 1fr) minmax(190px, 240px) auto minmax(120px, 1fr);
  align-items: end;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 34px rgba(16, 32, 27, 0.06);
}

.system-panel {
  gap: 14px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
}

.system-wide-field {
  grid-column: span 2;
}

.system-readonly-card {
  display: grid;
  gap: 6px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.system-readonly-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.system-readonly-card strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button.compact {
  min-height: 44px;
  padding: 0 18px;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.manage-panel {
  min-width: 0;
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 34px rgba(16, 32, 27, 0.06);
}

.roster-panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--soft-line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment-form,
.event-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
}

.segment-title-field,
.event-note-field {
  grid-column: span 2;
}

.event-segment-field {
  grid-column: span 2;
}

.segment-list,
.event-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.segment-item,
.event-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.segment-main,
.event-main {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.segment-item.active,
.event-item.active {
  border-color: rgba(11, 138, 97, 0.72);
  box-shadow: 0 0 0 3px rgba(11, 138, 97, 0.1);
}

.event-item.editing {
  border-color: rgba(34, 82, 145, 0.58);
}

.segment-main strong,
.event-main strong {
  font-size: 14px;
}

.segment-main span,
.event-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segment-actions,
.event-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.segment-actions button,
.event-actions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.class-pick-wrap {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.class-pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.class-pick-head strong {
  font-size: 13px;
}

.class-pick-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.class-pick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.class-pick-actions button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.class-pick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 160px;
  overflow: auto;
}

.class-pick {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.class-pick.active {
  border-color: rgba(11, 138, 97, 0.78);
  background: rgba(11, 138, 97, 0.1);
  color: var(--green);
}

.admin-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.roster-toolbar {
  display: grid;
  grid-template-columns: repeat(3, max-content) minmax(220px, 1fr);
  align-items: end;
  gap: 10px;
}

.ghost-button.compact {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.roster-search-field {
  justify-self: stretch;
}

.roster-file-manager {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(190px, 240px) minmax(0, 1fr);
  gap: 10px;
  height: clamp(360px, 48vh, 560px);
  min-width: 0;
}

.roster-pane,
.roster-sheet-pane {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.roster-pane {
  display: grid;
  min-height: 0;
  grid-template-rows: auto 1fr;
}

.roster-sheet-pane {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto 1fr;
}

.roster-pane-head,
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  background: #f7faf7;
}

.roster-pane-head strong,
.sheet-head strong {
  font-size: 13px;
}

.roster-pane-head span,
.sheet-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.sheet-head > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sheet-head strong,
.sheet-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-folder-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.folder-item,
.file-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.file-item {
  grid-template-columns: 30px minmax(0, 1fr) auto 28px;
}

.folder-item.active,
.file-item.active {
  border-color: rgba(11, 138, 97, 0.68);
  background: rgba(11, 138, 97, 0.08);
}

.folder-item.dimmed,
.file-item.dimmed {
  opacity: 0.42;
}

.folder-open,
.file-open,
.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
}

.folder-item input,
.file-item input {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-item input:focus,
.file-item input:focus {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(11, 138, 97, 0.72);
}

.folder-item b,
.file-item b {
  color: var(--muted);
  font-size: 12px;
}

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

.sheet-table-wrap {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.sheet-table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  table-layout: fixed;
}

.sheet-table th,
.sheet-table td {
  padding: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.sheet-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  padding: 0 10px;
  background: #f7faf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.sheet-table th:first-child,
.sheet-table td:first-child {
  width: 44px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.sheet-table th:last-child,
.sheet-table td:last-child {
  width: 42px;
  text-align: center;
}

.sheet-table th:nth-child(2),
.sheet-table td:nth-child(2) {
  width: 42%;
}

.sheet-table th:nth-child(3),
.sheet-table td:nth-child(3) {
  width: auto;
}

.sheet-cell {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.sheet-cell:focus {
  box-shadow: inset 0 0 0 2px rgba(11, 138, 97, 0.72);
}

.bulk-import {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.bulk-import summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  background: #f7faf7;
}

.bulk-import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px 0;
}

.bulk-import .roster-input {
  width: calc(100% - 24px);
  margin: 10px 12px;
}

.bulk-import .ghost-button {
  margin: 0 12px 12px;
}

.roster-input {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  outline: none;
}

.roster-input:focus {
  border-color: rgba(11, 138, 97, 0.75);
  box-shadow: 0 0 0 4px rgba(11, 138, 97, 0.12);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.weekly-panel {
  gap: 12px;
}

.weekly-export-bar {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(180px, 220px) minmax(180px, 1fr);
  align-items: end;
  gap: 10px;
}

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

.weekly-class-option {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.weekly-class-option-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
  font-weight: 900;
}

.weekly-class-option-head input {
  width: 17px;
  height: 17px;
  margin: 0;
  flex: 0 0 auto;
}

.weekly-class-option-head span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.weekly-class-option-head strong,
.weekly-class-option-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weekly-class-option-head small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.lesson-board-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.lesson-board-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.lesson-board-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.lesson-board-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lesson-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.lesson-check-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.lesson-check-card-main {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.lesson-check-card-main input {
  width: 17px;
  height: 17px;
  margin: 0;
  flex: 0 0 auto;
}

.lesson-check-card-main span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lesson-check-card-main strong,
.lesson-check-card-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-check-card-main strong {
  font-size: 14px;
}

.lesson-check-card-main small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.lesson-check-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.lesson-check-stats b {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  text-align: center;
}

.lesson-check-stats .present {
  color: #0b7b57;
}

.lesson-check-stats .absent {
  color: #a33b2b;
}

.lesson-check-detail summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.week-matrix-board {
  display: grid;
  gap: 14px;
}

.week-matrix {
  display: grid;
  grid-template-columns: minmax(120px, 160px) repeat(7, minmax(92px, 1fr));
  gap: 6px;
  overflow: auto;
}

.week-matrix-head,
.week-matrix-lesson,
.week-matrix-cell {
  min-width: 0;
  border-radius: 8px;
}

.week-matrix-head {
  padding: 8px;
  background: #eef5f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.week-matrix-lesson {
  display: flex;
  align-items: center;
  padding: 8px;
  background: #f7faf8;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.week-matrix-cell {
  display: grid;
  gap: 2px;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.week-matrix-cell strong {
  font-size: 16px;
}

.week-matrix-cell small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.week-matrix-cell.active {
  border-color: rgba(11, 138, 97, 0.8);
  box-shadow: 0 0 0 3px rgba(11, 138, 97, 0.12);
}

.check-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.check-detail-column {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.check-detail-column h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.check-detail-column h3 b {
  color: var(--ink);
}

.check-detail-column ul {
  display: grid;
  gap: 6px;
  max-height: 220px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.check-detail-column li {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 6px;
  background: #ffffff;
}

.check-detail-column li strong,
.check-detail-column li small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-detail-column li strong {
  font-size: 13px;
}

.check-detail-column li small {
  color: var(--muted);
  font-size: 11px;
}

.check-detail-column.present h3 {
  color: #0b7b57;
}

.check-detail-column.absent h3 {
  color: #a33b2b;
}

.check-detail-column.outside h3 {
  color: #7a5a16;
}

.empty-mini {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.attendance-class {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attendance-class.warning {
  border-color: rgba(193, 59, 50, 0.32);
}

.attendance-class-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.attendance-class-head strong {
  font-size: 15px;
}

.attendance-class-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-list b,
.mini-list span {
  padding: 4px 7px;
  border-radius: 8px;
  background: #f2f7f3;
}

.mini-list b {
  color: var(--red);
}

.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.display-panel {
  gap: 12px;
}

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

.display-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(160px, 220px);
  gap: 10px;
}

.display-active-list,
.display-device-list {
  display: grid;
  gap: 8px;
}

.display-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.display-session-item.online {
  border-color: rgba(11, 138, 97, 0.48);
}

.display-session-item > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.display-session-item strong,
.display-device-head strong {
  font-size: 14px;
}

.display-session-item span,
.display-device-head span,
.display-device-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.display-session-item button,
.display-device-actions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.display-device-section {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.display-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.display-section-head > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.display-section-head strong {
  font-size: 14px;
}

.display-section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.display-section-head b {
  flex: 0 0 auto;
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--green);
  font-size: 12px;
  text-align: center;
}

.display-section-list {
  display: grid;
  gap: 8px;
}

.display-device-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.display-device-card.online,
.display-device-card.approved {
  border-color: rgba(11, 138, 97, 0.48);
}

.display-device-card.pending {
  border-color: rgba(34, 82, 145, 0.44);
}

.display-device-card.disabled {
  opacity: 0.72;
}

.display-device-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.display-device-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.display-device-head b {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 8px;
  background: #f7faf7;
  color: var(--green);
  font-size: 12px;
}

.display-device-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.display-device-meta {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
}

.display-device-meta .warn {
  color: var(--red);
}

.display-device-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.display-device-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.display-detail-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border: 1px solid #edf3ee;
  border-radius: 8px;
  background: #fbfdfb;
}

.display-detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.display-detail-row code {
  min-width: 0;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 34px rgba(16, 32, 27, 0.06);
}

.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-width: 760px;
  padding: 20px;
  border-bottom: 1px solid var(--soft-line);
  background: #ffffff;
}

.record-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.table-toolbar h2 {
  margin: 0 0 5px;
  font-size: 20px;
  line-height: 1.2;
}

.table-toolbar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-search {
  width: min(320px, 38vw);
}

.record-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  min-width: 760px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--soft-line);
  background: #fbfdfb;
}

.record-filters .table-search {
  grid-column: span 2;
  width: auto;
}

.admin-field select {
  width: 100%;
  height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  outline: none;
}

.admin-field.compact select {
  height: 44px;
}

.record-table {
  width: 100%;
  border-collapse: collapse;
}

.record-table th,
.record-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  font-size: 14px;
}

.record-table th {
  position: sticky;
  top: 0;
  background: #f7faf7;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.empty-cell {
  color: var(--muted);
  font-weight: 800;
  text-align: center !important;
}

.record-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 760px;
  padding: 14px 20px;
  border-top: 1px solid var(--soft-line);
  background: #ffffff;
}

.record-pager span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.record-pager > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.record-pager button:disabled {
  opacity: 0.45;
}

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

  .admin-tabs {
    position: static;
    display: flex;
    overflow-x: auto;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(16, 32, 27, 0.06);
    scrollbar-width: thin;
  }

  .admin-tab {
    width: auto;
    flex: 0 0 auto;
    color: var(--muted);
    text-align: center;
  }

  .admin-tab:hover {
    border-color: var(--line);
    background: #f7faf8;
    color: var(--ink);
  }

  .admin-tab.is-active {
    background: var(--green);
    color: #ffffff;
  }

  .segment-form,
  .event-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segment-title-field,
  .event-note-field,
  .event-segment-field {
    grid-column: span 2;
  }

  .roster-toolbar {
    grid-template-columns: repeat(3, max-content);
  }

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

  .roster-file-manager {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: auto;
  }

  .display-toolbar,
  .display-filters,
  .weekly-export-bar,
  .display-device-editor,
  .display-device-details {
    grid-template-columns: 1fr 1fr;
  }

  .lesson-card-list,
  .check-detail-grid {
    grid-template-columns: 1fr;
  }

  .roster-sheet-pane {
    grid-column: 1 / -1;
    min-height: 360px;
  }
}

@media (max-width: 620px) {
  .qr-stage {
    padding: 16px;
  }

  .qr-board {
    width: min(92vmin, 460px);
  }

  .admin-shell {
    width: min(100vw - 20px, 560px);
    padding: 18px 0 24px;
  }

  .admin-hero {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 10px;
  }

  .admin-hero h1 {
    font-size: 26px;
  }

  .admin-tabs {
    gap: 6px;
    padding: 8px;
  }

  .settings-panel {
    grid-template-columns: 1fr;
  }

  .admin-tabs {
    padding: 6px;
  }

  .admin-tab {
    min-height: 36px;
    padding: 0 11px;
    font-size: 13px;
  }

  .manage-panel,
  .settings-panel {
    padding: 16px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .admin-grid,
    .roster-toolbar,
    .roster-file-manager,
    .bulk-import-grid,
    .segment-form,
    .event-form,
    .attendance-grid,
    .weekly-export-bar,
    .display-toolbar,
    .display-filters,
    .display-device-editor,
    .display-device-details {
    grid-template-columns: 1fr;
  }

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

  .segment-title-field,
  .event-note-field,
  .event-segment-field {
    grid-column: auto;
  }

  .roster-file-manager {
    height: auto;
  }

  .roster-pane,
  .roster-sheet-pane {
    min-height: 220px;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
    min-width: 760px;
  }

  .record-actions {
    justify-content: flex-start;
  }

  .record-filters,
  .record-pager {
    min-width: 760px;
  }

  .record-filters {
    grid-template-columns: 1fr 1fr;
  }

  .record-filters .table-search {
    grid-column: span 2;
    width: 100%;
  }
}
