/* ============ Tokens ============
   Phương án A "Xanh dương doanh nghiệp" (kiểu Microsoft 365 / Atlassian / MISA).
   Sáng: nền xanh xám rất nhạt, thẻ trắng, menu navy.
   Tối: kiểu GitHub Dimmed — xám xanh vừa phải (không đen kịt), mỗi lớp sáng dần rõ rệt
   để phân biệt menu / nền / thẻ / ô nhập / tab đang chọn. */
:root {
  --bg: #f4f6fa;               /* nền trang: xanh xám rất nhạt */
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --line: #e1e6ee;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #2563eb;          /* nút chính, liên kết, mục đang chọn */
  --primary-2: #1d4ed8;        /* khi rê chuột */
  --primary-soft: #e8effd;
  --on-primary: #ffffff;
  --brand: #0f2447;
  --brand-2: #1d4ed8;
  --side: #0f2447;             /* nền menu trái: xanh navy */
  --side-accent: #60a5fa;      /* vạch mục menu đang chọn */
  --hero-a: #1e40af;           /* nền thẻ nổi bật */
  --hero-b: #2563eb;
  --seg-bg: #e6ebf3;           /* nền nhóm tab */
  --seg-on: #ffffff;           /* tab đang chọn */
  --gold: #d4af6a;             /* điểm nhấn vàng đồng (thẻ quảng bá) */
  --gold-2: #e8c887;
  --good: #15803d;
  --good-soft: #e7f6ec;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fdf2e0;
  --sale: #2563eb;
  --buy: #f59e0b;
  --shadow: 0 1px 2px rgba(15, 36, 71, .05), 0 6px 20px -10px rgba(15, 36, 71, .16);
  --shadow-lg: 0 10px 28px -8px rgba(15, 36, 71, .2);
  --focus: rgba(37, 99, 235, .22);
  --cta-shadow: rgba(37, 99, 235, .45);
  /* Bảng kiểu Excel (báo cáo / form nhập) */
  --x-bg: #ffffff; --x-text: #111111; --x-head: #dce6f2; --x-head-text: #1f3b66; --x-grid: #8c8c8c; --x-rule: #222222;
  --x-sep: #bdbdbd; --x-dot: #cfcfcf; --x-border: #d6dbe3; --x-card-line: #e3e3e3; --x-muted: #666666;
  --x-note: #333333; --x-ph: #bdbdbd; --x-neg: #d90000; --x-hl: #ffff00; --x-hl-text: #111111;
  --x-focus: #2563eb; --x-focus-bg: #eef4ff; --x-bad-bg: #fff0f0; --x-manual: #c25400;
  --c1: #2563eb; --c2: #b07d2a;   /* màu biểu đồ: gia hạn / phí triển khai (đã kiểm tra mù màu) */
  --r: 14px;
  --r-sm: 10px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c2230;
    --surface: #252c3b;
    --surface-2: #2e3647;
    --line: #353e52;
    --text: #dfe4ec;
    --muted: #9aa6b8;
    --primary: #6ea8fe;
    --primary-2: #8fbcff;
    --primary-soft: rgba(110, 168, 254, .16);
    --on-primary: #0b1426;
    --brand: #151a24;
    --brand-2: #2a4a8a;
    --side: #151a24;
    --side-accent: #6ea8fe;
    --hero-a: #22417a;
    --hero-b: #2c58a3;
    --seg-bg: #151a24;
    --seg-on: #343d51;
    --good: #5fd08f;
    --good-soft: rgba(95, 208, 143, .14);
    --bad: #f47a7a;
    --bad-soft: rgba(244, 122, 122, .14);
    --warn: #e8b15a;
    --warn-soft: rgba(232, 177, 90, .14);
    --sale: #6ea8fe;
    --buy: #e8b15a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 18px -10px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 30px -8px rgba(0, 0, 0, .5);
    --focus: rgba(110, 168, 254, .3);
    --cta-shadow: rgba(0, 0, 0, .45);
    --x-bg: #252c3b; --x-text: #dfe4ec; --x-head: #34405a; --x-head-text: #e6ecf5; --x-grid: #46506a; --x-rule: #7a869c;
    --x-sep: #4a5570; --x-dot: #353e52; --x-border: #353e52; --x-card-line: #353e52; --x-muted: #9aa6b8;
    --x-note: #c9d1dc; --x-ph: #66728a; --x-neg: #f47a7a; --x-hl: rgba(250, 204, 21, .24); --x-hl-text: #fde68a;
    --x-focus: #6ea8fe; --x-focus-bg: rgba(110, 168, 254, .12); --x-bad-bg: rgba(244, 122, 122, .13); --x-manual: #f0a55a;
  --c1: #3d7fe6; --c2: #b0812c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c2230;
  --surface: #252c3b;
  --surface-2: #2e3647;
  --line: #353e52;
  --text: #dfe4ec;
  --muted: #9aa6b8;
  --primary: #6ea8fe;
  --primary-2: #8fbcff;
  --primary-soft: rgba(110, 168, 254, .16);
  --on-primary: #0b1426;
  --brand: #151a24;
  --brand-2: #2a4a8a;
  --side: #151a24;
  --side-accent: #6ea8fe;
  --hero-a: #22417a;
  --hero-b: #2c58a3;
  --seg-bg: #151a24;
  --seg-on: #343d51;
  --good: #5fd08f;
  --good-soft: rgba(95, 208, 143, .14);
  --bad: #f47a7a;
  --bad-soft: rgba(244, 122, 122, .14);
  --warn: #e8b15a;
  --warn-soft: rgba(232, 177, 90, .14);
  --sale: #6ea8fe;
  --buy: #e8b15a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 18px -10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 30px -8px rgba(0, 0, 0, .5);
  --focus: rgba(110, 168, 254, .3);
  --cta-shadow: rgba(0, 0, 0, .45);
  --x-bg: #252c3b; --x-text: #dfe4ec; --x-head: #34405a; --x-head-text: #e6ecf5; --x-grid: #46506a; --x-rule: #7a869c;
  --x-sep: #4a5570; --x-dot: #353e52; --x-border: #353e52; --x-card-line: #353e52; --x-muted: #9aa6b8;
  --x-note: #c9d1dc; --x-ph: #66728a; --x-neg: #f47a7a; --x-hl: rgba(250, 204, 21, .24); --x-hl-text: #fde68a;
  --x-focus: #6ea8fe; --x-focus-bg: rgba(110, 168, 254, .12); --x-bad-bg: rgba(244, 122, 122, .13); --x-manual: #f0a55a;
  --c1: #3d7fe6; --c2: #b0812c;
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
button { font: inherit; color: inherit; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 20px 0; }
.grow { flex: 1; min-width: 0; }
.strong { font-weight: 600; }
.neg { color: var(--bad) !important; }
.pos { color: var(--good); }
.nowrap { white-space: nowrap; }
.ic { flex-shrink: 0; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============ Shell ============ */
.app { min-height: 100vh; }
.side { display: none; }
.main { padding-bottom: calc(var(--tabbar) + 90px + env(safe-area-inset-bottom)); }
.page { max-width: 1120px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-h p { margin: 2px 0 0; font-size: .88rem; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .7rem; font-weight: 500; background: none; border: 0; cursor: pointer;
}
.tabbar .on { color: var(--primary); }
.tabbar .on .ic { stroke-width: 2.3; }

@media (min-width: 900px) {
  .side {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: 236px; z-index: 20;
    background: var(--side); color: #fff; padding: 18px 10px 12px; overflow-y: auto; box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06);
  }
  .main { margin-left: 236px; padding-bottom: 90px; }
  .tabbar { display: none; }
  .page { padding: 28px 32px; }
  h1 { font-size: 1.6rem; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand b { display: block; font-size: 1.05rem; }
.brand small { color: rgba(255, 255, 255, .6); font-size: .78rem; }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--primary); color: var(--on-primary); }
.side .logo { background: rgba(96, 165, 250, .16); border: 1px solid rgba(96, 165, 250, .45); color: #bfdbfe; }
.logo.big { width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 6px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: rgba(255, 255, 255, .68); font-weight: 500; transition: background .15s, color .15s, transform .15s;
}
.side nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.side nav a.on { background: rgba(255, 255, 255, .13); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--side-accent); }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding: 0 2px; }
.side-foot .who { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 6px; }
.side-foot small { color: rgba(255, 255, 255, .55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; }
.side-foot .icon-btn { width: 30px; height: 30px; color: rgba(255, 255, 255, .6); }
.side-foot .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* Thẻ quảng bá dịch vụ — ghim đáy menu (theo bộ cấu kiện mẫu) */
@keyframes promoGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 106, 0); } 50% { box-shadow: 0 0 16px 2px rgba(212, 175, 106, .28); } }
@keyframes promoBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.promo-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px;
  margin: auto 6px 6px; padding: 14px 12px 12px; border-radius: 14px; text-decoration: none;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .14); border-top: 2px solid var(--gold);
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
  animation: promoGlow 2.8s ease-in-out infinite;
}
.promo-card:hover { transform: translateY(-3px); background: rgba(255, 255, 255, .09); border-color: rgba(212, 175, 106, .55); }
.promo-card:active { transform: translateY(0); }
.promo-card-icon {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; background: rgba(212, 175, 106, .16); border: 1px solid rgba(212, 175, 106, .45);
  animation: promoBounce 2.4s ease-in-out infinite;
}
.promo-card-text { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.promo-card-text strong { font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, .95); line-height: 1.4; }
.promo-card-text span { font-size: 11px; font-weight: 800; color: var(--gold-2); white-space: nowrap; }
.promo-card.on-light { background: var(--side); margin: 4px 0 0; }

.theme-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 6px; padding: 8px;
  border: 0; border-radius: 8px; background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .8);
  font-size: .78rem; font-weight: 500; cursor: pointer; transition: background .15s;
}
.theme-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* ============ Controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.08); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0 4px; }
.flip { display: inline-flex; transform: rotate(180deg); }

.inp {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.inp.num { text-align: right; font-variant-numeric: tabular-nums; }
.inp.big { font-size: 1.2rem; font-weight: 600; }
input[type=date].inp { min-width: 0; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld > span { font-size: .82rem; font-weight: 500; color: var(--muted); }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row.wrap { flex-wrap: wrap; justify-content: space-between; }
.w-date { width: 165px; flex-shrink: 0; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; min-height: 44px; }
.toggle.small { font-size: .82rem; min-height: auto; color: var(--muted); }
.toggle input { width: 20px; height: 20px; accent-color: var(--primary); }
.hint { margin: 0; font-size: .82rem; color: var(--muted); }

.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 180px; }
.search .ic { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search .inp { padding-left: 36px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.combo-wrap { position: relative; flex: 1; min-width: 200px; }
.combo-wrap .inp { padding-right: 36px; }
.combo-wrap .clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 34px; height: 34px; cursor: pointer; border-radius: 50%; }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px;
  list-style: none; max-height: 260px; overflow: auto; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-lg);
}
.combo-list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.combo-list li:hover, .combo-list li.hi { background: var(--primary-soft); }
.combo-list li.new { color: var(--primary); font-weight: 600; border-top: 1px solid var(--line); margin-top: 2px; }

.seg { display: inline-flex; background: var(--seg-bg); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 500; font-size: .9rem;
  color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 38px;
}
.seg button.on { background: var(--seg-on); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

.range { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 99px;
  font-size: .85rem; font-weight: 500; white-space: nowrap; cursor: pointer; color: var(--muted);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.range-dates { display: flex; align-items: center; gap: 8px; }
.range-dates .inp { flex: 1; }
.range-dates span { color: var(--muted); }
@media (min-width: 1150px) {
  .range { flex-direction: row; align-items: center; justify-content: space-between; }
  .chips { margin: 0; padding: 0; }
  .range-dates { width: 340px; }
}

.badge { display: inline-flex; align-items: center; gap: 3px; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--good-soft); color: var(--good); }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .9rem; text-transform: uppercase;
}

.fab {
  position: fixed; z-index: 25; right: 16px; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 8px; height: 54px; padding: 0 22px 0 18px; border-radius: 27px;
  border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: .98rem; cursor: pointer;
  box-shadow: 0 8px 22px -6px var(--cta-shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.fab:hover { transform: translateY(-3px); background: var(--primary-2); box-shadow: 0 12px 28px -6px var(--cta-shadow); }
.fab:active { transform: translateY(-1px) scale(.98); }
@media (min-width: 900px) { .fab { bottom: 28px; right: 32px; } }

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 4px; gap: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 1000px) { .grid2 { grid-template-columns: 1.15fr 1fr; align-items: start; } }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); color: var(--text); min-width: 0;
}
.kpi > span { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi b { font-size: clamp(1.02rem, 4.4vw, 1.3rem); font-weight: 700; letter-spacing: -.01em; }
.kpi > small { font-size: .74rem; color: var(--muted); }
.kpi.hero {
  grid-column: 1 / -1; position: relative; overflow: hidden; border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--hero-a) 0%, var(--hero-b) 100%); box-shadow: var(--shadow-lg);
}
.kpi.hero::before, .kpi.hero::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08); pointer-events: none; }
.kpi.hero::before { width: 160px; height: 160px; top: -70px; right: -50px; }
.kpi.hero::after { width: 110px; height: 110px; bottom: -60px; left: -30px; background: rgba(255, 255, 255, .06); }
.kpi.hero > * { position: relative; }
.kpi.hero > span, .kpi.hero > small { color: inherit; opacity: .85; }
.kpi.hero b { font-size: 1.9rem; }
.kpi.good b { color: var(--good); }
.kpi.bad b { color: var(--bad); }
.kpi.link:hover { border-color: var(--primary); }
@media (min-width: 700px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi.hero { grid-column: span 1; }
  .kpi.hero b { font-size: 1.5rem; }
}
@media (min-width: 1200px) { .kpis { grid-template-columns: repeat(5, 1fr); } }

.legend { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.dot.sale { background: var(--sale); }
.dot.buy { background: var(--buy); }
.chart svg { width: 100%; height: 220px; display: block; }
.chart-tip { font-size: .85rem; min-height: 22px; margin-bottom: 4px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .bar.sale { fill: var(--sale); }
.chart .bar.buy { fill: var(--buy); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart g.hov .hit { fill: var(--surface-2); }
.chart g.dim .bar { opacity: .35; }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.tbl tr.first td { border-top: 1px solid var(--line); }
.tbl tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--line); }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .c { text-align: center; color: var(--good); }
.tbl tbody tr:hover td { background: var(--surface-2); }

.debts { list-style: none; margin: 0 -8px; padding: 0; max-height: 520px; overflow: auto; }
.debts a, .debts button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border-radius: var(--r-sm);
  color: var(--text); background: none; border: 0; cursor: pointer; text-align: left;
}
.debts a:hover, .debts button:hover { background: var(--surface-2); }
.total-row { display: flex; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 600; }

/* lists of orders/payments */
.summary { display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.summary div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.summary div:last-child { text-align: right; }
.summary div > span { font-size: .75rem; color: var(--muted); }
.summary b { font-size: 1.05rem; }
.day { display: flex; flex-direction: column; gap: 8px; }
.day-h { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 6px 4px 0; }
.order {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow);
}
.order:hover { border-color: var(--primary); }
.order-h { display: flex; align-items: center; gap: 8px; }
.order-h b:first-child { flex: 1; font-size: 1rem; }
.order-lines { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.order-lines li { display: flex; gap: 10px; align-items: baseline; }
.order-lines li > span:nth-child(2) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-lines .money { min-width: 90px; text-align: right; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; background: none;
  border-radius: var(--r-sm); text-align: left; cursor: pointer; color: var(--text);
}
.row + .row { border-top: 1px solid var(--line); border-radius: 0; }
.row:hover { background: var(--surface-2); }
.row .grow { display: flex; flex-direction: column; }
.row small { font-size: .8rem; }

/* ============ Modal / sheet ============ */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(9, 18, 36, .55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s;
}
.sheet {
  width: 100%; max-height: 94vh; background: var(--surface); border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; box-shadow: 0 24px 60px -12px rgba(9, 18, 36, .45); animation: up .24s cubic-bezier(.2, .9, .3, 1.1);
  position: relative; overflow: hidden;
}
/* Thanh kéo trên điện thoại */
.sheet::before { content: ''; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 99px; background: var(--line); }
.sheet-h { display: flex; align-items: center; gap: 12px; padding: 20px 14px 14px 20px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; }
.sheet-sub { margin: 2px 0 0; font-size: .82rem; color: var(--muted); }
.sheet-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.sheet-ic.warn { background: var(--warn-soft); color: var(--warn); }
.sheet-ic.danger { background: var(--bad-soft); color: var(--bad); }
.sheet-ic.ok { background: var(--good-soft); color: var(--good); }
.sheet-b { padding: 18px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
/* Không cho nội dung trong hộp thoại bị ép bẹp khi dài — hộp thoại tự cuộn */
.sheet-b > * { flex-shrink: 0; }
.sheet-f {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface-2);
}
.sheet-f .total { display: flex; flex-direction: column; }
.sheet-f .total small { font-size: .75rem; color: var(--muted); }
.sheet-f .total b { font-size: 1.2rem; }
.confirm-text { margin: 0; line-height: 1.6; }
.confirm-text + .confirm-text { margin-top: -6px; color: var(--muted); font-size: .9rem; }
@media (min-width: 700px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { width: 560px; border-radius: 18px; max-height: 88vh; animation: pop .2s cubic-bezier(.2, .9, .3, 1.2); }
  .sheet::before { display: none; }
  .sheet.wide { width: 920px; }
  .sheet.small { width: 440px; }
  .sheet.small .sheet-h { border-bottom: 0; padding-bottom: 4px; }
  .sheet.small .sheet-b { padding-top: 8px; }
  .sheet.small .sheet-f { background: transparent; border-top: 0; padding-top: 4px; padding-bottom: 18px; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-grid a, .menu-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; border-radius: var(--r);
  background: var(--surface-2); border: 0; color: var(--text); font-size: .82rem; font-weight: 500; text-align: center; cursor: pointer;
}
.menu-grid .on { background: var(--primary-soft); color: var(--primary); }
.menu-grid .emoji { font-size: 24px; line-height: 26px; }

/* order lines editor */
.lines { display: flex; flex-direction: column; gap: 10px; }
.lines-h { display: none; }
.line {
  display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  grid-template-columns: .8fr 1.1fr 1.1fr 40px;
  grid-template-areas: "prod prod prod del" "qty price amt amt" "note note note note";
}
.c-prod { grid-area: prod; } .c-qty { grid-area: qty; } .c-price { grid-area: price; }
.c-amt { grid-area: amt; font-weight: 600; } .c-note { grid-area: note; } .c-del { grid-area: del; align-self: center; }
.c-amt.manual { border-color: var(--warn); }
.line .inp { background: var(--surface); }
.line .inp.num { padding: 9px 10px; }
.add-line { align-self: flex-start; }
@media (min-width: 700px) {
  .lines-h, .line { display: grid; grid-template-columns: 1.5fr .75fr 1fr 1.1fr 1fr 40px; grid-template-areas: "prod qty price amt note del"; gap: 8px; }
  .line { padding: 0; border: 0; background: none; }
  .lines-h span { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
  .lines-h span:nth-child(n+2):nth-child(-n+4) { text-align: right; }
}
.paynow { width: 220px; }
.balance-hint { background: var(--primary-soft); color: var(--text); padding: 10px 14px; border-radius: var(--r-sm); font-size: .9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* statement / bill */
.day-pick { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.day-pick .inp { max-width: 180px; }
.bill { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.bill-h { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; padding-bottom: 12px; border-bottom: 2px solid var(--primary); }
.bill-h small { display: block; font-size: .75rem; color: var(--muted); }
.bill-h h2 { font-size: 1.3rem; }
.bill-h .r { text-align: right; }
.sub-h { font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
.pays-mini { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.pays-mini div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; background: var(--good-soft); border-radius: 8px; }
.totals { margin: 0; display: flex; flex-direction: column; gap: 6px; margin-left: auto; width: 100%; max-width: 380px; }
.totals div { display: flex; justify-content: space-between; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--line); padding-top: 8px; margin-top: 4px; font-size: 1.15rem; }
.totals .grand dt { color: var(--text); font-weight: 700; }
.totals .grand dd { color: var(--primary); font-weight: 700; }
.note { margin: 0; font-size: .88rem; color: var(--muted); font-style: italic; }
.bill-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Form nhập phiếu bán / nhập: y hệt bảng báo cáo (nền giấy trắng) */
.xl.xf-paper { overflow: visible; padding: 14px 10px 10px; }
.xf-party { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.xf-party .combo { flex: 1; max-width: 360px; }
.xf-party .inp { background: var(--x-bg); color: var(--x-text); border-color: var(--x-sep); }
.xl-tbl.xf { font-size: .92rem; }
.xf th { background: var(--x-head); color: var(--x-head-text); }
.xf col.x-d { width: 9%; } .xf col.x-n { width: 17%; } .xf col.x-q { width: 11%; } .xf col.x-p { width: 13%; }
.xf col.x-a { width: 14%; } .xf col.x-t { width: 14%; } .xf col.x-g { width: 18%; } .xf col.x-x { width: 4%; }
.xf td { padding: 0; vertical-align: middle; }
.xf .cell .inp, .xf .inp.cell {
  border: 0; border-radius: 0; background: transparent; color: inherit; min-height: 38px; padding: 7px 6px; box-shadow: none; width: 100%;
}
.xf .cell .inp:focus, .xf .inp.cell:focus { outline: 2px solid var(--x-focus); outline-offset: -2px; background: var(--x-focus-bg); box-shadow: none; }
.xf .inp::placeholder { color: var(--x-ph); }
/* Máy tính: đã có tiêu đề cột nên ẩn chữ gợi ý trong ô (trừ dòng đầu) */
@media (min-width: 700px) { .xf tbody tr:not(:first-child) .inp::placeholder { color: transparent; } }
.xf .t-date .inp, .xf .t-prod .inp, .xf .t-note .inp { text-align: center; }
.xf .inp.bad { outline: 2px solid var(--x-neg); outline-offset: -2px; background: var(--x-bad-bg); }
.xf .inp.amt { font-weight: 600; }
.xf .inp.amt.manual { color: var(--x-manual); }
.xf tr.neg td:not(.t-pay):not(.t-note) .inp { color: var(--x-neg); font-weight: 700; }
.xf tr.neg td.t-pay, .xf tr.neg td.t-note { color: var(--x-text); font-weight: 400; }
.qty-cell { display: flex; align-items: center; }
.qty-cell .sign { border: 0; background: none; color: var(--x-ph); font-weight: 700; font-size: .95rem; width: 18px; padding: 0; cursor: pointer; flex-shrink: 0; }
.qty-cell .sign:hover { color: var(--x-neg); }
.xf .t-del .icon-btn { width: 28px; height: 28px; color: var(--x-ph); }
.xf .t-del .icon-btn:hover { color: var(--x-neg); background: var(--x-bad-bg); }
.xf .combo-list { color: var(--text); text-align: left; }
.xf-paper .add-line { margin-top: 6px; color: var(--primary); }
@media (max-width: 699px) {
  .xl-tbl.xf, .xf tbody, .xf tfoot { display: block; }
  .xf colgroup, .xf thead { display: none; }
  .xf tbody tr {
    display: grid; grid-template-columns: 1fr 1fr 1.2fr 34px;
    grid-template-areas: "date prod prod del" "qty price amt amt" "pay pay note note";
    border: 1px solid var(--x-sep); border-radius: 8px; margin-bottom: 8px;
  }
  .xf td { display: block; border: 0 !important; }
  .xf .t-date { grid-area: date; border-right: 1px solid var(--x-card-line) !important; border-bottom: 1px solid var(--x-card-line) !important; }
  .xf .t-prod { grid-area: prod; border-bottom: 1px solid var(--x-card-line) !important; }
  .xf .t-del { grid-area: del; display: grid; place-items: center; border-bottom: 1px solid var(--x-card-line) !important; }
  .xf .t-qty { grid-area: qty; border-right: 1px solid var(--x-card-line) !important; }
  .xf .t-price { grid-area: price; border-right: 1px solid var(--x-card-line) !important; }
  .xf .t-amt { grid-area: amt; }
  .xf .t-pay { grid-area: pay; border-top: 1px solid var(--x-card-line) !important; border-right: 1px solid var(--x-card-line) !important; }
  .xf .t-note { grid-area: note; border-top: 1px solid var(--x-card-line) !important; }
  .xf .t-pay .inp::placeholder, .xf .t-note .inp::placeholder, .xf .t-amt .inp::placeholder { color: var(--x-ph); }
  .xf tfoot tr { display: flex; justify-content: space-between; border-top: 1px solid var(--x-rule); }
  .xf tfoot td { display: block; }
  .xf tfoot td:empty { display: none; }
}

/* Phiếu dạng Excel (báo cáo khách / NCC) — luôn nền trắng như tờ giấy để chụp ảnh gửi Zalo */
.xl-wrap { display: flex; flex-direction: column; gap: 12px; }
.xl {
  background: var(--x-bg); color: var(--x-text); border: 1px solid var(--x-border); border-radius: 6px; padding: 16px 12px 14px;
  font-family: 'Be Vietnam Pro', Arial, sans-serif; box-shadow: var(--shadow); overflow-x: auto;
}
.xl-party { font-size: .95rem; margin-left: 8%; }
.xl-party span { font-weight: 600; margin-right: 6px; }
.xl-party b { font-weight: 700; }
.xl-title { text-align: center; font-size: clamp(1rem, 4.2vw, 1.35rem); font-weight: 700; margin: 8px 0 12px; color: var(--x-text); }
.xl-tbl { width: 100%; min-width: 340px; border-collapse: collapse; font-size: clamp(.7rem, 3vw, .9rem); font-variant-numeric: tabular-nums; }
.xl-tbl col.c-d { width: 9%; } .xl-tbl col.c-n { width: 17%; } .xl-tbl col.c-q { width: 11%; }
.xl-tbl col.c-p { width: 14%; } .xl-tbl col.c-a { width: 17%; } .xl-tbl col.c-t { width: 17%; } .xl-tbl col.c-g { width: 15%; }
.xl-tbl th {
  background: var(--x-head); color: var(--x-head-text); font-weight: 700; text-align: center; padding: 8px 4px; border-top: 1px solid var(--x-rule); border-bottom: 1px solid var(--x-rule);
  border-left: 1px solid var(--x-grid); white-space: nowrap;
}
.xl-tbl th:first-child, .xl-tbl td:first-child { border-left: 0; }
.xl-tbl td { padding: 6px 6px; border-left: 1px solid var(--x-grid); border-bottom: 1px dotted var(--x-dot); vertical-align: top; }
.xl-tbl tbody tr.first td { border-top: 1px solid var(--x-sep); }
.xl-tbl tbody tr:first-child td { border-top: 0; }
.xl-tbl .c { text-align: center; } .xl-tbl .r { text-align: right; white-space: nowrap; }
.xl-tbl tr.neg td:not(.pay):not(.gc) { color: var(--x-neg); font-weight: 700; }
.xl-tbl .negc { color: var(--x-neg); font-weight: 700; }
.xl-tbl td.gc { font-size: .88em; color: var(--x-note); text-align: center; }
.xl-tbl td.empty { color: var(--x-muted); padding: 18px; }
.xl-tbl tfoot td { border-bottom: 0; padding: 8px 6px; font-size: 1.05em; }
.xl-tbl tfoot tr:first-child td { border-top: 1px solid var(--x-rule); }
.xl-tbl tfoot tr + tr td { border-top: 1px solid var(--x-rule); }
.xl-tbl tfoot .lbl { text-align: right; font-weight: 700; border-left: 0; }
.xl-tbl tfoot .b { font-weight: 700; }
.xl-tbl tfoot .hl { background: var(--x-hl); color: var(--x-hl-text); }
@media (max-width: 520px) {
  .xl { padding: 12px 4px 10px; }
  .xl-party { margin-left: 4px; font-size: .88rem; }
  .xl-tbl { min-width: 0; font-size: 9.5px; }
  .xl-tbl colgroup { display: none; }
  .xl-tbl th { white-space: normal; padding: 6px 2px; line-height: 1.2; }
  .xl-tbl td { padding: 5px 2px; }
  .xl-tbl td.gc { min-width: 40px; font-size: 1em; }
  .xl-tbl tfoot td { font-size: 1em; padding: 7px 2px; }
}
}
/* Khi chụp ảnh: khổ cố định, chữ to rõ */
.xl.capture { width: 820px; border: 0; border-radius: 0; box-shadow: none; padding: 22px 18px 18px; overflow: visible; }
.xl.capture .xl-title { font-size: 1.45rem; }
.xl.capture .xl-tbl { font-size: 15px; }
@media print { .xl { border: 0; box-shadow: none; padding: 0; } }

/* states */
.loading { display: grid; place-items: center; padding: 60px 0; }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 50px 16px; color: var(--muted); text-align: center; }
.empty p { margin: 0; }
.errbox { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; background: var(--bad-soft); color: var(--bad); padding: 12px 14px; border-radius: var(--r-sm); }

.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; pointer-events: auto;
  background: var(--surface); color: var(--text); padding: 11px 10px 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); border-left: 4px solid var(--good); box-shadow: var(--shadow-lg);
  font-weight: 500; font-size: .92rem; line-height: 1.45; animation: up .22s;
}
.toast-ic { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; background: var(--good-soft); color: var(--good); }
.toast.err { border-left-color: var(--bad); }
.toast.err .toast-ic { background: var(--bad-soft); color: var(--bad); }
.toast-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; }
.toast-x:hover { background: var(--surface-2); color: var(--text); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 0%, var(--primary-soft), var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 30px 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card .fld { text-align: left; }
.login-card p { margin: 0 0 6px; font-size: .9rem; }

/* ============ Hiệu ứng (theo bộ cấu kiện mẫu) ============ */
@keyframes gtFadeInDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes gtFadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes gtFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes gtPulseRing { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .4); } 50% { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); } }
/* Nội dung mỗi trang hiện dần từ dưới lên, so le từng khối */
.page > :not(.fab):not(.overlay) { animation: gtFadeInUp .45s ease both; }
.page > :nth-child(2) { animation-delay: .04s; } .page > :nth-child(3) { animation-delay: .08s; }
.page > :nth-child(4) { animation-delay: .12s; } .page > :nth-child(5) { animation-delay: .16s; }
.page > :nth-child(n+6) { animation-delay: .2s; }
.kpis > .kpi { animation: gtFadeInUp .45s ease both; }
.kpis > .kpi:nth-child(2) { animation-delay: .06s; } .kpis > .kpi:nth-child(3) { animation-delay: .12s; }
.kpis > .kpi:nth-child(4) { animation-delay: .18s; } .kpis > .kpi:nth-child(5) { animation-delay: .24s; }
/* Nổi lên khi rê chuột */
.kpi, .order, .card, .menu-grid a, .menu-grid button { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.order:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.menu-grid a:hover, .menu-grid button:hover { transform: translateY(-3px); }
.btn { transition: background .15s, transform .12s, box-shadow .15s; }
.btn.primary:hover { box-shadow: 0 6px 16px -4px var(--cta-shadow); transform: translateY(-1px); }

/* ============ Trang Giới thiệu (theo bộ cấu kiện mẫu) ============
   Màu thống nhất với menu: navy trầm + điểm nhấn vàng đồng, còn lại trung tính (không dùng xanh dương chói). */
.intro {
  --i-deep: #0f2447; --i-mid: #1f3b66; --i-ink: #1f3b66; --i-soft: #eef2f8; --i-soft-line: #dfe6f1;
  --i-gold: #b8893b; --i-gold-soft: #fbf4e6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .intro {
    --i-deep: #1d2a44; --i-mid: #2b3d60; --i-ink: #c3cfe2; --i-soft: #2a3244; --i-soft-line: #39435a;
    --i-gold: #e3bd72; --i-gold-soft: rgba(227, 189, 114, .12);
  }
}
:root[data-theme="dark"] .intro {
  --i-deep: #1d2a44; --i-mid: #2b3d60; --i-ink: #c3cfe2; --i-soft: #2a3244; --i-soft-line: #39435a;
  --i-gold: #e3bd72; --i-gold-soft: rgba(227, 189, 114, .12);
}
.page.intro { gap: 0; }
.page.intro > :not(.fab):not(.overlay) { animation: none; }
.gt-hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 42px 24px 38px;
  background: linear-gradient(135deg, var(--i-deep) 0%, var(--i-mid) 100%); border-top: 3px solid var(--gold);
  color: #fff; text-align: center; margin-bottom: 20px; box-shadow: var(--shadow-lg);
}
.page.intro > .gt-hero { animation: gtFadeInDown .55s ease both; }
.gt-hero::before, .gt-hero::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .06); }
.gt-hero::before { width: 240px; height: 240px; top: -100px; right: -70px; }
.gt-hero::after { width: 170px; height: 170px; bottom: -80px; left: -50px; background: rgba(212, 175, 106, .08); }
.gt-hero-icon { position: relative; font-size: 46px; display: inline-block; margin-bottom: 10px; animation: gtFloat 3s ease-in-out infinite; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .2)); }
.gt-hero-title { position: relative; margin: 0 0 10px; font-size: 27px; font-weight: 800; letter-spacing: -.01em; }
.gt-hero-sub { position: relative; margin: 0 auto; max-width: 580px; font-size: 14.5px; line-height: 1.6; color: rgba(255, 255, 255, .86); }
.gt-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--i-mid);
  border-radius: 0 14px 14px 0; padding: 18px 20px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.page.intro > .gt-card, .page.intro > .gt-banner, .page.intro > .gt-cta, .page.intro > .gt-social-row { animation: gtFadeInUp .5s ease both; }
.gt-card p { margin: 0 0 12px; line-height: 1.75; font-size: 14px; }
.gt-card p:last-child { margin-bottom: 0; }
.gt-eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 4px; color: var(--i-gold); }
.gt-section-title { margin: 0 0 16px; font-size: 19px; font-weight: 800; }
.gt-exp-badge {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; margin-left: 4px;
  font-size: 11.5px; font-weight: 800; color: var(--i-gold); background: var(--i-gold-soft);
  border: 1px solid color-mix(in srgb, var(--i-gold) 40%, transparent); padding: 4px 11px; border-radius: 20px;
}
.gt-feature-grid, .gt-service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 24px; }
.gt-feature-card {
  display: flex; align-items: flex-start; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px 16px; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  opacity: 0; animation: gtFadeInUp .5s ease both;
}
.gt-feature-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--i-soft-line); }
.gt-feature-icon { flex-shrink: 0; width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--i-soft); font-size: 18px; }
.gt-feature-text { font-size: 13.5px; line-height: 1.55; padding-top: 5px; }
.gt-banner {
  text-align: center; border-radius: 14px; padding: 16px 22px; font-size: 13.5px; line-height: 1.7; margin-bottom: 26px;
  background: var(--i-soft); color: var(--i-ink); border: 1px solid var(--i-soft-line);
}
.gt-divider { height: 1px; background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent); margin: 4px 0 26px; }
.gt-service-grid { gap: 12px; margin-bottom: 26px; }
.gt-service-card {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 15px; font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  opacity: 0; animation: gtFadeInUp .5s ease both;
}
.gt-service-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--i-gold) 55%, transparent); }
.gt-service-icon { font-size: 17px; flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--i-gold-soft); }
.gt-steps { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; max-width: 800px; margin: 0 auto 26px; }
.gt-step {
  display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 30px; padding: 7px 16px 7px 7px; font-size: 12.5px; font-weight: 700;
  opacity: 0; animation: gtFadeInUp .45s ease both;
}
.gt-step-num { width: 25px; height: 25px; border-radius: 50%; background: var(--i-mid); color: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
.gt-step-arrow { color: var(--muted); font-size: 18px; font-weight: 800; }
.gt-cta {
  display: block; text-align: center; text-decoration: none; border-radius: 20px; padding: 30px 20px 26px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--i-deep) 0%, var(--i-mid) 100%); color: #fff; border-top: 3px solid var(--gold);
  box-shadow: var(--shadow-lg); transition: transform .18s ease, box-shadow .18s ease;
}
.gt-cta:hover { transform: translateY(-4px); box-shadow: 0 16px 36px -10px rgba(15, 36, 71, .55); }
.gt-cta:active { transform: translateY(-1px) scale(.99); }
@keyframes gtPulseGold { 0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 106, .45); } 50% { box-shadow: 0 0 0 12px rgba(212, 175, 106, 0); } }
.gt-cta-ring {
  display: inline-flex; align-items: center; justify-content: center; width: 50px; height: 50px; border-radius: 50%;
  background: rgba(212, 175, 106, .16); border: 1px solid rgba(212, 175, 106, .5); margin-bottom: 12px; font-size: 23px;
  animation: gtPulseGold 1.8s ease-in-out infinite;
}
.gt-cta-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: rgba(255, 255, 255, .8); margin-bottom: 6px; }
.gt-cta-phone { font-size: 27px; font-weight: 800; letter-spacing: .6px; color: var(--gold-2); }
.gt-social-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 4px 0 18px; }
.gt-social-btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 13.5px; font-weight: 700;
  color: var(--i-ink); background: var(--surface); border: 1px solid var(--line); border-radius: 30px; padding: 10px 20px;
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.gt-social-btn .ic { color: var(--i-gold); }
.gt-social-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--i-gold) 55%, transparent); }
.gt-tagline { text-align: center; font-weight: 800; color: var(--i-ink); margin: 4px 0 0; font-size: 13.5px; }

/* Giảm hiệu ứng nếu máy bật chế độ hạn chế chuyển động */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============ In ấn ============ */
@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .side, .tabbar, .fab, .no-print, .toasts { display: none !important; }
  .main { margin: 0; padding: 0; }
  .page { padding: 0; max-width: none; }
  .bill { border: 0; box-shadow: none; padding: 0; }
  .tbl-wrap { overflow: visible; margin: 0; padding: 0; }
  .tbl tbody tr:hover td { background: none; }
}

/* ---------- Hạn dùng: băng nhắc + trang gia hạn ---------- */
.lic-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 16px 0; padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid; font-size: 14px; line-height: 1.45; }
.lic-banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.lic-banner.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.lic-banner .grow { flex: 1 1 220px; }
.lic-emoji { font-size: 20px; line-height: 1; }
.lic-status { border-left: 4px solid var(--good); }
.lic-status.warn { border-left-color: var(--warn); }
.lic-status.bad { border-left-color: var(--bad); }
.lic-big { font-size: 20px; margin: 0; }
.lic-status p { margin: 0; }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.plan { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; transition: border-color .15s, transform .15s; }
.plan:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-1px); }
.plan:disabled { opacity: .6; cursor: wait; }
.plan-price { font-size: 20px; font-weight: 700; color: var(--primary); }
.pay { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.qr-box { width: 260px; height: 260px; max-width: 100%; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px; box-sizing: border-box; }
img.qr-box { height: auto; aspect-ratio: 1; }
.pay-info { flex: 1 1 240px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pay-info p { margin: 0; }
.pay-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.pay-dl dt { color: var(--muted); }
.pay-dl dd { margin: 0; overflow-wrap: anywhere; }
.pay-wait { display: flex; align-items: center; gap: 8px; color: var(--primary); }
.spin.sm { width: 16px; height: 16px; border-width: 2px; }
.lic-done { display: flex; gap: 12px; align-items: flex-start; background: var(--good-soft); color: var(--good); padding: 14px; border-radius: var(--r-sm); }
.lic-done p { margin: 4px 0 0; }
@media (max-width: 640px) { .lic-banner { margin: 10px 12px 0; } .pay { justify-content: center; } }

/* ============ App quản lý khách hàng ============ */
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.badges:empty { display: none; }
.dim { opacity: .55; }
.w-sm { width: 110px; }
.w-auto { width: auto; min-width: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.pre { white-space: pre-wrap; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; font-weight: 500; align-self: flex-start; }
.ext { display: inline-flex; align-items: center; gap: 3px; overflow-wrap: anywhere; }
.inp.sm { height: 34px; padding: 4px 8px; font-size: .88rem; max-width: 150px; margin-left: auto; }

.avatar.code { width: auto; min-width: 42px; height: 30px; padding: 0 6px; border-radius: 8px; font-size: .74rem; letter-spacing: .02em; }
.avatar.promo { font-size: 1rem; }
.code-tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); vertical-align: middle; }
.code-tag.big { font-size: .9rem; padding: 2px 8px; }

.flush-list { display: flex; flex-direction: column; margin: 0 -8px; }
.flush-list > * + * { border-top: 1px solid var(--line); }
.flush-list .row + .row { border-top: 0; }
.row-actions { display: flex; align-items: center; gap: 6px; padding-right: 8px; }
.row-actions .row { flex: 1; min-width: 0; }
.row .r { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.row .grow { min-width: 0; flex: 1; }
.type-row { cursor: default; }
.type-row .grow { gap: 2px; }

.expiry-card { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--good); box-shadow: var(--shadow); }
.expiry-card.warn { border-left-color: var(--warn); }
.expiry-card.bad { border-left-color: var(--bad); }
.expiry-card.bad b { color: var(--bad); }
.expiry-card .grow { display: flex; flex-direction: column; gap: 2px; }
.expiry-card span { font-size: .8rem; color: var(--muted); }
.expiry-card b { font-size: 1.5rem; }
.expiry-card small { color: var(--muted); }

.dl { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 8px 14px; margin: 0; }
.dl > div { display: contents; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; line-height: 1.5; }
.steps.compact { gap: 6px; }
.steps li.done::marker { color: var(--good); }
.steps li.done { color: var(--muted); }
.steps li.done::after { content: ' ✓'; color: var(--good); font-weight: 700; }
.codebox { margin: 0; padding: 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-family: ui-monospace, Consolas, monospace; font-size: .82rem; white-space: pre-wrap; word-break: break-all; user-select: all; }
.check-box { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); font-size: .9rem; }
.check-box.ok { background: var(--good-soft); }
.check-box.warn { background: var(--warn-soft); }

.plan-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.plan-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.plan-opt:hover { border-color: var(--primary); }
.plan-opt.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--focus); }
.plan-opt .money { font-weight: 700; color: var(--primary); }
.plan-opt s { font-size: .8rem; }
.promo-tag { color: var(--warn); font-size: .75rem; font-weight: 600; }
.expiry-preview { display: flex; align-items: center; justify-content: space-around; gap: 10px; padding: 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.expiry-preview div { display: flex; flex-direction: column; align-items: center; }
.expiry-preview span { font-size: .78rem; color: var(--muted); }
.expiry-preview b { font-size: 1.1rem; }

.kpis-4 { grid-template-columns: repeat(2, 1fr); }
.kpis-4 .kpi.hero { grid-column: 1 / -1; }
@media (min-width: 900px) { .kpis-4 { grid-template-columns: repeat(4, 1fr); } }
.kpi.warn b { color: var(--warn); }
a.kpi { text-decoration: none; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.bar-row span { color: var(--muted); }
.bar-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--primary); min-width: 2px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid h4 { margin: 8px 0 -4px; font-size: .9rem; color: var(--primary); }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.pick-box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow: auto; }
.pick-box legend { font-size: .82rem; font-weight: 500; color: var(--muted); padding: 0 4px; }
.pick-group { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.pick-group > small { flex-basis: 100%; }
.guide .steps code { font-size: .8rem; }
/* Nhóm tab trong hộp thoại: chia đều, chữ dài tự xuống dòng thay vì tràn ngang */
.seg.fill { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; overflow: visible; }
.seg.fill button { white-space: normal; line-height: 1.2; padding: 6px 6px; }
@media (max-width: 640px) {
  .seg.fill button { font-size: .8rem; }
  .row-actions .badge { display: none; }
  .row-actions .btn { padding: 0 10px; }
}
.tbl tr.clickable { cursor: pointer; }

/* ============ Bảng giá: 4 gói chuẩn ============ */
.price-base { flex-direction: row; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; border-top: 3px solid var(--primary); }
.price-base-l { flex: 1 1 300px; display: flex; flex-direction: column; gap: 4px; }
.price-eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.price-base-inp { display: flex; align-items: center; gap: 10px; flex: 0 1 300px; }
.price-base-inp .inp { font-size: 1.5rem; font-weight: 700; min-height: 56px; color: var(--primary); }
.price-base-inp > span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.price-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .price-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .price-grid { grid-template-columns: repeat(4, 1fr); } }
.pc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; transition: border-color .15s, opacity .15s;
}
.pc.sale { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.pc.off { opacity: .55; }
.pc-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-h b { font-size: 1.05rem; }
.pc-price { display: flex; align-items: baseline; gap: 4px; }
.pc-price b { font-size: 1.6rem; color: var(--primary); letter-spacing: -.01em; }
.pc-price small { color: var(--muted); }
.pc-note { margin: 0; font-size: .8rem; }
.pc-full { font-size: .84rem; color: var(--muted); }
.pc-row .link { white-space: nowrap; }
.pc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-pct { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.pc-pct .inp { width: 76px; min-height: 38px; padding: 6px 10px; }
.pc-foot { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px dashed var(--line); margin-top: auto; }
.save-tag { align-self: flex-start; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
/* Công tắc bật/tắt */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .18s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Thanh lưu dính đáy màn hình */
.save-bar {
  position: sticky; bottom: calc(var(--tabbar) + 10px + env(safe-area-inset-bottom)); z-index: 15;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px 10px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  font-size: .9rem; color: var(--muted);
}
.save-bar.show { border-color: var(--primary); box-shadow: 0 10px 30px -10px var(--cta-shadow); color: var(--text); font-weight: 500; }
@media (min-width: 900px) { .save-bar { bottom: 16px; } }

/* ============ Tổng quan ============ */
.dash-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.dash-h p { margin: 2px 0 0; font-size: .88rem; }
.dash-h .dash-date { font-size: .76rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--primary); margin: 0 0 4px; }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--r-sm); font-size: .9rem; font-weight: 500;
  border: 1px solid; color: var(--text); transition: transform .15s;
}
.alert:hover { transform: translateX(3px); }
.alert.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert.bad .ic, .alert.bad b { color: var(--bad); }
.alert.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.alert.info .ic, .alert.info b { color: var(--primary); }
.alert b { font-size: .85rem; white-space: nowrap; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 1000px) { .stats { grid-template-columns: 1.3fr 1fr 1fr 1fr; } }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); color: var(--text);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
a.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.stat-ic { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.stat-l { font-size: .8rem; font-weight: 500; color: var(--muted); padding-right: 40px; }
.stat-v { font-size: clamp(1.15rem, 4.6vw, 1.5rem); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-v small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.stat-s { font-size: .76rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat.hero {
  grid-column: 1 / -1; overflow: hidden; border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--hero-a) 0%, var(--hero-b) 100%); box-shadow: var(--shadow-lg);
}
@media (max-width: 999px) { .stats > .stat:last-child { grid-column: 1 / -1; } }
@media (min-width: 1000px) { .stat.hero { grid-column: auto; } }
.stat.hero::before, .stat.hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08); pointer-events: none; }
.stat.hero::before { width: 170px; height: 170px; top: -80px; right: -50px; }
.stat.hero::after { width: 110px; height: 110px; bottom: -60px; left: 40%; background: rgba(255, 255, 255, .05); }
.stat.hero .stat-l, .stat.hero .stat-s, .stat.hero .stat-v small { color: rgba(255, 255, 255, .82); }
.stat.hero .stat-v { font-size: clamp(1.5rem, 6vw, 1.9rem); }
.trend { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 99px; font-weight: 700; font-size: .74rem; background: rgba(255, 255, 255, .18); color: #fff; }
.trend.dn { background: rgba(0, 0, 0, .18); }

.dash-grid { display: grid; gap: 14px; }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: 1.55fr 1fr; align-items: stretch; } }
.card-h small { display: block; font-size: .78rem; }
.legend { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 6px; flex-shrink: 0; }
.sw.c1 { background: var(--c1); } .sw.c2 { background: var(--c2); }

/* Biểu đồ doanh thu */
.rc { display: flex; flex-direction: column; gap: 12px; }
.rc-tip { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; font-size: .85rem; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.rc-tip > span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.rc-tip > span b { color: var(--text); }
.rc-tip .sw { margin-left: 0; }
.rc-total { margin-left: auto; }
.rc-tip .rc-total b { color: var(--primary); }
.rc-plot { position: relative; height: 220px; padding-left: 38px; }
.rc-grid { position: absolute; inset: 0 0 24px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.rc-grid div { position: relative; border-top: 1px dashed var(--line); height: 0; }
.rc-grid div:last-child { border-top: 1px solid color-mix(in srgb, var(--muted) 45%, transparent); }
.rc-grid span { position: absolute; left: 0; top: -8px; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rc-cols { position: relative; height: 100%; display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.rc-col {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0;
  border: 0; background: none; padding: 0; cursor: pointer; border-radius: 8px 8px 0 0; height: 100%;
}
.rc-col:hover, .rc-col.on { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.rc-area { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.rc-stack { display: flex; flex-direction: column; gap: 2px; width: min(60%, 26px); transition: height .5s cubic-bezier(.2, .8, .2, 1); }
.rc-stack .rc-seg { display: block; min-height: 3px; }
.rc-stack .rc-seg:first-child { border-radius: 4px 4px 0 0; }
.rc-stack .rc-seg.c1 { background: var(--c1); } .rc-stack .rc-seg.c2 { background: var(--c2); }
.rc-col:not(.on) .rc-stack { opacity: .78; }
.rc-x { height: 24px; line-height: 24px; font-size: .72rem; color: var(--muted); flex-shrink: 0; }
.rc-col.on .rc-x { color: var(--text); font-weight: 700; }
.rc-col:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; }

/* Tình trạng khách */
.sb { display: flex; flex-direction: column; gap: 14px; }
.sb-big { display: flex; align-items: baseline; gap: 8px; }
.sb-big b { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.sb-big span { color: var(--muted); font-size: .88rem; }
.sb-bar { display: flex; gap: 2px; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.sb-seg, .sb-dot { background: var(--muted); }
.sb-seg.ok, .sb-dot.ok { background: var(--good); }
.sb-seg.warn, .sb-dot.warn { background: var(--warn); }
.sb-seg.grace, .sb-dot.grace { background: color-mix(in srgb, var(--bad) 55%, var(--surface)); }
.sb-seg.readonly, .sb-dot.readonly { background: var(--bad); }
.sb-seg.none, .sb-dot.none { background: color-mix(in srgb, var(--muted) 55%, var(--surface)); }
.sb-seg.stopped, .sb-dot.stopped { background: var(--line); }
.sb-list { list-style: none; margin: 0 -8px; padding: 0; display: flex; flex-direction: column; }
.sb-list a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--text); font-size: .9rem; }
.sb-list a:hover { background: var(--surface-2); }
.sb-list li.zero a { color: var(--muted); }
.sb-list b { font-variant-numeric: tabular-nums; min-width: 24px; text-align: right; }
.sb-list small { min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.sb-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.soon-sum { font-size: .82rem; color: var(--muted); }
.soon-sum b { color: var(--text); }
.days-pill { flex-shrink: 0; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--good-soft); color: var(--good); white-space: nowrap; }
.days-pill.warn { background: var(--warn-soft); color: var(--warn); }
.days-pill.bad { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 640px) { .row-actions .days-pill { display: none; } }
