:root {
  --bg: #0f1219; --card: #171b26; --card2: #0f1219; --line: #232838;
  --text: #e8eaf0; --muted: #9aa3b8; --accent: #ffd21e; --accent2: #4c8dff;
  --driver: #29c467; --fee: #ffd21e; --danger: #ff5a5a;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must always win over any element's `display` rule below
   (e.g. #overlay{display:flex}); otherwise the modal/menu show on load. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
#map { position: fixed; inset: 0; }

/* Top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px;
  background: linear-gradient(180deg, rgba(15,18,25,.92), rgba(15,18,25,0));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand .logo { font-size: 20px; }
#account { display: flex; align-items: center; gap: 8px; }
#usermenu { display: flex; align-items: center; gap: 8px; }
.username { color: var(--muted); font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  background: var(--accent); color: #1a1a1a; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.big { width: 100%; padding: 14px; font-size: 15px; margin-top: 12px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.mini { border: 0; background: var(--line); color: var(--text); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }

/* Panel + cards */
#panel {
  position: fixed; z-index: 5; left: 14px; bottom: 14px; width: 380px; max-width: calc(100vw - 28px);
  display: flex; flex-direction: column; gap: 10px;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
#hero h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.2; }
#hero .accent { color: var(--accent); }
#hero p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Fields */
.field { display: flex; align-items: center; gap: 10px; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; margin-bottom: 8px; }
.field.activept { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(76,141,255,.25); }
.field input { flex: 1; border: 0; background: transparent; color: var(--text); font-size: 14px; padding: 10px 0; outline: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.pickup { background: var(--driver); }
.dot.dropoff { background: var(--accent2); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 2px 0; }

/* Suggestions */
#suggest { display: none; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
#suggest.open { display: block; }
.sug { padding: 10px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sug:last-child { border-bottom: 0; }
.sug:hover { background: #1b2130; }

/* Estimate + 95/5 split */
.estimate { margin-top: 6px; }
.fare-row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); font-size: 14px; }
.fare-row b { color: var(--text); }
.fare-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-size: 16px; }
.split { margin-top: 12px; }
.split-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--line); }
.split-bar .s-driver { width: 95%; background: var(--driver); }
.split-bar .s-fee { width: 5%; background: var(--fee); }
.split-legend { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); gap: 8px; }
.split-legend b { color: var(--text); }
.k-driver, .k-fee { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.k-driver { background: var(--driver); } .k-fee { background: var(--fee); }

/* Active ride */
.active-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pill { background: var(--accent2); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.pill.completed { background: var(--driver); } .pill.cancelled { background: var(--danger); }
.route-line { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.route-line .addr { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* History */
#historyList { max-height: 46vh; overflow: auto; }
.hride { border-bottom: 1px solid var(--line); padding: 10px 2px; }
.hride:last-child { border-bottom: 0; }
.hride .top { display: flex; justify-content: space-between; font-size: 13px; }
.hride .sub { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* FAB */
.fab { position: fixed; right: 14px; bottom: 24px; z-index: 5; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.fab svg { width: 22px; height: 22px; fill: currentColor; }

/* MapLibre markers */
.mk { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.mk.pickup { background: var(--driver); } .mk.dropoff { background: var(--accent2); }
.mk.car { width: 30px; height: 30px; border: 0; background: none; font-size: 24px; display: flex; align-items: center; justify-content: center; }

/* Segmented mode toggle */
.seg { display: inline-flex; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--accent); color: #1a1a1a; }

/* Avatar + menu */
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--accent2); color: #fff; font-weight: 700; cursor: pointer; }
.menu { position: fixed; top: 56px; right: 12px; z-index: 6; width: 240px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 16px 48px rgba(0,0,0,.5); }
.menu-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-head .muted { font-size: 12px; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); padding: 11px 12px; border-radius: 9px; font-size: 14px; cursor: pointer; }
.menu-item:hover { background: #1b2130; }
.menu-item.danger { color: var(--danger); }
.muted { color: var(--muted); }

/* Inputs (driver reg + settings) */
.in { width: 100%; padding: 11px 12px; margin-bottom: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font-size: 14px; outline: none; }
.in:focus { border-color: var(--accent2); }
.row2 { display: flex; gap: 8px; } .row2 .in { flex: 1; }
h2 { font-size: 18px; margin: 0 0 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0 4px; cursor: pointer; }
.req { color: var(--muted); font-size: 12px; }

/* Driver home */
.earn { display: flex; align-items: baseline; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 10px 0; font-size: 14px; color: var(--muted); }
.earn b { color: var(--driver); font-size: 18px; }
.drow { border-bottom: 1px solid var(--line); padding: 10px 2px; }
.drow:last-child { border-bottom: 0; }
.drow .top { display: flex; justify-content: space-between; font-size: 13px; }
.drow .sub { color: var(--muted); font-size: 12px; margin: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drow .acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.drow .acts .btn { padding: 6px 12px; font-size: 12px; }
.on-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #667; margin-right: 6px; }
.on-dot.live { background: var(--driver); box-shadow: 0 0 0 3px rgba(41,196,103,.25); }

/* Full-page views (profile / settings) — a solid page, NOT a modal over the map */
#page { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.page-head b { font-size: 18px; }
.iconbtn { background: transparent; border: 0; color: var(--text); font-size: 24px; line-height: 1; cursor: pointer; width: 38px; height: 38px; border-radius: 9px; }
.iconbtn:hover { background: #1b2130; }
.page-body { flex: 1; overflow-y: auto; padding: 20px 18px 40px; max-width: 620px; margin: 0 auto; width: 100%; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 16px; margin-bottom: 14px; }
.psec { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 4px 8px; }
.prof-hero { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.prof-av { width: 60px; height: 60px; border-radius: 50%; background: var(--accent2); color: #fff; font-weight: 700; font-size: 26px; display: flex; align-items: center; justify-content: center; flex: none; }
.prof-name { font-size: 20px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); flex: none; } .kv b { color: var(--text); word-break: break-all; text-align: right; }

@media (max-width: 480px) {
  #panel { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .brand { font-size: 16px; }
  .seg button { padding: 6px 12px; }
}
