/* ============================================================
   HỆ THỐNG THIẾT KẾ — ECAREMATRIX "Dark & Gold"
   Nền #1A0A0A/#120707 · Vàng #D4AF37 · Đỏ đô #7A1515
   Chữ: Be Vietnam Pro (UI) / Space Mono (số tiền, mã)
   (Giữ nguyên tên class — app.js không đổi)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
  --bg:         #120707;
  --bg2:        #1A0A0A;
  --surface:    #241414;
  --surface2:   #2c1413;
  --ink:        #efe3cf;
  --gold:       #D4AF37;
  --gold-dim:   #8a7128;
  --brand:      #7A1515;
  --brand-600:  #5a0f0f;
  --brand-tint: rgba(212,175,55,.10);
  --amber:      #E5A742;
  --amber-soft: rgba(229,167,66,.14);
  --flow:       #4FB477;
  --blue:       #5E8BD6;
  --line:       #3a2418;
  --line2:      #2a1810;
  --muted:      #B09B71;
  --danger:     #D2553C;
  --danger-soft:rgba(210,85,60,.14);
  --shadow:     0 14px 40px -16px rgba(0,0,0,.7);
  --radius:     15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.mono { font-family: 'Space Mono', monospace; }

/* ---------- Khung app (mô phỏng mobile, dùng được trên web) ---------- */
.app {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  background: var(--bg); display: flex; flex-direction: column; position: relative;
  box-shadow: 0 0 60px rgba(0,0,0,.55), inset 0 0 0 1px rgba(212,175,55,.16);
}
.topbar {
  background: linear-gradient(180deg,#1f0e0e,#160a0a); color: var(--ink);
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line);
}
.topbar .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); border:1px solid var(--gold);
  display: grid; place-items: center; font-weight: 800; color: var(--gold); font-size: 11px; flex:none;
}
.topbar h1 { font-size: 21px; font-weight: 800; letter-spacing: .4px; color: var(--gold); line-height:1.05; }
.topbar .sub { font-size: 11px; color: var(--muted); font-weight: 500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar .brandwrap{ display:flex; align-items:center; gap:11px; min-width:0; }
.topbar .brandtext{ min-width:0; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12px; color: var(--muted); text-align: right; white-space:nowrap; flex:none; }
.topbar .who b { color: var(--ink); display: block; white-space:nowrap; }
.topbar .tb-grp { display:flex; align-items:center; gap:9px; flex:none; }
.topbar .tb-ic { width:40px; height:40px; flex:none; border-radius:11px; background:rgba(212,175,55,.1); border:1px solid var(--gold-dim); color:var(--gold); display:grid; place-items:center; cursor:pointer; position:relative; font-family:inherit; padding:0; }
.topbar .tb-ic:hover { background:rgba(212,175,55,.18); }
.topbar .tb-ic svg { width:21px; height:21px; }
.topbar .tb-ic .nd { position:absolute; top:8px; right:9px; width:7px; height:7px; border-radius:50%; background:var(--danger); border:1.5px solid #160a0a; }
.topbar .tb-ava { background:linear-gradient(135deg,#7A1515,#3a0d0d); color:var(--gold); font-weight:800; font-family:'Space Mono',monospace; font-size:15px; }

.screen { flex: 1; padding: 18px 16px 96px; overflow-y: auto; }
.screen.center { display: flex; flex-direction: column; justify-content: center; }
.app > .screen.center{ flex:0 0 auto; justify-content:flex-start; padding-top:18px; }

/* ---------- Thành phần chung ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
h2.title, .title { font-size: 21px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 4px; color: var(--ink); }
.lead { color: var(--muted); font-size: 14px; margin-bottom: 16px; text-align: justify; }

.btn {
  width: 100%; border: 1px solid var(--gold); border-radius: 12px; padding: 14px 16px;
  font-family: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  background: linear-gradient(135deg,#e6c34e,#c08f22); color: #1A0A0A; transition: transform .06s, filter .15s;
}
.btn:active { transform: scale(.985); }
.btn:hover { filter: brightness(1.12); }
.btn.amber { background: linear-gradient(135deg,#E5A742,#c8821f); border-color:#E5A742; color:#1A0A0A; }
.btn.amber:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--gold); border:1px solid var(--gold-dim); }
.btn.ghost:hover { background: var(--brand-tint); }
.btn.lg { padding: 17px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.agree{ display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--muted); margin:4px 0 12px; cursor:pointer; }
.agree input{ width:16px; height:16px; accent-color:var(--gold); flex:none; }
.agree a{ color:var(--gold); }
.lnk{ color:var(--gold); font-weight:800; text-decoration:underline; }
.btn + .btn { margin-top: 10px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 11px;
  font-family: inherit; font-size: 15px; background: var(--surface); color: var(--ink);
}
.field input::placeholder, .field textarea::placeholder { color: rgba(176,155,113,.45); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }

.pill { display:inline-flex; align-items:center; justify-content:center; gap:5px; line-height:1; font-size: 11px; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
.pill.green  { background: rgba(79,180,119,.14); color: var(--flow); border:1px solid rgba(79,180,119,.4); }
.pill.amber  { background: var(--amber-soft); color: var(--amber); border:1px solid rgba(229,167,66,.4); }
.pill.gray   { background: rgba(176,155,113,.12); color: var(--muted); border:1px solid var(--line); }
.pill.blue   { background: rgba(94,139,214,.13); color: var(--blue); border:1px solid rgba(94,139,214,.4); }
.pill.gold   { background: var(--gold); color:#1a0a0a; border:1px solid var(--gold); font-weight:800; }
.pill.red    { background: var(--danger-soft); color: var(--danger); border:1px solid rgba(210,85,60,.45); }

.banner { border-radius: 12px; padding: 12px 14px; font-size: 13px; display:flex; gap:10px; align-items:flex-start; margin-bottom: 14px; }
.banner.warn { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(210,85,60,.5); }
.banner.warn b { color: #e98469; }
.banner.info { background: var(--brand-tint); color: var(--gold); border:1px solid var(--gold-dim); }
.banner .ico { line-height: 1; }

.row { display:flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.divider { height:1px; background: var(--line); margin: 12px 0; border: none; }

/* ---------- Lưới danh mục dịch vụ ---------- */
.svc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.svc-tile { background:var(--surface); border:1.5px solid var(--line); border-radius:14px; padding:14px; cursor:pointer; text-align:left; transition: border-color .15s, transform .06s; }
.svc-tile:hover { border-color: var(--gold); }
.svc-tile:active { transform: scale(.98); }
.svc-tile.active { border-color: var(--gold); background: var(--brand-tint); }
.svc-tile .ic { color: var(--gold); }
.svc-tile .nm { font-weight: 700; font-size: 13.5px; margin-top: 6px; line-height: 1.3; color: var(--ink); }
.svc-tile .fee { font-size: 12px; color: var(--gold); font-weight: 700; margin-top: 3px; }
.o-price { font-size:14.5px; font-weight:800; color:#f3e4b0; margin-top:5px; letter-spacing:.3px; }

/* ---------- Nút cấp cứu ---------- */
.sos {
  width: 100%; border: none; border-radius: 16px; padding: 16px 18px; cursor: pointer;
  background: linear-gradient(100deg, #FF8C00, #B8400A); color: #fff;
  font-family: inherit; font-weight: 800; font-size: 16px; text-align: left;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 26px rgba(184,64,10,.42);
}
.sos small { display:block; font-weight: 500; font-size: 12px; opacity: .92; }

/* ---------- Hoá đơn tách bạch (SIGNATURE) ---------- */
.bill { background:var(--surface); border:1px solid var(--line); border-radius:14px; overflow:hidden; }
.bill-sec { padding: 14px 16px; }
.bill-sec + .bill-sec { border-top: 1px dashed var(--line); }
.bill-head { display:flex; align-items:center; gap:8px; margin-bottom: 10px; }
.bill-head .tag { font-size: 11px; font-weight: 800; letter-spacing:.5px; text-transform: uppercase; }
.bill-head .tag.labor { color: var(--gold); }
.bill-head .tag.mat { color: var(--amber); }
.bill-head .lock { font-size: 11px; color: var(--muted); margin-left:auto; }
.line-item { display:flex; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 14px; }
.line-item .nm { font-weight: 500; color: var(--ink); }
.line-item .code { font-size: 11px; color: var(--muted); }
.line-item .amt { font-weight: 700; white-space: nowrap; color: var(--ink); }
.bill-total { background: linear-gradient(135deg,#2a1410,#1A0A0A); border-top:1px solid var(--gold-dim); color:#fff; padding: 16px; display:flex; justify-content: space-between; align-items:center; }
.bill-total .lbl { font-size: 13px; color:var(--muted); }
.bill-total .val { font-size: 22px; font-weight: 800; color: var(--gold); }

/* ---------- Tiến trình đơn ---------- */
.steps { display:flex; flex-direction: column; gap: 0; }
.step { display:flex; gap: 12px; }
.step .dot { width: 26px; display:flex; flex-direction:column; align-items:center; }
.step .circle { width: 14px; height: 14px; border-radius:50%; border:2.5px solid var(--line); background:var(--surface); flex-shrink:0; margin-top:3px; }
.step .bar { flex:1; width:2.5px; background: var(--line); margin: 2px 0; }
.step:last-child .bar { display:none; }
.step.done .circle { background: var(--flow); border-color: var(--flow); }
.step.done .bar { background: var(--flow); }
.step.active .circle { border-color: var(--gold); box-shadow: 0 0 0 4px var(--brand-tint); }
.step .txt { padding-bottom: 16px; }
.step .txt .t { font-weight: 700; font-size: 14px; color: var(--ink); }
.step .txt .s { font-size: 12px; color: var(--muted); }
.step.pending .txt .t { color: var(--muted); font-weight: 500; }

/* ---------- List đơn / item ---------- */
.list-item { background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:13px 14px; margin-bottom:10px; cursor:pointer; }
.list-item:hover { border-color: var(--gold); }
.list-item .top { display:flex; justify-content: space-between; align-items:center; margin-bottom:4px; }
.list-item .ttl { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.list-item .meta { font-size: 12.5px; color: var(--muted); }

/* ---------- Bản đồ giả lập ---------- */
.map { height: 150px; border-radius: 14px; margin-bottom: 14px; position: relative; overflow: hidden;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 22px, rgba(212,175,55,.06) 23px),
    repeating-linear-gradient(90deg, transparent, transparent 22px, rgba(212,175,55,.06) 23px),
    #1c1010;
  display:flex; align-items:center; justify-content:center; }
.map .route { position:absolute; left:18%; top:70%; width: 64%; height:2px; background: var(--gold); }
.map .pinA, .map .pinB { position:absolute; }
.map .pinA { left:14%; top:60%; } .map .pinB { right:14%; top:14%; }
.map .van { position:absolute; left:18%; top:64%; animation: drive 4s ease-in-out infinite; }
@keyframes drive { 0%{left:18%;top:64%} 100%{left:78%;top:16%} }

/* ---------- Modal đăng nhập demo ---------- */
.demo-creds { background: var(--brand-tint); border:1px solid var(--gold-dim); border-radius:11px; padding:12px 14px; font-size:12.5px; color: var(--gold); margin-top: 14px; }
.demo-creds b { display:block; margin-bottom:4px; color: var(--ink); }
.demo-creds code { font-family:'Space Mono',monospace; background:var(--bg2); padding:1px 5px; border-radius:5px; color: var(--gold); }

.empty { text-align:center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left:50%; transform: translateX(-50%); bottom: 24px; background: #2a1410; border:1px solid var(--gold-dim); color:var(--ink);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 100; max-width: 90%;
  box-shadow: var(--shadow); opacity:0; transition: opacity .2s, transform .2s; }
.toast.show { opacity:1; transform: translateX(-50%) translateY(0); }

/* ---------- Admin web (rộng hơn) ---------- */
.admin { max-width: 1040px; margin: 0 auto; padding: 24px 20px 60px; box-shadow: inset 0 0 0 1px rgba(212,175,55,.12); }
.stat-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:16px; }
.stat .k { font-size:12px; color: var(--muted); font-weight:600; }
.stat .v { font-size:24px; font-weight:800; margin-top:4px; letter-spacing:-.5px; color: var(--gold); font-family:'Space Mono',monospace; }
.tbl { width:100%; min-width:560px; background:var(--surface); border:1px solid var(--line); border-radius:14px; border-collapse:separate; border-spacing:0; overflow:hidden; }
.tbl td.num, .tbl th.num { text-align:right; font-variant-numeric:tabular-nums; }
.tbl th { text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.5px; color:var(--gold-dim); padding:11px 14px; background:var(--bg2); border-bottom:1px solid var(--line); }
.tbl td { padding:11px 14px; font-size:13.5px; border-bottom:1px solid var(--line2); color: var(--ink); }
.tbl tr:last-child td { border-bottom:none; }

/* icon SVG dùng chung (thay emoji) */
.emi{width:1.1em;height:1.1em;display:inline-block;vertical-align:-.15em;flex:none}
.emi svg, .ico svg { width:100%; height:100%; }
.ico svg, .emi svg { stroke: currentColor; }

/* fix: ghìm cỡ icon cảnh báo (tránh SVG phình to) */
.banner .ico,.banner .emi{width:22px!important;height:22px!important;flex:none;display:inline-flex}
.banner .ico svg,.banner .emi svg{width:22px!important;height:22px!important}
.ico{width:1.2em;height:1.2em;display:inline-flex;flex:none}

/* fix: bảng cuộn ngang trên mobile + ô không rớt dòng */
.tablewrap{ overflow-x:auto; -webkit-overflow-scrolling:touch; max-width:100%; margin-bottom:24px; }
.tablewrap .tbl{ margin-bottom:0; }
.tbl td, .tbl th{ white-space:nowrap; }

/* fix: header chống đè tuyệt đối trên mobile */
.topbar .brandwrap{ flex:1 1 auto; }
.topbar .who{ flex:0 0 auto; }
.topbar .out{ display:inline-flex; align-items:center; gap:6px; flex:0 0 auto; }
@media (max-width:430px){
  .topbar{ padding:12px 14px; gap:8px; }
  .topbar h1{ font-size:18px; }
  .topbar .out .txt{ display:none; }
  .topbar .out{ padding:8px; }
}

/* fix FINAL: login chỉ brand; mobile ẩn tên user dài */
.topbar.login-topbar{ justify-content:center; }
.topbar.login-topbar .brandwrap{ flex:0 0 auto; }
@media (max-width:430px){
  .topbar .who{ display:none; }
}

/* fix: icon SOS to + pulse, ẩn slogan mobile, nav rõ */
.sos .b{ width:46px; height:46px; flex:none; background:none; display:grid; place-items:center; animation:sospulse 1.8s ease-out infinite; }
.sos .b .emi, .sos .b svg{ width:32px; height:32px; stroke-width:2.3; }
@keyframes sospulse{ 0%{box-shadow:0 0 0 0 rgba(255,255,255,.45)} 70%{box-shadow:0 0 0 11px rgba(255,255,255,0)} 100%{box-shadow:0 0 0 0 rgba(255,255,255,0)} }
@media (max-width:430px){ .topbar .sub{ display:none; } }

/* fix: ẩn slogan mobile (trang trong) + nav rõ nét */
@media (max-width:430px){
  .topbar:not(.login-topbar) .sub{ display:none; }
}
.tabbar svg{ stroke-width:2; }
.tabbar button:not(:disabled){ transition:color .15s; }

/* fix: nhấn heading login */
.screen.center .title{ font-weight:800; }

/* ===== FOOTER cao cấp Dark/Gold ===== */
.site-footer{ background:#16110e; border-top:1px solid #2d221a; padding:36px 20px 0; margin-top:32px; }
.ft-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:32px; max-width:1180px; margin:0 auto; }
.ft-col h4{ color:#d4af37; font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.7px; margin:0 0 15px; }
.ft-col > a{ display:flex; justify-content:space-between; align-items:center; color:#b9a890; font-size:13px; text-decoration:none; padding:10px 0; line-height:1.4; border-bottom:1px solid rgba(212,175,55,.1); transition:color .15s; }
.ft-col > a:last-child{ border-bottom:none; }
.ft-col > a::after{ content:"\203A"; color:var(--gold-dim); font-size:18px; line-height:1; margin-left:10px; }
.ft-col > a:hover::after{ color:var(--gold); }
.ft-col > a:hover{ color:#e3c466; }
.ft-brand .ft-logo{ display:flex; align-items:center; gap:9px; margin-bottom:13px; }
.ft-brand .ft-ec{ width:30px; height:30px; border-radius:8px; background:#7A1515; border:1px solid #d4af37; display:grid; place-items:center; font-family:var(--mono,monospace); font-weight:800; color:#d4af37; font-size:12px; flex:none; }
.ft-brand .ft-logo b{ font-size:19px; color:#d4af37; font-weight:800; letter-spacing:.4px; }
.ft-slogan{ color:#e7d9bd; font-size:12.5px; font-style:italic; margin-bottom:11px; line-height:1.5; }
.ft-intro{ color:#a39285; font-size:12px; line-height:1.65; margin:0 0 13px; }
.ft-dev{ color:#a39285; font-size:12px; }
.ft-dev b{ color:#d4af37; }
.ft-ct{ display:flex; gap:9px; align-items:flex-start; color:#a39285; font-size:12.5px; margin-bottom:12px; line-height:1.45; }
.ft-ct svg{ width:15px; height:15px; flex:none; margin-top:2px; }
.ft-ct b{ color:#e7d9bd; display:block; }
.ft-ct small{ color:#a39285; font-size:11px; }
.ft-social{ display:flex; gap:9px; margin-top:4px; }
.ft-social a{ width:34px; height:34px; border:1px solid #d4af37; border-radius:9px; display:grid; place-items:center; color:#d4af37; background:rgba(212,175,55,.06); }
.ft-social a:hover{ border-color:#d4af37; color:#d4af37; }
.ft-social svg{ width:16px; height:16px; }
.ft-bottom{ max-width:1180px; margin:26px auto 0; border-top:1px solid #2d221a; text-align:center; color:#8c7a68; font-size:11.5px; padding:18px 0 calc(16px + env(safe-area-inset-bottom,24px)); }
.app .ft-grid{ grid-template-columns:1fr; gap:26px; }
.app .site-footer{ padding:24px 18px 0; margin-top:14px; }
@media (max-width:760px){ .ft-grid{ grid-template-columns:1fr 1fr; gap:26px 22px; } }
@media (max-width:480px){ .ft-grid{ grid-template-columns:1fr; gap:26px; } }

/* footer trên app có bottom-nav: chừa chỗ cho nav (bản quyền không bị che) */
.app .ft-bottom{ padding-bottom:calc(92px + env(safe-area-inset-bottom,24px)); }
