:root {
  --bg: #f2f6f4;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --text: #18231f;
  --muted: #718078;
  --border: #dde7e1;
  --primary: #176bd6;
  --primary-soft: #eaf2ff;
  --green: #169d63;
  --green-dark: #087548;
  --green-soft: #e7f7ef;
  --orange: #e57326;
  --orange-soft: #fff0e5;
  --red: #d94d4d;
  --red-soft: #ffeded;
  --purple: #7658db;
  --purple-soft: #f0edff;
  --shadow: 0 12px 35px rgba(21, 48, 37, 0.08);
  --shadow-small: 0 5px 18px rgba(21, 48, 37, 0.06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1512;
  --surface: #16211d;
  --surface-2: #111a17;
  --text: #eff7f3;
  --muted: #8b9a93;
  --border: #2b3b34;
  --primary: #64a1ff;
  --primary-soft: rgba(49, 116, 219, 0.17);
  --green: #48cb8d;
  --green-dark: #75dfaa;
  --green-soft: rgba(33, 173, 105, 0.16);
  --orange: #ff9857;
  --orange-soft: rgba(229, 115, 38, 0.16);
  --red: #ff7777;
  --red-soft: rgba(217, 77, 77, 0.16);
  --purple: #ad99ff;
  --purple-soft: rgba(118, 88, 219, 0.18);
  --shadow: 0 16px 45px rgba(0, 0, 0, 0.3);
  --shadow-small: 0 6px 20px rgba(0, 0, 0, 0.18);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(23, 107, 214, 0.3);
  outline-offset: 2px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
  transition: 0.16s ease;
}

.icon-button:hover {
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-small);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: var(--surface-2);
}

input,
select {
  min-height: 45px;
  padding: 0 12px;
}

textarea {
  min-height: 100px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 214, 0.12);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 44px;
}

.password-wrap button {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 730;
  transition: 0.16s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, #176bd6, #247ee8);
  box-shadow: 0 8px 20px rgba(23, 107, 214, 0.2);
}

.button-secondary {
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
}

.button-success {
  color: white;
  background: var(--green);
}

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

.button-small {
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 10px;
}

.button-full {
  width: 100%;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 235px minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: 235px;
  flex-direction: column;
  padding: 20px 15px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar .brand {
  width: 100%;
  max-width: 205px;
  align-self: center;
}

.profile-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 21px 0 18px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
}

.avatar {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 10px;
  font-weight: 800;
}

.profile-box div {
  min-width: 0;
}

.profile-box strong,
.profile-box small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-box strong {
  font-size: 11px;
}

.profile-box small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.side-nav {
  display: grid;
  gap: 5px;
}

.side-nav button {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}

.side-nav button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.side-nav button.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.side-nav .nav-icon {
  width: 22px;
  font-size: 15px;
  text-align: center;
}

.logout-button {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
}

.logout-button:hover {
  color: var(--red);
  background: var(--red-soft);
}

.main-wrap {
  min-width: 0;
  grid-column: 2;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  padding: 0 27px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px);
}

:root[data-theme="dark"] .topbar {
  background: rgba(22, 33, 29, 0.9);
}

.topbar-school {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

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

.content {
  width: 100%;
  max-width: 1450px;
  margin: 0 auto;
  padding: 29px 31px 48px;
}

.page-stack {
  display: grid;
  gap: 20px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.page-heading .overline {
  display: block;
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-heading h1,
.page-heading p {
  margin: 0;
}

.page-heading h1 {
  font-size: clamp(25px, 2.6vw, 34px);
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.page-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.card {
  padding: 21px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 750;
}

.pill-blue {
  color: var(--primary);
  background: var(--primary-soft);
}

.pill-green {
  color: var(--green-dark);
  background: var(--green-soft);
}

.pill-orange {
  color: var(--orange);
  background: var(--orange-soft);
}

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

.stat-card {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.stat-icon {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  font-size: 17px;
}

.stat-icon.blue { background: var(--primary-soft); }

.stat-icon.green { background: var(--green-soft); }

.stat-icon.orange { background: var(--orange-soft); }

.stat-icon.purple { background: var(--purple-soft); }

.stat-card span:not(.stat-icon),
.stat-card strong,
.stat-card small {
  display: block;
}

.stat-card span:not(.stat-icon) {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card strong {
  margin: 3px 0 2px;
  font-size: 23px;
  letter-spacing: -0.04em;
}

.stat-card small {
  color: var(--muted);
  font-size: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2,
.section-head p {
  margin: 0;
}

.section-head h2 {
  font-size: 15px;
  letter-spacing: -0.02em;
}

.section-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.progress {
  overflow: hidden;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #4bd79a);
}

.history-row,
.person-row,
.document-row,
.checkin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 2px;
  border-top: 1px solid var(--border);
}

.row-icon {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
}

.row-icon.green { color: var(--green-dark); background: var(--green-soft); }

.row-icon.orange { color: var(--orange); background: var(--orange-soft); }

.row-icon.blue { color: var(--primary); background: var(--primary-soft); }

.row-main {
  min-width: 0;
  flex: 1;
}

.row-main strong,
.row-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main strong {
  font-size: 10px;
}

.row-main small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 730;
  white-space: nowrap;
}

.badge-green { color: var(--green-dark); background: var(--green-soft); }

.badge-orange { color: var(--orange); background: var(--orange-soft); }

.badge-gray { color: var(--muted); background: var(--surface-2); }

.badge-blue { color: var(--primary); background: var(--primary-soft); }

.empty-state {
  display: grid;
  justify-items: center;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state span {
  font-size: 30px;
}

.empty-state strong {
  margin-top: 9px;
  color: var(--text);
  font-size: 11px;
}

.empty-state p {
  margin: 4px 0 0;
  font-size: 9px;
}

.local-box {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid rgba(23, 107, 214, 0.22);
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
}

.local-box strong {
  display: block;
  font-size: 10px;
}

.local-box p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-row input {
  flex: 1;
}

.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 12, 9, 0.67);
  backdrop-filter: blur(5px);
}

.modal {
  position: relative;
  z-index: 1;
  width: min(510px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease-out;
}

.modal.wide {
  width: min(820px, 100%);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 19px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 19px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 17px;
}

.file-box {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 21px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  text-align: center;
}

.file-box span {
  font-size: 25px;
}

.file-box strong {
  margin-top: 5px;
  color: var(--text);
  font-size: 10px;
}

.file-box small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.file-box input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  display: flex;
  max-width: min(390px, calc(100% - 40px));
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid rgba(22, 157, 99, 0.28);
  border-radius: 12px;
  color: var(--green-dark);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 10px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav,
.mobile-menu-button,
.sidebar-overlay {
  display: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}
