/* Shiksha Connect — styles carried over from the approved prototype, adapted from a phone mock to a real full-screen app. */
:root {
  --primary: #6B2C5C;
  --primary-dark: #4A1E40;
  --primary-light: #F4E6EF;
  --accent: #E07A3F;
  --accent-light: #FBE9DA;
  --success: #2E7D5B;
  --success-light: #DFF1E7;
  --warning: #C7901A;
  --warning-light: #FCF1D9;
  --danger: #B23A3A;
  --danger-light: #FBE3E3;
  --bg: #F5F3F0;
  --surface: #FFFFFF;
  --surface-2: #FAFAFA;
  --text: #1A1A1A;
  --text-2: #5A5A5A;
  --text-3: #8C8C8C;
  --border: #E5E1DC;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Devanagari", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #f0eae3 0%, #e7dfd6 100%);
  color: var(--text);
  overscroll-behavior: none;
}
button, input, select, textarea { font-family: inherit; }

#app {
  max-width: 480px; margin: 0 auto;
  height: 100vh; height: 100dvh;
  background: var(--bg);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
@media (min-width: 520px) {
  body { padding: 16px 0; }
  #app { height: calc(100dvh - 32px); border-radius: 24px; box-shadow: 0 30px 60px rgba(0,0,0,0.18); }
}

/* Demo-version banner */
#mode-strip { display: none; flex-shrink: 0; background: repeating-linear-gradient(135deg, #E07A3F, #E07A3F 12px, #d56d31 12px, #d56d31 24px);
  color: #fff; font-size: 11px; font-weight: 700; text-align: center; padding: 5px 8px; letter-spacing: 0.02em; }
#mode-strip.on { display: block; }
.demo-box { border: 1.5px dashed var(--accent); background: var(--accent-light); border-radius: 12px; padding: 12px; margin-bottom: 16px; font-size: 12px; line-height: 1.6; }
.demo-box .kv { font-size: 12px; padding: 2px 0; }

/* Network / sync strip */
#net-strip {
  display: none; font-size: 11px; font-weight: 600; text-align: center;
  padding: 4px 8px; flex-shrink: 0; cursor: pointer;
}
#net-strip.offline { display: block; background: var(--danger-light); color: var(--danger); }
#net-strip.pending { display: block; background: var(--warning-light); color: var(--warning); }

#view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* App bar */
.app-bar {
  padding: 12px 16px 14px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--primary); color: white;
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.app-bar.mob { background: var(--accent); }
.app-bar.mgr { background: var(--primary-dark); }
.app-bar-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; transition: background 0.15s; position: relative; flex-shrink: 0;
  border: none; color: white;
}
.app-bar-icon:hover { background: rgba(255,255,255,0.28); }
.app-bar-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-sub { font-size: 11px; opacity: 0.85; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: #ff5a5a; border-radius: 50%; border: 1.5px solid white; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: calc(var(--nav-h) + 24px); -webkit-overflow-scrolling: touch; }
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }

/* Bottom nav */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: space-around; align-items: center;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04); z-index: 20;
}
.nav-item {
  flex: 1; text-align: center; padding: 8px 4px; cursor: pointer;
  color: var(--text-3); font-size: 10px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: color 0.15s; background: none; border: none; position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 20px; }
.nav-item .dot { top: 4px; right: calc(50% - 16px); }

.screen { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* SPLASH */
.splash-view {
  flex: 1; display: flex; flex-direction: column;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white; align-items: center; justify-content: center; padding: 32px; position: relative;
}
.splash-logo {
  width: 96px; height: 96px; border-radius: 24px; background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 800; margin-bottom: 24px; animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.splash-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.splash-sub { font-size: 13px; opacity: 0.85; text-align: center; }
.splash-foot { position: absolute; bottom: 32px; font-size: 11px; opacity: 0.7; text-align: center; width: 100%; left: 0; }

/* LOGIN */
.login-view { flex: 1; background: var(--surface); padding: 24px; overflow-y: auto; }
.login-back { font-size: 22px; color: var(--text); cursor: pointer; margin-bottom: 16px; background: none; border: none; }
.login-brand { display: flex; align-items: center; gap: 12px; margin: 8px 0 28px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.login-h { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-3); margin-bottom: 24px; line-height: 1.5; }

.input-grp { margin-bottom: 14px; }
.input-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 15px; outline: none; background: var(--surface); transition: border-color 0.15s; color: var(--text);
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 70px; }
.input.with-prefix { padding-left: 56px; }
.prefix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; font-weight: 600; color: var(--text-2); pointer-events: none; }
.input-wrap { position: relative; }
.pin-input { letter-spacing: 0.5em; font-size: 20px; font-weight: 700; text-align: center; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.login-hint { background: var(--primary-light); padding: 10px 12px; border-radius: 10px; font-size: 11px; color: var(--primary); margin-bottom: 12px; line-height: 1.5; }
.link { color: var(--primary); font-weight: 600; cursor: pointer; background: none; border: none; font-size: inherit; }

/* ROLE SELECT */
.rs-card {
  border: 1.5px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 10px; cursor: pointer;
  transition: all 0.15s; display: flex; gap: 14px; align-items: center; background: var(--surface); width: 100%; text-align: left;
}
.rs-card:hover { border-color: var(--primary); background: var(--primary-light); }
.role-icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; font-weight: 700;
}
.role-icon.mobiliser { background: var(--accent); }
.role-icon.manager { background: var(--primary-dark); }
.rs-card-title { font-weight: 700; font-size: 14px; }
.rs-card-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Generic UI */
.card { background: var(--surface); border-radius: 14px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 12px; }
.card.tight { padding: 10px 12px; }
.section-title {
  font-size: 12px; font-weight: 600; color: var(--text-2); margin: 16px 4px 8px; text-transform: uppercase; letter-spacing: 0.04em;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.section-title:first-child { margin-top: 4px; }
.section-action { font-size: 11px; font-weight: 600; color: var(--primary); cursor: pointer; text-transform: none; letter-spacing: normal; background: none; border: none; }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: relative; overflow: hidden; cursor: pointer; transition: transform 0.15s;
}
.kpi:hover { transform: translateY(-2px); }
.kpi-num { font-size: 24px; font-weight: 700; color: var(--text); }
.kpi-num small { font-size: 14px; color: var(--text-3); font-weight: 600; }
.kpi-lbl { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.kpi-trend { font-size: 10px; font-weight: 600; margin-top: 6px; display: inline-block; padding: 2px 6px; border-radius: 6px; }
.kpi-trend.up { background: var(--success-light); color: var(--success); }
.kpi-trend.down { background: var(--danger-light); color: var(--danger); }
.kpi-trend.flat { background: var(--surface-2); color: var(--text-2); }
.kpi-accent { position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: var(--primary); }
.kpi:nth-child(2) .kpi-accent { background: var(--accent); }
.kpi:nth-child(3) .kpi-accent { background: var(--success); }
.kpi:nth-child(4) .kpi-accent { background: var(--warning); }

/* Buttons */
.btn {
  background: var(--primary); color: white; border: none; padding: 14px 16px; border-radius: 12px; cursor: pointer;
  font-weight: 600; font-size: 14px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.15s, transform 0.1s; text-decoration: none;
}
.btn + .btn { margin-top: 8px; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-accent { background: var(--accent); }
.btn-danger { background: var(--danger); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); }
.btn-sm { padding: 8px 12px; font-size: 12px; width: auto; }
.btn-row { display: flex; gap: 8px; margin-bottom: 10px; }
.btn-row .btn { margin-top: 0; }

/* Quick actions */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick {
  background: var(--surface); border-radius: 14px; padding: 14px; text-align: left; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1.5px solid transparent; transition: all 0.15s;
}
.quick:hover { border-color: var(--primary); transform: translateY(-2px); }
.quick-ic { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 10px; }
.quick-ic.b1 { background: var(--primary-light); color: var(--primary); }
.quick-ic.b2 { background: var(--accent-light); color: var(--accent); }
.quick-ic.b3 { background: var(--success-light); color: var(--success); }
.quick-ic.b4 { background: var(--warning-light); color: var(--warning); }
.quick-title { font-size: 13px; font-weight: 600; }
.quick-sub { font-size: 10px; color: var(--text-3); margin-top: 2px; }

/* List rows */
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row.static { cursor: default; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.a2 { background: linear-gradient(135deg, #4A8BC2 0%, #6FB1D9 100%); }
.avatar.a3 { background: linear-gradient(135deg, #2E7D5B 0%, #5DAE83 100%); }
.avatar.a4 { background: linear-gradient(135deg, #C7901A 0%, #E4B654 100%); }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 64px; height: 64px; font-size: 20px; margin: 0 auto 12px; }
.list-name { font-weight: 600; font-size: 13px; }
.list-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.grow { flex: 1; min-width: 0; }
.chev { font-size: 18px; color: var(--text-3); }

/* Charts */
.chart-card { background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 12px; }
.chart-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chart-title { font-size: 13px; font-weight: 600; }
.chart-tag { font-size: 10px; color: var(--text-3); }
.chart-container { position: relative; height: 150px; }

/* Alerts */
.alert { display: flex; gap: 12px; padding: 12px; border-radius: 12px; background: var(--warning-light); align-items: flex-start; margin-bottom: 10px; cursor: pointer; transition: transform 0.1s; }
.alert:hover { transform: translateY(-1px); }
.alert.danger { background: var(--danger-light); }
.alert-ic { font-size: 18px; }
.alert-title { font-size: 13px; font-weight: 600; }
.alert-body { font-size: 11px; color: var(--text-2); margin-top: 2px; line-height: 1.4; }

/* Photo capture */
.photo-mock {
  background: linear-gradient(135deg, #2c3e50, #4a6580); height: 220px; border-radius: 12px; position: relative;
  overflow: hidden; margin-bottom: 12px; display: flex; align-items: center; justify-content: center;
  color: white; cursor: pointer; transition: transform 0.15s; background-size: cover; background-position: center;
}
.photo-mock:hover { transform: scale(1.005); }
.photo-overlay { position: absolute; bottom: 8px; left: 8px; right: 8px; background: rgba(0,0,0,0.5); border-radius: 8px; padding: 8px 10px; font-size: 10px; color: white; }
.gps-tag { display: flex; gap: 4px; align-items: center; margin-bottom: 2px; font-weight: 600; }
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumb { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #ddd; position: relative; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb span { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,0.55); color: white; font-size: 9px; padding: 1px 5px; border-radius: 6px; }
.full-img { width: 100%; border-radius: 12px; margin-bottom: 12px; display: block; }

/* Tabs */
.tabs { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--border); }
.tab { flex: 1; text-align: center; padding: 8px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-3); transition: all 0.15s; background: none; border: none; }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 100px; font-size: 10px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.badge.good { background: var(--success-light); color: var(--success); }
.badge.warn { background: var(--warning-light); color: var(--warning); }
.badge.bad, .badge.closed { background: var(--danger-light); color: var(--danger); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* Progress */
.progress { height: 6px; background: var(--surface-2); border-radius: 100px; overflow: hidden; margin-top: 6px; border: 1px solid var(--border); }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 100px; transition: width 0.3s; }

/* Child tile */
.child-tile { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border-radius: 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.child-info { flex: 1; min-width: 0; }
.child-name { font-weight: 600; font-size: 13px; }
.child-age { font-size: 11px; color: var(--text-3); }
.att-buttons { display: flex; gap: 8px; }
.att-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; color: var(--text-3); transition: all 0.15s;
}
.att-btn:hover { transform: scale(1.08); }
.att-btn.p.active { background: var(--success); color: white; border-color: var(--success); }
.att-btn.a.active { background: var(--danger); color: white; border-color: var(--danger); }
.sticky-foot { position: sticky; bottom: 0; padding-top: 10px; background: linear-gradient(transparent, var(--bg) 30%); }

/* Map */
.map { height: 200px; border-radius: 12px; margin-bottom: 12px; overflow: hidden; background: #e6efe9; z-index: 0; }
.pin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.pin.good { background: var(--success); } .pin.warn { background: var(--warning); } .pin.bad, .pin.closed { background: var(--danger); }
.pin.me { background: var(--primary); box-shadow: 0 0 0 6px rgba(107,44,92,0.2); }

/* Toast */
#toast-container { position: absolute; top: 60px; left: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--text); color: white; padding: 12px 14px; border-radius: 12px; font-size: 12px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 10px; animation: toastIn 0.3s ease-out;
}
.toast.success { background: var(--success); } .toast.error { background: var(--danger); }
.toast.info { background: var(--primary); } .toast.warn { background: var(--warning); }
.toast.out { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* Modal (bottom sheet) */
#modal-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; display: none; align-items: flex-end;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
#modal-overlay.active { display: flex; animation: modalFade 0.2s; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  background: var(--surface); width: 100%; border-radius: 24px 24px 0 0; max-height: 90%; overflow-y: auto;
  animation: modalSlide 0.3s ease-out; position: relative; padding-bottom: env(safe-area-inset-bottom);
}
@keyframes modalSlide { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 100px; margin: 8px auto; }
.modal-content { padding: 8px 20px 24px; }
.modal-h { font-size: 18px; font-weight: 700; margin-bottom: 4px; padding-right: 36px; }
.modal-sub { font-size: 12px; color: var(--text-3); margin-bottom: 16px; }
.modal-close {
  position: absolute; top: 16px; right: 20px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; z-index: 5; border: none;
}

/* Busy overlay */
.capture-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 250; display: none; flex-direction: column; align-items: center; justify-content: center; color: white; }
.capture-overlay.active { display: flex; }
.capture-circle { width: 80px; height: 80px; border-radius: 50%; border: 4px solid white; border-top-color: transparent; animation: spin 0.9s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.capture-text { font-size: 14px; text-align: center; padding: 0 24px; }

/* Misc */
.empty { text-align: center; padding: 28px 16px; color: var(--text-3); font-size: 12px; }
.empty-ic { font-size: 32px; margin-bottom: 8px; opacity: 0.6; }
.muted { color: var(--text-3); }
.small { font-size: 11px; }
.kv { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 6px 0; gap: 12px; }
.kv span:last-child { color: var(--text-2); font-size: 12px; text-align: right; }
.bullets { font-size: 12px; line-height: 1.7; }
.search { border: none; outline: none; width: 100%; font-size: 13px; background: transparent; padding: 6px 0; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.chip { padding: 6px 12px; border-radius: 100px; border: 1.5px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; color: var(--text-2); }
.chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.score-grid { display: grid; grid-template-columns: 1fr 80px; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 13px; }
.score-grid .input { padding: 8px 10px; text-align: center; }
.note { font-size: 12px; line-height: 1.5; padding: 8px 0; border-bottom: 1px solid var(--border); }
.note:last-child { border-bottom: none; }
.note .muted { font-size: 10px; }
