:root {
  --bg: rgb(255, 251, 240);
  --surface: rgb(255, 255, 255);
  --surface2: inherit;
  --text: rgb(15, 23, 42);
  --muted: rgb(100, 116, 139);
  --border: rgb(226, 232, 240);
  --green: inherit;
  --red: inherit;
  --blue: inherit;
  --amber: inherit;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

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

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.hidden { display: none !important; }

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  font-size: 1.3rem;
}

.login-tagline { font-size: 0.8rem; color: var(--muted); }
.login-card h1 { font-size: 1.4rem; margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin-bottom: 12px;
}

input:focus { outline: none; border-color: var(--blue); }

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--green);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn:active { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.err {
  background: rgba(239, 68, 68, 0.15);
  color: var(--text);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.autofill-trap { position: absolute; left: -9999px; opacity: 0; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-bar h1 { font-size: 1.1rem; }
.kicker { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.top-bar-center { flex: 1; text-align: center; min-width: 0; }
.top-bar-center h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-bar-center p { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.screen-body {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.trip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
}

.trip-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.trip-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface2);
  padding: 4px 8px;
  border-radius: 6px;
}

.trip-card small { color: var(--muted); font-size: 0.8rem; }

.trip-btn {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--green);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.trip-btn.continue { background: var(--blue); }
.trip-done { display: block; margin-top: 12px; color: var(--muted); font-size: 0.85rem; }
.trip-locked { display: block; margin-top: 8px; color: var(--amber); font-size: 0.82rem; }

.status-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.status-tile {
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: var(--surface2);
}

.status-tile strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.1;
}

.status-tile span {
  display: block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

.status-tile.on-board strong { color: var(--green); }
.status-tile.dropped strong { color: var(--blue); }
.status-tile.absent strong { color: var(--amber); }

.trip-actions { padding: 8px 12px 0; }
.trip-actions .btn-action {
  width: 100%;
  background: var(--blue);
  margin-bottom: 4px;
}

.search-input {
  margin-bottom: 6px;
}
.swipe-tip {
  margin: 0 0 10px;
  font-size: 0.72rem;
  color: var(--muted);
}

.student-list { padding-bottom: 8px; }

.student-row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  transition: transform 0.12s ease;
  overflow: hidden;
}

.row-swipe-hint {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 72px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text);
  background: rgba(59, 130, 246, 0.12);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.student-row.swipe-ready .row-swipe-hint { opacity: 1; }
.student-row.swipe-ready { border-color: rgba(59, 130, 246, 0.45); }

.student-row.status-on_board { border-color: rgba(34, 197, 94, 0.35); }
.student-row.status-dropped { opacity: 0.75; }
.student-row.status-absent { border-color: rgba(245, 158, 11, 0.35); }

.row-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.row-info { flex: 1; min-width: 0; }
.row-info strong { display: block; font-size: 0.92rem; }
.route-seq {
  display: inline-block; min-width: 1.25rem; margin-right: 4px;
  color: var(--text);
}
.row-info small { color: var(--muted); font-size: 0.74rem; }

.row-badge {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--muted);
  flex-shrink: 0;
}

.status-on_board .row-badge { background: rgba(34, 197, 94, 0.2); color: 
.status-dropped .row-badge { background: rgba(59, 130, 246, 0.2); color: 
.status-absent .row-badge { background: rgba(245, 158, 11, 0.2); color: 
.status-pending .row-badge { background: rgba(148, 163, 184, 0.15); color: var(--muted); }

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.row-btn {
  flex: 1;
  padding: 11px 8px;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}

.row-btn.pick { background: var(--green); }
.row-btn.drop { background: var(--blue); }
.row-btn.absent { background: var(--red); }
.row-btn:disabled { opacity: 0.45; }

.run-footer {
  padding: 12px 16px max(12px, var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.btn-finish {
  background: var(--surface);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(20px, var(--safe-bottom));
  background: var(--surface);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  z-index: 50;
  border: 1px solid var(--border);
}

.offline-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid 
}
.offline-bar.hidden { display: none; }
