: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); }

/* Thanh toán điểm cuốc: hai bên xác nhận */
.pay { margin-top: .6em; border: 1px solid #b9dfcc; background: var(--g2); border-radius: 12px; padding: .6em .8em; }
.pay.wait { border-color: #ffb74d; background: #fff8e1; }
.pay.done { color: var(--g); font-size: .92em; }
.pay-amt b { font-size: 1.2em; }
.pay-note { font-size: .9em; margin: .2em 0; }
.pay-st { display: flex; flex-wrap: wrap; gap: .3em 1em; font-size: .88em; color: var(--muted); margin: .3em 0; }
.pay-st .ok { color: var(--g); font-weight: 600; }
.pay .acts { margin-top: .4em; }
.dot { background: #ff3d00; color: #fff; border-radius: 9px; padding: 0 .45em; font-size: .8em; }

/* Chat */
.chat-tab h2 { margin-bottom: .3em; }
.chat { display: flex; flex-direction: column; }
.msgs { display: flex; flex-direction: column; gap: .45em; padding: .3em 0 4.2em; }
.msg { max-width: 82%; align-self: flex-start; }
.msg b { font-size: .85em; }
.msg small { color: var(--muted); font-size: .75em; }
.msg .bub { background: #fff; border: 1px solid var(--rule); border-radius: 4px 14px 14px 14px; padding: .45em .7em; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; text-align: right; }
.msg.me .bub { background: var(--g); color: #fff; border-color: var(--g); border-radius: 14px 4px 14px 14px; text-align: left; }
.msg.me .bub a { color: #fff; }
.msg time { display: block; font-size: .72em; color: var(--muted); margin-top: .1em; }
.msg.sys { align-self: center; max-width: 92%; text-align: center; font-size: .82em; color: #5d4037; }
.msg.sys span { display: inline-block; background: #fff3e0; border-radius: 10px; padding: .3em .7em; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(3.6em + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; display: flex; gap: .4em; padding: .5em .7em; background: var(--bg); border-top: 1px solid var(--rule); z-index: 4; }
.composer input { margin: 0; }
#tripChat { position: fixed; inset: 0; z-index: 15; background: var(--bg); display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
#tripChat header { display: flex; gap: .6em; align-items: center; padding: .6em .8em; padding-top: max(.6em, env(safe-area-inset-top)); background: var(--g); color: #fff; }
#tripChat header small { display: block; opacity: .9; }
#tripChat .chat { flex: 1; overflow: auto; padding: 0 .9em; }
#tripChat .msgs { padding-bottom: 1em; }
#tripChat .composer { position: static; padding-bottom: max(.5em, env(safe-area-inset-bottom)); }
.req.hl { border-color: #ffb74d; background: #fff8e1; }
.tbl.bal td { vertical-align: top; }
.tbl.bal .btn { margin-top: .3em; }

/* Nhiều người cùng nhận cuốc */
.claim { margin-top: .6em; border: 2px solid #ff8f00; background: #fff3e0; border-radius: 12px; padding: .6em .8em; }
.claim [data-until] { font-size: 1.15em; font-variant-numeric: tabular-nums; }
.crowd { margin: .4em 0 0; font-size: .9em; color: #6d4c41; }
.claimers { margin-top: .5em; background: #fff8e1; border-radius: 10px; padding: .5em .7em; font-size: .92em; }

/* Yên lặng tin nhắn */
.btn.mute { font-size: 1.05em; }
.btn.mute.on { background: #eceff1; }
.mute-opts { display: flex; flex-direction: column; gap: .4em; }
#nav small.quiet, .dot.quiet { background: #90a4ae; }
#tripChat .tc-title { flex: 1; min-width: 0; }
#tripChat header .btn.mute { background: rgb(255 255 255 / .15); border-color: transparent; color: #fff; }

/* Gọi thoại trong ứng dụng */
.btn.callb { background: #e8f5e9; border-color: #a5d6a7; color: var(--g); font-weight: 600; }
#call { position: fixed; inset: 0; z-index: 40; background: linear-gradient(160deg, #0d6e4f, #062e22); color: #fff; display: flex; align-items: center; justify-content: center; padding: 1.5em; }
#call.in { background: linear-gradient(160deg, #1565c0, #0b2a55); }
.call-box { text-align: center; width: 100%; max-width: 360px; }
.call-ava { width: 96px; height: 96px; border-radius: 50%; background: rgb(255 255 255 / .18); display: flex; align-items: center; justify-content: center; font-size: 2.6em; font-weight: 800; margin: 0 auto .4em; }
#call.in .call-ava { animation: callpulse 1.2s ease-in-out infinite; }
@keyframes callpulse { 50% { box-shadow: 0 0 0 18px rgb(255 255 255 / .12); } }
.call-name { font-size: 1.6em; font-weight: 800; }
#call .muted { color: rgb(255 255 255 / .75); }
.call-st { margin: .8em 0 2em; font-size: 1.15em; font-variant-numeric: tabular-nums; }
.call-btns { display: flex; gap: 1em; justify-content: center; flex-wrap: wrap; }
.cbtn { font: inherit; font-weight: 700; border: 0; border-radius: 999px; padding: .9em 1.4em; background: rgb(255 255 255 / .2); color: #fff; cursor: pointer; min-width: 8em; }
.cbtn.red { background: #e53935; }
.cbtn.green { background: #2e7d32; }

/* Thành viên */
.seg.sub { margin: .8em 0 .2em; }
.seg.sub a { text-align: center; }
.members input#memFind { margin: .6em 0; }
.mem { display: flex; gap: .7em; align-items: center; background: #fff; border: 1px solid var(--rule); border-radius: 12px; padding: .55em .7em; margin: .4em 0; }
.mem-ava { position: relative; flex: none; width: 2.6em; height: 2.6em; border-radius: 50%; background: var(--g2); color: var(--g); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 1.1em; }
.mem-ava i { position: absolute; right: 0; bottom: 0; width: .7em; height: .7em; border-radius: 50%; background: #b0bec5; border: 2px solid #fff; }
.mem.on .mem-ava i { background: #00c853; }
.mem-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mem-info small { font-size: .82em; }
.mem-act { display: flex; flex-direction: column; gap: .3em; align-items: flex-end; }
.mem-act a.btn { text-decoration: none; }
.mem.tap { cursor: pointer; }
.mem.tap:active { background: var(--g2); }
.tagq { background: #fff3e0; color: #e65100; border-radius: 6px; padding: 0 .4em; }

/* Thống kê cuốc (quản trị) */
.stat-q { display: flex; gap: .5em; flex-wrap: wrap; align-items: flex-end; margin: .3em 0; }
.stat-q label { flex: 1; min-width: 9em; }
.stat-q.btns .btn { flex: none; }
.tbl.stat td.num, .tbl.stat th.num { white-space: nowrap; }
.tbl.stat th { font-size: .8em; }
.tbl.stat td:first-child { white-space: nowrap; }
.tbl.stat tr.dim { opacity: .5; }
.tbl.stat tr.sum td { font-weight: 800; border-top: 2px solid var(--rule); }
.card .scroll { overflow-x: auto; }

/* Ô tên đăng nhập + nút đổi bàn phím số / chữ */
.kbd-row { display: flex; gap: .4em; align-items: center; }
.kbd-row input { flex: 1; min-width: 0; }
.kbd-row .btn { flex: none; }

/* Quản lý tài khoản */
.tagq.mod { background: #e3f2fd; color: #1565c0; }
.pend { background: #fff8e1; border: 1px solid #ffe082; border-radius: 10px; padding: .5em .7em; margin: .5em 0; }
.pend h4 { margin: 0 0 .3em; }
.pend-row { display: flex; gap: .5em; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: .4em 0; border-top: 1px solid #ffe082; }
.pend-row:first-of-type { border-top: 0; }
#ufilter { margin: .5em 0; }

/* Đăng cuốc gõ tự do (+ nói) */
.quick-row { display: flex; gap: 8px; align-items: stretch; }
.quick-row textarea { flex: 1; font: inherit; font-size: 17px; line-height: 1.35; resize: vertical; min-height: 78px; padding: 8px 10px; }
.btn.mic { font-size: 24px; min-width: 56px; padding: 0 10px; }
.btn.mic.on { background: #d93025; color: #fff; animation: micpulse 1s infinite; }
@keyframes micpulse { 50% { opacity: .6; } }
.trip .free { font-size: 1.25em; font-weight: 700; line-height: 1.35; margin: .5em 0; white-space: pre-wrap; word-break: break-word; }
.loc-h { margin-bottom: -4px; }
.split { border-top: 1px dashed #ccd; padding-top: 8px; display: flex; flex-direction: column; gap: inherit; }
.row3 { display: grid; grid-template-columns: 1.3fr .7fr 1fr; gap: 8px; }
.trip .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: .3em 0; font-size: 1.05em; }
.barem-st { margin: -4px 0 8px; } .barem-st.ok { color: var(--g); }
.app-dl { display: block; text-align: center; margin-top: 14px; }
.barem-f fieldset { border: 1px solid #dfe5ea; border-radius: 10px; margin: 10px 0; padding: 6px 10px 10px; }
.barem-f legend { font-weight: 600; padding: 0 4px; }
.barem-f .brm input { width: 100%; min-width: 70px; }
.barem-f .brm td:last-child, .barem-f .brm th:last-child { width: 40px; }
.nowrap { white-space: nowrap; }
.warn-box { background: #fff7e6; border: 1px solid #f0c36d; }

/* Mã gắn Zalo ở trang Tài khoản */
.big-code { font-size: 1.4em; letter-spacing: 3px; }

/* Thống kê cuốc nhóm Zalo */
.tbl.zpost td { font-size: .92em; }
.tbl.zpost tr.dim { opacity: .5; }
#zMem { margin: .6em 0; }
#zMem summary { cursor: pointer; padding: .3em 0; }

/* Tự động Ok */
.agroups { border: 1px solid var(--rule); border-radius: 8px; padding: .4em .7em; margin: .5em 0; }
.agroups label.chk { display: flex; gap: .5em; align-items: center; margin: .25em 0; font-weight: normal; }
.agroups label.chk input { width: auto; }
#zAuto { margin: .6em 0; }
#zAuto summary { cursor: pointer; padding: .3em 0; }

/* ───── Máy tính (màn hình rộng): menu cột trái, Quản trị / Sổ điểm dùng cả chiều rộng ───── */
.zt-full { display: none; }
@media (min-width: 1000px) {
  #app:not(.shell) { max-width: 460px; }
  #app.shell { max-width: 1600px; display: grid; grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "head head" "nav body"; }
  #head { grid-area: head; padding-left: 1.5em; padding-right: 1.5em; }
  #nav { grid-area: nav; position: sticky; top: 4em; bottom: auto; left: auto; right: auto; max-width: none; margin: 1em 0 0; align-self: start;
    flex-direction: column; border: 1px solid var(--rule); border-radius: 14px; padding: .4em; gap: .15em; }
  #nav button { flex: none; flex-direction: row; gap: .6em; font-size: .95em; padding: .6em .8em; border-radius: 10px; justify-content: flex-start; }
  #nav button span { font-size: 1.25em; width: 1.3em; text-align: center; }
  #nav button[aria-pressed='true'] { box-shadow: none; background: var(--g2); }
  #nav small { position: static; margin-left: auto; }
  #body { grid-area: body; padding: 0 1.5em 2em; width: 100%; max-width: 820px; }
  body[data-tab="admin"] #body, body[data-tab="diem"] #body { max-width: none; }
  .composer { left: calc(max(0px, (100vw - 1600px) / 2) + 200px + 1.5em); right: auto; width: min(772px, calc(100vw - 200px - 3em)); max-width: none; bottom: 0; margin: 0; }
  #toast { bottom: 2em; }
  /* Quản trị: thẻ nhỏ (barem, cài đặt) xếp 2 cột, thẻ có bảng dùng cả hàng */
  .adm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.2em; align-items: start; grid-auto-flow: row dense; }
  .adm > * { grid-column: span 1; }
  .adm > .full { grid-column: 1 / -1; }
  .tbl { font-size: .92em; }
  .tbl.zpost td { font-size: .95em; }
  .zt-short { display: none; } .zt-full { display: inline; }
  .stat-q label { flex: 0 1 14em; }
  .row2 { gap: 1em; }
}
@media (min-width: 1400px) {
  #zaloCard .stat-q label { flex: 0 1 12em; }
}

/* Hộp chọn tính năng */
#dialog label.chk { display: flex; gap: .5em; align-items: center; margin: .45em 0; }
#dialog label.chk input { width: auto; margin: 0; }

/* Bảng cấp bổ lịch */
.tbl.lv input { width: 6em; margin: 0; padding: .35em .5em; }

/* Ô Bật / Tắt Bổ lịch: nổi bật */
.auto-onoff { padding: .5em .7em; border-radius: 10px; border: 2px solid; }
.auto-onoff.off { border-color: #e57373; background: #fff5f5; }
.auto-onoff.on { border-color: #66bb6a; background: #f1faf2; }
.auto-onoff b { display: block; }
