:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #dfe5ec;
  --nav: #07182f;
  --nav-2: #0b203c;
  --primary: #1f5fbf;
  --primary-soft: #e9f1ff;
  --success: #16804a;
  --warning: #b56b12;
  --danger: #c93b3b;
  --purple: #6f4dbf;
  --radius: 8px;
  --shadow: 0 6px 18px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 30;
  padding: 18px 14px;
  background: var(--nav);
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 0 6px;
}
.brand-text { min-height: 40px; align-items: center; }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff;
}
.brand h1 { margin: 0; font-size: 16px; font-weight: 600; }
.brand p, .sidebar-user .muted { margin: 2px 0 0; color: #aebbd0; font-size: 12px; }
.nav-section {
  margin: 16px 10px 6px;
  color: #8fa2be;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 2px 0;
  padding: 9px 10px;
  border-radius: 7px;
  color: #d7e2f2;
  font-size: 13px;
  font-weight: 500;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-link i { width: 18px; color: #aebbd0; font-size: 16px; }
.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  transform: translateX(2px);
}
.nav-link.active {
  background: #173965;
  color: #fff;
}
.nav-link.active i, .nav-link:hover i { color: #fff; }
.count {
  margin-left: auto;
  min-width: 20px;
  border-radius: 999px;
  padding: 1px 6px;
  background: #cf3f3f;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.count.warning { background: #b7791f; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 16px 6px 0;
  border-top: 1px solid rgba(255,255,255,.12);
}
.sidebar-user strong { font-size: 13px; font-weight: 600; }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
}
.top-left, .top-actions, .actions, .filters {
  display: flex;
  align-items: center;
  gap: 10px;
}
.menu-btn, .icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.menu-btn { display: none; }
.icon-btn:hover, .menu-btn:hover { background: var(--surface-2); border-color: #cbd5e1; color: var(--primary); }
.search {
  width: 390px;
  max-width: 42vw;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: #334155;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e9f1ff;
}

.content { padding: 24px 28px 34px; }
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.page-header h2 { margin: 0 0 4px; font-size: 24px; font-weight: 600; letter-spacing: 0; }
.page-header p { margin: 0; color: var(--muted); }
.actions, .filters { flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.btn:hover { background: #174f9f; transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.secondary { background: #fff; color: #24518a; border-color: #cdd9e8; }
.btn.secondary:hover { background: #f8fafc; border-color: #b9c7d9; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }

.grid { display: grid; gap: 16px; }
.mt-16 { margin-top: 16px; }
.align-end { display: flex; align-items: end; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.cards { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.two { grid-template-columns: 1.15fr .85fr; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}
.card:hover { border-color: #d2dae5; box-shadow: 0 8px 22px rgba(15,23,42,.07); }
.stat { display: flex; align-items: center; gap: 12px; }
.icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 18px;
  flex: 0 0 auto;
}
.i-blue { background: var(--primary-soft); color: var(--primary); }
.i-green { background: #e7f6ee; color: var(--success); }
.i-orange { background: #fff3df; color: var(--warning); }
.i-red { background: #fdeaea; color: var(--danger); }
.i-purple { background: #f0ecff; color: var(--purple); }
.stat h3 { margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat strong { display: block; margin-top: 4px; font-size: 22px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}
.panel-title h3 { margin: 0; font-size: 16px; font-weight: 600; }

.input, .select, .textarea {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 11px;
  background: #fff;
  color: #334155;
}
.textarea { width: 100%; min-height: 86px; resize: vertical; }
.filters { margin-bottom: 14px; }
.filters .input, .filters .select { min-width: 160px; }
.input:focus, .select:focus, .textarea:focus, .search:focus {
  outline: 2px solid rgba(31,95,191,.16);
  border-color: #8fb3e5;
}

.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  color: #667085;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
.data-table tbody tr { transition: background .14s ease; }
.data-table tbody tr:hover { background: #f9fbfd; }
.data-table tr:last-child td { border-bottom: 0; }
.student-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef4fb;
  color: #44617f;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
}
.paid, .ok { background: #e7f6ee; color: var(--success); }
.due, .bad { background: #fdeaea; color: var(--danger); }
.pending { background: #fff4dc; color: var(--warning); }
.info { background: #e9f1ff; color: var(--primary); }
.purple { background: #f0ecff; color: var(--purple); }
.gray { background: #eef2f6; color: #475569; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.label { display: block; margin-bottom: 6px; color: #667085; font-size: 12px; font-weight: 600; }
.upload {
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 14px;
  border: 1px dashed #bdc8d7;
  border-radius: 8px;
  background: #f8fafc;
  color: #667085;
  text-align: center;
}
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-actions { margin-left: auto; }
.compact-title { margin: 0; font-size: 22px; font-weight: 600; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.session-form { margin: 0; }
.session-form .select { min-width: 180px; }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.profile-photo {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 10px;
  background: #e9f1ff;
  color: var(--primary);
  font-size: 30px;
}
.tabs {
  display: flex;
  gap: 6px;
  margin-top: 18px;
  border-bottom: 1px solid var(--border);
  overflow: auto;
}
.tabs a, .tabs span {
  padding: 11px 12px;
  color: #667085;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.tabs .active, .tabs .on { color: var(--primary); border-bottom: 2px solid var(--primary); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px; margin: 8px 0; font-size: 14px; }
.kv span:first-child { color: #667085; }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #fdeaea; }
.progress b { display: block; height: 100%; background: var(--success); }
.timeline { display: grid; gap: 10px; }
.timeline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #334155;
  font-size: 13px;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.legend-dot.warning { background: var(--warning); }
.legend-dot.purple { background: var(--purple); }
.legend-dot.success { background: var(--success); }
.legend-dot.danger { background: var(--danger); }
.event { display: flex; gap: 10px; align-items: flex-start; }
.dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  flex: 0 0 auto;
}
.notice {
  padding: 12px 14px;
  border: 1px solid #f3d2a1;
  border-radius: 8px;
  background: #fff8eb;
  color: #8a5614;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  visibility: hidden;
  opacity: 0;
  padding: 20px;
  z-index: 60;
  background: rgba(2, 6, 23, .42);
  transition: opacity .18s ease, visibility .18s ease;
}
.modal.show { visibility: visible; opacity: 1; }
.modal-card {
  width: min(540px, 100%);
  padding: 20px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 22px 55px rgba(0,0,0,.18);
  transform: scale(.98);
  transition: transform .18s ease;
}
.modal.show .modal-card { transform: scale(1); }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  z-index: 70;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.toast.show { visibility: visible; opacity: 1; transform: translateY(0); }

.chart-box { position: relative; min-height: 220px; }
.chart-box.short { min-height: 190px; }
.fee-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.sub-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  box-shadow: none;
}
.sub-card h2 { margin: 4px 0 0; font-size: 20px; font-weight: 600; }
.footer-note { margin-top: 22px; color: #8a97aa; font-size: 12px; }

@media print {
  .sidebar, .topbar, .actions, .btn { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

@media (max-width: 1180px) {
  .cards, .three, .four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
  .search { display: none; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    width: 258px;
    transition: left .2s ease;
  }
  .sidebar.open { left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 30px; }
  .cards, .three, .four, .form-grid, .fee-summary { grid-template-columns: 1fr; }
  .page-header { display: block; }
  .actions { margin-top: 12px; }
  .kv { grid-template-columns: 1fr; }
  .top-actions .chip { display: none; }
}
