:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1f4f82;
  --primary-dark: #173c63;
  --success: #13795b;
  --warning: #a16207;
  --danger: #b42318;
  --followup: #b45309;
  --shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 0.4rem; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
h2 { font-size: 1.15rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-weight: 800;
  color: var(--text);
  font-size: 1.05rem;
}

.school-name {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.9rem;
}

.nav-actions form { margin: 0; }

.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
}

.narrow-page { width: min(740px, calc(100% - 2rem)); }

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.muted { color: var(--muted); margin: 0; }
.help-text { color: var(--muted); font-size: 0.85rem; margin-top: 1rem; }

.panel, .stat-card, .login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.panel { padding: 1.1rem; margin-bottom: 1rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.stat-card {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-number { font-size: 1.8rem; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat-card.success .stat-number { color: var(--success); }
.stat-card.warning .stat-number { color: var(--warning); }

.primary-button, .secondary-button, .danger-button {
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 42px;
}

.primary-button { background: var(--primary); color: white; }
.primary-button:hover { background: var(--primary-dark); text-decoration: none; }
.secondary-button { background: #eef2f7; color: var(--text); border: 1px solid var(--border); }
.secondary-button:hover { text-decoration: none; background: #e5eaf2; }
.danger-button { background: #fee4e2; color: var(--danger); border: 1px solid #fecdca; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
}
.plain-link { align-self: center; }

.filters {
  display: grid;
  grid-template-columns: 1fr 220px auto auto;
  align-items: end;
  gap: 0.8rem;
}

.stacked-form, .task-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.9rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: white;
}

textarea { resize: vertical; }

.button-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td { border-bottom: none; }
.teacher-link { font-weight: 800; color: var(--primary); }

.status-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.status-icon.complete { background: #dcfce7; color: var(--success); }
.status-icon.pending { background: #fef3c7; color: var(--warning); }
.status-icon.followup { background: #ffedd5; color: var(--followup); }
.status-icon.not-started { background: #eef2f7; color: var(--muted); }

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

.progress-bar {
  width: 82px;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #e5e7eb;
}
.progress-bar span { display: block; height: 100%; background: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
}
.badge-cleared { background: #dcfce7; color: var(--success); }
.badge-incomplete { background: #fef3c7; color: var(--warning); }
.badge-followup { background: #ffedd5; color: var(--followup); }

.empty-state { text-align: center; padding: 2rem; }
.alert { padding: 0.8rem 1rem; border-radius: 14px; margin-bottom: 1rem; font-weight: 700; }
.alert-error { background: #fee4e2; color: var(--danger); border: 1px solid #fecdca; }

.task-list, .report-list {
  display: grid;
  gap: 1rem;
}
.task-card { margin-bottom: 0; }
.task-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.verified-line { background: #f0fdf4; color: var(--success); padding: 0.7rem; border-radius: 12px; }
.missing-list { margin: 0; padding-left: 1.2rem; }
.missing-list li { margin-bottom: 0.75rem; }
.note-box { margin-top: 0.35rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 0.65rem; }
.details-pre { white-space: pre-wrap; margin: 0; font-size: 0.8rem; color: var(--muted); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card {
  width: min(420px, 100%);
  padding: 2rem;
}

@media (max-width: 820px) {
  .topbar, .hero-row { flex-direction: column; align-items: stretch; }
  .nav-actions { align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .button-row { align-items: stretch; }
  .button-row > * { width: 100%; }
}
