:root {
  --bg: #f5efe6; --surface: #fffdf8; --ink: #1a1a16; --ink-soft: #4a4a44; --ink-mute: #8a8580;
  --forest: #1e3a2c; --forest-light: #3a6b4a; --terra: #c45a3e; --amber: #b8842b;
  --cream: #ebe3d3; --line: #d9d1bf;
  --display: 'Iowan Old Style', 'Palatino', 'Palatino Linotype', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-family: var(--sans); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--forest); outline-offset: -1px; }
a { color: var(--forest-light); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { text-align: center; color: var(--ink-mute); padding: 48px 16px; margin: 0; }

/* Header and tabs */
.private-bar { background: var(--terra); color: var(--surface); padding: 6px 16px; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.header { background: var(--forest); color: var(--surface); position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(30,58,44,0.15); }
.header-inner { max-width: 1100px; margin: 0 auto; padding: 14px 20px 10px; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; flex: none; background: var(--terra); color: var(--surface); font-family: var(--display); font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.brand { flex: 1; min-width: 0; }
.brand-name { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; opacity: 0.75; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { text-align: right; font-size: 12px; line-height: 1.3; }
.who-name { font-weight: 600; }
.who-role { opacity: 0.75; }
.signout-btn { margin-top: 4px; background: transparent; color: var(--surface); border: 1px solid rgba(255,255,255,0.35); border-radius: 4px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.signout-btn:hover { background: rgba(255,255,255,0.1); }
.nav { max-width: 1100px; margin: 0 auto; display: flex; overflow-x: auto; padding: 0 8px; border-top: 1px solid rgba(255,255,255,0.1); scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; background: transparent; color: rgba(255,253,248,0.7); border: none; border-bottom: 2px solid transparent; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.nav-btn:hover { color: var(--surface); }
.nav-btn.active { color: var(--surface); border-bottom-color: var(--terra); }
.nav-btn.soon { opacity: 0.55; }
.main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.icon { display: inline-flex; align-items: center; }
.icon svg { display: block; }

/* Generic */
h2.view-title { font-family: var(--display); font-size: 26px; font-weight: 700; margin: 0; color: var(--forest); letter-spacing: -0.02em; }
.view-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.card-title { font-family: var(--display); font-size: 20px; font-weight: 700; margin: 0 0 8px; color: var(--forest); }
.muted { color: var(--ink-mute); }
.btn, .btn-primary, .btn-sm { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; background: var(--surface); color: var(--forest); border: 1px solid var(--line); border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-primary { background: var(--forest); color: var(--surface); border-color: var(--forest); }
.btn-primary:disabled, .btn-sm:disabled { opacity: 0.6; cursor: default; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.message { margin-top: 12px; padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.message.ok { background: #e7efe6; color: var(--forest); border: 1px solid #c9dac6; }
.message.error { background: #f8e6e1; color: #8a3520; border: 1px solid #ecc5b9; }

/* Sign in */
.signin-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.signin-card { width: 100%; max-width: 400px; }
.signin-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.signin-brand .brand-name { color: var(--forest); }
.signin-brand .brand-sub { color: var(--ink-mute); opacity: 1; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 6px; }
.text-field { width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 15px; }
.signin-card .btn-primary { width: 100%; margin-top: 12px; padding: 10px 14px; font-size: 14px; }
.fine-print { font-size: 12px; color: var(--ink-mute); margin: 14px 0 0; }

/* Roster */
.filter-bar { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.search-wrap { display: flex; align-items: center; gap: 8px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; color: var(--ink-mute); flex: 1; min-width: 200px; }
.search-input { padding: 8px 0; background: transparent; border: none; outline: none; font-size: 13px; flex: 1; width: 100%; }
select.field { padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.result-count { font-size: 12px; color: var(--ink-mute); margin-bottom: 12px; }
.pr-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 100px; font-size: 12px; cursor: pointer; user-select: none; }
.pr-toggle input { margin: 0; }
.pr-toggle.on { background: var(--forest); color: var(--surface); border-color: var(--forest); }
.rider-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin-bottom: 8px; }
.rider-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rider-name { font-size: 15px; font-weight: 600; }
.rider-meta { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }
.rider-side { display: flex; align-items: center; gap: 8px; flex: none; }
.plate-badge { background: var(--terra); color: var(--surface); padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; font-family: var(--display); }
.not-ready-flag { display: inline-block; background: var(--amber); color: var(--surface); font-size: 9px; padding: 2px 6px; border-radius: 3px; margin-left: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle; }
.ready-btn { font-size: 11px; padding: 4px 8px; }
.contact-block { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.contact-line { margin-bottom: 4px; overflow-wrap: anywhere; }
.contact-key { background: var(--cream); color: var(--forest); padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-right: 6px; }
.contact-phone { color: var(--ink-soft); }
.empty { text-align: center; color: var(--ink-mute); padding: 32px 16px; }

/* Placeholder tabs */
.soon-card { max-width: 560px; }
.soon-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--terra); font-weight: 600; margin-bottom: 6px; }

/* Emergency */
.call-911 { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: #b3261e; color: #fff; border-radius: 6px; font-weight: 700; font-size: 14px; }
.call-911:hover { text-decoration: none; background: #961f19; }
.em-offline { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--forest); background: #e7efe6; border: 1px solid #c9dac6; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; }
.em-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.em-card.open { border-color: var(--forest-light); box-shadow: 0 2px 10px rgba(30,58,44,0.08); }
.em-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: transparent; border: none; text-align: left; cursor: pointer; }
.em-plate { background: var(--terra); color: var(--surface); font-family: var(--display); font-size: 18px; font-weight: 700; padding: 6px 10px; border-radius: 6px; min-width: 64px; text-align: center; flex: none; }
.em-who { flex: 1; min-width: 0; }
.em-name { font-size: 16px; font-weight: 700; }
.em-meta { font-size: 12px; color: var(--ink-mute); }
.em-flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.em-flag { font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--surface); background: var(--terra); }
.em-flag.amber { background: var(--amber); }
.em-chevron { color: var(--ink-mute); transition: transform 0.15s; flex: none; }
.em-chevron.open { transform: rotate(90deg); }
.em-body { padding: 4px 14px 14px; border-top: 1px solid var(--line); background: var(--bg); }
.em-section { margin-top: 12px; }
.em-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--forest); margin-bottom: 6px; }
.em-med { background: var(--surface); padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; border-left: 3px solid var(--terra); }
.em-med.ok { border-left-color: var(--forest-light); }
.em-med.amber { border-left-color: var(--amber); }
.em-med-label { display: block; font-size: 11px; color: var(--ink-mute); text-transform: uppercase; font-weight: 600; letter-spacing: 0.05em; }
.em-med-text { font-size: 14px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.em-contact { padding: 8px 0; border-bottom: 1px dotted var(--line); }
.em-contact:last-child { border-bottom: none; }
.em-contact-name { font-weight: 600; font-size: 14px; }
.em-contact-rel { font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.05em; }
/* Call buttons sit directly under the name so they can never end up off the edge of a narrow window. */
.em-contact-calls { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.call-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--forest); color: var(--surface); padding: 9px 14px; border-radius: 6px; font-size: 14px; font-weight: 600; }
.call-btn.secondary { background: var(--surface); color: var(--forest); border: 1px solid var(--line); }
.call-btn:hover { text-decoration: none; }
.em-ins-row { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; flex-wrap: wrap; }
.em-ins-val { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.em-ins-row + .btn-sm, .em-section .btn-sm { margin-top: 6px; }
.em-small { margin: 0; font-size: 13px; }

@media (max-width: 600px) {
  .header-inner { padding: 10px 14px 8px; }
  .brand-name { font-size: 18px; }
  .who-role { display: none; }
  .main { padding: 16px 14px 40px; }
  h2.view-title { font-size: 21px; }
  .nav-btn { padding: 8px 10px; font-size: 12px; }
  .nav-btn .label { display: none; }
  .nav-btn.active .label { display: inline; }
  input, select { font-size: 16px !important; }
  .em-contact-calls { flex-direction: column; }
  .call-btn { justify-content: center; padding: 12px; white-space: nowrap; }
}
