:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #101828;
  --muted: #667085;
  --blue: #2563eb;
  --red: #ef4444;
  --green: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 18px;
}

.tab {
  border: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 56px;
  padding: 8px 4px;
  color: #475467;
  cursor: pointer;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  word-break: keep-all;
}

.tab.active {
  background: #eff6ff;
  color: var(--blue);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.tab:focus {
  outline: none;
}

.tab:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: -2px;
}

.day-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}

.day-tab {
  min-width: 52px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #475467;
  padding: 10px 12px;
}

.day-tab.active {
  color: var(--blue);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.attendance-panel {
  padding-top: 6px;
}

.day-panel {
  display: none;
  min-height: 260px;
  padding-top: 14px;
}

.day-panel.active {
  display: block;
}

.panel-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
  text-align: left;
}

th {
  color: #344054;
  font-weight: 700;
}

.student-col {
  width: 190px;
}

.action-col {
  width: 90px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

input[type="checkbox"] {
  width: auto;
}

label {
  display: block;
  font-weight: 700;
  margin: 16px 0 8px;
}

textarea {
  min-height: 160px;
  resize: vertical;
}

button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.danger {
  border-color: #fecaca;
  color: var(--red);
}

button.add {
  margin-top: 8px;
}

.guardian-list {
  display: grid;
  gap: 8px;
}

.weekday-checks {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.weekday-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 4px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
  cursor: pointer;
}

.student-day-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.student-day-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-day-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  background: #f8fafc;
}

.student-day-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.student-day-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-action {
  flex: 0 0 auto;
  padding: 12px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.student-day-info span,
.empty-day {
  color: var(--muted);
}

.student-day-info span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.empty-day {
  padding: 14px 0;
}

.guardian-item {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(320px, 1fr) auto;
  gap: 8px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
}

pre {
  min-height: 260px;
  margin: 14px 0 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: #344054;
}

.status {
  margin: 14px 0;
  color: var(--muted);
  font-weight: 700;
}

.logs {
  display: grid;
  gap: 8px;
}

.log {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #f8fafc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.log.error {
  border-color: #fecaca;
  color: var(--red);
}

.log.success {
  border-color: #bbf7d0;
  color: var(--green);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(15 23 42 / 32%);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(320px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 18px 40px rgb(15 23 42 / 18%);
  text-align: center;
}

.modal p {
  font-weight: 700;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

@media (max-width: 860px) {
  .app {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .grid {
    display: block;
  }

  .grid .panel + .panel {
    margin-top: 16px;
  }

}
