:root {
  --primary: #0ea5a4;
  --primary-d: #0b7f7e;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --card: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --gold: #b7791f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #0ea5a4 0%, #0f766e 220px, #f1f5f9 220px, #f1f5f9 100%);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.wrap { max-width: 480px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 32px; }
.brand { color: #fff; text-align: center; padding: 8px 0 16px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .3px; }
.brand p { margin: 5px 0 0; opacity: .92; font-size: 13px; }

.card { background: var(--card); border-radius: 16px; box-shadow: 0 10px 30px rgba(2, 6, 23, .12); padding: 20px; margin-bottom: 16px; }
h2 { margin: 0 0 14px; font-size: 18px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
label .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
label .dot.from { background: var(--primary); }
label .dot.to { background: var(--danger); }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.btn { width: 100%; padding: 13px; border: none; border-radius: 10px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 18px; }
.btn:hover { background: var(--primary-d); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.link { background: none; color: var(--primary); font-weight: 600; margin: 0; padding: 8px; width: auto; cursor: pointer; }
.btn.sm { width: auto; margin: 0; padding: 8px 14px; font-size: 13px; }

.row { display: flex; gap: 10px; } .row > * { flex: 1; min-width: 0; }
.msg { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-top: 14px; display: none; line-height: 1.45; }
.msg.show { display: block; }
.msg.err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.msg.ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.topbar { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 4px 2px 6px; }
.topbar .u { font-size: 13px; }
a.plain { color: var(--primary); }

/* Thẻ thu nhập */
.earn-card { background: linear-gradient(135deg, #0ea5a4, #0f766e); color: #fff; }
.earn-card .earn-label { font-size: 12.5px; opacity: .92; }
.earn-card .earn-total { font-size: 28px; font-weight: 800; margin-top: 2px; letter-spacing: .2px; font-variant-numeric: tabular-nums; }
.earn-card .earn-sub { font-size: 12.5px; opacity: .92; margin-top: 6px; line-height: 1.5; }
.earn-card .earn-btn { margin-top: 12px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .5); color: #fff; }
.earn-card .earn-btn:hover { background: rgba(255, 255, 255, .28); }

/* Nút huỷ chuyến trong lịch sử */
.hist-actions { margin-top: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.hist-actions .cancel-count { font-size: 13px; font-weight: 700; color: var(--danger); font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
.btn.hist-cancel { color: var(--danger); border-color: #fecaca; }
.btn.hist-cancel:hover { background: #fef2f2; }

/* Phân trang lịch sử */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.pager .pg-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--primary); font-size: 20px; font-weight: 700; cursor: pointer; line-height: 1; }
.pager .pg-btn:hover:not(:disabled) { background: #ecfeff; }
.pager .pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager .pg-info { font-size: 13px; color: var(--muted); font-weight: 600; min-width: 84px; text-align: center; }

/* Nút hỗ trợ Zalo (nổi) */
.support-fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 900;
  display: flex; align-items: center; gap: 7px; padding: 11px 16px 11px 13px;
  background: #0068ff; color: #fff; border-radius: 999px; text-decoration: none;
  font-weight: 700; font-size: 14px; box-shadow: 0 8px 22px rgba(0, 104, 255, .45);
}
.support-fab:hover { background: #0055d4; }
.support-fab:active { transform: scale(.96); }
.support-fab svg { width: 22px; height: 22px; flex: none; }

/* Trang hướng dẫn cài PWA */
.install-hero { text-align: center; }
.install-hero .install-icon { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 8px 24px rgba(2, 6, 23, .2); margin-bottom: 6px; }
.install-hero h2 { margin: 10px 0 8px; }
.install-hero .muted { font-size: 13.5px; line-height: 1.55; }
.install-hero .btn { max-width: 260px; margin-left: auto; margin-right: auto; }
.guide h3 { margin: 0 0 12px; font-size: 15px; color: var(--primary-d); }
.guide .steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.guide .steps li { position: relative; padding: 0 0 14px 40px; font-size: 14px; line-height: 1.5; counter-increment: step; }
.guide .steps li::before { content: counter(step); position: absolute; left: 0; top: -1px; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.guide .steps li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 28px; bottom: 4px; width: 2px; background: var(--border); }
.guide .done-note { margin: 6px 0 0; padding: 10px 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; color: #166534; font-size: 13px; }
.ic-share { display: inline-block; width: 15px; height: 17px; vertical-align: -3px; border: 2px solid currentColor; border-top: none; border-radius: 3px; position: relative; }
.ic-share::before { content: ""; position: absolute; left: 50%; top: -8px; transform: translateX(-50%); width: 2px; height: 9px; background: currentColor; }
.ic-share::after { content: ""; position: absolute; left: 50%; top: -8px; transform: translateX(-50%) rotate(45deg); width: 6px; height: 6px; border-top: 2px solid currentColor; border-left: 2px solid currentColor; }

/* Hộp xác nhận (modal) */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(2, 6, 23, .5); backdrop-filter: blur(2px); opacity: 0; transition: opacity .18s ease; }
.modal-overlay.show { opacity: 1; }
.modal { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 22px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, .4); transform: translateY(10px) scale(.97); transition: transform .18s ease; }
.modal-overlay.show .modal { transform: none; }
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.modal-body { font-size: 14.5px; color: var(--text); line-height: 1.55; }
.modal-route { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.modal-route .leg .txt, .modal-route .leg span:last-child { font-size: 14px; line-height: 1.35; }
.modal-total { font-size: 26px; font-weight: 800; color: #166534; text-align: center; margin: 14px 0 6px; font-variant-numeric: tabular-nums; }
.modal-note { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { margin-top: 0; }
.btn.danger { background: var(--danger); color: #fff; border: none; }
.btn.danger:hover { background: #b91c1c; }

/* Tài xế saycar (khối trong thẻ mã mời) */
.drv-box { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px dashed var(--border); background: #f8fafc; border-radius: 12px; padding: 12px 14px; margin-top: 14px; }

/* Mã mời */
.inv-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; letter-spacing: 1.5px; cursor: pointer; user-select: all; }
.inv-code.copied { color: var(--ok); }

/* Rút tiền: ô thông tin nhận tiền đã lưu */
.bank-box { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--border); background: #f8fafc; border-radius: 12px; padding: 12px 14px; margin-top: 14px; }
.bank-box .bank-line { font-size: 14px; }

/* Ô gợi ý địa chỉ */
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(2, 6, 23, .16); max-height: 240px; overflow-y: auto; }
.ac-item { padding: 11px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: #ecfeff; }
.ac-item .main { font-weight: 600; font-size: 14px; }
.ac-item .sec { color: var(--muted); font-size: 12px; }
.ac-empty { padding: 11px 14px; color: var(--muted); font-size: 13px; }

/* Hộp giá */
.price-box { margin-top: 16px; border: 1px solid #bbf7d0; background: #f0fdf4; border-radius: 12px; padding: 14px 16px; }
.price-box .route { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.4; }
.price-box .total { font-size: 26px; font-weight: 800; color: #166534; font-variant-numeric: tabular-nums; }
.price-box .brk { font-size: 12px; color: var(--muted); margin-top: 7px; }

/* Thẻ chuyến */
.hist-item { border: 1px solid var(--border); border-radius: 12px; padding: 13px; margin-top: 12px; }
.hist-item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.hist-item .meta { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.pill.pending { background: #fef9c3; color: #854d0e; }
.pill.success { background: #dcfce7; color: #166534; }
.pill.failed { background: #fee2e2; color: #991b1b; }
.leg { display: flex; align-items: flex-start; gap: 10px; position: relative; }
.leg + .leg { margin-top: 5px; }
.leg .pin { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex: none; z-index: 1; }
.leg.from .pin { background: var(--primary); }
.leg.to .pin { background: var(--danger); }
.leg.from::before { content: ""; position: absolute; left: 4px; top: 13px; bottom: -6px; width: 1.5px; background: var(--border); }
.leg .txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.hist-item .sub { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.hist-item .sub b { color: var(--text); font-weight: 600; }
.hist-item .err { color: var(--danger); font-size: 12.5px; margin-top: 6px; overflow-wrap: anywhere; }
.comm { font-size: 13px; font-weight: 700; margin-top: 10px; color: var(--muted); }
.comm.earned { color: var(--ok); }
