:root {
  --navy: #16324f;
  --navy-2: #1f4568;
  --teal: #0f766e;
  --teal-dark: #0b5e57;
  --ink: #1c2733;
  --muted: #5d6b7a;
  --line: #dbe2e8;
  --bg: #f2f4f6;
  --card: #ffffff;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --radius: 14px;
  /* Liquid glass (visual language adapted from the Your Wallet test line):
     frosted translucent surfaces over a soft tinted backdrop. The alpha is
     high (.82) so cards stay readable even where backdrop-filter is
     unsupported — glass is decoration, never at the cost of usability. */
  --glass-bg: rgba(255, 255, 255, .82);
  --glass-border: rgba(0, 0, 0, .08);
  --glass-border-strong: rgba(30, 58, 95, .30);
  --glass-hi: rgba(255, 255, 255, .8);
  --glass-shadow: 0 10px 32px rgba(26, 34, 51, .14);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans Myanmar", "Myanmar Text", -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Soft tinted backdrop — the frost needs something to blur. Kept very
     light so text contrast stays high; fixed so scrolling never shifts it. */
  background:
    radial-gradient(600px 300px at 85% -5%, rgba(15, 118, 110, .12), transparent 60%),
    radial-gradient(500px 260px at -10% 20%, rgba(22, 50, 79, .10), transparent 60%),
    linear-gradient(180deg, #eef3f6 0%, #f2f4f6 40%, #e9eef2 100%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.55;
}
.topbar {
  background: rgba(22, 50, 79, .85);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 4px 20px rgba(22, 50, 79, .18);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 13px; opacity: .85; }
main { max-width: 640px; margin: 0 auto; padding: 14px 14px 28px; }
.view.hidden, .hidden { display: none !important; }
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
  padding: 16px;
  margin-bottom: 12px;
}
/* No backdrop-filter (old browsers): solid white cards, same layout. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .card { background: #fff; }
  .topbar { background: var(--navy); }
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 17px; }
.today-date { font-size: 20px; font-weight: 700; }
.today-hours { font-size: 15px; margin-top: 2px; }
.today-note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--red); font-size: 14px; }
.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.staff-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 15px;
  cursor: pointer;
  min-height: 52px;
  text-align: center;
}
.staff-btn .role { display: block; font-size: 12px; color: var(--muted); }
.staff-btn.selected { border-color: var(--teal); background: #eefaf8; font-weight: 700; }
.staff-btn.done { border-color: var(--green); }
.actions { display: flex; gap: 10px; margin: 4px 0 12px; }
.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #129083, var(--teal));
  color: #fff;
  flex: 1;
  box-shadow: 0 6px 16px rgba(15, 118, 110, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:active { background: var(--teal-dark); }
.btn-secondary {
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(26, 34, 51, .08), inset 0 1px 0 var(--glass-hi);
  color: var(--ink);
  flex: 1;
}
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); width: 100%; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field span { font-size: 13px; color: var(--muted); }
.field input {
  font-size: 16px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff; /* form fields stay solid — readability first */
  color: var(--ink);
  min-height: 48px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.field input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .18);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row .grow { flex: 1; min-width: 140px; }
.row .btn { flex: none; }
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.tab {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .7);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
}
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 700;
}
.badge-present { background: #dcfce7; color: var(--green); }
.badge-late { background: #fef3c7; color: var(--amber); }
.badge-half_day { background: #fee2e2; color: var(--red); }
.badge-leave { background: #e0e7ff; color: #3730a3; }
.geo-locating { color: var(--muted); }
.geo-error h3 { color: var(--red); }
.geo-error p { margin: 6px 0; font-size: 14px; }
.result-ok { border-left: 5px solid var(--green); }
.result-late { border-left: 5px solid var(--amber); }
.result-half { border-left: 5px solid var(--red); }
.result-big { font-size: 20px; font-weight: 700; margin: 2px 0 6px; }
.staff-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.staff-row:last-child { border-bottom: none; }
.staff-row-btns { display: flex; gap: 6px; flex-shrink: 0; }
.staff-row.editing { flex-wrap: wrap; }
.staff-row.editing input { flex: 1 1 120px; min-width: 0; }
.mini-btn {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .75);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  min-height: 38px;
}
.mini-btn-danger { border-color: #fecaca; color: #b91c1c; }
.mini-btn-danger:active { background: #fef2f2; }
.rota-day { margin-bottom: 14px; }
.rota-day h4 { margin: 0 0 6px; font-size: 15px; }
.rota-day label { display: flex; gap: 8px; align-items: center; padding: 6px 0; font-size: 15px; }
.rota-day input[type="checkbox"] { width: 20px; height: 20px; }
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 26px; }
/* Offline banner + live indicator: plain, responsive text — no fancy styling. */
.offline-banner {
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  font-size: 14px;
  padding: 8px 12px;
}
.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
  flex-wrap: wrap;
}
.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  flex: none;
}
.live-dot-on { background: var(--green); }
.live-dot-off { background: var(--amber); }
/* Personal staff view: photo, map, YBS, signature, alerts. */
.photo-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: #e4ebf0;
  flex: none;
}
img.photo-circle { display: block; }
.photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--muted);
}
.photo-pick { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.me-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.me-info { flex: 1; min-width: 120px; }
.me-name { font-size: 19px; font-weight: 700; }
.photo-thumb { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
#map { height: 300px; border-radius: 8px; background: #e4ebf0; z-index: 0; }
.map-wrap { position: relative; }
.btn-recenter {
  position: absolute;
  right: 10px;
  bottom: 30px; /* clears the Leaflet attribution line */
  z-index: 500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  padding: 0;
}
.btn-recenter svg { width: 24px; height: 24px; display: block; }
.btn-recenter:active { background: #eff6ff; }
.map-fallback { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.dist-line { font-weight: 700; font-size: 15px; }
.alert-banner {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}
.ybs-stop { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ybs-stop:last-child { border-bottom: none; }
#signCanvas {
  width: 100%;
  height: 140px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  display: block;
}
/* Locked pad: page scrolls normally over it (no accidental drawing). */
#signCanvas.locked {
  touch-action: pan-y;
  border-style: dashed;
  background: #f8fafc;
}
/* Animated route line on the map (OSRM road route). */
.route-line {
  stroke-dasharray: 12 8;
  animation: route-dash 1.2s linear infinite;
}
.route-fallback {
  stroke-dasharray: 8 8;
}
@keyframes route-dash { to { stroke-dashoffset: -20; } }
.pending-note { font-size: 14px; }
.small { font-size: 12px; }
select {
  font-size: 16px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
  width: 100%;
}
textarea {
  font-size: 16px;
  font-family: inherit;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  resize: vertical;
}
/* Sign In / Sign Out: prominent pair, clear spacing from the map/signature
   above and the result panels below. */
.sign-actions { margin: 16px 0; }
/* Request Admin: smaller ghost button next to the sign-out flow. */
.btn-request {
  background: transparent;
  color: var(--teal);
  border: 1.5px solid var(--teal);
  font-size: 14px;
  padding: 10px 14px;
  min-height: 44px;
  flex: 1;
}
/* Pending-count badge on the Staff Request tab. */
.tab-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: 1px;
}
/* My history: one row per day, newest first. */
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.history-row:last-child { border-bottom: none; }
.history-date { font-weight: 700; font-size: 15px; }
.history-times { font-size: 14px; color: var(--muted); }
/* Early-leave request cards (admin Staff Request tab). */
.request-card {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .6);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.request-card:last-child { margin-bottom: 0; }
.request-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.request-name { font-weight: 700; font-size: 15px; }
.request-reason { margin: 8px 0; font-size: 15px; }
.request-meta { font-size: 13px; color: var(--muted); }

/* ---------- responsive: phone / tablet / PC ---------- */
/* Phone (<700px) is the default single column above. */
@media (min-width: 700px) {
  /* Tablet: a little wider, taller map. */
  main { max-width: 720px; padding: 18px 18px 32px; }
  #map { height: 340px; }
}
@media (min-width: 1024px) {
  /* PC: the admin tables get the width; the staff view goes two-column —
     actions + status on the left, map + bus stops + history on the right.
     Dense flow packs the right column from the top (the map must not sit
     half a page down). Every child defaults to column 1, so any element
     not listed here still lands somewhere sane. */
  main { max-width: 1080px; padding: 20px 24px 36px; }
  #view-checkin {
    display: grid;
    grid-template-columns: minmax(340px, 400px) 1fr;
    grid-auto-flow: row dense;
    gap: 14px;
    align-items: start;
  }
  #view-checkin > * { grid-column: 1; min-width: 0; }
  #view-checkin > .card, #view-checkin > .actions { margin-bottom: 0; }
  #mapCard, #ybsCard, #historyCard { grid-column: 2; }
  #map { height: 420px; }
  /* Admin: tables use the width; request cards flow two-up. */
  #tab-requests .card { display: block; }
  .request-card { display: inline-block; vertical-align: top; width: calc(50% - 6px); margin-right: 10px; }
  .request-card:nth-child(even) { margin-right: 0; }
}
