:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #6b7684;
  --line: #e2e6ec;
  --primary: #1f6feb;
  --primary-soft: #e6efff;
  --hot: #e5484d;
  --hot-soft: #ffecec;
  --ok: #2f9e44;
  --ok-soft: #e7f6ea;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --card: #1c222b;
    --text: #e8edf3;
    --muted: #93a0b0;
    --line: #2c3440;
    --primary: #4c8dff;
    --primary-soft: #1d2b45;
    --hot: #ff6b6f;
    --hot-soft: #3a1f22;
    --ok: #51c46b;
    --ok-soft: #1c3324;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 96px; }
.wrap.wide { max-width: 980px; }
header.top { margin: 4px 0 16px; }
header.top .label { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
header.top h1 { font-size: 24px; margin: 2px 0 0; }
header.top .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn-danger { background: var(--hot); border-color: var(--hot); color: #fff; font-weight: 700; }
.btn-block { width: 100%; display: block; padding: 16px; font-size: 18px; }
.btn-sm { padding: 6px 10px; font-size: 14px; border-radius: 9px; }

input[type=text], input[type=email], input[type=password], textarea {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }

/* 탑승객: 정류장 버튼 목록 */
.stops { display: flex; flex-direction: column; gap: 8px; }
.stop-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 16px; font-size: 19px; font-weight: 600;
  border-radius: var(--radius);
}
.stop-btn .no {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg); color: var(--muted); font-size: 14px; font-weight: 700;
}
.stop-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.stop-btn.selected .no { background: rgba(255,255,255,.25); color: #fff; }
.stop-btn.passed { text-decoration: line-through; color: var(--muted); }
.stop-btn .tag { margin-left: auto; font-size: 13px; font-weight: 600; }

.banner {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
}
.banner .big { font-size: 22px; font-weight: 800; }
.banner.ok { background: var(--ok-soft); border-color: var(--ok); }

/* 기사님 화면 */
.next {
  background: var(--hot-soft);
  border: 2px solid var(--hot);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.next .lbl { font-size: 14px; font-weight: 700; color: var(--hot); }
.next .name { font-size: 28px; font-weight: 800; margin-top: 2px; }
.next .cnt { font-size: 18px; font-weight: 700; }
.summary { display: flex; gap: 8px; margin-bottom: 12px; }
.summary .box {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.summary .num { font-size: 28px; font-weight: 800; }
.summary .k { font-size: 13px; color: var(--muted); }

.drow {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 12px 12px 14px;
  margin-bottom: 8px;
}
.drow .no { width: 26px; color: var(--muted); font-weight: 700; font-size: 15px; }
.drow .nm { flex: 1; font-size: 18px; font-weight: 600; min-width: 0; word-break: keep-all; }
.drow .badge {
  min-width: 48px; text-align: center; font-size: 22px; font-weight: 800;
  border-radius: 10px; padding: 4px 8px; background: var(--bg); color: var(--muted);
}
.drow.has { border: 2px solid var(--hot); background: var(--hot-soft); }
.drow.has .badge { background: var(--hot); color: #fff; }
.drow.done { opacity: .5; }
.drow.done .nm { text-decoration: line-through; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.bottom-bar .inner { max-width: 560px; margin: 0 auto; }

/* 관리자 */
.admin-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .admin-grid { grid-template-columns: 1fr; } }
.route-item {
  display: block; width: 100%; text-align: left; margin-bottom: 6px;
  padding: 12px 14px; font-weight: 600;
}
.route-item.active { background: var(--primary-soft); border-color: var(--primary); }
.route-item.off { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 140px; }
.stop-edit { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.stop-edit .no { width: 24px; color: var(--muted); font-weight: 700; text-align: right; }
.stop-edit input { flex: 1; min-width: 0; padding: 9px 12px; }
.qr-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .qr-wrap { grid-template-columns: 1fr; } }
.qr-card { text-align: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; color: #111; }
.qr-card .qr { display: inline-block; margin: 10px 0; }
.qr-card .t1 { font-weight: 800; font-size: 20px; }
.qr-card .t2 { font-size: 14px; color: #555; word-break: break-all; }
h2 { font-size: 18px; margin: 0 0 12px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist td, table.hist th { border-bottom: 1px solid var(--line); padding: 8px 4px; text-align: left; vertical-align: top; }

#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 15px; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--hot); }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .admin-grid { display: block; }
  .card { border: none; padding: 0; }
  .qr-card { break-inside: avoid; border: 2px solid #000; }
}
