:root {
  --primary: rgb(234, 179, 8);
  --primary-light: rgb(250, 204, 21);
  --primary-dark: rgb(202, 138, 4);
  --accent: rgb(245, 158, 11);
  --accent-warm: inherit;
  --bg: rgb(255, 251, 240);
  --card: inherit;
  --text: rgb(15, 23, 42);
  --muted: rgb(100, 116, 139);
  --border: rgb(226, 232, 240);
  --danger: rgb(220, 38, 38);
  --shadow: 0 4px 24px rgba(30, 64, 175, 0.08);
  --shadow-lg: 0 12px 40px rgba(30, 64, 175, 0.15);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body { padding-top: max(var(--safe-top), 0px); }
.hidden { display: none !important; }

.autofill-trap {
  position: absolute; left: -9999px; width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}

.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-bottom: max(24px, var(--safe-bottom));
  background: linear-gradient(145deg, var(--primary-light), var(--primary-dark));
}

.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-logo {
  width: 48px; height: 48px; background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border-radius: 14px; display: grid; place-items: center; font-size: 22px;
}
.login-tagline { font-size: 0.8rem; color: var(--muted); }
.login-card h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }
.otp-app-hint { color: 

label { display: block; font-size: 0.78rem; font-weight: 700; margin-bottom: 6px; color: 

input, textarea {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--border); border-radius: 12px;
  font: inherit; margin-bottom: 14px;
  transition: border-color 0.2s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary-light); }

.btn {
  width: 100%; padding: 15px; border: none; border-radius: 12px;
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--primary); color: 
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; }
.btn-glow { box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35); }
.btn-outline { background: 
.btn-sm { width: auto; padding: 10px 18px; font-size: 0.85rem; }
.btn-danger { background: var(--danger); margin-top: 8px; }

.link-btn {
  background: none; border: none; color: var(--primary);
  font: inherit; font-weight: 600; margin-top: 10px; cursor: pointer;
  width: 100%; text-align: center;
}

.err { background: 

.app {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

.header {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: var(--text);
  padding-top: max(14px, var(--safe-top));
}

.header h1 { font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.header .sub { color: 

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: rgba(255,255,255,0.18); color: 
  cursor: pointer; flex-shrink: 0;
}

.main { flex: 1; padding: 16px 18px; }

.section-title {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 12px;
}

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

.child-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.child-avatar {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
  color: var(--text);
}
.child-body { flex: 1; min-width: 0; }
.child-body h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 2px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; font-size: 0.72rem; font-weight: 700;
  padding: 6px 12px; border-radius: 999px;
}
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-waiting { background: 
.status-on-bus { background: 
.status-school { background: 
.status-home { background: 
.status-off { background: 
.status-alert { background: 

.empty { text-align: center; color: var(--muted); padding: 40px 20px; line-height: 1.6; }
.loading { text-align: center; padding: 48px; color: var(--muted); }

.home-updating { font-size: 0.72rem; color: 

.skeleton-card { pointer-events: none; }
.skeleton-avatar {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-line {
  height: 12px; border-radius: 6px; margin-bottom: 8px; width: 60%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-line.wide { width: 85%; height: 14px; }
.skeleton-pill {
  height: 22px; width: 100px; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.header-row { display: flex; align-items: center; gap: 12px; }
.back-btn {
  background: rgba(255,255,255,.2); border: none; color: 
  width: 42px; height: 42px; border-radius: 12px; font-size: 1.2rem; cursor: pointer;
}

.card.emergency { border-color: 

.settings-group { padding: 0; overflow: hidden; }
.settings-label {
  padding: 12px 16px 8px; font-size: 0.68rem; font-weight: 800;
  letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase;
}
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-top: 1px solid var(--border);
}
.settings-item {
  display: block; width: 100%; text-align: left;
  padding: 14px 16px; border: none; border-top: 1px solid var(--border);
  background: none; font: inherit; font-size: 0.92rem; font-weight: 600;
  color: var(--text); cursor: pointer; text-decoration: none;
}
.settings-item:active { background: 

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,0.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; z-index: 30;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1; border: none; background: none;
  font: inherit; font-size: 0.65rem; font-weight: 600;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; padding-top: 6px;
}
.nav-icon { font-size: 1.35rem; line-height: 1; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-label { font-weight: 800; }

.nav-item-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.nav-badge {
  position: absolute; top: -4px; right: -10px;
  background: var(--danger); color: 
  font-size: 0.6rem; font-weight: 800; min-width: 18px; height: 18px;
  border-radius: 999px; display: grid; place-items: center; padding: 0 4px;
}

.toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(var(--nav-h) + 16px + var(--safe-bottom));
  background: var(--surface);
  border-radius: 14px; font-size: 0.85rem; font-weight: 600;
  text-align: center; z-index: 40; box-shadow: var(--shadow-lg);
}

.history-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: none; }

.meta { color: var(--muted); font-size: 0.82rem; }

.map-main {
  padding: 0; display: flex; flex-direction: column;
  height: calc(100dvh - 100px - var(--nav-h) - var(--safe-bottom));
  position: relative;
}
.live-map { flex: 1; min-height: 280px; width: 100%; z-index: 1; position: relative; }
.map-status { margin: 12px 16px 16px; font-size: 0.85rem; line-height: 1.45; }
.map-status[data-motion="moving"] { border-color: #86efac; }
.map-status[data-motion="stopped"] { border-color: #fcd34d; }
.map-status[data-motion="offline"] { border-color: #fca5a5; }
.map-follow-btn {
  position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%);
  z-index: 5; border: 0; border-radius: 999px; padding: 10px 18px;
  background: #1d4ed8; color: #fff; font-weight: 800; font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.28);
}
.map-follow-btn.hidden { display: none; }
.bus-wrap,
.sb-bus-wrap { position: relative; width: 72px; height: 72px; pointer-events: none; z-index: 2; }
.bus-pulse,
.sb-bus-pulse {
  position: absolute; left: 50%; top: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px;
  border-radius: 50%; background: rgba(34, 197, 94, 0.28);
  animation: sbPulse 1.8s ease-out infinite; z-index: 0;
}
.bus-pulse.stopped,
.sb-bus-pulse.stopped { background: rgba(245, 158, 11, 0.28); animation-duration: 2.6s; }
.bus-pulse.offline,
.sb-bus-pulse.offline { background: rgba(239, 68, 68, 0.25); animation: none; }
@keyframes sbPulse {
  0% { transform: scale(0.55); opacity: 0.85; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
.sb-bus-shadow {
  position: absolute; left: 50%; top: 58%; width: 40px; height: 10px; margin: 0 0 0 -20px;
  border-radius: 50%; background: rgba(15, 23, 42, 0.22); filter: blur(2px); z-index: 1;
}
.bus-marker-el,
.sb-bus-body {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 32px;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.35));
  background: none; border: 0; border-radius: 0; box-shadow: none; margin: 0;
}
.sb-bus-svg { display: block; width: 56px; height: 32px; }

.absence-disabled p { color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

.idle-lock {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.idle-lock-card {
  width: 100%; max-width: 360px; text-align: center;
  padding: 28px 22px; border-radius: var(--radius);
}
.idle-lock-card h2 { margin: 12px 0 6px; font-size: 1.35rem; }
.idle-lock-card .sub { margin-bottom: 16px; }
.idle-lock-card form { display: flex; flex-direction: column; gap: 12px; }
.idle-lock-card input {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--border); font-size: 1.1rem; text-align: center;
  letter-spacing: 0.2em;
}
.idle-lock-card .link-btn { margin-top: 12px; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: var(--text);
  border-bottom: none;
}
.top-bar h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.2; color: 
.top-bar .kicker { font-size: 0.72rem; color: 
.top-bar .sub { font-size: 0.82rem; color: 
.top-bar-actions { display: flex; gap: 8px; }
.top-bar .icon-btn {
  background: rgba(255,255,255,0.18); color: 
}
.icon-btn-spacer { width: 42px; flex-shrink: 0; }

.child-card-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
}
.child-card-head .child-body { flex: 1; min-width: 0; }
.child-card-head h3 {
  font-size: 1.1rem; font-weight: 800; margin-bottom: 6px;
  line-height: 1.25; word-break: break-word;
}
.grade-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  color: var(--muted); background: 
}
.child-status-row { margin-bottom: 14px; }
.child-status-row .status-pill { margin-top: 0; font-size: 0.8rem; padding: 8px 14px; }
.child-school { font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.child-trip-name { font-size: 0.88rem; font-weight: 700; color: 
.child-eta { font-size: 0.84rem; color: var(--primary); margin-bottom: 6px; }
.child-last-event { font-size: 0.75rem; color: 
.child-journey { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.journey-leg {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: 
}
.journey-leg.is-active { border-color: 
.journey-leg-name { font-size: 0.82rem; font-weight: 700; color: 
.detail-school, .detail-trip, .detail-eta { padding: 0 2px; margin-bottom: 10px; }
.detail-journey { margin-bottom: 14px; }

.child-card-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.action-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 10px; border-radius: 12px; border: none;
  font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.action-btn:active { transform: scale(0.98); }
.action-primary { background: var(--primary); color: 
.action-secondary { background: 

.btn-track { background: var(--primary); }
.btn-ghost { background: 
.btn-sm { width: 100%; padding: 12px 16px; margin-bottom: 14px; font-size: 0.85rem; border-radius: 12px; }

.status-hero { text-align: center; padding: 20px; margin-bottom: 12px; }
.status-hero .status-pill { font-size: 0.9rem; padding: 8px 14px; }

.today-row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.today-row:last-child { border-bottom: none; }
.today-row small { color: var(--muted); font-size: 0.72rem; }

.notif-toolbar { margin-bottom: 14px; }

.notif-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.notif-card.unread {
  border-color: var(--border);
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.15);
}
.notif-row {
  display: flex; gap: 12px; align-items: flex-start;
}
.notif-icon {
  flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.1rem;
}
.notif-icon.boarded { background: 
.notif-icon.emergency { background: 
.notif-icon.bus { background: 
.notif-icon.default { background: 
.notif-body { flex: 1; min-width: 0; }
.notif-body strong {
  display: block; font-size: 0.95rem; font-weight: 800;
  margin-bottom: 6px; line-height: 1.35; word-break: break-word;
}
.notif-body p {
  font-size: 0.84rem; color: var(--muted); line-height: 1.45;
  margin-bottom: 8px; word-break: break-word;
}
.notif-body small { color: 
.notif-count {
  display: inline-block; font-size: 0.72rem; font-weight: 800;
  color: var(--primary); background: 
  border-radius: 999px; margin-left: 4px; vertical-align: middle;
}

.settings-item.card {
  display: block; width: 100%; text-align: left; padding: 14px 16px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
  margin-top: 8px;
}

.icon-btn.sound-off { opacity: 0.45; }

.sound-setup {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
}

.sound-setup.hidden { display: none !important; }

.sound-setup-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.sound-setup-icon { font-size: 3rem; margin-bottom: 8px; }

.sound-setup-card h2 {
  font-size: 1.35rem;
  margin-bottom: 8px;
}

.sound-setup-card p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 12px;
  text-align: left;
}

.sound-setup-steps {
  text-align: left;
  margin: 0 0 16px 1.1rem;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.6;
}

.sound-setup-card .btn { margin-top: 8px; }
