[hidden] { display: none !important; }
:root {
  --bg: #f7f3ec;
  --card: #ffffff;
  --ink: #2a2118;
  --muted: #7a6d5f;
  --line: #e6dccd;
  --gold: #7a4f12;
  --gold-2: #a8741f;
  --gold-soft: #f6ecd9;
  --red: #b3261e;
  --green: #2f7a4b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 4px 14px rgba(60, 40, 10, .06);
  font-size: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--gold); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.08rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 2rem 1rem; }
.small { font-size: .88rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 1rem 16px 6rem; }

/* ---------- thanh trên ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 16px;
  background: linear-gradient(90deg, #5f3c0c, #7a4f12 60%, #8d5d18);
  color: #f6e7c1;
}
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: #f6e7c1; color: #7a4f12; font-size: 1.4rem; font-family: serif;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 1.05rem; }
.brand-text small { opacity: .8; font-size: .78rem; }
.nav { display: flex; gap: .25rem; margin-left: 1rem; }
.nav a {
  color: #f6e7c1; text-decoration: none; padding: .55rem .9rem; border-radius: 10px; font-weight: 600;
}
.nav a.active, .nav a:hover { background: rgba(255, 255, 255, .14); }
.me { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.me button { background: rgba(255,255,255,.14); color: #f6e7c1; border: 0; min-height: 40px; padding: 0 .8rem; border-radius: 10px; font: inherit; cursor: pointer; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: none; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; text-align: center; padding: .5rem 0 .55rem; text-decoration: none; color: var(--muted);
  font-size: .8rem; font-weight: 600;
}
.bottomnav a .ico { display: block; font-size: 1.35rem; line-height: 1.2; }
.bottomnav a.active { color: var(--gold); }

@media (max-width: 760px) {
  .nav { display: none; }
  .bottomnav:not([hidden]) { display: flex; }
  .me .who { display: none; }
  .brand-mark { width: 36px; height: 36px; font-size: 1.15rem; }
  h1 { font-size: 1.35rem; }
}

/* ---------- thẻ, lưới ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.grid > .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-tiers { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: .4rem 0 1rem; }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: 0 1.1rem; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--gold-2); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-primary:hover { background: #64400e; }
.btn-zalo { background: #0068ff; border-color: #0068ff; color: #fff; }
.btn-call { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { color: var(--red); border-color: #efc7c4; }
.btn-sm { min-height: 40px; padding: 0 .8rem; font-size: .9rem; }
.btn-icon { min-width: 48px; padding: 0; }
.btn-block { width: 100%; }

/* ---------- form ---------- */
label.field { display: block; }
label.field > span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; min-height: 50px; padding: .6rem .8rem; border: 1px solid #d7cab6; border-radius: 12px;
  font: inherit; color: var(--ink); background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(168, 116, 31, .25); border-color: var(--gold-2); }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-weight: 700; color: var(--gold); margin: 1.2rem 0 .3rem; grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.search { position: relative; flex: 1; min-width: 220px; }
.search input { padding-left: 2.6rem; }
.search::before { content: "🔍"; position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); font-size: .95rem; opacity: .6; }

/* ---------- hạng, sao ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .65rem; border-radius: 999px;
  font-size: .82rem; font-weight: 700; color: #fff; white-space: nowrap;
}
.stars { color: #d39b1c; letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: #ddd2c0; }
.stars-input button {
  background: none; border: 0; font-size: 1.9rem; line-height: 1; padding: .1rem .15rem; cursor: pointer; color: #ddd2c0;
  min-width: 44px; min-height: 44px;
}
.stars-input button.on { color: #d39b1c; }
.tier-card { border-left: 6px solid var(--c); padding: .8rem 1rem; }
.tier-card .n { font-size: 1.6rem; font-weight: 800; }
.stat { font-size: 1.6rem; font-weight: 800; }

/* ---------- danh sách khách ---------- */
.cust-list { display: grid; gap: .7rem; }
.cust {
  display: grid; grid-template-columns: 52px 1fr auto; gap: .8rem; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
}
.cust:hover { border-color: var(--gold-2); }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold); font-weight: 800; font-size: 1.15rem;
}
.cust .name { font-weight: 700; font-size: 1.05rem; }
.cust .sub { color: var(--muted); font-size: .88rem; }
.cust .right { text-align: right; }
.cust .money { font-weight: 700; }
@media (max-width: 560px) {
  .cust { grid-template-columns: 46px 1fr; }
  .avatar { width: 46px; height: 46px; }
  .cust .right { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; text-align: left; border-top: 1px dashed var(--line); padding-top: .5rem; }
}

/* ---------- chi tiết khách ---------- */
.profile-head { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
.profile-head .avatar { width: 72px; height: 72px; font-size: 1.6rem; }
.profile-head .actions { grid-column: 1 / -1; display: flex; gap: .6rem; flex-wrap: wrap; }
.profile-head .actions .btn { flex: 1 1 140px; }
@media (min-width: 900px) {
  .profile-head { grid-template-columns: auto 1fr auto; }
  .profile-head .actions { grid-column: auto; flex-wrap: nowrap; }
  .profile-head .actions .btn { flex: 0 0 auto; }
}
.kpis { display: flex; gap: 1.4rem; flex-wrap: wrap; margin-top: .4rem; }
.kpis div { font-size: .88rem; color: var(--muted); }
.kpis b { display: block; font-size: 1.1rem; color: var(--ink); }

.tabs {
  display: flex; gap: .3rem; overflow-x: auto; margin: 1rem 0; padding-bottom: 2px;
  position: sticky; top: 62px; z-index: 5; background: var(--bg);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; min-height: 46px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--gold); border-color: var(--gold); color: #fff; }
.tabs button.private { border-style: dashed; }
.tabs button.private.active { background: #3b2a16; border-color: #3b2a16; }

dl.info { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: .45rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); font-size: .92rem; }
dl.info dd { margin: 0; font-weight: 500; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 480px) { dl.info { grid-template-columns: 1fr; gap: 0; } dl.info dd { margin-bottom: .55rem; } }

.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: start;
  padding: .8rem 0; border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item .thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--gold-soft); display: grid; place-items: center; font-size: 1.6rem; }
.item .title { font-weight: 700; }
.item .meta { color: var(--muted); font-size: .88rem; }
.item .tools { display: flex; gap: .3rem; }
.pill { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--gold-soft); color: var(--gold); }
.pill.grey { background: #eee8df; color: #6b6156; }
.pill.red { background: #fbe4e2; color: var(--red); }
.pill.green { background: #e2f3e8; color: var(--green); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--gold-2); }
.timeline .when { font-size: .85rem; color: var(--muted); }

.task { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task input[type=checkbox] { width: 28px; height: 28px; min-height: 0; flex: 0 0 auto; accent-color: var(--gold); }
.task .t { flex: 1; }
.task.done .t { text-decoration: line-through; color: var(--muted); }

.private-box { background: #2f2316; color: #f6e7c1; border-color: #2f2316; }
.private-box textarea { background: #3b2c1b; color: #fff6df; border-color: #5b4529; min-height: 260px; }
.private-box .hint { color: #cdb894; }

.event { display: flex; gap: .8rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }
.event .ico { font-size: 1.5rem; width: 2.2rem; text-align: center; }
.event .info { flex: 1; min-width: 0; }
.event .days { font-weight: 800; color: var(--gold); white-space: nowrap; }
.event .days.today { color: var(--red); }
.empty { color: var(--muted); padding: .6rem 0; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(30, 20, 8, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 760px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 1.1rem 16px calc(1.1rem + env(safe-area-inset-bottom));
}
@media (min-width: 760px) { .modal-back { align-items: center; } .modal { border-radius: 18px; padding: 1.4rem; } }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.1rem; position: sticky; bottom: -1.2rem; background: #fff; padding: .6rem 0; }
.modal-actions .btn { flex: 1 1 auto; max-width: 240px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #2a2118; color: #fff; padding: .75rem 1.2rem; border-radius: 12px; z-index: 60; transition: .2s; pointer-events: none;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- đăng nhập ---------- */
.auth-wrap { min-height: 90vh; display: grid; place-items: center; }
.auth { width: 100%; max-width: 420px; }
.auth .brand-mark { width: 72px; height: 72px; font-size: 2.2rem; margin: 0 auto 1rem; background: var(--gold); color: #f6e7c1; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .4rem; border-top: 1px solid var(--line); }
.table th { color: var(--muted); font-size: .85rem; font-weight: 600; }

@media (max-width: 760px) {
  .page-head .btn-primary:not(#print) { display: none; }
  .grid-tiers { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .tier-card { padding: .55rem .6rem; border-left-width: 5px; }
  .tier-card .n { font-size: 1.3rem; }
  .tier-card .small { font-size: .78rem; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .profile-head .avatar { width: 56px; height: 56px; font-size: 1.25rem; align-self: start; }
}

/* ---------- chăm đệ tử ---------- */
.red { color: var(--red); }
.home-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }
.fast-card { border-left: 6px solid #6a9a3a; }
.fast-card.is-soon { background: #f4f9ec; border-color: #cfe3b5; border-left-color: #4f8a1f; }
.fast-ico { font-size: 2rem; }
.fast-title { font-weight: 800; font-size: 1.15rem; }
.seg { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 .6rem; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 0 0 auto; min-height: 44px; padding: 0 .85rem; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: .92rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg button.active { background: var(--gold-soft); border-color: var(--gold-2); color: var(--gold); }
.seg .count { display: inline-block; min-width: 1.5rem; padding: 0 .35rem; border-radius: 999px; background: var(--gold); color: #fff; font-size: .78rem; text-align: center; margin-left: .2rem; }
.care-list { display: grid; }
.care-row { display: grid; grid-template-columns: 46px 1fr auto; gap: .7rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--line); }
.care-row:first-child { border-top: 0; }
.care-row .avatar { width: 46px; height: 46px; font-size: 1rem; text-decoration: none; }
.care-row .who { color: inherit; text-decoration: none; min-width: 0; }
.care-row .sub { color: var(--muted); font-size: .86rem; }
.care-row .acts { display: flex; gap: .4rem; }
.btn-done { border-color: var(--gold-2); color: var(--gold); }
.btn-done.is-done { background: #e2f3e8; border-color: #bfe0ca; color: var(--green); }
.row-done .who { opacity: .55; }
@media (max-width: 560px) {
  .care-row { grid-template-columns: 42px 1fr; }
  .care-row .avatar { width: 42px; height: 42px; }
  .care-row .acts { grid-column: 2; }
  .care-row .acts .btn { flex: 1; }
}
.cycle { display: flex; gap: .7rem; align-items: center; padding: .55rem 0; border-top: 1px solid var(--line); }
.cycle:first-of-type { border-top: 0; }
.cycle .ico { font-size: 1.4rem; width: 2rem; text-align: center; }
.cycle .info { flex: 1; }
.cycle.due .info b { color: var(--red); }
.num-head { display: flex; gap: .9rem; align-items: center; margin-bottom: .5rem; }
.num-big { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-size: 2rem; font-weight: 800; background: linear-gradient(135deg, #7a4f12, #b9852c); color: #fff6df; }
.num-card p { margin: .4rem 0; }
.num-care { background: var(--gold-soft); border-radius: 10px; padding: .55rem .7rem; }
.table-wrap { overflow-x: auto; }
.le-table td { vertical-align: top; }

@media print {
  .topbar, .bottomnav, .no-print, #toast { display: none !important; }
  body { background: #fff; font-size: 13pt; }
  .container { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .le-table a { color: inherit; text-decoration: none; }
}
@media (max-width: 600px) {
  .le-table tr:first-child { display: none; }
  .le-table tr { display: grid; grid-template-columns: 2rem 1fr; border-top: 1px solid var(--line); padding: .5rem 0; }
  .le-table td { border: 0; padding: .1rem .2rem; }
  .le-table td:nth-child(n+3) { grid-column: 2; }
  .le-table td:nth-child(3), .le-table td:nth-child(4) { color: var(--muted); }
}

/* ---------- lễ ---------- */
.le-row { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.le-row:first-of-type { border-top: 0; }
.le-row.is-main { background: var(--gold-soft); border-radius: 12px; padding: .6rem; margin: .2rem 0; border-top: 0; }
.le-date { flex: 0 0 64px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .3rem 0; line-height: 1.2; }
.le-date b { display: block; font-size: 1.05rem; color: var(--gold); }
.le-date span { font-size: .75rem; color: var(--muted); }
.le-info { flex: 1; min-width: 0; }
.le-count { text-align: center; line-height: 1.1; }
.le-count b { display: block; font-size: 1.2rem; }
.le-count span { font-size: .72rem; color: var(--muted); }
.le-month { margin-top: 1rem; }
.le-month h3 { color: var(--gold); }
.le-card { border-left: 6px solid #c0841a; }
.le-mota { background: #fffaf0; }
.chk { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; white-space: nowrap; }
.chk input { width: 24px; height: 24px; min-height: 0; accent-color: var(--green); }
.print-only { display: none; }
@media print { .print-only { display: block; } }
@media (max-width: 560px) { .le-row .btn { display: none; } }

/* ---------- tử vi ---------- */
.warn-box { background: #fbe9e7; border: 1px solid #f1c3bd; border-radius: 12px; padding: .7rem .9rem; margin-top: .8rem; }
.warn-box ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.ok-box { background: #e2f3e8; border-radius: 12px; padding: .7rem .9rem; margin-top: .8rem; }
.advice { display: flex; gap: .8rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.advice:first-of-type { border-top: 0; }
.advice .ai { font-size: 1.6rem; }
.advice p { margin: .15rem 0 0; }
.seg button { flex: 0 1 auto; max-width: 100%; white-space: normal; text-align: left; padding: .4rem .85rem; }

/* ---------- vận hạn tháng ---------- */
.van-card { border-left: 6px solid #8a5bd6; }
.van-row .sub { margin-top: .15rem; }
.van-ask { color: #4b3a8a; }
.van-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.van-month { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; background: #fff; border-left: 5px solid #c9a227; }
.van-month.van-green { border-left-color: var(--green); }
.van-month.van-grey { border-left-color: #b7ab9b; }
.van-month.van-red { border-left-color: var(--red); background: #fff8f7; }
.van-month.is-now { box-shadow: 0 0 0 2px var(--gold-2); }
.van-line { font-size: .9rem; margin-top: .35rem; }
