:root {
  --navy: #0c3b2a;
  --navy-2: #134a35;
  --accent: #16a34a;
  --accent-2: #0e7a3a;
  --ink: #16202e;
  --muted: #6b7686;
  --line: #e6e9ee;
  --bg: #f4f6f9;
  --card: #ffffff;
  --warn: #b4541f;
  --good: #157a4f;
  --radius: 14px;
  --maxw: 520px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  background: var(--navy); color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; flex-direction: column; }
.logo { font-weight: 800; letter-spacing: 1px; font-size: 22px; }
.tagline { font-size: 11px; color: #9fb2cc; letter-spacing: .3px; }
.sonar-badge {
  font-size: 11px; color: #cfe0f5; text-decoration: none;
  border: 1px solid #2f5a44; border-radius: 999px; padding: 5px 10px; white-space: nowrap;
}
.sonar-badge b { color: #fff; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 16px 14px 28px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 16px; margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 10px; }
.muted { color: var(--muted); font-weight: 400; }
.authcard { background: #eef6f1; }
.authrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.authbtns { display: flex; gap: 6px; flex: none; }
.authrow #authStatus { font-size: 13px; }

.row { display: flex; gap: 8px; align-items: center; }
.control {
  width: 100%; font-size: 16px; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfe; color: var(--ink); appearance: none;
}
.control:focus { outline: none; border-color: var(--accent); }
.row .control { flex: 1; }
.btn-ghost {
  font-size: 13px; padding: 11px 12px; white-space: nowrap; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; color: var(--accent-2); font-weight: 600;
}
.search-results { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.search-results li { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
.search-results li:last-child { border-bottom: none; }
.search-results li:active { background: #eef6f4; }
.search-results .sr-mkt { color: var(--accent-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.near-note { font-size: 12px; color: var(--accent-2); font-weight: 600; margin-top: 7px; }

.segmented { display: flex; gap: 6px; background: #eef1f5; padding: 4px; border-radius: 12px; }
.seg {
  flex: 1; border: none; background: transparent; font-size: 13px; font-weight: 600;
  padding: 11px 6px; border-radius: 9px; color: var(--muted);
}
.seg.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(11,31,58,.12); }

.more-options { padding: 0; }
.more-summary { list-style: none; cursor: pointer; padding: 15px 14px; font-size: 14px; font-weight: 700; color: var(--ink); display: flex; align-items: center; }
.more-summary::-webkit-details-marker { display: none; }
.more-summary::after { content: "▾"; margin-left: auto; color: var(--muted); font-weight: 400; }
details[open] .more-summary::after { content: "▴"; }
.more-body { padding: 0 14px 16px; }
.more-h { font-size: 14px; font-weight: 700; margin: 2px 0 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-size: 13px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
}
.chip.on { background: var(--warn); border-color: var(--warn); color: #fff; }

.btn-primary {
  width: 100%; font-size: 17px; font-weight: 700; color: #fff; background: var(--accent);
  border: none; border-radius: 12px; padding: 16px; margin: 4px 0 8px;
}
.btn-primary:active { background: var(--accent-2); }
.btn-primary:disabled { opacity: .6; }

.result { margin-top: 6px; }
.headline {
  background: var(--navy); color: #fff; border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.headline .lead { font-size: 13px; color: #9fb2cc; }
.headline .move { font-size: 21px; font-weight: 800; margin-top: 2px; }
.headline .move b { color: #7ee2a8; }

.map-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 12px; }
.map-wrap svg { width: 100%; height: auto; display: block; }

.legcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.leg { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.leg:last-child { border-bottom: none; }
.leg .num { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.leg .body { flex: 1; }
.leg .lane { font-weight: 700; font-size: 15px; }
.leg .stats { font-size: 12px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap;
  border: none; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 3px; }
.tag.good { background: #e3f4ec; color: var(--good); }
.tag.warn { background: #fbe9df; color: var(--warn); }
.tag.mid { background: #eef1f5; color: var(--muted); }
.tag-i { font-size: 10px; opacity: .5; font-weight: 400; }
.legtip { font-size: 11.5px; color: var(--ink); line-height: 1.45; margin-top: 7px;
  background: #f4f6f9; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

/* --- weather callouts --- */
.wx { background: #fff7ed; border: 1px solid #f4c89a; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.wx-h { font-size: 13px; font-weight: 800; color: var(--warn); margin-bottom: 6px; }
.wx-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid #f4d9bd; }
.wx-row:first-of-type { border-top: none; }
.wx-info { min-width: 0; }
.wx-mkt { font-size: 14px; font-weight: 700; }
.wx-ev { font-size: 12px; color: var(--warn); }
.wx-btn { flex: none; font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid var(--warn);
  background: #fff; color: var(--warn); border-radius: 9px; padding: 8px 11px; cursor: pointer; }
.wx-btn:active { background: var(--warn); color: #fff; }
.wx-toggle { font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 8px 13px; margin-bottom: 12px; cursor: pointer; }
.wx-toggle.on { background: #fff7ed; border-color: #f4c89a; color: var(--warn); }

.update { background: #eef6f1; border: 1px solid #cfe6d8; border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 11px 13px; margin-bottom: 12px; }
.update-h { font-size: 12px; font-weight: 800; color: var(--accent-2); margin-bottom: 3px; }
.update-b { font-size: 13px; color: var(--ink); line-height: 1.45; }

/* seasoned drivers: hide the beginner explainer sub-text */
body.seasoned .helper { display: none; }

/* --- Quickstart onboarding overlay --- */
.onboard { position: fixed; inset: 0; z-index: 100; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 24px; }
.onboard[hidden] { display: none; } /* author display:flex otherwise overrides the hidden attribute */
.ob-card { width: 100%; max-width: 420px; text-align: center; color: #fff; }
.ob-logo { font-size: 34px; font-weight: 800; letter-spacing: 1.5px; }
.ob-logo span { color: var(--accent); }
.ob-tagline { font-size: 13px; color: #9fb2cc; margin: 6px 0 28px; }
.ob-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 22px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: #2f5a44; display: inline-block; transition: width .2s; }
.ob-dots i.on { background: var(--accent); width: 22px; border-radius: 4px; }
.ob-dots i.done { background: #7ee2a8; }
.ob-q { font-size: 22px; font-weight: 800; margin-bottom: 22px; line-height: 1.3; }
.ob-opts { display: flex; flex-direction: column; gap: 10px; }
.ob-opt { font-size: 17px; font-weight: 700; color: #fff; background: rgba(255,255,255,.08); border: 1px solid #2f5a44; border-radius: 12px; padding: 16px; cursor: pointer; }
.ob-opt:active { background: var(--accent); border-color: var(--accent); }
.ob-skip { margin-top: 24px; background: none; border: none; color: #9fb2cc; font-size: 13px; text-decoration: underline; cursor: pointer; }

.infeasible { background: #fdecec; border: 1px solid #f3b4b4; border-radius: var(--radius); padding: 16px; }
.inf-h { font-size: 15px; font-weight: 800; color: #b42318; margin-bottom: 4px; }
.inf-b { font-size: 13px; color: var(--ink); line-height: 1.5; }

.summary { display: flex; gap: 10px; margin: 12px 0; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .l { font-size: 11px; color: var(--muted); }

.app-footer {
  max-width: var(--maxw); margin: 0 auto; padding: 14px; text-align: center;
  font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px;
}
.app-footer .powered b { color: var(--accent-2); }
.spin { text-align: center; color: var(--muted); padding: 18px; font-size: 14px; }
.recruit { background: var(--card); border: 0.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.recruit-h { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.badge-spon { font-size: 10px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; }
.recruit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.rco { font-size: 14px; font-weight: 600; }
.rnote { font-size: 12px; color: var(--muted); }
.rpay { font-size: 14px; font-weight: 700; color: var(--accent-2); white-space: nowrap; }

/* --- view tabs (Plan / Market) --- */
.tabs { display: flex; gap: 6px; background: #eef1f5; padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tab { flex: 1; border: none; background: transparent; font-size: 14px; font-weight: 700; padding: 11px 6px; border-radius: 9px; color: var(--muted); }
.tab.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(11,31,58,.12); }

/* --- market momentum --- */
.mkt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.mov-grid { display: flex; gap: 14px; }
.mov-grid > div { flex: 1; min-width: 0; }
.mov-h { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.mov-h.up { color: var(--good); }
.mov-h.down { color: var(--warn); }
.mov-list { list-style: none; margin: 0; padding: 0; }
.mov-list li { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.mov-list li:active { background: #eef6f4; }
.mov-list .mc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-list .md { font-weight: 700; white-space: nowrap; }
.mov-list .md.up { color: var(--good); }
.mov-list .md.down { color: var(--warn); }
.mov-list .mc { display: flex; align-items: center; gap: 7px; }
.heat-pip { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

/* --- heat map legend --- */
.heat-legend { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 8px; font-size: 10px; color: var(--muted); }
.heat-bar { flex: none; width: 120px; height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, hsl(205 80% 47%), hsl(140 80% 47%), hsl(55 80% 47%), hsl(20 80% 47%)); }

/* --- profile page --- */
.profile-h { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--accent-2); margin: 22px 4px 9px; }
.profile-h:first-child { margin-top: 6px; }
#profileSetupSlot:empty { display: none; }
.route-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.route-row:first-child { padding-top: 2px; }
.route-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.route-main { flex: 1; min-width: 0; }
.route-lane { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.route-meta { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: capitalize; }
.route-pay { font-size: 12.5px; color: var(--good); font-weight: 700; margin-top: 3px; }
.route-rerun { flex: none; background: var(--accent); color: #fff; border: none; border-radius: 9px;
  padding: 9px 15px; font-size: 13px; font-weight: 700; cursor: pointer; }
.route-rerun:active { transform: translateY(1px); }

/* text link (forgot password) */
.link-btn { background: none; border: none; color: var(--accent-2); font-size: 12.5px; padding: 8px 0 2px; cursor: pointer; text-decoration: underline; font-family: inherit; }
.link-btn:active { opacity: .7; }

/* recent-routes: type badge + expandable stop path */
.route-head { display: flex; align-items: center; gap: 8px; }
.route-type { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; padding: 2px 7px; border-radius: 6px; background: #eef1f5; color: #54606e; flex: none; }
.route-type.roundtrip { background: #eef9f1; color: var(--accent-2); }
.route-caret { margin-left: auto; color: var(--muted); font-size: 12px; transition: transform .15s; }
.route-expandable { cursor: pointer; }
.route-expandable.open .route-caret { transform: rotate(180deg); }
.route-path { margin-top: 8px; font-size: 12.5px; color: var(--accent-2); font-weight: 600; line-height: 1.55; }

/* "how it works" links */
.how-link { display: block; text-align: center; color: var(--accent-2); text-decoration: none; font-weight: 600; font-size: 13px; padding: 14px 0 4px; }
.how-link:active { opacity: .7; }
.how-foot { color: var(--accent-2); text-decoration: none; font-weight: 600; }
