:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.container.narrow { max-width: 460px; padding-top: 40px; }

/* ---------- Top nav ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 700; color: var(--primary-dark); font-size: 1.15rem; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; font-size: 1.4rem; padding: 4px 12px; cursor: pointer; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.topbar nav a {
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  position: relative;
}
.topbar nav a:hover, .topbar nav a.active { background: #eef2ff; color: var(--primary-dark); }
.nav-badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 0.7rem; padding: 1px 6px; margin-left: 4px; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: 0.88rem; color: var(--muted); margin-left: auto; padding: 8px 10px; }
.user-box em { font-style: normal; color: var(--primary-dark); }

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

/* ---------- Dashboard quick-action tiles (big, tap-friendly) ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  text-align: center;
  min-height: 96px;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.tile:active { transform: scale(0.97); }
.tile:hover { box-shadow: 0 4px 14px rgba(37,99,235,0.12); border-color: #c7d6fb; }
.tile-icon { font-size: 1.8rem; line-height: 1; }
.tile-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.tile-primary:hover { background: var(--primary-dark); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card.stat-danger { border-color: #fecaca; background: #fff5f5; }
.stat-num { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

/* ---------- Tabs (Courses/Tuitions, Admission/Tuition, Queries) ---------- */
.tabbar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Forms ---------- */
form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}
form input, form select, form textarea {
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  min-height: 46px;
}
form textarea { min-height: 80px; }
form input:disabled, form select:disabled, form textarea:disabled { background: #f1f5f9; color: var(--muted); }

.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.inline-form label { margin-bottom: 0; min-width: 150px; }
.inline-form input[type="text"], .inline-form input[type="search"] { min-width: 220px; }

/* ---------- Big touch-choice tiles (mode / query type on forms) ---------- */
.field-group { margin-bottom: 18px; }
.field-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.big-choice, .mode-choice { display: flex; gap: 10px; flex-wrap: wrap; border: none; padding: 0; margin: 0; }
.mode-choice legend { font-size: 0.85rem; color: var(--muted); padding: 0 0 8px; }
.big-tile, .radio-tile {
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px 10px;
  cursor: pointer;
  text-align: center;
  min-height: 60px;
  justify-content: center;
  font-weight: 600;
  font-size: 0.92rem;
  background: #fff;
}
.radio-tile { flex-direction: row; min-height: 52px; }
.big-tile-icon { font-size: 1.6rem; }
.big-tile input, .radio-tile input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.big-tile:has(input:checked), .radio-tile:has(input:checked) {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary-dark);
}

/* ---------- Buttons ---------- */
.btn, .btn-secondary {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 46px;
  line-height: 1.2;
}
.btn { background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); }
.btn-block { width: 100%; text-align: center; }
.btn-secondary { background: #eef2ff; color: var(--primary-dark); }
.btn-link {
  background: none; border: none; color: var(--primary-dark);
  cursor: pointer; text-decoration: none; font-size: 0.87rem; padding: 6px 8px;
}
.btn-link.danger { color: var(--danger); }
.inline { display: inline; }
.export-links { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tables (horizontal scroll on small screens) ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td { padding: 11px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table tr.row-overdue { background: #fff5f5; }
.actions { white-space: nowrap; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-soon { background: #e0f2fe; color: #075985; }
.badge-urgent { background: #fef3c7; color: #92400e; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-status-new { background: #fef3c7; color: #92400e; }
.badge-status-contacted { background: #e0f2fe; color: #075985; }
.badge-status-converted { background: #dcfce7; color: #166534; }
.badge-status-closed { background: #e2e8f0; color: #475569; }
.badge-att-present { background: #dcfce7; color: #166534; }
.badge-att-absent { background: #fee2e2; color: #991b1b; }
.badge-att-late { background: #fef3c7; color: #92400e; }
.badge-att-leave { background: #e0f2fe; color: #075985; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }
.error { color: var(--danger); }

.enquiry-card h1 { font-size: 1.3rem; }

/* ---------- Print ---------- */
.print-actions { margin-bottom: 16px; }
@media print {
  .no-print, .print-actions { display: none !important; }
  .print-sheet .table { min-width: 0; }
  body { background: #fff; }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .container { padding: 16px 14px 60px; }
  .nav-toggle { display: inline-block; }
  .topbar nav { display: none; flex-direction: column; align-items: stretch; gap: 2px; margin-top: 10px; }
  .topbar nav.open { display: flex; }
  .topbar nav a { padding: 14px; border-radius: 8px; }
  .user-box { margin-left: 0; margin-top: 8px; flex-direction: column; align-items: flex-start; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { text-align: center; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form label { min-width: 0; width: 100%; }
  .inline-form input[type="text"] { min-width: 0; width: 100%; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .export-links { width: 100%; }
  .export-links a { flex: 1; text-align: center; }
}
