* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #1d4ed8; --blue-dark: #1e40af; --ink: #111827; --muted: #6b7280;
  --line: #e5e7eb; --bg: #f3f4f6; --bubble-in: #ffffff; --bubble-out: #dbeafe;
  --amber: #fef3c7; --amber-line: #f59e0b;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
#app { max-width: 860px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; background: #fff; }
button { font: inherit; cursor: pointer; border: none; border-radius: 10px; }
input, textarea, select { font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; width: 100%; background: #fff; }
textarea { resize: none; }
.btn { background: var(--blue); color: #fff; padding: 11px 18px; font-weight: 600; }
.btn:active { background: var(--blue-dark); }
.btn.secondary { background: #eef2ff; color: var(--blue-dark); }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; }

/* centered card screens (setup / login) */
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.card h1 { font-size: 26px; text-align: center; }
.card .van { font-size: 52px; text-align: center; }
.card label { font-size: 14px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }

/* app chrome */
header.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--blue); color: #fff; flex-shrink: 0;
}
header.topbar .title { font-weight: 700; font-size: 18px; flex: 1; }
header.topbar .who { font-size: 13px; opacity: .9; text-align: right; line-height: 1.25; }
header.topbar button { background: rgba(255,255,255,.18); color: #fff; padding: 7px 12px; font-size: 13px; }
.pushbar { background: #fffbeb; border-bottom: 1px solid #fde68a; padding: 10px 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
nav.tabs { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; overflow-x: auto; }
nav.tabs button { background: transparent; padding: 8px 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
nav.tabs button.active { background: #eef2ff; color: var(--blue-dark); }
nav.tabs .badge { background: #dc2626; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 6px; vertical-align: 2px; }
main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }

/* driver profiles */
.profiles { display: flex; gap: 10px; overflow-x: auto; padding: 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.profile-card { min-width: 150px; max-width: 190px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 84px; height: 84px; font-size: 30px; }
.profile-card .pname { font-weight: 700; }
.profile-card .pvan { font-size: 13px; color: var(--blue-dark); font-weight: 600; }
.profile-card .pbio { font-size: 13px; color: var(--muted); }

/* messages */
.messages { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 16px; line-height: 1.4; word-wrap: break-word; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg.announcement { align-self: center; max-width: 94%; background: var(--amber); border: 1px solid var(--amber-line); text-align: left; }
.msg.announcement .a-head { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #92400e; margin-bottom: 4px; }
.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); flex-shrink: 0; background: #fff; }
.composer textarea { flex: 1; max-height: 110px; }
.composer button { align-self: flex-end; }

/* inbox */
.inbox-list { display: flex; flex-direction: column; }
.thread-row { display: flex; gap: 12px; align-items: center; padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; background: #fff; width: 100%; border-radius: 0; }
.thread-row:active { background: #f9fafb; }
.thread-row .t-main { flex: 1; min-width: 0; }
.thread-row .t-name { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.thread-row .t-last { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-row .t-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.unread-dot { background: #dc2626; color: #fff; border-radius: 999px; font-size: 11px; min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; font-weight: 700; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }

/* admin people */
.people { padding: 14px; display: flex; flex-direction: column; gap: 16px; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person-row .p-info { flex: 1; min-width: 0; }
.person-row .p-role { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.add-form { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.add-form h3 { font-size: 16px; }
.form-view { padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.form-view label { font-size: 14px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.backbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.backbar button { background: transparent; color: var(--blue-dark); font-weight: 700; padding: 6px 8px; }
.backbar .bb-name { font-weight: 700; flex: 1; }
