:root {
  color: #263238;
  background: #f7fbf4;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7fbf4 0%, #eef8fb 54%, #fff7e7 100%);
}

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

input,
textarea {
  min-width: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 2.5vw, 28px) 34px;
}

.login-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px clamp(14px, 2.5vw, 28px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(310px, 0.75fr);
  align-items: center;
  gap: 18px;
}

.login-hero {
  min-height: 520px;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr);
  gap: 16px;
}

.login-copy {
  display: grid;
  align-content: end;
  justify-items: start;
  gap: 8px;
}

.login-copy h1 {
  font-size: 34px;
}

.login-copy p:last-child {
  max-width: 430px;
  color: #5c7072;
  font-size: 15px;
  line-height: 1.65;
}

.login-art {
  overflow: hidden;
  border-radius: 8px;
  background: #e9f8f6;
  box-shadow:
    0 16px 38px rgba(73, 106, 107, 0.13),
    inset 0 0 0 1px rgba(77, 91, 98, 0.08);
}

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

.login-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 16px 38px rgba(73, 106, 107, 0.14),
    inset 0 0 0 1px rgba(77, 91, 98, 0.08);
}

.login-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-title h2 {
  font-size: 18px;
}

.login-panel input {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #31484b;
  background: #f5fbf8;
  box-shadow: inset 0 0 0 1px rgba(75, 99, 101, 0.14);
}

.login-error {
  padding: 10px 12px;
  border-radius: 8px;
  color: #9b3d31;
  background: #fff0e8;
  font-size: 13px;
  font-weight: 800;
}

.topbar {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-mark,
.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.brand-mark {
  background: #ffca7a;
  color: #6b3d18;
  box-shadow: 0 10px 24px rgba(232, 153, 61, 0.2);
}

.icon-button {
  border: 0;
  background: rgba(255, 255, 255, 0.88);
  color: #466168;
  box-shadow: inset 0 0 0 1px rgba(86, 105, 112, 0.14);
}

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

.user-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border-radius: 999px;
  color: #42656a;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 0 0 1px rgba(86, 105, 112, 0.12);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 3px;
  color: #5f7f83;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #263238;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-strip {
  position: relative;
  min-height: 232px;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(260px, 1.05fr);
  gap: 18px;
  align-items: stretch;
  padding: 18px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow:
    0 16px 38px rgba(73, 106, 107, 0.14),
    inset 0 0 0 1px rgba(77, 91, 98, 0.08);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0;
}

.hero-copy span {
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  background: #e4f7ee;
  color: #317069;
  font-size: 12px;
  font-weight: 800;
}

.hero-copy strong {
  margin-top: 12px;
  color: #2e4448;
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 440px;
  margin-top: 10px;
  color: #5c7072;
  font-size: 15px;
  line-height: 1.65;
}

.hero-art {
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #e9f8f6;
}

.hero-art img {
  width: 100%;
  height: 100%;
  min-height: 196px;
  display: block;
  object-fit: cover;
}

.tab-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.tab-grid button {
  min-height: 62px;
  border: 0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #657d80;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 0 0 1px rgba(77, 91, 98, 0.1);
}

.tab-grid button.active {
  color: #26454a;
  background: #bfeadf;
  box-shadow: 0 10px 24px rgba(75, 146, 139, 0.18);
}

.tab-grid span {
  font-size: 13px;
  font-weight: 800;
}

.content-zone {
  min-height: 420px;
}

.view-stack {
  display: grid;
  gap: 15px;
}

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

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

.metric-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 8px;
  padding: 15px;
  color: #2d3c3f;
  box-shadow: 0 10px 24px rgba(83, 103, 107, 0.1);
}

.health-card {
  min-height: 96px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 10px 24px rgba(83, 103, 107, 0.1),
    inset 0 0 0 1px rgba(77, 91, 98, 0.08);
}

.health-card span {
  color: #5b7274;
  font-size: 13px;
  font-weight: 900;
}

.health-card b {
  font-size: 26px;
  color: #2d4b4f;
}

.health-card.ok svg {
  color: #2f8b77;
}

.health-card.warn svg,
.health-card.warn b {
  color: #b97913;
}

.health-card.bad svg,
.health-card.bad b {
  color: #b94a3a;
}

.metric-card span {
  color: rgba(40, 57, 61, 0.72);
  font-size: 13px;
  font-weight: 800;
}

.metric-card b {
  font-size: 30px;
  line-height: 1;
}

.mint {
  background: #d9f5d8;
}

.sky {
  background: #d5ecff;
}

.peach {
  background: #ffe1bd;
}

.pink {
  background: #ffdce8;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.section-title div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.section-title h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-title span {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: #537274;
  background: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
}

.record-list,
.device-list,
.student-grid,
.notification-list {
  display: grid;
  gap: 11px;
}

.record-card,
.device-card,
.student-card,
.student-editor,
.notification-card,
.soft-panel,
.sim-panel,
.settings-panel,
.event-card {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 10px 24px rgba(83, 103, 107, 0.1),
    inset 0 0 0 1px rgba(77, 91, 98, 0.08);
}

.record-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.record-body {
  min-width: 0;
}

.record-body div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-body b,
.device-card b,
.student-card b,
.notification-card b,
.event-card b {
  color: #263238;
  font-size: 15px;
}

.record-body span,
.device-card span,
.student-card span,
.notification-card span,
.event-card span {
  color: #6b8182;
  font-size: 13px;
}

.record-body p {
  margin-top: 5px;
  color: #7a8b8b;
  font-size: 13px;
  line-height: 1.35;
}

.record-pill {
  min-width: 74px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 999px;
  background: #e7f7ef;
  color: #34786f;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.record-card.left .record-pill {
  background: #e8f2ff;
  color: #426aa2;
}

.record-card.low_quality .record-pill,
.record-card.unknown .record-pill {
  background: #fff0d5;
  color: #a46b21;
}

.avatar {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  background: #f7e3c1;
}

.avatar.generated {
  display: grid;
  place-items: center;
  background: hsl(var(--hue), 72%, 86%);
  color: hsl(var(--hue), 52%, 32%);
  font-weight: 900;
  font-size: 20px;
}

.soft-panel,
.sim-panel,
.settings-panel {
  padding: 14px;
}

.status-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.status-row + .status-row {
  border-top: 1px dashed rgba(94, 119, 121, 0.18);
}

.status-row span {
  color: #5b7274;
  font-size: 14px;
  font-weight: 800;
}

.status-row b {
  color: #2d4b4f;
  font-size: 13px;
  text-align: right;
  overflow-wrap: anywhere;
}

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

.event-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.event-score {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff0c7;
  color: #8a5b1e;
  font-weight: 900;
}

.event-card div:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.event-card small {
  color: #a46b21;
  font-size: 12px;
  font-weight: 800;
}

.sim-panel {
  display: grid;
  gap: 14px;
}

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

.settings-panel .primary-button {
  grid-column: 1 / -1;
}

.student-editor {
  display: grid;
  gap: 14px;
  padding: 14px;
}

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

.editor-title div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #2d4b4f;
}

.student-editor-body {
  display: grid;
  grid-template-columns: minmax(176px, 0.34fr) minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.face-photo-field {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.face-photo-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #2d4b4f;
  font-size: 13px;
  font-weight: 900;
}

.face-photo-button {
  width: 100%;
  aspect-ratio: 4 / 5;
  min-height: 220px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  color: #45666a;
  background: #f4fbf8;
  box-shadow:
    inset 0 0 0 1px rgba(75, 99, 101, 0.14),
    0 10px 24px rgba(83, 103, 107, 0.08);
}

.face-photo-button.empty {
  border: 1px dashed rgba(73, 116, 113, 0.42);
  background:
    linear-gradient(180deg, rgba(245, 253, 248, 0.96), rgba(237, 249, 248, 0.96));
}

.face-photo-button.has-photo {
  background: #eef7f4;
}

.face-photo-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.face-photo-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
}

.face-photo-empty svg {
  color: #70aaa0;
}

.face-photo-empty b {
  color: #31585d;
  font-size: 15px;
  line-height: 1.25;
}

.face-photo-empty small {
  color: #7b9294;
  font-size: 12px;
  font-weight: 800;
}

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

.photo-error {
  color: #9b3d31;
  font-size: 12px;
  font-weight: 900;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.avatar-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f0fbf5;
}

.avatar-preview div:last-child {
  display: grid;
  gap: 3px;
}

label {
  display: grid;
  gap: 8px;
  color: #4d6567;
  font-size: 13px;
  font-weight: 900;
}

select,
input[type="range"],
input[type="number"],
input:not([type]),
textarea {
  width: 100%;
}

select,
input[type="number"],
input:not([type]),
textarea {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #31484b;
  background: #f5fbf8;
  box-shadow: inset 0 0 0 1px rgba(75, 99, 101, 0.14);
}

textarea {
  min-height: 82px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

input[type="range"] {
  accent-color: #75bfb0;
}

.label-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.toggle-row {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #fff7df;
}

.primary-button,
.mini-button,
.text-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
}

.primary-button {
  min-height: 50px;
  border-radius: 8px;
  color: #243f43;
  background: #ffd36d;
  box-shadow: 0 10px 24px rgba(205, 146, 55, 0.18);
}

.primary-button:disabled,
.mini-button:disabled {
  opacity: 0.68;
}

.device-card,
.student-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.student-card.muted {
  opacity: 0.64;
}

.device-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #35575b;
}

.device-icon.entry {
  background: #d9f5d8;
}

.device-icon.exit {
  background: #dcecff;
}

.device-card div:nth-child(2),
.student-card div:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.device-card small,
.student-card small {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #879999;
  font-size: 12px;
}

.student-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.device-card em {
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.device-card em.online {
  color: #247263;
  background: #dff7ed;
}

.device-card em.maintenance {
  color: #9b6a16;
  background: #fff0c8;
}

.mini-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: #335b60;
  background: #d8f1eb;
}

.mini-button.danger {
  color: #7a3b31;
  background: #ffe2d8;
}

.text-button {
  min-height: 34px;
  padding: 0;
  color: #4d7577;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

.notification-card {
  display: grid;
  gap: 5px;
  padding: 13px;
}

.notification-card em {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  color: #4f766f;
  background: #e8f8f0;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.empty-state {
  min-height: 76px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #6b8182;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(77, 91, 98, 0.08);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  padding: 16px;
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .login-shell {
    min-height: 0;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .login-hero {
    min-height: 0;
  }

  .login-copy h1 {
    font-size: 28px;
  }

  .login-art img {
    aspect-ratio: 16 / 9;
    min-height: 0;
  }

  .app-shell {
    padding-bottom: 22px;
  }

  h1 {
    font-size: 24px;
  }

  .hero-strip {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 14px;
  }

  .hero-copy strong {
    font-size: 30px;
  }

  .hero-art img {
    aspect-ratio: 16 / 9;
    min-height: 0;
  }

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

  .metric-grid,
  .health-grid,
  .event-grid,
  .settings-panel,
  .student-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .face-photo-button {
    width: min(100%, 260px);
    min-height: 0;
    justify-self: center;
  }

  .face-photo-actions {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .topbar {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .brand-mark,
  .icon-button {
    width: 40px;
    height: 40px;
  }

  h1 {
    font-size: 22px;
  }

  .hero-copy strong {
    font-size: 28px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .health-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card {
    min-height: 104px;
  }

  .metric-card b {
    font-size: 26px;
  }

  .record-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .device-card,
  .student-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .record-pill {
    grid-column: 2;
    width: fit-content;
    min-width: 0;
  }

  .record-body div {
    display: grid;
    gap: 3px;
  }

  .status-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .status-row b {
    grid-column: 2;
    text-align: left;
  }

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

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

  .face-photo-button {
    width: min(100%, 220px);
  }

  .device-card em,
  .student-actions {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
