/* CHAN HAIR – tông đen / trắng / vàng kem. Mobile-first. */
:root {
  --ink: #141414;
  --ink-2: #3a3a3a;
  --muted: #7a746b;
  --line: #e7dfd2;
  --bg: #faf7f2;
  --card: #ffffff;
  --cream: #f3e9d7;
  --gold: #b8935a;
  --gold-d: #9a7841;
  --ok: #2f7d4f;
  --ok-bg: #e5f3ea;
  --warn: #9a6a00;
  --warn-bg: #fdf3d8;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;
  --info: #2c5b8a;
  --info-bg: #e6eef7;
  --r: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 16px rgba(20, 20, 20, .05);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

/* ---------- Thương hiệu ---------- */
.brand { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: .18em; line-height: 1; white-space: nowrap; }
.brand b { color: var(--gold); font-weight: 600; }

/* ---------- Khung ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.top-in { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.top .brand { font-size: 22px; }
.top-title { font-size: 13px; color: #cfc6b6; border-left: 1px solid #444; padding-left: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: #e8e1d4; min-width: 0; }
.top-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
.top-user button { background: transparent; border: 1px solid #555; color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
@media (max-width: 560px) {
  .top .brand { font-size: 19px; }
  .top-user span { display: none; }
  .top-title { flex: 1; }
}
.mock-bar { background: var(--cream); color: var(--ink-2); font-size: 12px; text-align: center; padding: 4px 16px; }
.mock-bar a { color: var(--gold-d); }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; border: 0; background: transparent; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
}
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--ink); }
.nav button.on::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
.nav .dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; padding: 0 5px; }
main { max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 32px); }

@media (min-width: 900px) {
  .nav { position: sticky; top: 52px; height: auto; border: 0; border-bottom: 1px solid var(--line); justify-content: center; gap: 4px; padding: 0 16px; }
  .nav button { flex: 0 0 auto; flex-direction: row; padding: 14px 18px; font-size: 14px; }
  .nav button svg { width: 18px; height: 18px; }
  .nav button.on::before { top: auto; bottom: 0; left: 18px; right: 18px; border-radius: 3px 3px 0 0; }
  .nav .dot { position: static; }
  main { padding-bottom: 48px; }
}

/* ---------- Thành phần ---------- */
h1 { font-size: 22px; margin: 4px 0 14px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.sp { height: 8px; }

label.f { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; }
.in, select.in, textarea.in {
  width: 100%; min-height: 46px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px;
  font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.in { min-height: 70px; resize: vertical; }
.in:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184, 147, 90, .18); }
.in.sm { min-height: 38px; padding: 6px 10px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--bad); border-color: #f0c9c5; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-size: 16px; }
.linkbtn { background: none; border: 0; color: var(--gold-d); font-weight: 600; padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--cream); color: var(--ink-2); }
.b-CHO_DEN { background: var(--info-bg); color: var(--info); }
.b-DA_DEN, .b-DA_THANH_TOAN { background: var(--ok-bg); color: var(--ok); }
.b-KHONG_DEN, .b-HUY { background: var(--bad-bg); color: var(--bad); }
.b-DOI_LICH { background: var(--warn-bg); color: var(--warn); }
.b-NHAP { background: var(--cream); color: var(--gold-d); }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #f0c9c5; font-weight: 500; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* Bảng */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-bottom: 1px solid #f1ebe1; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r, .tbl th.r { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); }
.num { font-variant-numeric: tabular-nums; }
.disc { color: var(--bad); font-weight: 600; white-space: nowrap; }
.strike { text-decoration: line-through; color: var(--muted); font-size: 12px; }

/* Danh sách lịch */
.list { display: flex; flex-direction: column; gap: 10px; }
.bk {
  display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px;
  cursor: pointer; text-align: left; width: 100%; border-left: 4px solid var(--info);
}
.bk:hover { border-color: #d8ccb7; }
.bk.st-DA_DEN { border-left-color: var(--ok); }
.bk.st-KHONG_DEN, .bk.st-HUY { border-left-color: var(--bad); opacity: .75; }
.bk.st-DOI_LICH { border-left-color: var(--warn); }
.bk-time { font-size: 20px; font-weight: 700; min-width: 58px; font-variant-numeric: tabular-nums; }
.bk-time small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.bk-main { flex: 1; min-width: 0; }
.bk-name { font-weight: 600; font-size: 16px; }
.bk-sub { font-size: 13px; color: var(--muted); }
.bk-items { font-size: 13px; margin-top: 4px; color: var(--ink-2); }
.bk-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* Chọn dịch vụ */
.svc-group { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
.svc { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.svc.on { border-color: var(--gold); background: #fffcf6; }
.svc-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.svc-head input { width: 22px; height: 22px; accent-color: var(--ink); flex: 0 0 auto; }
.svc-name { flex: 1; font-weight: 500; }
.svc-price { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.svc-body { margin-top: 8px; padding-left: 32px; }
.svc-hint { font-size: 12px; color: var(--gold-d); font-weight: 600; }

.totals { display: grid; gap: 6px; font-size: 15px; }
.totals div { display: flex; justify-content: space-between; }
.totals .big { font-size: 20px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }

/* Ô tra SĐT */
.lookup { background: var(--ink); color: #fff; border-radius: var(--r); padding: 18px 16px; margin-bottom: 14px; }
.lookup h2 { color: #f3e9d7; font-weight: 600; }
.lookup .row { flex-wrap: nowrap; }
.lookup .in { color: var(--ink); font-size: 24px; min-height: 58px; letter-spacing: .06em; font-weight: 600; border: 0; }
.lookup .btn { min-height: 58px; padding: 0 22px; font-size: 17px; }

.kh { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.kh-name { font-size: 20px; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .v.gold { color: var(--gold-d); }

.seg { display: inline-flex; background: #efe8dc; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 500; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.lock { font-size: 12px; }
.tag-them { font-size: 11px; font-weight: 600; background: var(--info-bg); color: var(--info); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.inv-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 10px; }
.inv-lines .in.sm { min-width: 110px; }
.pct-in { width: 70px !important; min-width: 0 !important; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.x:hover { color: var(--bad); }
.unsaved { font-size: 12px; color: var(--warn); font-weight: 600; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); padding: 10px 0 6px; margin: 8px 0 -6px; z-index: 2; }
.sticky-actions .row { flex-wrap: nowrap; }
.sticky-actions .btn.lg { font-size: 15px; padding: 10px 12px; }

/* Danh sách dịch vụ của lịch */
.items { font-size: 14px; }
.it { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid #f1ebe1; }
.it-r { text-align: right; white-space: nowrap; }
.it-tot { font-weight: 700; font-size: 15px; border-bottom: 0; padding-bottom: 0; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }

/* Đăng nhập */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: var(--ink); }
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 28px 22px; }
.login .brand { font-size: 38px; color: #fff; text-align: center; }
.login-sub { color: #cfc6b6; text-align: center; margin: 10px 0 22px; font-size: 14px; letter-spacing: .04em; }
.login-hint { margin-top: 14px; font-size: 13px; color: var(--muted); background: var(--cream); border-radius: 10px; padding: 10px 12px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(20, 20, 20, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 24px; padding-bottom: max(24px, env(safe-area-inset-bottom)); animation: up .2s; }
.modal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.modal-h h2 { margin: 0; }
@media (min-width: 720px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* Toast */
#toasts { position: fixed; z-index: 60; left: 16px; right: 16px; top: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; max-width: 480px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: up .2s; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 30px; color: var(--muted); }
