:root {
  color-scheme: only light;
  --burgundy: #8f1833;
  --burgundy-deep: #681126;
  --burgundy-soft: #f5e9ec;
  --ink: #1e252b;
  --muted: #6a737b;
  --line: #ddd9d7;
  --surface: #ffffff;
  --canvas: #f5f3f2;
  --success: #167a59;
  --red-house: #b4233c;
  --blue-house: #2764a8;
  --purple-house: #75509a;
  --shadow: 0 14px 36px rgba(40, 30, 32, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html { min-width: 320px; background: var(--canvas); }

body { margin: 0; min-height: 100vh; background: var(--canvas); }

button, input { font: inherit; }

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

button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(39, 100, 168, 0.35);
  outline-offset: 2px;
}

.app-frame { min-height: 100vh; }
.offline-banner { position: sticky; z-index: 40; top: 0; min-height: 34px; padding: 8px 18px; color: #fff; background: #9c2e2e; text-align: center; font-size: 12px; font-weight: 800; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand img { border-radius: 50%; object-fit: contain; }

.brand span, .identity-chip span { display: grid; gap: 2px; }

.brand strong { font-size: 18px; }

.brand small, .identity-chip small { color: var(--muted); font-size: 12px; }

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

.install-app-command {
  min-height: 36px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--burgundy);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.install-app-command > span { font-size: 18px; line-height: 1; }
.install-app-command:hover { color: #fff; border-color: var(--burgundy); background: var(--burgundy); }

.install-app-dialog,
.camera-permission-dialog {
  width: min(430px, calc(100% - 32px));
  max-width: 430px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(30, 20, 24, 0.24);
}

.install-app-dialog::backdrop,
.camera-permission-dialog::backdrop { background: rgba(30, 25, 27, 0.52); }

dialog[open] {
  position: fixed;
  z-index: 100;
  inset: 0;
  margin: auto;
}

.app-dialog__body { padding: 26px; display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px 16px; }
.app-dialog__mark { width: 48px; height: 48px; display: grid; place-items: center; grid-row: span 2; border-radius: 50%; color: #fff; background: var(--burgundy); font-size: 25px; font-weight: 800; }
.app-dialog__mark--camera { font-size: 23px; }
.app-dialog__body h2 { margin: 1px 0 6px; font-size: 21px; line-height: 1.2; }
.app-dialog__body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.app-dialog__guidance { grid-column: 1 / -1; padding: 12px 14px; border-left: 3px solid var(--burgundy); background: #fbf5f6; color: var(--ink) !important; }
.app-dialog__status { min-height: 20px; grid-column: 1 / -1; color: var(--burgundy) !important; font-weight: 700; }
.app-dialog__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.app-dialog__body > .secondary-command { grid-column: 2; justify-self: start; }

@media (display-mode: standalone) {
  .install-app-command { display: none !important; }
}

.locale-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 104px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0eeed;
  overflow: hidden;
}

.locale-switch button {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.locale-switch button.is-active { color: var(--burgundy); background: var(--surface); box-shadow: 0 1px 4px rgba(30, 37, 43, 0.09); }

.identity-chip { display: flex; align-items: center; gap: 8px; }

.identity-chip strong { font-size: 13px; }

.identity-avatar, .role-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: var(--burgundy);
  font-size: 13px;
  font-weight: 800;
}

.icon-command {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--burgundy);
  background: var(--surface);
  cursor: pointer;
  font-size: 21px;
}

.sign-out-command {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--burgundy);
  border-radius: 6px;
  color: var(--burgundy);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sign-out-command:hover { color: #fff; background: var(--burgundy); }

.mobile-back-command {
  display: none;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--burgundy);
  background: var(--surface);
  cursor: pointer;
  font-size: 21px;
}

.login-main {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  min-height: calc(100vh - 71px);
  display: grid;
  grid-template-columns: minmax(500px, 0.92fr) minmax(520px, 1.08fr);
  align-items: center;
  gap: 64px;
  padding: 56px 0 84px;
}

.login-intro { padding: 20px 0; }

.environment-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-left: 3px solid var(--burgundy);
  color: var(--burgundy);
  background: var(--burgundy-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-intro h1 {
  margin: 0 0 14px;
  font-size: 60px;
  line-height: 0.98;
  font-weight: 600;
  white-space: nowrap;
  overflow-wrap: normal;
}

.environment-badge + h1 { margin-top: 22px; }
html:lang(en) .login-intro h1 { font-size: 46px; }

.login-intro p { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.55; }

.status-line { margin-top: 34px; display: flex; align-items: center; gap: 9px; color: var(--success); font-size: 13px; font-weight: 700; }

.status-line span { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(22, 122, 89, 0.12); }

.role-selector {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sso-entry {
  min-height: 92px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: #fbf7f8;
}

.login-flash { margin: 0; border-width: 0 0 1px; border-radius: 0; }

.sso-entry img { border-radius: 50%; object-fit: contain; }
.sso-entry span { min-width: 0; display: grid; gap: 4px; }
.sso-entry strong { font-size: 15px; }
.sso-entry small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.sso-entry a {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--burgundy);
  text-decoration: none;
  font-size: 20px;
}

.section-heading, .panel-heading {
  min-height: 76px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }

.section-heading h2, .panel-heading h2 { margin: 3px 0 0; font-size: 17px; }

.section-heading > small { color: var(--burgundy); font-size: 11px; font-weight: 800; }

.role-grid { display: grid; }

.role-option {
  min-height: 74px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eeeae8;
}

.role-option:last-child { border-bottom: 0; }

.role-option:hover { background: #faf8f7; }

.role-mark--red { background: var(--red-house); }
.role-mark--blue { background: var(--blue-house); }
.role-mark--purple { background: var(--purple-house); }
.role-mark--neutral { background: #46545e; }

.role-copy { min-width: 0; display: grid; gap: 3px; }
.role-copy strong, .role-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-copy strong { font-size: 14px; }
.role-copy small { color: var(--muted); font-size: 12px; }

.role-option button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--burgundy);
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
}

.house-onboarding { width: min(940px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 80px; }
.house-onboarding__intro { max-width: 680px; }
.house-onboarding__intro > span { color: var(--burgundy); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.house-onboarding__intro h1 { margin: 8px 0 12px; font-size: 42px; font-weight: 600; }
.house-onboarding__intro p { margin: 0; color: var(--muted); line-height: 1.6; }
.house-choice-grid { margin-top: 30px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.house-choice { min-height: 168px; padding: 22px; display: grid; align-content: center; justify-items: start; gap: 8px; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.house-choice input { position: absolute; opacity: 0; pointer-events: none; }
.house-choice > span { width: 34px; height: 8px; border-radius: 3px; }
.house-choice strong { font-size: 19px; }
.house-choice small { color: var(--muted); }
.house-choice--red > span { background: var(--red-house); }
.house-choice--blue > span { background: var(--blue-house); }
.house-choice--purple > span { background: var(--purple-house); }
.house-choice--red:has(input:checked) { border-color: var(--red-house); background: #fbf1f3; }
.house-choice--blue:has(input:checked) { border-color: var(--blue-house); background: #eff5fb; }
.house-choice--purple:has(input:checked) { border-color: var(--purple-house); background: #f5f1f8; }
.house-confirmation { grid-column: 1 / -1; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.house-confirmation input { width: 18px; height: 18px; accent-color: var(--burgundy); }
.house-choice-grid > button { grid-column: 1 / -1; justify-self: start; }

.workspace { min-height: calc(100vh - 71px); display: grid; grid-template-columns: 220px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 70px;
  height: calc(100dvh - 70px);
  align-self: start;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background: #fbfaf9;
  overflow-y: auto;
}

.sidebar nav { display: grid; gap: 5px; }

.sidebar nav a {
  min-height: 42px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  color: #4c555d;
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.sidebar nav a span { text-align: center; font-size: 17px; }
.sidebar nav a:hover, .sidebar nav a.is-active { color: var(--burgundy); background: var(--burgundy-soft); }

.sidebar-context { padding: 14px 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.sidebar-context span { color: var(--muted); font-size: 11px; }
.sidebar-context strong { font-size: 13px; }

.dashboard-main { min-width: 0; padding: 36px clamp(22px, 4vw, 58px) 64px; }

.dashboard-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.dashboard-heading span { color: var(--burgundy); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.dashboard-heading h1 { margin: 5px 0 0; font-size: 32px; font-weight: 600; }
.date-range { color: var(--muted); font-size: 13px; }

.inventory-strip {
  margin-top: 28px;
  min-height: 104px;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) repeat(3, minmax(120px, 0.55fr));
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--burgundy);
  border-radius: 8px;
  background: var(--surface);
}

.flash {
  margin-top: 20px;
  min-height: 42px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  border: 1px solid;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.flash--success { color: #0d6749; border-color: #a8d9c8; background: #edf8f4; }
.flash--error { color: #8d2034; border-color: #e2b4bd; background: #fbf0f2; }
.duplicate-warning { margin-top: 20px; min-height: 82px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid #e2c17f; border-left: 4px solid #a86816; border-radius: 8px; background: #fff9ed; }
.duplicate-warning > div:first-child { display: grid; gap: 3px; }
.duplicate-warning span { color: #8b5a18; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.duplicate-warning h2 { margin: 0; font-size: 14px; }
.duplicate-warning > div:last-child { display: flex; gap: 8px; }

.award-workbench { margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.award-form { padding: 18px; display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(88px, 0.45fr) minmax(180px, 1fr) minmax(160px, 0.9fr) auto; align-items: end; gap: 12px; }
.award-form label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.award-form select, .award-form input { width: 100%; height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); }
.award-form select:focus, .award-form input:focus { border-color: var(--blue-house); outline: 2px solid rgba(39, 100, 168, 0.14); }
.primary-command { min-height: 42px; padding: 9px 16px; border: 0; border-radius: 6px; color: #fff; background: var(--burgundy); cursor: pointer; font-weight: 800; white-space: nowrap; }
.primary-command:hover { background: var(--burgundy-deep); }
.secondary-command { min-height: 38px; padding: 8px 13px; border: 1px solid var(--burgundy); border-radius: 6px; color: var(--burgundy); background: var(--surface); cursor: pointer; font-weight: 800; }
.secondary-command:hover { color: #fff; background: var(--burgundy); }
.secondary-command[href] { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.danger-command { min-height: 42px; padding: 9px 16px; border: 0; border-radius: 6px; color: #fff; background: #9c2e2e; cursor: pointer; font-weight: 800; white-space: nowrap; }
.danger-command:hover { background: #731f1f; }

.student-picker { grid-column: span 2; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #faf9f8; }
.student-picker__heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.student-picker__heading > div { display: grid; gap: 3px; }
.student-picker__heading > div > span { color: var(--muted); font-size: 11px; }
.student-picker__heading strong { color: var(--ink); font-size: 14px; }
.student-search { position: relative; margin-top: 10px; }
.student-search input { background: #fff; }
.student-search-results { position: absolute; z-index: 8; inset: calc(100% + 4px) 0 auto; max-height: 250px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.student-search-results:empty { display: none; }
.student-result { width: 100%; min-height: 52px; padding: 8px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; border: 0; border-bottom: 1px solid #eeeae8; color: var(--ink); background: #fff; cursor: pointer; text-align: left; }
.student-result:last-child { border-bottom: 0; }
.student-result:hover, .student-result:focus-visible { background: var(--burgundy-soft); }
.student-result strong { overflow: hidden; text-overflow: ellipsis; }
.student-result span { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--burgundy); font-size: 11px; font-weight: 800; }
.student-result small { color: var(--muted); }
.student-results-note { padding: 14px; color: var(--muted); font-size: 12px; }
.selected-student { position: relative; margin-top: 10px; min-height: 58px; padding: 9px 48px 9px 13px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 10px; border-left: 4px solid var(--success); border-radius: 5px; background: #edf7f3; }
.selected-student > span { grid-row: 1 / 3; color: var(--success); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.selected-student strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-student small { color: var(--muted); }
.selected-student .icon-command { position: absolute; right: 8px; top: 11px; }
.scanner-panel { margin-top: 12px; padding: 12px; display: grid; grid-template-columns: minmax(220px, .8fr) minmax(220px, 1.2fr); gap: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.scanner-panel video { width: 100%; aspect-ratio: 4 / 3; border-radius: 5px; background: #15191c; object-fit: cover; }
.scanner-panel__copy { display: grid; align-content: center; gap: 9px; }
.scanner-panel__copy p { min-height: 34px; margin: 0; color: var(--muted); font-size: 12px; }
.scanner-panel__copy > div { display: flex; flex-wrap: wrap; gap: 8px; }

.deduction-workbench { margin-top: 22px; border: 1px solid #e0c9c9; border-radius: 8px; background: #fff; overflow: hidden; }
.deduction-workbench .panel-heading { background: #fbf2f2; }
.deduction-workbench .panel-heading small { display: block; margin-top: 4px; color: #7c5555; }
.deduction-form { padding: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 12px; }
.deduction-form label:not(.deduction-confirm), .segmented-field { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.deduction-form select, .deduction-form input[type="text"] { width: 100%; height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.segmented-field { grid-column: 1 / -1; padding: 0; display: flex; flex-wrap: wrap; border: 0; }
.segmented-field legend { width: 100%; margin-bottom: 6px; }
.segmented-field label { display: inline-flex !important; }
.segmented-field input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-field span { min-width: 110px; min-height: 38px; padding: 8px 14px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; cursor: pointer; }
.segmented-field input:checked + span { border-color: var(--burgundy); color: var(--burgundy); background: var(--burgundy-soft); }
.deduction-confirm { grid-column: 1 / -2; min-height: 42px; display: flex; align-items: center; gap: 9px; color: #6e3b3b; font-size: 12px; }

.operation-history { margin-top: 22px; }
.operation-history .panel-heading small { display: block; margin-top: 4px; color: var(--muted); }
.operation-list { display: grid; }
.operation-row { min-height: 76px; padding: 12px 18px; display: grid; grid-template-columns: 52px minmax(180px, 1fr) minmax(280px, .8fr); align-items: center; gap: 14px; border-top: 1px solid #eeeae8; }
.operation-amount { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.operation-amount--positive { color: var(--success); }
.operation-amount--negative { color: #9c2e2e; }
.operation-copy { min-width: 0; display: grid; gap: 3px; }
.operation-copy strong, .operation-copy span, .operation-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operation-copy span, .operation-copy small { color: var(--muted); font-size: 11px; }
.correction-form { display: grid; grid-template-columns: minmax(130px, 1fr) auto; gap: 8px; }
.correction-form input { min-width: 0; height: 38px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; }

.student-summary { margin-top: 22px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.student-summary > div { min-height: 88px; padding: 16px 18px; display: grid; align-content: center; gap: 5px; border-right: 1px solid var(--line); }
.student-summary > div:last-child { border-right: 0; }
.student-summary span { color: var(--muted); font-size: 11px; }
.student-summary strong { font-size: 24px; }
.qr-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.qr-actions form { display: grid; gap: 8px; }
.qr-replace-confirm { max-width: 290px; display: flex; align-items: flex-start; gap: 7px; color: #7c5555; font-size: 11px; text-align: left; }

.management-workbench { margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.management-workbench .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.management-workbench .panel-heading small { display: block; margin-top: 4px; color: var(--muted); }
.management-filter { padding: 14px 18px; display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: 10px; border-top: 1px solid #eeeae8; background: #faf9f8; }
.management-filter--logs { grid-template-columns: minmax(140px, .4fr) minmax(220px, 1fr) auto; }
.management-filter label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.management-filter input, .management-filter select { width: 100%; height: 38px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.management-list { max-height: 460px; overflow-y: auto; }
.management-list > p, .backup-list > p { margin: 0; padding: 24px 18px; color: var(--muted); font-size: 12px; }
.management-list article { min-height: 66px; padding: 10px 18px; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(120px, .6fr); gap: 3px 14px; border-top: 1px solid #eeeae8; }
.management-list article > strong, .management-list article > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.management-list article > span { color: var(--burgundy); font-size: 11px; font-weight: 800; text-align: right; }
.management-list article > small { grid-column: 1 / -1; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.log-level--error, .log-level--critical { color: #9c2e2e !important; }
.backup-create { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid #eeeae8; }
.backup-create label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.backup-list article { min-height: 66px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid #eeeae8; }
.backup-list article > span { min-width: 0; display: grid; gap: 4px; }
.backup-list article strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-list article small { color: var(--muted); }

.batch-workbench { margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.quota-workbench { margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.semester-workbench { margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.semester-workbench .panel-heading small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.semester-form { padding: 18px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.semester-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.semester-form input { width: 100%; height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.semester-form .semester-confirm { grid-column: 1 / -1; display: flex; align-items: center; gap: 9px; font-size: 12px; }
.semester-confirm input { width: 18px; height: 18px; accent-color: var(--burgundy); }
.semester-form > button { grid-column: 1 / -1; justify-self: start; }
.quota-workbench .panel-heading small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.quota-default-form { padding: 18px; display: grid; gap: 14px; }
.select-all-line { display: flex; align-items: center; gap: 8px; color: var(--burgundy); font-size: 13px; font-weight: 800; }
.select-all-line input, .quota-recipient-list input { width: 17px; height: 17px; accent-color: var(--burgundy); }
.quota-recipient-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.quota-recipient-list label { min-height: 58px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #eeeae8; }
.quota-recipient-list label:nth-child(odd) { border-right: 1px solid #eeeae8; }
.quota-recipient-list label > span { min-width: 0; display: grid; gap: 3px; }
.quota-recipient-list strong { font-size: 13px; }
.quota-recipient-list small { color: var(--muted); font-size: 11px; }
.quota-number-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.quota-number-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.quota-number-grid input { width: 100%; height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.quota-submit-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.quota-submit-actions button { min-height: 42px; }
.temporary-quota-list { border-top: 1px solid var(--line); }
.temporary-quota-heading, .temporary-quota-row { min-height: 62px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #eeeae8; }
.temporary-quota-heading { background: #fbfaf9; }
.temporary-quota-heading > *, .temporary-quota-row > span { display: grid; gap: 3px; }
.temporary-quota-heading small, .temporary-quota-row small { color: var(--muted); font-size: 11px; }
.temporary-quota-row > div { display: flex; gap: 7px; }
.temporary-quota-row > div form { margin: 0; }
.batch-workbench .panel-heading small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 500; }
.batch-guide { padding: 16px 18px 0; display: grid; grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr); gap: 8px 20px; color: var(--muted); }
.batch-guide strong { color: var(--ink); font-size: 13px; }
.batch-guide p { margin: 4px 0 0; font-size: 12px; line-height: 1.55; }
.batch-guide pre { grid-row: span 2; margin: 0; padding: 11px 13px; overflow-x: auto; border-left: 3px solid var(--brand); background: #fbf7f7; color: var(--ink); font: 12px/1.7 Consolas, "Courier New", monospace; white-space: pre; }
.batch-guide > small { grid-column: 1 / -1; color: #755b5b; font-size: 11px; line-height: 1.55; }
.batch-form { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.batch-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.batch-form textarea { width: 100%; min-height: 112px; padding: 11px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); font: 13px/1.55 Consolas, "Courier New", monospace; }
.batch-form textarea:focus { border-color: var(--blue-house); outline: 2px solid rgba(39, 100, 168, 0.14); }
.batch-preview { border-top: 1px solid var(--line); background: #fbfaf9; }
.batch-preview > h3 { margin: 0; padding: 14px 18px 0; font-size: 14px; }
.batch-summary { padding: 14px 18px; display: grid; grid-template-columns: repeat(2, minmax(100px, 0.35fr)) minmax(200px, 1fr); gap: 14px; border-bottom: 1px solid var(--line); }
.batch-summary span { display: grid; gap: 3px; }
.batch-summary small { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.batch-summary strong { font-size: 15px; }
.batch-preview-rows { max-height: 260px; overflow: auto; background: var(--surface); }
.batch-preview-rows > div { min-height: 50px; padding: 9px 18px; display: grid; grid-template-columns: minmax(0, 1fr) 90px minmax(130px, 0.7fr); align-items: center; gap: 12px; border-bottom: 1px solid #eeeae8; font-size: 12px; }
.batch-preview-rows span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-preview-rows small { color: var(--muted); }
.batch-actions { padding: 14px 18px; display: flex; justify-content: flex-end; gap: 10px; }

.student-grid { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr); gap: 22px; }
.qr-card { min-height: 300px; padding: 26px; display: grid; grid-template-columns: minmax(0, 1fr) 240px; align-items: center; gap: 26px; border: 1px solid var(--line); border-left: 4px solid var(--burgundy); border-radius: 8px; background: var(--surface); }
.qr-card-copy > span { color: var(--burgundy); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.qr-card-copy h2 { margin: 6px 0 10px; font-size: 28px; }
.qr-card-copy p { max-width: 360px; margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.qr-image { width: 240px; aspect-ratio: 1; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.qr-image img { width: 100%; height: 100%; display: block; }
.activity-list { margin: 0; padding: 0; list-style: none; }
.activity-list li { min-height: 64px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #eeeae8; }
.activity-list li:last-child { border-bottom: 0; }
.activity-list li > span { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.activity-list strong { min-width: 40px; color: var(--success); font-size: 20px; }
.activity-list time { color: var(--muted); font-size: 11px; }

.inventory-strip > div:first-child span, .coin-stat span { color: var(--muted); font-size: 11px; }
.inventory-strip h2 { margin: 4px 0 0; font-size: 18px; }
.coin-stat { min-height: 62px; padding-left: 16px; display: grid; align-content: center; gap: 3px; border-left: 1px solid var(--line); }
.coin-stat strong { font-size: 27px; font-variant-numeric: tabular-nums; }
.coin-stat--5 strong { color: var(--success); }
.coin-stat--10 strong { color: var(--blue-house); }
.coin-stat--20 strong { color: var(--burgundy); }

.dashboard-grid { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 22px; }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.panel-heading { min-height: 62px; padding: 14px 18px; }

.house-list { display: grid; }
.house-row { min-height: 66px; padding: 12px 18px; display: grid; grid-template-columns: 24px 12px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid #eeeae8; }
.house-row:last-child { border-bottom: 0; }
.rank-number { color: var(--muted); font-size: 13px; font-weight: 800; }
.house-swatch { width: 10px; height: 36px; border-radius: 3px; }
.house-swatch--red { background: var(--red-house); }
.house-swatch--blue { background: var(--blue-house); }
.house-swatch--purple { background: var(--purple-house); }
.house-row strong { font-size: 14px; }
.house-row > span:last-child { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.empty-state { min-height: 198px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); text-align: center; padding: 24px; }
.empty-state span { width: 52px; height: 52px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; font-size: 20px; }
.empty-state p { margin: 0; font-size: 13px; }
.leader-list { margin: 0; padding: 0; list-style: none; }
.leader-list li { min-height: 50px; padding: 10px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eeeae8; }
.ranking-secondary { margin-top: 14px; }
.winner-row { min-height: 132px; padding: 24px; display: grid; grid-template-columns: 12px minmax(0,1fr) auto; align-items: center; gap: 14px; }
.winner-row em, .house-stat-list em { color: var(--burgundy); font-size: 22px; font-style: normal; font-weight: 800; }
.house-stat-list > div { min-height: 58px; padding: 10px 18px; display: grid; grid-template-columns: 12px minmax(0,1fr) auto auto; align-items: center; gap: 10px; border-bottom: 1px solid #eeeae8; }
.house-stat-list > div:last-child { border-bottom: 0; }
.house-stat-list small { color: var(--muted); }

@media (max-width: 1120px) {
  .login-main { grid-template-columns: 1fr; gap: 28px; align-content: start; padding-top: 44px; }
  .login-intro h1 { font-size: 46px; }
  html:lang(en) .login-intro h1 { font-size: 42px; }
}

@media (max-width: 900px) {
  .login-main { grid-template-columns: 1fr; gap: 28px; align-content: start; padding-top: 44px; }
  .login-intro h1 { font-size: 46px; }
  .workspace { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar nav a { grid-template-columns: 1fr; justify-items: center; padding-inline: 5px; font-size: 0; }
  .sidebar nav a span { font-size: 18px; }
  .sidebar-context { display: none; }
  .inventory-strip { grid-template-columns: 1fr repeat(3, minmax(78px, 0.5fr)); }
  .award-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-picker { grid-column: 1 / -1; }
  .deduction-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operation-row { grid-template-columns: 48px minmax(0, 1fr); }
  .correction-form { grid-column: 1 / -1; }
  .student-grid { grid-template-columns: 1fr; }
  .batch-preview-rows > div { grid-template-columns: minmax(0, 1fr) 70px; }
  .batch-preview-rows small { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .topbar { min-height: 62px; padding: 8px 12px; gap: 8px; }
  .brand { min-width: 0; flex: 1 1 auto; gap: 8px; }
  .brand span { min-width: 0; }
  .brand img { width: 40px; height: 40px; }
  .brand strong { max-width: 140px; font-size: 14px; line-height: 1.08; }
  .brand small, .identity-chip span:not(.identity-avatar) { display: none; }
  .topbar--authenticated .brand { flex: 0 0 auto; }
  .topbar--authenticated .brand span { display: none; }
  .topbar--authenticated .identity-chip { flex: 0 0 34px; }
  .topbar--authenticated .icon-command { width: 34px; }
  .topbar--authenticated .sign-out-command { min-height: 34px; padding-inline: 8px; font-size: 11px; }
  .install-app-command { width: 34px; height: 34px; min-height: 34px; padding: 0; justify-content: center; }
  .install-app-command strong { display: none; }
  .topbar-actions { flex: 0 0 auto; gap: 6px; }
  .mobile-back-command { display: grid; }
  .locale-switch { width: 76px; min-width: 76px; height: 34px; padding: 2px; }
  .locale-switch button { padding: 0; font-size: 11px; }
  .login-main { width: min(100% - 28px, 540px); min-height: calc(100vh - 62px); padding: 32px 0 56px; }
  .login-intro { padding: 0; }
  .login-intro h1 { margin-top: 0; font-size: 34px; line-height: 1.05; white-space: nowrap; overflow-wrap: normal; }
  .environment-badge + h1 { margin-top: 18px; }
  html:lang(en) .login-intro h1 { font-size: 27px; }
  .login-intro p { font-size: 15px; }
  .status-line { margin-top: 24px; }
  .role-option { grid-template-columns: 40px minmax(0, 1fr) 36px; padding-inline: 12px; }
  .house-onboarding { width: min(100% - 28px, 540px); padding: 40px 0 64px; }
  .house-onboarding__intro h1 { font-size: 34px; }
  .house-choice-grid { grid-template-columns: 1fr; gap: 10px; }
  .house-choice { min-height: 112px; }
  .section-heading > small { max-width: 92px; line-height: 1.3; text-align: right; }
  .workspace { display: block; padding-bottom: 62px; }
  .sidebar { position: fixed; z-index: 15; inset: auto 0 0; height: 62px; padding: 5px max(8px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border: 0; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.97); overflow: visible; }
  .sidebar nav { grid-template-columns: repeat(5, minmax(0, 1fr)); height: 100%; gap: 2px; }
  .sidebar nav a { min-height: 46px; }
  .sidebar nav a:nth-child(n+6) { display: none; }
  .dashboard-main { padding: 24px 14px 38px; }
  .dashboard-heading { align-items: start; }
  .dashboard-heading h1 { font-size: 25px; }
  .date-range { display: none; }
  .inventory-strip { padding: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
  .inventory-strip > div:first-child { grid-column: 1 / -1; margin-bottom: 14px; }
  .coin-stat { min-height: 58px; padding: 0 8px; text-align: center; }
  .coin-stat:nth-child(2) { border-left: 0; }
  .coin-stat strong { font-size: 23px; }
  .coin-stat span { min-height: 28px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
  .award-form { grid-template-columns: 1fr; }
  .student-picker { grid-column: auto; }
  .student-picker__heading { align-items: stretch; flex-direction: column; }
  .scanner-panel { grid-template-columns: 1fr; }
  .deduction-form { grid-template-columns: 1fr; }
  .deduction-confirm { grid-column: auto; }
  .danger-command { width: 100%; }
  .operation-row { grid-template-columns: 44px minmax(0, 1fr); padding-inline: 12px; }
  .correction-form { grid-template-columns: 1fr; }
  .student-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-summary > div:nth-child(2) { border-right: 0; }
  .student-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .management-workbench .panel-heading { align-items: stretch; flex-direction: column; }
  .management-filter, .management-filter--logs { grid-template-columns: 1fr; }
  .management-list article { grid-template-columns: 1fr; }
  .management-list article > span { text-align: left; }
  .management-list article > small { grid-column: auto; }
  .backup-create, .backup-list article { align-items: stretch; flex-direction: column; }
  .primary-command { width: 100%; }
  .batch-form { grid-template-columns: 1fr; }
  .batch-guide { grid-template-columns: 1fr; }
  .batch-guide pre { grid-row: auto; }
  .quota-recipient-list { grid-template-columns: 1fr; }
  .quota-recipient-list label:nth-child(odd) { border-right: 0; }
  .quota-number-grid { grid-template-columns: 1fr; }
  .quota-submit-actions { display: grid; grid-template-columns: 1fr; }
  .quota-submit-actions button { width: 100%; white-space: normal; }
  .semester-form { grid-template-columns: 1fr; }
  .temporary-quota-row { align-items: stretch; flex-direction: column; }
  .batch-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-summary span:last-child { grid-column: 1 / -1; }
  .duplicate-warning { align-items: stretch; flex-direction: column; }
  .duplicate-warning > div:last-child { justify-content: flex-end; }
  .qr-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .qr-card-copy { display: grid; justify-items: center; }
  .qr-image { width: min(240px, 100%); }
  .app-dialog__body { padding: 22px 18px; grid-template-columns: 42px minmax(0, 1fr); }
  .app-dialog__mark { width: 42px; height: 42px; }
  .app-dialog__actions { display: grid; grid-template-columns: 1fr; }
  .app-dialog__actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
