/* ============================================================
   Ơn Spa CRM – design system (nền sáng, card bo tròn, bóng nhẹ)
   ============================================================ */
:root {
  --bg: #f3f5fb; --card: #fff; --ink: #16172b; --ink-2: #4a4d66; --muted: #8b8fa7; --line: #eceef5; --line-2: #f5f6fa;
  --brand: #5146e8; --brand-2: #7c6cf6; --brand-soft: #eeedfe; --brand-ink: #fff;
  --accent: #5146e8;
  --ok: #15924a; --ok-soft: #e4f6eb; --warn: #b86b00; --warn-soft: #fff3dc; --bad: #d93f45; --bad-soft: #fdeced;
  --info: #2a78d6; --info-soft: #e7f0fc; --violet: #6b4fd8; --violet-soft: #f0ebfd;
  --radius: 20px; --radius-sm: 14px; --nav-h: 64px; --rail: 84px;
  --shadow: 0 1px 2px rgba(22, 23, 43, .04), 0 8px 24px rgba(22, 23, 43, .05);
  --shadow-lg: 0 12px 32px rgba(81, 70, 232, .18);
  /* màu phân loại cho biểu đồ (đã kiểm tra mù màu) – theo thứ tự cố định */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 16px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.bad { color: var(--bad); }
.clip { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------- Khung: thanh menu dọc + nội dung ---------------- */
.shell { display: flex; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; width: var(--rail); flex: none; display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 20px 0 16px; background: var(--card); border-right: 1px solid var(--line); z-index: 20; transition: width .2s; }
.rail .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--ink); }
.rail .logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--shadow-lg); }
.rail .brand b { display: none; font-size: 16px; }
.rail .brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.rail nav { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: center; }
.rail nav a, .rail .foot a, .rail .foot button { position: relative; display: flex; align-items: center; gap: 12px; width: 48px; height: 48px;
  justify-content: center; border-radius: 16px; color: var(--muted); background: none; border: 0; cursor: pointer; font: inherit; }
.rail nav a span, .rail .foot span { display: none; white-space: nowrap; font-weight: 500; }
.rail nav a:hover, .rail .foot a:hover, .rail .foot button:hover { background: var(--line-2); color: var(--ink); }
.rail nav a.on { background: var(--ink); color: #fff; box-shadow: 0 6px 16px rgba(22, 23, 43, .22); }
.rail nav a .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); border: 2px solid var(--card); }
.rail .foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: center; }
.rail .toggle { position: absolute; top: 28px; right: -13px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.rail .toggle .ico { width: 14px; height: 14px; }
/* thu gọn khi hover: hiện tên mục */
.rail nav a[data-tip]:hover::after, .rail .foot [data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 58px; top: 50%; transform: translateY(-50%);
  background: var(--ink); color: #fff; font-size: 12px; padding: 5px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none; }
/* mở rộng: hiện nhãn */
.shell.wide { --rail: 228px; }
.shell.wide .rail { align-items: stretch; padding-left: 14px; padding-right: 14px; }
.shell.wide .rail .brand { padding-left: 4px; }
.shell.wide .rail .brand b { display: block; }
.shell.wide .rail nav, .shell.wide .rail .foot { align-items: stretch; }
.shell.wide .rail nav a, .shell.wide .rail .foot a, .shell.wide .rail .foot button { width: 100%; justify-content: flex-start; padding: 0 14px; height: 44px; }
.shell.wide .rail nav a span, .shell.wide .rail .foot span { display: inline; }
.shell.wide .rail [data-tip]:hover::after { display: none; }
.shell.wide .rail .toggle { transform: rotate(180deg); }

.main { flex: 1; min-width: 0; padding: 20px 32px 40px; max-width: 1360px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.search { position: relative; flex: 0 1 340px; }
.search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { padding-left: 42px; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius-sm); min-height: 46px; }
.today { color: var(--brand); font-weight: 600; font-size: 13px; white-space: nowrap; }
.icon-btn { position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--card);
  color: var(--ink-2); box-shadow: var(--shadow); border: 0; cursor: pointer; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--bad);
  color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--card); }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #ff9a6b, #e8508c); box-shadow: var(--shadow); }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; box-shadow: none; }
.me-name { line-height: 1.2; font-size: 13px; }
.me-name small { display: block; color: var(--muted); font-size: 11px; }

.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 30px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.chip-select { width: auto; min-height: 40px; border: 0; box-shadow: var(--shadow); border-radius: 12px; padding: 0 12px; font-weight: 500; }

/* ---------------- Card & ô số liệu ---------------- */
.card { background: var(--card); border: 0; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head .muted { font-size: 12px; }
.go { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--line-2); color: var(--ink); }
.go.dark { background: var(--ink); color: #fff; }
.go .ico { width: 16px; height: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { position: relative; display: block; background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); color: inherit; }
.stat .muted, .stat > span:first-child { font-size: 13px; color: var(--ink-2); }
.stat b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 14px 0 4px; }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat .go { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; }
.stat.alert { box-shadow: inset 0 0 0 1.5px #f6c3c5, var(--shadow); }
.stat.hero { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: var(--shadow-lg); }
.stat.hero > span:first-child, .stat.hero small { color: rgba(255, 255, 255, .8); }
.stat.hero .go { background: #fff; color: var(--brand); }
.stats.k6 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
a.stat:hover { transform: translateY(-1px); }
.trend { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; margin-left: 8px; vertical-align: middle; }
.trend.up { background: var(--ok-soft); color: var(--ok); }
.trend.down { background: var(--bad-soft); color: var(--bad); }
.stat.hero .trend.up { background: rgba(255, 255, 255, .95); color: var(--ok); }
.stat.hero .trend.down { background: rgba(255, 255, 255, .95); color: var(--bad); }

/* ô "98 orders" – số lớn + mô tả */
.big-card { display: flex; flex-direction: column; justify-content: space-between; min-height: 190px; color: inherit; }
.big-card .top { display: flex; align-items: center; justify-content: space-between; }
.big-card .circle { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--line-2); color: var(--ink); }
.big-card .num { font-size: 44px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.big-card .num small { font-size: 20px; font-weight: 500; letter-spacing: 0; margin-left: 6px; color: var(--ink); }
.big-card p { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.big-card p em { font-style: normal; color: var(--bad); }

/* thẻ trạng thái có dải màu (kiểu "Order list") */
.status-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.status-card { display: block; background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); color: inherit;
  outline: 2px solid transparent; transition: outline-color .15s; }
.status-card .hd { padding: 9px 14px; font-size: 13px; font-weight: 600; }
.status-card .bd { padding: 12px 14px 14px; display: flex; align-items: baseline; gap: 10px; }
.status-card .bd b { font-size: 26px; font-weight: 700; }
.status-card.on { outline-color: var(--ink); }
.status-card.c1 .hd { background: #dfe6ff; color: #2c3aa8; } .status-card.c2 .hd { background: #ffe1cc; color: #a24a10; }
.status-card.c3 .hd { background: #fff0c2; color: #8a6200; } .status-card.c4 .hd { background: #d6f5df; color: #156b36; }
.status-card.c5 .hd { background: #fde0e1; color: #a1272d; } .status-card.c6 .hd { background: #ece6fd; color: #4f36b3; }

.flash { background: var(--card); border-left: 4px solid var(--brand); padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; box-shadow: var(--shadow); }
.error { border-left-color: var(--bad); background: var(--bad-soft); }

/* ---------------- Nút & form ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #d9dcea; background: #fafbff; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: 0 6px 16px rgba(22, 23, 43, .18); }
.btn.primary:hover { background: #2a2c46; }
.btn.brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: 0; color: #fff; box-shadow: var(--shadow-lg); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 11px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn .ico { width: 16px; height: 16px; }
input, select, textarea { font: inherit; width: 100%; min-height: 44px; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fbfbfe; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 80px; }
input[type=checkbox], input[type=radio] { width: 18px; min-height: 18px; flex: none; accent-color: var(--brand); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
label.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 14px; font-weight: 500; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
details summary { cursor: pointer; font-weight: 600; }

/* ---------------- Bảng (kiểu Order list) ---------------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: #f7f8fc; border: 0; }
th:first-child { border-radius: 12px 0 0 12px; } th:last-child { border-radius: 0 12px 12px 0; }
tr:hover td { background: #fafbff; }
.table-wrap { overflow-x: auto; }
.kv th { width: 110px; text-transform: none; font-size: 12px; background: none; letter-spacing: 0; }
.kv tr:hover td { background: none; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 260px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow);
  font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* tab dạng viên thuốc */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding: 4px; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow); width: max-content; max-width: 100%; }
.tabs a { white-space: nowrap; padding: 7px 14px; border-radius: 10px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.tabs a:hover { background: var(--line-2); }
.tabs a.on { background: var(--ink); color: #fff; }

/* nhãn trạng thái: nền nhạt + chấm màu */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.b-new, .b-booked { background: var(--info-soft); color: var(--info); }
.b-consulted, .b-confirmed { background: var(--violet-soft); color: var(--violet); }
.b-arrived { background: var(--warn-soft); color: var(--warn); }
.b-purchased, .b-done { background: var(--ok-soft); color: var(--ok); }
.b-lost, .b-cancelled, .b-no_show { background: var(--bad-soft); color: var(--bad); }

.list-item { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-2); align-items: center; }
.list-item:last-child { border-bottom: 0; }
.time { font-weight: 700; min-width: 52px; color: var(--ink); }
.sig.overdue { background: var(--bad-soft); margin: 0 -20px; padding-left: 20px; padding-right: 20px; box-shadow: inset 4px 0 0 var(--bad); }
.menu a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line-2); color: var(--ink); font-size: 15px; font-weight: 500; }
.menu a:last-child { border-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.actions form { margin: 0; }
.kpi-bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.kpi-bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* chọn giờ / nút phân đoạn */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 8px; }
.slots label { margin: 0; }
.slots input, .seg input { display: none; }
.slots span, .seg span { display: block; text-align: center; padding: 10px 0; border: 1px solid var(--line); border-radius: 12px; background: #fbfbfe;
  color: var(--ink); cursor: pointer; font-weight: 600; font-size: 13px; }
.slots input:checked + span, .seg input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: flex; gap: 6px; margin-bottom: 4px; }
.seg label { margin: 0; flex: 1; }

/* lịch dạng danh sách */
.lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.appt { border-left: 4px solid var(--info); background: #fafbff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.appt.s-confirmed { border-color: var(--violet); } .appt.s-arrived { border-color: #f59e0b; } .appt.s-done { border-color: var(--ok); }
.appt.s-cancelled, .appt.s-no_show { border-color: var(--bad); opacity: .6; }

/* đăng nhập */
.login { max-width: 400px; margin: 10vh auto; padding: 0 16px; }
.login .logo { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 14px; color: #fff; font-weight: 800; font-size: 22px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--shadow-lg); }

/* ---------------- Biểu đồ ---------------- */
.bars { position: relative; display: grid; grid-template-columns: 58px 1fr; gap: 8px; height: 240px; }
.bars .yaxis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; padding-bottom: 22px; }
.bars .plot { position: relative; display: flex; align-items: flex-end; gap: 2px; padding-bottom: 22px;
  background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% calc((100% - 22px) / var(--ticks, 4)); }
.bars .col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bars .col i { display: block; width: min(70%, 34px); min-height: 2px; background: var(--brand); border-radius: 4px 4px 0 0; transition: filter .15s; }
.bars .col.today i { background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.bars .col span { position: absolute; bottom: -20px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.bars .col .tip { position: absolute; bottom: calc(var(--h) + 8px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px;
  padding: 5px 9px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; }
.bars .col:hover i, .bars .col:focus-visible i { filter: brightness(1.15); }
.bars .col:hover .tip, .bars .col:focus-visible .tip { opacity: 1; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { position: relative; width: 150px; height: 150px; border-radius: 50%; flex: none; }
.donut::after { content: ""; position: absolute; inset: 30px; border-radius: 50%; background: var(--card); }
.donut .c { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; text-align: center; font-size: 11px; color: var(--muted); }
.donut .c b { display: block; font-size: 22px; color: var(--ink); }
.legend-list { display: grid; gap: 10px; font-size: 13px; flex: 1; min-width: 160px; }
.legend-list div { display: flex; align-items: center; gap: 10px; }
.legend-list i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend-list b { margin-left: auto; font-weight: 600; }
.sw1 { background: var(--s1); } .sw2 { background: var(--s2); } .sw3 { background: var(--s3); } .sw4 { background: var(--s4); }
.sw5 { background: var(--s5); } .sw6 { background: var(--s6); } .sw7 { background: var(--s7); } .sw8 { background: #9aa0b8; }

/* ---------------- Trò chuyện, hóa đơn, ảnh ---------------- */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 16px 16px 16px 4px; background: var(--line-2); align-self: flex-start; white-space: pre-wrap; word-break: break-word; }
.bubble.out { background: var(--brand-soft); align-self: flex-end; border-radius: 16px 16px 4px 16px; }
.bubble img { max-width: 200px; border-radius: 10px; display: block; margin-top: 4px; }
.bubble small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.bill { max-width: 760px; }
.line { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; background: #fbfbfe; }
.line .seg { margin-top: 8px; }
.line.custom { border-style: dashed; border-color: #c9c2fb; background: #f8f7ff; }
.line-price { text-align: right; font-weight: 700; margin-top: 8px; }
.line .tech { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.line .tech select { width: auto; flex: 1; min-height: 36px; }
.sum { display: flex; justify-content: space-between; padding: 4px 0; }
.sum.big { font-size: 20px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.total-bar { position: sticky; bottom: 12px; z-index: 5; box-shadow: 0 -4px 24px rgba(22, 23, 43, .08); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.thumbs a, .ph { position: relative; display: block; }
.thumbs img, .ph img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: var(--line-2); display: block; }
.thumbs span { position: absolute; left: 6px; bottom: 6px; background: rgba(22, 23, 43, .6); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 7px; }
.day-group { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.day-group h3 { font-size: 13px; margin: 0 0 8px; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.ph form { position: absolute; top: 6px; right: 6px; }
.ph form button { background: rgba(22, 23, 43, .6); color: #fff; border: 0; border-radius: 8px; width: 26px; height: 26px; cursor: pointer; }
.ph .cap { font-size: 11px; color: var(--muted); margin-top: 3px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2px 16px; margin-top: 8px; }

/* ---------------- Lịch dòng thời gian ---------------- */
.tl { padding: 0; overflow: hidden; container-type: inline-size; }
.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tl-grid { --label: 150px; --w: max(38px, calc((100cqw - var(--label)) / var(--n))); --lane: 58px; position: relative;
  width: calc(var(--label) + var(--w) * var(--n)); }
.tl-row { display: flex; }
.tl-label { position: sticky; left: 0; z-index: 3; flex: none; width: var(--label); padding: 8px 14px; background: var(--card);
  font-size: 13px; display: flex; align-items: center; gap: 10px; }
.tl-label .who { display: flex; flex-direction: column; min-width: 0; }
.tl-label small { font-size: 11px; color: var(--muted); }
.tl-track { position: relative; flex: none; width: calc(var(--w) * var(--n));
  background: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px calc(var(--w) * 2)); }
.tl-head .tl-track { height: 44px; background: none; }
.tl-head .tl-label { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.tl-head .hr { position: absolute; top: 12px; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: var(--muted); }
.tl-head .hr:first-child { transform: none; padding-left: 6px; }
.tl-free .tl-track { height: 34px; background: none; }
.tl-free .tl-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.fc { position: absolute; top: 5px; bottom: 5px; width: calc(var(--w) - 4px); margin-left: 2px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.fc.f2, .lg.f2 { background: var(--ok-soft); color: var(--ok); }
.fc.f1, .lg.f1 { background: var(--warn-soft); color: var(--warn); }
.fc.f0, .lg.f0 { background: var(--bad-soft); color: var(--bad); }
.fc.f0 { font-size: 0; } .fc.f0::after { content: "Hết"; font-size: 10px; font-weight: 700; }
.fc.past { background: transparent; }
.tl-tech { border-top: 1px solid var(--line-2); }
.tl-tech .tl-track { height: calc(var(--lane) * var(--lanes) + 10px); }
.tl-tech .add { position: absolute; top: 0; bottom: 0; width: var(--w); display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 18px; text-decoration: none; border-radius: 10px; }
.tl-tech .add:hover, .tl-tech .add:focus-visible { background: var(--brand-soft); color: var(--brand); }
@media (hover: none) { .tl-tech .add { color: #d6d8e6; } }
.tl-past { position: absolute; top: 44px; bottom: 0; left: var(--label); background: rgba(243, 245, 251, .55); z-index: 1; pointer-events: none; }
/* thanh lịch hẹn: màu đậm + chữ trắng như mẫu */
.bar { position: absolute; z-index: 2; height: calc(var(--lane) - 8px); padding: 6px 10px 6px 6px; border-radius: 14px; color: #fff; font-size: 12px;
  overflow: hidden; white-space: nowrap; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #2a78d6, #4f8fe6); box-shadow: 0 6px 14px rgba(42, 120, 214, .25); }
.bar .av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: rgba(255, 255, 255, .25); }
.bar .tx { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.bar b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.bar span { opacity: .85; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.bar:hover { filter: brightness(1.06); }
.bar.s-confirmed, .lg.s-confirmed { background: linear-gradient(135deg, #5146e8, #7c6cf6); box-shadow: 0 6px 14px rgba(81, 70, 232, .25); }
.bar.s-arrived, .lg.s-arrived { background: linear-gradient(135deg, #f08a1c, #f7a93b); box-shadow: 0 6px 14px rgba(240, 138, 28, .25); }
.bar.s-done, .lg.s-done { background: linear-gradient(135deg, #169a55, #2bb673); box-shadow: 0 6px 14px rgba(22, 154, 85, .22); }
.lg.s-booked { background: linear-gradient(135deg, #2a78d6, #4f8fe6); }
.tl .now { position: absolute; top: 44px; bottom: 0; width: 2px; background: var(--brand); z-index: 4; pointer-events: none; }
.tl .now::before { content: attr(data-t); position: absolute; top: -30px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 4px 18px; font-size: 12px; align-items: center; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 4px; margin-right: 5px; vertical-align: middle; }

/* ---------------- Điện thoại / iPad ---------------- */
.bottom { display: none; }
@media (max-width: 1024px) { .main { padding: 18px 20px 40px; } .today { display: none; } }
@media (max-width: 820px) {
  .rail { display: none; }
  .main { padding: 14px 14px calc(var(--nav-h) + 28px); }
  .topbar { margin-bottom: 16px; }
  .search { flex: 1; }
  .me-name { display: none; }
  .page-head h1 { font-size: 24px; }
  .bottom { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); height: var(--nav-h);
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); border-radius: 22px; box-shadow: 0 10px 30px rgba(22, 23, 43, .14); z-index: 30; padding: 0 6px; }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: var(--muted); gap: 3px; }
  .bottom a.on { color: var(--ink); }
  .bottom a.on .ico { color: #fff; background: var(--ink); border-radius: 10px; padding: 5px; width: 30px; height: 30px; }
  .hide-sm { display: none !important; }
  .stats { gap: 10px; } .stat { padding: 14px; } .stat b { font-size: 20px; margin-top: 10px; }
  .stat .go { display: none; }
  .grid.wide { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 18px; }
  .sig.overdue { margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .total-bar { bottom: calc(var(--nav-h) + 20px); padding: 10px 14px; }
  .total-bar .sum:not(.big) { display: none; }
  .total-bar .sum.big { border: 0; margin: 0; padding: 0; font-size: 18px; }
  .total-bar .btn { min-height: 44px !important; margin-top: 8px !important; }
  .tl-grid { --label: 108px; --w: 44px; --lane: 54px; } .tl-label { padding: 6px 8px; } .tl-label .avatar { display: none; }
  .big-card { min-height: 150px; } .big-card .num { font-size: 36px; }
  .bars { height: 200px; grid-template-columns: 46px 1fr; }
  .day-group { grid-template-columns: 1fr; }
}

/* ---------------- Dashboard ---------------- */
.dash-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 2fr); gap: 18px; margin-bottom: 18px; }
.dash-top .stat { margin: 0; }
.dash-top .chart-card { grid-column: 3; grid-row: 1 / span 2; }
.dash-top.no-chart { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.dash-mid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); gap: 18px; }
.dash-mid .card + .card { margin-top: 0; }
@media (max-width: 1180px) {
  .dash-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-top .chart-card { grid-column: 1 / -1; grid-row: auto; }
  .dash-mid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-mid > .card:last-child:nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 820px) { .dash-top, .dash-mid { gap: 10px; } .dash-mid { grid-template-columns: 1fr 1fr; } .dash-mid .card:nth-child(3) { grid-column: 1 / -1; } }
.bars .col .tip { font-style: normal; }
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 36px 40px; align-items: center; gap: 10px; color: var(--ink); font-size: 13px; }
.hbar .lbl { color: var(--ink-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .trk { height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.hbar .trk i { display: block; height: 100%; min-width: 4px; background: var(--brand); border-radius: 99px; }
.hbar b { text-align: right; } .hbar small { color: var(--muted); text-align: right; }
.hbar:hover .trk i { background: var(--brand-2); }
.status-cards { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.lead-table td:first-child { min-width: 220px; }
.lead-table td:nth-child(2) { min-width: 130px; }
.lead-table td:nth-child(3) { min-width: 220px; }
.lead-table td:nth-child(4), .lead-table td:nth-child(5) { white-space: nowrap; }
@media (max-width: 820px) { .status-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; } .status-card .bd b { font-size: 20px; } .status-card .bd .muted { display: none; } .lead-table td:first-child { min-width: 0; } }
.card-head { flex-wrap: wrap; } .card-head h2 { white-space: nowrap; }
@media (max-width: 820px) {
  .topbar .spacer { display: none; }
  .topbar .search { flex: 1 1 auto; min-width: 0; }
  .card-head .muted { order: 5; width: 100%; }
  .page-head { align-items: flex-start; } .page-head .spacer { display: none; }
}
.picked { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 20px; }
.pick { display: inline-flex; align-items: center; gap: 8px; padding: 7px 8px 7px 14px; border-radius: 99px; background: var(--brand-soft);
  color: var(--brand); font-weight: 600; font-size: 13px; }
.pick button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(81, 70, 232, .15); color: var(--brand); cursor: pointer; font-size: 14px; line-height: 1; }
/* ---- hồ sơ khách ---- */
.profile { padding: 22px 24px; }
.profile-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-top h1 { margin: 0 0 6px; font-size: 26px; }
.profile-top .muted .ico { width: 14px; height: 14px; vertical-align: -2px; }
.avatar.xl { width: 64px; height: 64px; font-size: 24px; border-radius: 20px; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.profile-stats span { display: block; font-size: 12px; color: var(--muted); }
.profile-stats b { font-size: 18px; }
.pkg { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.pkg:last-child { border-bottom: 0; }
.pkg.done { opacity: .55; }
.pkg-item { display: grid; grid-template-columns: minmax(0, 1fr) 120px 40px; gap: 10px; align-items: center; margin-top: 8px; font-size: 13px; }
@media (max-width: 820px) { .profile { padding: 16px; } .profile-stats { grid-template-columns: repeat(3, 1fr); } .profile-top .spacer { display: none; } }
.next-call { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--info-soft); color: var(--info); margin-bottom: 8px; }
.next-call .muted { color: inherit; opacity: .8; }
.next-call.late { background: var(--bad-soft); color: var(--bad); }
.call-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.call-row:last-child { border-bottom: 0; }
.call-row .n { width: 28px; height: 28px; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
/* ---- bộ chọn khoảng ngày ---- */
.dr { position: relative; }
.dr-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--card);
  box-shadow: var(--shadow); font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.dr-btn .ico { width: 16px; height: 16px; color: var(--brand); }
.dr-btn small { color: var(--muted); font-weight: 500; }
.dr-pop { position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; display: flex; max-width: calc(100vw - 16px); background: var(--card); border-radius: 18px;
  box-shadow: 0 20px 50px rgba(22, 23, 43, .18); overflow: hidden; }
.toolbar .dr-pop, .page-head .dr-pop { left: auto; right: 0; }
.dr-presets { width: 200px; padding: 12px 8px; border-right: 1px solid var(--line); max-height: 400px; overflow-y: auto; }
.dr-presets label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink); }
.dr-presets label:hover { background: var(--line-2); }
.dr-presets input { accent-color: var(--brand); }
.dr-main { padding: 14px 16px; display: flex; flex-direction: column; }
.dr-cals { position: relative; display: flex; gap: 22px; padding: 0 22px; }
.dr-nav { position: absolute; top: -2px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--line-2); cursor: pointer; font-size: 18px; }
.dr-nav.prev { left: 0; } .dr-nav.next { right: 0; }
.dr-mh { text-align: center; font-weight: 700; margin-bottom: 8px; }
.dr-grid { display: grid; grid-template-columns: repeat(7, 36px); gap: 2px 0; }
.dr-grid .wd { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.dr-grid button { height: 34px; border: 0; background: none; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.dr-grid button:hover { background: var(--line-2); border-radius: 8px; }
.dr-grid button.in { background: var(--brand-soft); }
.dr-grid button.start, .dr-grid button.end { background: var(--brand); color: #fff; border-radius: 8px; }
.dr-grid button.today { font-weight: 800; color: var(--brand); }
.dr-grid button.start.today, .dr-grid button.end.today { color: #fff; }
.dr-grid button.off { color: #c9ccda; cursor: default; }
.dr-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.dr-foot .dr-range { flex-basis: 100%; order: -1; }
.dr-foot label { margin: 0; }
.dr-foot select { width: auto; min-height: 34px; }
@media (max-width: 820px) {
  .dr-pop { position: fixed; left: 10px !important; right: 10px !important; top: 70px; flex-direction: column; max-height: calc(100vh - 160px); overflow-y: auto; }
  .dr-presets { width: auto; display: flex; flex-wrap: wrap; gap: 4px; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .dr-presets label { padding: 6px 10px; background: var(--line-2); }
  .dr-cals { flex-direction: column; align-items: center; gap: 14px; }
  .dr-cal:nth-of-type(2) { display: none; }
}
.sum-table tr.total td { background: #f7f8fc; font-weight: 600; }
.sum-table td { white-space: nowrap; }
.status-card .bd .trend { margin-left: 0; }
/* ---- chia trang ---- */
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 4px 4px; }
.pages { display: flex; gap: 4px; }
.pg { min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px; display: grid; place-items: center; font-weight: 600; font-size: 13px;
  color: var(--ink-2); background: var(--line-2); }
.pg:hover { background: var(--brand-soft); color: var(--brand); }
.pg.on { background: var(--ink); color: #fff; }
.pg.off { opacity: .35; pointer-events: none; }
.pg.gap { background: none; pointer-events: none; }
@media (max-width: 820px) { .pager { justify-content: center; } .pager .spacer { display: none; } }
