:root { --g: #0d6e4f; --g2: #e6f4ee; --ink: #1d2530; --muted: #6b7684; --rule: #dde3e9; --bad: #c62828; --warn: #a15c00; --bg: #f3f6f8; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: var(--g); }
h2 { font-size: 1.15em; margin: .9em 0 .5em; }
h2 small, h3 small { font-weight: 400; color: var(--muted); font-size: .8em; margin-left: .3em; }
h3 { font-size: 1em; margin: 1em 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.warn { color: var(--warn); margin: .3em 0 0; }
.neg { color: var(--bad); }
.posv { color: var(--g); }
.empty { color: var(--muted); text-align: center; padding: 2em 1em; }

.btn { font: inherit; border: 1px solid var(--rule); background: #fff; color: var(--ink); border-radius: 10px; padding: .55em 1em; cursor: pointer; }
.btn.primary { background: var(--g); border-color: var(--g); color: #fff; font-weight: 600; }
.btn.danger { color: var(--bad); border-color: #f1b9b9; }
.btn.big { width: 100%; padding: .85em; font-size: 1.05em; }
.btn.sm { padding: .3em .6em; font-size: .85em; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.take { background: #ff8f00; border-color: #ff8f00; color: #fff; font-weight: 800; letter-spacing: .02em; }

input, select { font: inherit; width: 100%; padding: .6em .7em; border: 1px solid var(--rule); border-radius: 10px; background: #fff; margin-top: .25em; }
label { display: block; margin: .6em 0; font-size: .92em; color: #39424e; }
.card { background: #fff; border: 1px solid var(--rule); border-radius: 14px; padding: .9em 1em; margin: .8em 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7em; }
.row2 label { margin: .3em 0; }
.row-between { display: flex; gap: .6em; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-between h3 { margin: 0; }
.row-between input { width: auto; flex: 1; min-width: 12em; margin: 0; }

/* Đăng nhập */
.login { padding: 2em 1.2em; text-align: center; }
.login .logo { font-size: 3.2em; }
.login h1 { margin: .1em 0 0; color: var(--g); }
.login form { text-align: left; }
.seg { display: flex; background: #e3e9ee; border-radius: 12px; padding: 4px; margin: 1em 0 0; }
.seg a { flex: 1; padding: .55em; border-radius: 9px; text-decoration: none; color: var(--ink); font-weight: 600; }
.seg a.on { background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .1); }

/* Khung ứng dụng */
#head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .6em; padding: .6em 1em calc(.6em); padding-top: max(.6em, env(safe-area-inset-top)); background: var(--g); color: #fff; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { opacity: .9; }
.who .on { color: #b9f6ca; } .who .off { color: #ffcdd2; }
.pts { font: inherit; border: 0; border-radius: 12px; background: #fff; color: var(--g); font-weight: 900; font-size: 1.5em; padding: .1em .6em; line-height: 1.1; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.pts small { font-size: .45em; font-weight: 600; color: var(--muted); }
.pts.neg { color: var(--bad); }
#body { flex: 1; padding: 0 .9em 6em; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 640px; margin: 0 auto; display: flex; background: #fff; border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#nav button { flex: 1; font: inherit; font-size: .75em; border: 0; background: none; padding: .45em .2em .5em; color: var(--muted); display: flex; flex-direction: column; align-items: center; position: relative; cursor: pointer; }
#nav button span { font-size: 1.6em; line-height: 1.2; }
#nav button[aria-pressed='true'] { color: var(--g); font-weight: 700; box-shadow: inset 0 3px 0 var(--g); }
#nav small { position: absolute; top: .2em; left: 55%; background: #ff3d00; color: #fff; border-radius: 9px; padding: 0 .45em; font-size: .9em; font-weight: 700; }

/* Cuốc xe: điểm đón – điểm trả to rõ */
.trip { background: #fff; border: 1px solid var(--rule); border-radius: 16px; padding: .8em 1em; margin: .7em 0; box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.trip.st-OPEN { border-left: 5px solid #ff8f00; }
.trip.st-TAKEN { border-left: 5px solid var(--g); }
.trip.st-CANCELLED { opacity: .65; }
.trip-top { display: flex; justify-content: space-between; align-items: center; font-size: .85em; }
.tp { background: #fff3e0; color: #e65100; font-weight: 800; border-radius: 8px; padding: .1em .55em; font-size: 1.1em; }
.route { margin: .5em 0; position: relative; padding-left: 1.5em; }
.route::before { content: ''; position: absolute; left: .45em; top: .9em; bottom: .9em; border-left: 3px dotted #b0bec5; }
.pt { position: relative; margin: .2em 0; }
.pt::before { content: ''; position: absolute; left: -1.38em; top: .45em; width: .8em; height: .8em; border-radius: 50%; }
.pt.a::before { background: var(--g); }
.pt.b::before { background: var(--bad); }
.pt i { display: block; font-style: normal; font-size: .72em; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.pt b { display: block; font-size: 1.3em; line-height: 1.25; }
.when, .note, .by, .state, .cus { font-size: .92em; margin: .25em 0; }
.note { background: #fffde7; border-radius: 8px; padding: .3em .6em; }
.state { color: var(--g); }
.st-CANCELLED .state { color: var(--bad); }
.cus { font-weight: 700; }
.acts { display: flex; gap: .5em; flex-wrap: wrap; margin-top: .6em; }
.tag { margin: 1em 0 -.5em .3em; font-size: .8em; font-weight: 700; }
.tag.give { color: var(--g); } .tag.got { color: #e65100; }

/* Điểm */
.balance { background: linear-gradient(135deg, var(--g), #14966b); color: #fff; border-radius: 18px; padding: 1em 1.2em; margin: 1em 0; text-align: center; }
.balance.neg { background: linear-gradient(135deg, #b71c1c, #e53935); }
.balance small { opacity: .9; }
.balance > b { display: block; font-size: 3em; line-height: 1.1; }
.bal-btns { display: flex; gap: .6em; justify-content: center; margin-top: .6em; }
.balance .btn.primary { background: #fff; color: var(--g); }
.reqs { list-style: none; padding: 0; margin: 0; }
.req { display: flex; justify-content: space-between; gap: .6em; align-items: center; background: #fff; border: 1px solid var(--rule); border-radius: 12px; padding: .6em .8em; margin: .4em 0; }
.req-btns { display: flex; gap: .3em; flex-wrap: wrap; justify-content: flex-end; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; font-size: .88em; }
.tbl th, .tbl td { padding: .4em .5em; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .9em; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.locked td { opacity: .6; }
.ubtns { display: flex; flex-wrap: wrap; gap: .25em; justify-content: flex-end; }
.info p { display: flex; justify-content: space-between; margin: .4em 0; }
.info span { color: var(--muted); }

/* Hộp thoại, thông báo */
#dialog { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: flex; align-items: center; justify-content: center; padding: 1em; z-index: 20; }
#dialog[hidden] { display: none; }
.dlg { background: #fff; border-radius: 16px; padding: 1em 1.1em; width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; }
.dlg.wide { max-width: 640px; }
.dlg h3 { margin-top: 0; }
.dlg .scroll { max-height: 60vh; overflow: auto; }
.dlg-btns { display: flex; gap: .5em; justify-content: flex-end; margin-top: 1em; }
.dlg-body p { margin: .4em 0; }
.big-route { font-size: 1.2em; line-height: 1.4; }
#toast { position: fixed; left: 50%; bottom: 5.5em; transform: translateX(-50%); background: #263238; color: #fff; padding: .7em 1em; border-radius: 12px; max-width: 92vw; z-index: 30; box-shadow: 0 4px 16px rgb(0 0 0 / .25); }
#toast.bad { background: var(--bad); }
#toast[hidden] { display: none; }

/* Định vị */
.loc { margin: -.3em 0 .6em; display: flex; flex-wrap: wrap; gap: .4em; align-items: center; }
.loc [data-link] { flex: 1; min-width: 12em; margin: 0; font-size: .9em; padding: .45em .6em; }
.loc-st { flex-basis: 100%; }
.loc-st:empty { display: none; }
.maps { display: flex; flex-wrap: wrap; gap: .35em; margin: .4em 0; }
.maps a.btn { text-decoration: none; display: inline-block; }
.maps .muted { flex-basis: 100%; }
.dist { font-weight: 700; color: var(--g); }
