/* Sổ tay xe 2.0 — layout.css · khung điện thoại (CHỈ điện thoại dọc) · © Kiên VC
 * Một cột căn giữa, tối đa --col (480px). Thanh điều hướng dưới LUÔN hiện, ở mọi chiều rộng. Không sidebar / rail / breakpoint máy tính.
 * Hỗ trợ 320 – 430 px; màn rộng hơn chỉ là cùng cột đó căn giữa. */
:root { --gxl: calc(var(--gutter) + var(--sal)); --gxr: calc(var(--gutter) + var(--sar)); }
body { --offtop: 0px; }
body.is-offline { --sat-eff: 0px; --offh: 28px; --offtop: calc(var(--sat) + 28px); }
@media (min-width: 481px) { html { background: var(--surface-3); } }

#app { position: relative; max-width: var(--col); margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--canvas); }
@media (min-width: 481px) { #app { box-shadow: 0 0 0 1px var(--border); } }
#view { min-width: 0; padding: var(--offtop) var(--gxr) calc(var(--nav-h) + var(--sab) + 28px) var(--gxl); }
#view.notab { padding-bottom: calc(var(--sab) + 32px); }
#view.has-fab { padding-bottom: calc(var(--nav-h) + var(--sab) + 96px); }
#view.notab.has-fab { padding-bottom: calc(var(--sab) + 96px); }
body.kb #view { padding-bottom: 24px; }
body.kb #tabbar, body.kb .fab-cta { display: none; }
#view > .empty:first-child { padding-top: calc(var(--sat-eff) + 56px); }

/* ---------- thanh tiêu đề (UI.top) ---------- */
.top {
  position: sticky; top: var(--offtop); z-index: 20; margin: 0 calc(-1 * var(--gxr)) 0 calc(-1 * var(--gxl));
  padding: calc(var(--sat-eff) + 6px) calc(var(--gxr) - 6px) 6px calc(var(--gxl) - 6px);
  min-height: calc(var(--sat-eff) + 56px); display: flex; align-items: center; gap: 4px;
  background: var(--canvas); border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--border); }
.top .l, .top .r { flex: 1 1 0; min-width: 44px; display: flex; align-items: center; }
.top .r { justify-content: flex-end; }
.top .t { flex: 0 1 auto; max-width: 58%; min-width: 0; text-align: center; font-weight: 600; font-size: 17px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 16px; padding: 0 10px; min-height: 44px; min-width: 44px; border-radius: var(--r-ctl); white-space: nowrap; }
.tbtn:active { opacity: .55; }
.tbtn.danger { color: var(--st-over-fg); }
.tbtn:disabled { opacity: .4; }
.tbtn.back { gap: 0; margin-left: -4px; padding-left: 4px; }
.tbtn.back .bi { width: 22px; height: 22px; flex: none; display: inline-block; }
.tbtn.back .bi svg { width: 22px; height: 22px; }
.tbtn.back .ell { max-width: 96px; }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; color: var(--text); border-radius: var(--r-ctl); flex: none; padding: 0; }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn:active { background: var(--surface-3); transform: scale(.94); }
.iconbtn .ib-badge { position: absolute; top: 0; right: -2px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 10px; background: var(--danger-btn); color: #fff; font-size: 12px; font-weight: 700; line-height: 16px; text-align: center; border: 2px solid var(--canvas); box-sizing: content-box; }
.iconbtn.tonal { background: var(--surface); border: 1px solid var(--border); }

/* tiêu đề trang gốc (không có nút Quay lại): lời chào / tên mục + icon phải */
.phead { display: flex; align-items: center; gap: 12px; padding: calc(var(--sat-eff) + 10px) 0 6px; min-height: calc(var(--sat-eff) + 64px); }
.phead .pt { flex: 1 1 auto; min-width: 0; }
.phead .ps { font-size: var(--fs-cap); color: var(--text-2); font-weight: 500; }
.phead h1 { font-size: var(--fs-title); line-height: 1.15; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.phead .pr { display: flex; align-items: center; gap: 2px; flex: none; margin-right: -6px; }

/* ---------- thanh điều hướng dưới (5 mục, mọi chiều rộng) ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: var(--col); z-index: 30;
  background: var(--nav-bg); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border); padding-bottom: var(--sab);
}
#tabbar .in { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: var(--nav-h); }
#tabbar button { position: relative; border: 0; background: none; color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; letter-spacing: -.01em; padding: 4px 0 2px; min-width: 0; min-height: 44px; line-height: 1.1; }
#tabbar button svg { width: 24px; height: 24px; }
#tabbar .tabi { display: flex; flex-direction: column; align-items: center; gap: 3px; max-width: 100%; }
#tabbar button.on { color: var(--accent); }
#tabbar button.on:not(.plus)::before { content: ""; position: absolute; top: 0; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 3px 3px; background: var(--blue); }
#tabbar button:active:not(.plus) { opacity: .6; }
#tabbar .plus { overflow: visible; }
#tabbar .plus .plus-b { width: 52px; height: 52px; border-radius: 50%; background: var(--btn); color: #fff; display: grid; place-items: center; margin-top: -24px; border: 4px solid var(--surface); box-shadow: 0 6px 16px rgba(43, 107, 230, .35); transition: transform .12s; }
#tabbar .plus .plus-b svg { width: 26px; height: 26px; stroke-width: 2.4; }
#tabbar .plus:active .plus-b { transform: scale(.94); }
#tabbar .plus .tabl { color: var(--text-2); }

/* ---------- nút "＋ Ghi hoạt động" cố định phía trên thanh dưới ---------- */
.fab-cta { position: fixed; left: 0; right: 0; margin: 0 auto; max-width: var(--col); bottom: calc(var(--nav-h) + var(--sab) + 20px); z-index: 25; display: flex; justify-content: flex-end; padding: 0 var(--gxr) 0 var(--gxl); pointer-events: none; }
.fab-cta .btn { pointer-events: auto; min-height: 52px; border-radius: var(--r-pill); padding: 0 20px 0 16px; box-shadow: var(--sh-3); }
#view.notab .fab-cta { bottom: calc(var(--sab) + 16px); }

/* ---------- thanh nút cố định cuối form ---------- */
.sticky-actions { position: sticky; bottom: 0; margin: 20px calc(-1 * var(--gxr)) 0 calc(-1 * var(--gxl)); padding: 12px var(--gxr) calc(var(--sab) + 12px) var(--gxl); background: var(--nav-bg); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--border); z-index: 10; }

/* ---------- toast + dải ngoại tuyến ---------- */
#toast { position: fixed; left: 0; right: 0; margin: 0 auto; max-width: var(--col); bottom: calc(var(--nav-h) + var(--sab) + 14px); z-index: 70; display: flex; justify-content: center; pointer-events: none; padding: 0 var(--gutter); }
#toast.notab { bottom: calc(var(--sab) + 88px); }
#toast.hasfab { bottom: calc(var(--nav-h) + var(--sab) + 84px); }
#toast.notab.hasfab { bottom: calc(var(--sab) + 84px); }
#offline { position: fixed; top: 0; left: 0; right: 0; margin: 0 auto; max-width: var(--col); z-index: 55; background: #3A4558; color: #fff; text-wrap: balance; font-size: 13px; font-weight: 600; line-height: 18px; text-align: center; padding: calc(var(--sat) + 5px) 12px 5px; pointer-events: none; }
#offline svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }

/* ---------- lớp phủ (sheet / hộp thoại) ---------- */
#layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- cổng cài đặt iOS (chưa cài vào Màn hình chính) ---------- */
.gate { padding: calc(var(--sat-eff) + 20px) 0 96px; }
.gate .g-head { text-align: center; }
.gate .g-logo { display: block; width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 20px; box-shadow: var(--sh-2); }
.gate h1 { font-size: 28px; line-height: 1.12; font-weight: 700; letter-spacing: -.025em; }
.gate .g-tag { display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: var(--r-pill); background: var(--blue-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.gate .g-sub { color: var(--text-2); font-size: 14px; margin-top: 10px; }
.gate .g-steps { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.gate .g-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.gate .g-step.hot { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.gate .g-fig { background: var(--surface-2); border-bottom: 1px solid var(--border); line-height: 0; }
.gate .g-fig svg { display: block; width: 100%; height: auto; }
.gate .g-cap { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; font-size: 14px; }
.gate .g-cap .n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--btn); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.gate .g-cap b { font-weight: 700; }
.gate .g-actions { margin-top: 16px; display: grid; gap: 10px; }
/* hình minh hoạ 3 bước (inline SVG, theo màu giao diện sáng/tối) */
.f-bg { fill: var(--surface-2); } .f-panel { fill: var(--border); } .f-bar { fill: var(--surface); } .f-line { stroke: var(--border-strong); stroke-width: 1; }
.f-ico { fill: none; stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; } .f-ico.hot { stroke: var(--accent); stroke-width: 2.4; }
.f-hotbg { fill: var(--blue-soft); } .f-hotring { fill: none; stroke: var(--blue); stroke-width: 2.5; }
.f-arrow { fill: none; stroke: var(--btn); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.f-lbl { fill: var(--accent); font-size: 12px; font-weight: 700; } .f-lbl2 { fill: var(--text); font-size: 12px; font-weight: 600; }
.f-app { fill: var(--surface-3); } .f-appmain { fill: var(--navy); } .f-glyph { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gate-arrow { position: fixed; left: 0; right: 0; margin: 0 auto; max-width: var(--col); bottom: 0; padding: 28px 0 calc(var(--sab) + 4px); background: linear-gradient(to bottom, transparent, var(--canvas) 55%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 0; pointer-events: none; color: var(--btn); }
.gate-arrow .ga-txt { background: var(--btn); color: #fff; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: var(--r-pill); box-shadow: var(--sh-2); }
.gate-arrow svg { width: 34px; height: 34px; animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
.arrow-bob { animation: bob 1.1s ease-in-out infinite; }

/* màn hình thấp (iPhone SE/8): nút cố định đưa xuống cuối nội dung để không che hàng tab của hồ sơ xe */
@media (max-height: 640px) {
  .fab-cta, #view.notab .fab-cta { position: static; max-width: none; margin: 12px 0 0; padding: 0; }
  .fab-cta .btn { width: 100%; justify-content: center; }
}
/* ---------- landscape: chỉ cần không vỡ bố cục ---------- */
@media (orientation: landscape) and (max-height: 480px) {
  :root { --nav-h: 52px; }
  #tabbar .plus .plus-b { width: 44px; height: 44px; margin-top: -14px; }
}
