:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #6b7785;
  --line: #dde5ee;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #d97706;
  --success: #15803d;
  --danger: #b91c1c;
  --shadow: 0 12px 30px rgba(22, 32, 42, 0.08);
}

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

a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: #10202b; color: #eef7f6; padding: 24px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; margin-bottom: 28px; }
.brand img { width: 40px; height: 40px; }
.nav { display: grid; gap: 8px; }
.nav a { padding: 12px 14px; border-radius: 8px; color: #cfe2e0; }
.nav a.is-active, .nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.main { padding: 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 28px; }
.menu-btn { display: none; border: 0; border-radius: 8px; background: var(--brand); color: #fff; padding: 10px 12px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(280px, 420px) 1fr; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.card-body { padding: 18px; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 8px; }
.section-title { margin: 0 0 14px; font-size: 18px; }
form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.check-row input { width: auto; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  font: inherit;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 12px 14px;
  font-weight: 800;
  cursor: pointer;
}
.button.secondary { background: #eef4f7; color: var(--ink); }
.button.compact { padding: 8px 10px; margin: 2px 2px 2px 0; font-size: 12px; }
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  background: #eef4f7;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.install-btn[hidden] { display: none; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.badge { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; background: #eef4f7; color: var(--muted); }
.badge.paid, .badge.active { background: #dcfce7; color: var(--success); }
.badge.present { background: #dcfce7; color: var(--success); }
.badge.late { background: #fef3c7; color: var(--accent); }
.badge.absent { background: #fee2e2; color: var(--danger); }
.badge.pending { background: #fef3c7; color: var(--accent); }
.badge.inactive { background: #fee2e2; color: var(--danger); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar label { min-width: 220px; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 13px;
  background: #fff;
}
.segmented input { width: auto; }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.alert { border: 1px solid #fecaca; background: #fee2e2; color: var(--danger); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #f6f8fb 0%, #e7f5f2 100%);
}
.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin: 0 0 18px; }
.auth-brand { color: var(--ink); margin-bottom: 18px; }
.parent-page { max-width: 980px; margin: 0 auto; padding: 24px; }
.parent-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.parent-header img { width: 48px; height: 48px; }
.parent-header h1 { margin: 0; }
.parent-header p { margin: 4px 0 0; color: var(--muted); }
.parent-install { margin-left: auto; }
.logo-preview { display: flex; align-items: center; gap: 14px; }
.logo-preview img { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; }
.inline-note-form { min-width: 220px; gap: 6px; }
.student-note-preview { color: var(--ink); font-size: 13px; margin-bottom: 8px; max-width: 280px; }
.modal-open { overflow: hidden; }
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 43, 0.58);
}
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-header .section-title { margin: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .main { padding: 18px; }
  .grid.stats, .grid.two { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 720px; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 23px; }
  .card-body { padding: 14px; }
  .parent-header { align-items: flex-start; flex-wrap: wrap; }
  .parent-install { margin-left: 0; width: 100%; }
  .modal { padding: 10px; align-items: end; }
  .modal-panel { max-height: calc(100vh - 20px); }
  .modal-actions { flex-direction: column-reverse; }
}
