/* ===========================================================
   Tutor Pro — Mobile-first SaaS design system
   Premium emerald + warm neutral · Manrope + JetBrains Mono
   =========================================================== */

:root {
  /* Brand */
  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;

  /* Surface (warm stone) */
  --stone-50:  #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;

  /* Status */
  --paid:      #10b981;
  --paid-bg:   #d1fae5;
  --due:       #f59e0b;
  --due-bg:    #fef3c7;
  --partial:   #f97316;
  --partial-bg:#ffedd5;
  --overdue:   #dc2626;
  --overdue-bg:#fee2e2;

  /* Semantic */
  --bg:           var(--stone-50);
  --surface:      #ffffff;
  --surface-2:    var(--stone-100);
  --border:       var(--stone-200);
  --border-soft:  #f0efee;
  --text:         var(--stone-900);
  --text-soft:    var(--stone-600);
  --text-muted:   var(--stone-500);
  --primary:      var(--emerald-600);
  --primary-soft: var(--emerald-50);

  /* Shape */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(28,25,23,.04), 0 1px 3px rgba(28,25,23,.04);
  --shadow-md: 0 4px 12px rgba(28,25,23,.05), 0 2px 4px rgba(28,25,23,.04);
  --shadow-lg: 0 12px 32px rgba(28,25,23,.08), 0 4px 8px rgba(28,25,23,.04);
  --shadow-fab: 0 8px 24px rgba(5,150,105,.32), 0 2px 6px rgba(5,150,105,.24);

  /* Layout */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  --bar-h: 56px;
  --max-w: 520px; /* phone-frame on tablets/desktop */

  /* Type */
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ----------- Reset ----------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
  min-height: 100vh;
  min-height: 100dvh;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

/* ----------- App frame ----------- */
.app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}
@media (min-width: 600px) {
  body { background: linear-gradient(135deg, #ecfdf5 0%, #fafaf9 60%, #f0fdfa 100%); }
  .app {
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border);
  }
}

/* ----------- Top bar ----------- */
.topbar {
  height: var(--bar-h);
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); background: rgba(250,250,249,.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.topbar .greet { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar .greet .hello { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.topbar .greet .name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: transform .15s, background .15s;
}
.icon-btn:active { transform: scale(.94); background: var(--surface-2); }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after {
  content: ''; position: absolute; top: 9px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--overdue); border: 2px solid var(--surface);
}
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--emerald-100);
  color: var(--emerald-700);
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  overflow: hidden;
  font-size: 14px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ----------- Main scroll area ----------- */
main.view {
  flex: 1;
  padding: 12px 16px calc(var(--nav-h) + 24px + var(--safe-bottom));
  overflow-x: hidden;
}
.page { display: none; animation: fadeUp .26s ease both; }
.page.active { display: block; }
@keyframes fadeUp { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 4px 10px;
}
.section-title h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.section-title .link { font-size: 13px; color: var(--primary); font-weight: 600; background: transparent; border: 0; padding: 4px 6px; }

/* ----------- Bottom nav ----------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max-w);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 40;
}
@media (min-width: 600px) {
  .bottom-nav { border-radius: 0 0 32px 32px; }
}
.bottom-nav button {
  flex: 1;
  background: none; border: 0; padding: 8px 4px 6px;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  position: relative;
  transition: color .15s;
}
.bottom-nav button svg { width: 22px; height: 22px; stroke-width: 2; }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--primary);
}
.bottom-nav button:active svg { transform: scale(.88); }
.bottom-nav button svg { transition: transform .15s; }

/* ----------- FAB ----------- */
.fab {
  position: fixed;
  right: max(16px, calc((100vw - var(--max-w))/2 + 16px));
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: #fff;
  border: 0;
  box-shadow: var(--shadow-fab);
  display: inline-flex; align-items: center; justify-content: center;
  z-index: 35;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), opacity .15s;
}
.fab:active { transform: scale(.92); }
.fab.hidden { transform: scale(0) translateY(20px); opacity: 0; pointer-events: none; }
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* ----------- Greeting card (home hero) ----------- */
.hero-card {
  background: linear-gradient(135deg, var(--stone-900) 0%, var(--emerald-700) 100%);
  color: #fff;
  border-radius: var(--r-xl);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero-card::before {
  content: '';
  position: absolute;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,.45) 0%, transparent 70%);
  right: -80px; top: -80px;
  pointer-events: none;
}
.hero-card .label {
  font-size: 12px; font-weight: 600; opacity: .8;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 4px;
}
.hero-card .big {
  font-family: var(--font-mono);
  font-size: 32px; font-weight: 700; letter-spacing: -.02em;
  line-height: 1.1;
}
.hero-card .sub {
  font-size: 13px; opacity: .85; margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}
.hero-card .sub strong { font-family: var(--font-mono); color: #6ee7b7; }
.hero-card .mini-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 16px;
  position: relative; z-index: 1;
}
.hero-card .mini {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-md);
  padding: 10px;
}
.hero-card .mini .k { font-size: 11px; opacity: .8; font-weight: 500; }
.hero-card .mini .v { font-family: var(--font-mono); font-size: 16px; font-weight: 700; margin-top: 2px; }

/* ----------- Stat grid ----------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat .icon-bubble {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.stat .icon-bubble svg { width: 18px; height: 18px; }
.stat .v { font-family: var(--font-mono); font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.stat .k { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 4px; }
.stat.paid .icon-bubble    { background: var(--paid-bg);    color: var(--paid); }
.stat.due  .icon-bubble    { background: var(--due-bg);     color: var(--due); }
.stat.partial .icon-bubble { background: var(--partial-bg); color: var(--partial); }
.stat.overdue .icon-bubble { background: var(--overdue-bg); color: var(--overdue); }
.stat.neutral .icon-bubble { background: var(--stone-100);  color: var(--stone-700); }
.stat.brand .icon-bubble   { background: var(--primary-soft); color: var(--primary); }

/* ----------- Cards ----------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 10px; }

/* Student card */
.student-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.student-card + .student-card { margin-top: 8px; }
.student-card .ph {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.student-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.student-card .ph .status-dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--paid);
}
.student-card .ph .status-dot.due     { background: var(--due); }
.student-card .ph .status-dot.partial { background: var(--partial); }
.student-card .ph .status-dot.overdue { background: var(--overdue); }
.student-card .body { flex: 1; min-width: 0; }
.student-card .name {
  font-weight: 700; font-size: 15px; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.student-card .meta {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
}
.student-card .meta .dot { width: 2px; height: 2px; border-radius: 50%; background: currentColor; opacity: .5; }
.student-card .fee {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  flex-shrink: 0;
}
.student-card .fee .amt { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }

/* Action row inside card */
.qa-row {
  display: flex; gap: 6px; margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.qa-row button {
  flex: 1;
  height: 34px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: background .15s, transform .15s;
}
.qa-row button:active { transform: scale(.97); background: var(--surface-2); }
.qa-row button.wa { background: #25D366; color: #fff; border-color: #25D366; }
.qa-row button.wa:active { background: #1ebe57; }
.qa-row button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.qa-row button svg { width: 13px; height: 13px; }

/* ----------- Status pills ----------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 700;
  letter-spacing: .02em;
}
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.paid    { background: var(--paid-bg);    color: var(--paid); }
.pill.due     { background: var(--due-bg);     color: var(--due); }
.pill.partial { background: var(--partial-bg); color: var(--partial); }
.pill.overdue { background: var(--overdue-bg); color: var(--overdue); }
.pill.active  { background: var(--paid-bg);    color: var(--paid); }
.pill.inactive{ background: var(--stone-100);  color: var(--stone-500); }
.pill.present { background: var(--paid-bg);    color: var(--paid); }
.pill.absent  { background: var(--overdue-bg); color: var(--overdue); }
.pill.late    { background: var(--due-bg);     color: var(--due); }

/* ----------- Filter chips ----------- */
.chips {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 4px 0 8px; margin: 0 -16px 4px;
  padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all .15s;
}
.chip.active { background: var(--stone-900); color: #fff; border-color: var(--stone-900); }
.chip:active { transform: scale(.96); }
.chip .count { font-family: var(--font-mono); font-size: 11px; opacity: .8; }

/* ----------- Search ----------- */
.search-wrap {
  position: relative;
  margin-bottom: 8px;
}
.search-wrap svg.s {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
}
.search-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 42px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5,150,105,.12); }

/* ----------- Forms ----------- */
.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
  letter-spacing: .01em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field { margin: 0; }

/* Photo upload */
.photo-upload {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.photo-preview {
  width: 72px; height: 72px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
  flex-shrink: 0;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload .ph-body { flex: 1; }
.photo-upload .ph-body .ph-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.photo-upload .ph-pick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border-radius: var(--r-full);
  background: var(--stone-900); color: #fff;
  font-size: 12px; font-weight: 600;
  border: 0;
}

/* ----------- Buttons ----------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: transform .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:active { background: var(--emerald-700); }
.btn.dark { background: var(--stone-900); color: #fff; border-color: var(--stone-900); }
.btn.danger { background: var(--overdue); color: #fff; border-color: var(--overdue); }
.btn.ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn.wa { background: #25D366; color: #fff; border-color: #25D366; }
.btn svg { width: 16px; height: 16px; }

/* ----------- Sheet (modal) ----------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(28,25,23,.45);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%);
  width: 100%; max-width: var(--max-w);
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  z-index: 101;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 32px rgba(28,25,23,.12);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: translateX(-50%) translateY(0); }
.sheet .handle {
  width: 36px; height: 4px; background: var(--stone-300);
  border-radius: 4px; margin: 8px auto 4px;
}
.sheet .head {
  padding: 4px 16px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.sheet .head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.sheet .head .close-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-soft);
}
.sheet .body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.sheet .foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex; gap: 8px;
  background: var(--bg);
}

/* ----------- Toast ----------- */
.toast-stack {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: 100%;
  max-width: var(--max-w);
  padding: 0 16px;
}
.toast {
  background: var(--stone-900);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  opacity: 0;
  transform: translateY(-12px);
  animation: toastIn .25s forwards;
  pointer-events: auto;
}
.toast.error { background: var(--overdue); }
.toast.success { background: var(--emerald-700); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes toastIn { to { opacity: 1; transform: translateY(0); } }
.toast.leaving { animation: toastOut .2s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ----------- Login screen ----------- */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, #ecfdf5 0%, #fafaf9 55%, #f0fdfa 100%);
  z-index: 90;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px calc(var(--safe-bottom) + 32px);
  text-align: center;
}
.login-screen.hidden { display: none; }
.login-screen .brand-mark {
  width: 76px; height: 76px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-700));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  box-shadow: var(--shadow-fab);
  margin-bottom: 22px;
  font-family: var(--font-mono);
}
.login-screen h1 {
  font-size: 30px; font-weight: 800; letter-spacing: -.02em;
  margin: 0 0 6px;
}
.login-screen .tag {
  color: var(--text-soft); font-size: 14px; max-width: 320px;
  line-height: 1.55; font-weight: 500;
}
.login-screen .features {
  margin: 28px 0 24px;
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 320px;
}
.login-screen .features li {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 13px; font-weight: 600;
  text-align: left;
}
.login-screen .features li .ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.login-screen .features li .ico svg { width: 14px; height: 14px; }
.google-btn {
  width: 100%; max-width: 320px;
  height: 52px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 15px; font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow-md);
  transition: transform .15s;
}
.google-btn:active { transform: scale(.98); }
.google-btn .g-icon { width: 20px; height: 20px; }
.login-screen .legal { color: var(--text-muted); font-size: 11px; margin-top: 18px; }

/* ----------- Loading splash ----------- */
.splash {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
}
.splash.hidden { display: none; }
.splash .brand-mark {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-700));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800;
  box-shadow: var(--shadow-md);
  font-family: var(--font-mono);
}
.splash .spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------- Admin badge ----------- */
.admin-tag {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--r-full);
  letter-spacing: .05em;
  margin-left: 6px;
  text-transform: uppercase;
}

/* ----------- Reminder rows ----------- */
.reminder-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}
.reminder-row + .reminder-row { margin-top: 6px; }
.reminder-row .av { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; overflow: hidden; }
.reminder-row .av img { width: 100%; height: 100%; object-fit: cover; }
.reminder-row .b { flex: 1; min-width: 0; }
.reminder-row .b .n { font-weight: 600; font-size: 14px; }
.reminder-row .b .m { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.reminder-row .wa-mini {
  width: 36px; height: 36px;
  border-radius: 50%; background: #25D366; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; flex-shrink: 0;
}
.reminder-row .wa-mini svg { width: 16px; height: 16px; }

/* ----------- Empty state ----------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty .e-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.empty h3 { color: var(--text); font-size: 15px; margin: 0 0 4px; font-weight: 700; }
.empty p { font-size: 13px; margin: 0; }

/* ----------- Attendance grid ----------- */
.att-student {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.att-student + .att-student { margin-top: 6px; }
.att-student .av { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; overflow: hidden; }
.att-student .av img { width: 100%; height: 100%; object-fit: cover; }
.att-student .n { flex: 1; min-width: 0; font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-student .att-toggle { display: flex; gap: 4px; }
.att-student .att-toggle button {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-weight: 700; font-size: 11px;
  transition: all .12s;
}
.att-student .att-toggle button:active { transform: scale(.92); }
.att-student .att-toggle button.sel-p { background: var(--paid); color: #fff; border-color: var(--paid); }
.att-student .att-toggle button.sel-a { background: var(--overdue); color: #fff; border-color: var(--overdue); }
.att-student .att-toggle button.sel-l { background: var(--due); color: #fff; border-color: var(--due); }

/* ----------- Tab bar inside pages ----------- */
.subtabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--r-full);
  padding: 4px;
  gap: 2px;
  margin-bottom: 14px;
}
.subtabs button {
  flex: 1;
  height: 36px;
  background: transparent;
  border: 0;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  transition: all .15s;
}
.subtabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ----------- Invoice / print ----------- */
.invoice {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  color: var(--stone-900);
}
.invoice .inv-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 2px dashed var(--border);
}
.invoice .inv-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.invoice .inv-head .meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.invoice .inv-head .stamp {
  text-align: right;
}
.invoice .inv-head .stamp .id {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-muted);
}
.invoice .inv-head .stamp .date {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  margin-top: 2px;
}
.invoice .inv-rows {
  display: grid; gap: 8px;
  margin-bottom: 14px;
}
.invoice .inv-row {
  display: flex; justify-content: space-between;
  font-size: 13px;
}
.invoice .inv-row .k { color: var(--text-muted); font-weight: 500; }
.invoice .inv-row .v { font-weight: 600; }
.invoice .inv-total {
  background: var(--stone-900);
  color: #fff;
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.invoice .inv-total .k { font-size: 12px; opacity: .8; }
.invoice .inv-total .v {
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 700;
  letter-spacing: -.01em;
}
.invoice .inv-foot {
  margin-top: 14px;
  font-size: 11px; color: var(--text-muted);
  text-align: center;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

@media print {
  .topbar, .bottom-nav, .fab, .sheet-backdrop { display: none !important; }
  body { background: #fff; }
  .app { box-shadow: none; max-width: 100%; margin: 0; border-radius: 0; }
  main.view { padding: 0; }
  .invoice { border: 0; box-shadow: none; }
}

/* ----------- Misc ----------- */
.spinner-inline {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.mb-8 { margin-bottom: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }

/* Sync indicator dot */
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--paid);
  display: inline-block;
  margin-right: 5px;
}
.sync-dot.syncing { background: var(--due); animation: pulse 1s infinite; }
.sync-dot.offline { background: var(--overdue); }
@keyframes pulse { 50% { opacity: .35; } }

/* Skeleton */
.skel {
  background: linear-gradient(90deg, var(--stone-100) 25%, var(--stone-200) 50%, var(--stone-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { to { background-position: -200% 0; } }
