:root {
  --bg-1: #f3f7f6;
  --bg-2: #e9eef0;
  --ink: #1f2a2e;
  --muted: #5c6b73;
  --brand: #1f7a6b;
  --brand-2: #c47a3a;
  --card: #ffffff;
  --line: #d8e0e5;
  --shadow: 0 16px 50px rgba(16, 24, 40, 0.12);
}

html.dark {
  --bg-1: #0f1416;
  --bg-2: #151c1f;
  --ink: #e6eef0;
  --muted: #a9b5bb;
  --brand: #2aa693;
  --brand-2: #d08a4a;
  --card: #1a2326;
  --line: #2a3439;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 500;
  margin: 0;
  padding: 32px 18px 48px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9efe8 0%, transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, #f3e5d6 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  color: var(--ink);
  transition: background 1s ease, color 1s ease;
}

body,
.container,
.login-box,
input,
select,
button,
table,
th,
td,
.loading-screen,
.loading-card,
.app-header {
  transition: background 1s ease, color 1s ease, border-color 1s ease, box-shadow 1s ease;
}

html.dark body {
  background:
    radial-gradient(1200px 600px at 10% -10%, #14332e 0%, transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, #2a1f12 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.app-header {
  max-width: 920px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.app-logo {
  height: 100px;
  width: auto;
  transition: opacity 0.6s ease;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 32px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #e7eaee;
  border-radius: 999px;
  transition: background 0.25s ease;
  box-shadow: inset 0 2px 6px rgba(16, 24, 40, 0.15);
}

.theme-slider:before {
  content: "";
  position: absolute;
  height: 28px;
  width: 28px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.18);
}

.theme-slider:after {
  content: "☀";
  position: absolute;
  left: 6px;
  top: 5px;
  font-size: 16px;
  color: #e58a00;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s ease, color 0.25s ease;
}

.theme-switch input:checked + .theme-slider:after {
  content: "☾";
  left: 40px;
  color: #5f74ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.theme-switch input:checked + .theme-slider {
  background: #58607a;
}

.theme-switch input:checked + .theme-slider:before {
  transform: translateX(32px);
}

h1 {
  text-align: center;
  color: var(--brand);
  font-size: 28px;
  letter-spacing: 0.2px;
  margin: 8px 0 12px;
}

.container {
  margin: 0 auto;
  background: var(--card);
  padding: 24px 22px 26px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  max-width: 920px;
}

input,
select,
button {
  padding: 8px;
  margin: 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
  font-family: inherit;
}

button {
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  transition: transform 0.08s ease, background 0.2s ease;
}

button:hover {
  background: #17685b;
}

button:active {
  transform: translateY(1px);
}

#monthSelector {
  width: 150px;
  cursor: pointer;
  background: #f7fbfa;
}

#appSection {
  display: none;
  width: 80%;
  margin: 0 auto;
  animation: fadeIn 0.35s ease;
}

#loginSection {
  display: none;
}

#logoutBtn {
  float: right;
  background: #7a1f1f;
}

#logoutBtn:hover {
  background: #661919;
}

.logout-row {
  margin-top: 16px;
  text-align: center;
}

#logoutBtnBottom {
  background: #7a1f1f;
}

#logoutBtnBottom:hover {
  background: #661919;
}

/* Show bottom logout only on mobile */
@media (min-width: 641px) {
  .logout-row {
    display: none;
  }
}

@media (max-width: 640px) {
  #loginSection {
    display: block;
    margin-top: 35%;
  }

  .login-box {
    margin: 10vh auto 0;

  }

  #logoutBtn {
    display: none;
  }
}

.credit-line {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 16px 0 0;
  padding: 8px 0;
  background: linear-gradient(90deg, transparent 0%, rgba(3, 142, 117, 0.12) 50%, transparent 100%);
}

.credit-brand {
  font-weight: 700;
}

.credit-logo {
  height: 20px;
  width: auto;
  vertical-align: middle;
  margin: 0 6px;
}

.app-footer {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
  text-align: left;
}

.footer-row {
  position: relative;
  margin-top: 8px;
  width: 80%;
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

.footer-row .credit-line {
  margin: 0;
  padding: 6px 0;
  text-align: center;
  background: none;
}

.footer-row .app-footer {
  margin: 0;
  text-align: left;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* On login page, stack footer items vertically */
#loginSection ~ .footer-row {
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

#loginSection ~ .footer-row .app-footer {
  position: static;
  text-align: center;
  margin-top: 6px;
}

.loading-screen {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg-1) 90%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.2s ease-in, visibility 0.2s ease-in;
}

.loading-screen.hide {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.loading-card {
  background: var(--card);
  padding: 20px 24px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loading-logo {
  height: 80px;
  width: auto;
}

.loading-text {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.student-field {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  gap: 10px;
}

.student-field input[type="text"] {
  flex: 2;
}

.student-field input[type="number"] {
  width: 80px;
}

.report {
  margin-top: 20px;
}

.reading-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.room-nav {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.export-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 10px;
}

th,
td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}

th {
  background: #f3f7f5;
  color: var(--ink);
}

.login-box {
  width: min(380px, 92%);
  margin: 0 auto;
  padding: 28px 26px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.login-box::after {
  content: "";
  display: block;
  clear: both;
}


.login-box h2 {
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 5px;
  font-weight: 600;
}

.form-group input {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.password-wrapper {
  position: relative;
}

.password-wrapper span {
  position: absolute;
  right: 10px;
  top: calc(50% + 13px);
  transform: translateY(-50%);
  cursor: pointer;
  user-select: none;
}

.login-box button {
  padding: 8px 20px;
  cursor: pointer;
  margin-top: 10px;
  background: #1f7a3a;
  float: right;
}

.login-box button:hover {
  background: #1a6630;
}

.error-msg {
  color: #c0392b;
  margin-top: 10px;
  min-height: 20px;
}

select {
  background: #f7fbfa;
}

input:focus,
select:focus {
  outline: none;
  border-color: #9bcac1;
  box-shadow: 0 0 0 3px rgba(31, 122, 107, 0.12);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  #appSection {
    width: 100%;
  }

  .container {
    padding: 20px 16px 22px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 20px 12px 36px;
  }

  h1 {
    font-size: 22px;
  }

  .app-logo {
    height: 72px;
  }

  .container {
    border-radius: 12px;
  }

  .reading-row {
    flex-direction: column;
    gap: 12px;
  }

  .student-field {
    flex-wrap: nowrap;
    align-items: center;
  }

  .student-field input[type="number"] {
    width: 70px;
  }

  .student-field input[type="checkbox"] {
    width: auto;
  }

  .student-field label {
    margin-left: 2px;
  }

  button,
  input,
  select {
    width: 100%;
    margin: 6px 0;
  }

  .room-nav {
    display: flex;
    gap: 6px;
    width: 100%;
    flex-wrap: nowrap;
  }

  .room-nav button {
    width: auto;
    flex: 1 1 0;
  }

  .export-row {
    display: flex;
    gap: 6px;
    width: 100%;
    flex-wrap: nowrap;
  }

  .export-row button {
    width: auto;
    flex: 1 1 0;
  }

  #logoutBtn {
    float: none;
    width: 100%;
  }

  .app-header {
    justify-content: center;
  }

  table {
    font-size: 12px;
  }

  #loginSection {
    display: block;
    margin-top: 35%;
  }

  .footer-row {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .footer-row .app-footer {
    position: static;
    text-align: center;
    margin-top: 10px;
  }
}
