:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f7f5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
}

.student-page {
  background:
    linear-gradient(135deg, rgba(18, 122, 95, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(34, 98, 167, 0.12), transparent 40%),
    #f4f7f5;
}

.check-shell,
.login-shell,
.admin-shell {
  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.check-shell,
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.panel,
.records-section,
.qr-card {
  background: #ffffff;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(31, 50, 44, 0.08);
}

.panel {
  width: min(520px, 100%);
  padding: 28px;
}

.status-line {
  margin: 0 0 8px;
  color: #2f6f5c;
  font-size: 14px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

label,
.signature-block {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cddbd3;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  background: #ffffff;
}

input:focus,
canvas:focus {
  outline: 3px solid rgba(47, 111, 92, 0.2);
  border-color: #2f6f5c;
}

.signature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.period-choice {
  display: grid;
  gap: 4px;
  min-height: 84px;
  border: 1px solid #cddbd3;
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  text-align: left;
}

.period-choice strong {
  font-size: 18px;
}

.period-choice span,
.period-choice em {
  font-style: normal;
  color: #44545d;
  font-weight: 700;
}

.period-choice.selected {
  border-color: #176f54;
  box-shadow: 0 0 0 3px rgba(23, 111, 84, 0.16);
}

.period-choice.closed {
  opacity: 0.55;
}

.signature-header button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cddbd3;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  height: 38px;
  padding: 0 12px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

canvas {
  width: 100%;
  aspect-ratio: 640 / 260;
  border: 1px solid #cddbd3;
  border-radius: 6px;
  background: #ffffff;
  touch-action: none;
}

.primary {
  min-height: 50px;
  border: 0;
  border-radius: 6px;
  background: #176f54;
  color: white;
  font: inherit;
  font-weight: 800;
}

.primary:disabled {
  opacity: 0.55;
}

.message {
  min-height: 24px;
  margin-top: 18px;
  line-height: 1.5;
  font-weight: 700;
}

.message.error {
  color: #b42318;
}

.message.success {
  color: #176f54;
}

.admin-header,
.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.qr-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.period-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  min-height: 30px;
  margin-top: 10px;
  border-radius: 6px;
  font-weight: 800;
}

.period-state.on {
  background: #e5f5ed;
  color: #176f54;
}

.period-state.off {
  background: #ffe8e5;
  color: #b42318;
}

.qr-card img {
  width: min(100%, 280px);
  justify-self: center;
  image-rendering: crisp-edges;
}

.records-section,
.settings-section {
  margin-top: 20px;
  padding: 20px;
  background: #ffffff;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(31, 50, 44, 0.08);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr)) minmax(130px, 160px) minmax(170px, 220px);
  gap: 12px;
  margin-top: 16px;
  align-items: stretch;
}

.period-toggle-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #cddbd3;
  border-radius: 6px;
  padding: 0 12px;
  background: #f8fbf9;
  font-weight: 800;
  width: 100%;
}

.toggle-button {
  width: 68px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 900;
  color: #ffffff;
}

.toggle-button.on {
  background: #176f54;
}

.toggle-button.off {
  background: #b42318;
}

.quick-button,
.danger-lite {
  min-height: 46px;
}

.quick-button {
  width: 100%;
}

.stacked-actions {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.stacked-actions .quick-button {
  height: 100%;
}

.settings-save {
  width: 100%;
}

.settings-grid .settings-save {
  grid-column: auto;
}

.danger-lite {
  color: #b42318;
  border-color: #efc7c2;
}

.success-text {
  color: #176f54;
  font-weight: 700;
}

.error-text {
  color: #b42318;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

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

.records-actions .danger-lite {
  min-height: 38px;
  padding: 0 14px;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #e5ece8;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #44545d;
  font-size: 14px;
}

.flag {
  display: inline-block;
  max-width: 300px;
  white-space: normal;
  color: #b42318;
  font-weight: 700;
}

@media (max-width: 720px) {
  .check-shell,
  .login-shell,
  .admin-shell {
    width: min(100vw - 20px, 920px);
    padding: 16px 0;
  }

  .panel,
  .records-section,
  .qr-card {
    padding: 18px;
  }

  h1 {
    font-size: 25px;
  }

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

  .period-list {
    grid-template-columns: 1fr;
  }

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

  .settings-grid .settings-save {
    grid-column: auto;
  }

  .records-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .records-actions {
    width: 100%;
    justify-content: space-between;
  }
}
