/* ==========================================================================
   NHẤT ĐẠI TÔNG SƯ — Hệ thống giao diện v3 "Lịch Xuyến Chỉ"
   Cảm hứng ứng dụng lịch: lưới ngày rõ ràng, con số lớn, nhãn âm lịch phụ, thẻ nhẹ, nhịp khoảng trắng đều.
   Bản sắc: giấy Xuyến Chỉ, mực đen, chu sa ấn chương, vàng đồng — tối giản, sang trọng.
   ========================================================================== */
:root {
  --paper: #F4EFE6; --surface: #FFFDF8; --surface-2: #F8F3EA; --sunk: #EDE5D7;
  --ink: #1E1B18; --ink-2: #4A433B; --muted: #8A8175; --rule: #E3D9C9; --rule-2: #D6CAB6;
  --cinnabar: #9E2A2B; --cinnabar-2: #7F1F20; --cinnabar-soft: #F3DEDA;
  --gold: #B8893A; --gold-soft: #F2E6CC; --jade: #2D6A55; --jade-soft: #DCEBE3; --indigo: #3B4D7A; --indigo-soft: #E1E5F0;
  --shadow: 0 1px 0 rgba(30,27,24,.04), 0 8px 24px -12px rgba(30,27,24,.18);
  --shadow-lg: 0 24px 60px -20px rgba(30,27,24,.35);
  --r: 18px; --r-sm: 12px; --r-xs: 8px;
  --serif: 'Noto Serif', 'Source Serif Pro', Cambria, 'Times New Roman', Georgia, serif; /* Georgia trên Windows thiếu dấu tiếng Việt chồng (Ấ, Ộ…) → để cuối */
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px; --side-w: 248px; --maxw: 760px;
  color-scheme: light;
}
[data-theme="dark"] {
  --paper: #11100E; --surface: #1A1815; --surface-2: #211E1A; --sunk: #2A2621;
  --ink: #F1EBE0; --ink-2: #CFC5B6; --muted: #978D7F; --rule: #2F2A24; --rule-2: #3B352D;
  --cinnabar: #C8484A; --cinnabar-2: #E05A5C; --cinnabar-soft: #3A1D1C;
  --gold: #D4AE6A; --gold-soft: #3A3021; --jade: #5FAE8E; --jade-soft: #1C3229; --indigo: #8EA0D8; --indigo-soft: #222A40;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.8);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cinnabar); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; line-height: 1.25; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 18px; } h4 { font-size: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 11.5px; letter-spacing: .02em; }
.serif { font-family: var(--serif); } .center { text-align: center; } .hidden { display: none !important; }
.row { display: flex; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.gap { gap: 10px; } .gap-s { gap: 6px; } .gap-l { gap: 16px; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; } .stack-l > * + * { margin-top: 20px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.eyebrow { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* ── Khung ứng dụng ─────────────────────────────────────────────────────── */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.main { padding: calc(14px + var(--safe-t)) 16px calc(var(--tab-h) + 24px + var(--safe-b)); max-width: var(--maxw); width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 40px; }
.topbar h1 { font-size: 24px; flex: 1; }
.topbar .sub { font-size: 13px; color: var(--muted); font-family: var(--sans); font-weight: 400; display: block; margin-top: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-2); position: relative; }
.icon-btn:hover { background: var(--sunk); }
.icon-btn .badge { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--cinnabar); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a.on { color: var(--cinnabar); }
.tabbar a.ask-tab .ask-bubble { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: var(--cinnabar); color: #fff; margin-top: -18px; box-shadow: 0 10px 22px -8px var(--cinnabar); }
.tabbar a.ask-tab .ic { stroke: #fff; }
.side { display: none; }

@media (min-width: 980px) {
  .shell { grid-template-columns: var(--side-w) 1fr; }
  .tabbar { display: none; }
  .main { padding: 28px 40px 48px; max-width: 920px; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 24px 16px; border-right: 1px solid var(--rule); background: var(--surface-2); }
  .side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
  .side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 500; }
  .side nav a:hover { background: var(--sunk); }
  .side nav a.on { background: var(--surface); color: var(--cinnabar); box-shadow: var(--shadow); }
  .side .side-foot { margin-top: auto; }
}
.brand-mark { width: 36px; height: 36px; display: block; object-fit: contain; flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); }
.brand-name { font-family: var(--serif); font-weight: 700; letter-spacing: .06em; font-size: 14px; }
.brand-tag { font-size: 11px; color: var(--muted); }

/* ── Thẻ, nút, ô nhập ───────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; } .card.tight { padding: 12px; } .card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-head h3 { font-size: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--rule-2); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); } .btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff; } .btn.primary:hover { background: var(--cinnabar-2); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; } .btn.ghost:hover { background: var(--sunk); }
.btn.danger { background: transparent; border-color: var(--cinnabar); color: var(--cinnabar); }
.btn.block { width: 100%; } .btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.busy { position: relative; color: transparent !important; } .btn.busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--rule-2); background: var(--surface); font-size: 13.5px; cursor: pointer; line-height: 1.3; text-align: left; }
.chip:hover { border-color: var(--cinnabar); color: var(--cinnabar); } .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; } .chips.scroll > * { white-space: nowrap; flex: none; } .chips.scroll { align-items: center; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; } .chips.scroll::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--ink-2); }
.pill.red { background: var(--cinnabar-soft); color: var(--cinnabar); } .pill.gold { background: var(--gold-soft); color: var(--gold); } .pill.jade { background: var(--jade-soft); color: var(--jade); } .pill.indigo { background: var(--indigo-soft); color: var(--indigo); }
.field { display: block; margin-bottom: 14px; } .field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); } .field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--rule-2); background: var(--surface); outline: none; }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
.input:focus { border-color: var(--cinnabar); box-shadow: 0 0 0 3px var(--cinnabar-soft); }
.input.err { border-color: var(--cinnabar); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); margin: 10px 0; cursor: pointer; } .check input { margin-top: 3px; accent-color: var(--cinnabar); width: 18px; height: 18px; flex: none; }
.seg { display: inline-flex; background: var(--sunk); border-radius: 12px; padding: 3px; gap: 2px; } .seg button { white-space: nowrap; border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--muted); } .seg button.on { background: var(--ink); color: var(--paper); box-shadow: var(--shadow); } .seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.seg-opt { position: relative; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; padding: 7px 14px; min-height: 36px; border-radius: 9px;
  font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--muted); -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.seg-opt.on { background: var(--ink); color: var(--paper); box-shadow: var(--shadow); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } @media (max-width: 520px) { .grid2.resp { grid-template-columns: 1fr; } }
.divider { height: 1px; background: var(--rule); margin: 14px 0; }
.list { display: flex; flex-direction: column; } .list-item { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--rule); cursor: pointer; color: inherit; } .list-item:last-child { border-bottom: 0; } .list-item:hover { background: color-mix(in srgb, var(--sunk) 50%, transparent); }
.list-item .meta { flex: 1; min-width: 0; } .list-item .title { font-weight: 600; } .list-item .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; font-family: var(--serif); flex: none; }

/* ── Hôm nay: tờ lịch ──────────────────────────────────────────────────── */
.leaf { position: relative; overflow: hidden; padding: 0; }
.leaf-top { background: var(--cinnabar); color: #fff; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; letter-spacing: .04em; font-size: 13px; }
.leaf-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 6px; padding: 18px 16px 16px; align-items: center; }
.leaf-day { font-family: var(--serif); font-size: 104px; line-height: .9; font-weight: 700; color: var(--ink); letter-spacing: -.04em; }
.leaf-weekday { font-family: var(--serif); font-size: 18px; margin-top: 6px; }
.leaf-lunar { border-left: 1px solid var(--rule); padding-left: 16px; }
.leaf-lunar .big { font-family: var(--serif); font-size: 44px; line-height: 1; color: var(--cinnabar); font-weight: 700; }
.leaf-lunar .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.cc { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px dashed var(--rule-2); }
.cc > div { padding: 10px 12px; text-align: center; } .cc > div + div { border-left: 1px dashed var(--rule-2); }
.cc .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; } .cc .v { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.hour { border-radius: 12px; padding: 8px 4px; text-align: center; background: var(--surface-2); border: 1px solid var(--rule); }
.hour .n { font-family: var(--serif); font-weight: 600; } .hour .t { font-size: 11px; color: var(--muted); }
.hour.good { background: var(--jade-soft); border-color: transparent; } .hour.good .n { color: var(--jade); }
.hour.best { background: var(--jade); border-color: var(--jade); } .hour.best .n, .hour.best .t { color: #fff; }
.hour.now { outline: 2px solid var(--cinnabar); outline-offset: -2px; }
.ask-hero { display: flex; gap: 10px; align-items: center; padding: 6px 6px 6px 16px; border-radius: 16px; border: 1px solid var(--rule-2); background: var(--surface); box-shadow: var(--shadow); cursor: text; }
.ask-hero > span:first-child { flex: 1; color: var(--muted); }
.quota { display: flex; align-items: center; gap: 12px; } .bar { height: 6px; background: var(--sunk); border-radius: 999px; overflow: hidden; flex: 1; } .bar > i { display: block; height: 100%; background: var(--gold); border-radius: 999px; }

/* ── Lịch tháng ────────────────────────────────────────────────────────── */
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-head h2 { font-size: 24px; } .month-head .sub { font-size: 13px; color: var(--muted); }
.dow, .mgrid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dow div { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 6px 0; letter-spacing: .05em; } .dow div:last-child { color: var(--cinnabar); }
.mgrid { gap: 4px; }
.mcell { aspect-ratio: 1 / 1.08; border-radius: 14px; background: var(--surface); border: 1px solid var(--rule); padding: 6px; display: flex; flex-direction: column; cursor: pointer; position: relative; min-width: 0; }
.mcell.out { visibility: hidden; } .mcell .s { font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 1; } .mcell .l { font-size: 10.5px; color: var(--muted); margin-top: auto; }
.mcell .l.first { color: var(--cinnabar); font-weight: 700; } .mcell.sun .s { color: var(--cinnabar); }
.mcell.today { background: var(--ink); border-color: var(--ink); } .mcell.today .s, .mcell.today .l { color: var(--paper); }
.mcell.sel { outline: 2px solid var(--cinnabar); outline-offset: 1px; }
.mcell .mk { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; }
.mcell.tot .mk { background: var(--jade); } .mcell.ky .mk { background: var(--cinnabar); }
@media (min-width: 600px) { .mcell .s { font-size: 22px; } .mcell .l { font-size: 12px; } }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; } .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }

/* ── Hỏi Tông Sư ───────────────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 14px; padding-bottom: 210px; }
.msg-user { align-self: flex-end; max-width: 86%; background: var(--ink); color: var(--paper); padding: 11px 15px; border-radius: 18px 18px 6px 18px; white-space: pre-wrap; }
.msg-ai { align-self: stretch; }
.ai-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.ai-card .who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.seal { width: 22px; height: 22px; display: block; object-fit: contain; flex: none; }
.notice { font-size: 13.5px; color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--rule-2); border-radius: 12px; padding: 10px 12px; }
.progress-steps { display: flex; flex-direction: column; gap: 8px; } .pstep { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); } .pstep .dotp { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--rule-2); }
.pstep.done { color: var(--ink-2); } .pstep.done .dotp { background: var(--jade); border-color: var(--jade); } .pstep.cur { color: var(--ink); font-weight: 600; } .pstep.cur .dotp { border-color: var(--cinnabar); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--cinnabar-soft); } }
.reframe { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.reframe summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; } .reframe summary::-webkit-details-marker { display: none; }
.reframe dl { margin: 10px 0 0; display: grid; grid-template-columns: 128px 1fr; gap: 6px 12px; } .reframe dt { color: var(--muted); font-size: 12.5px; } .reframe dd { margin: 0; }
@media (max-width: 520px) { .reframe dl { grid-template-columns: 1fr; } .reframe dt { margin-top: 6px; } }
.prose p { margin: 0 0 12px; font-size: 15.5px; line-height: 1.72; } .prose p:first-child { font-family: var(--serif); font-size: 17px; line-height: 1.6; font-weight: 600; }
.prose ul { padding-left: 18px; margin: 0 0 12px; }
.reading-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 15; padding: 10px 16px 12px; background: linear-gradient(to top, var(--paper) 70%, transparent); }
.composer-inner { max-width: var(--maxw); margin: 0 auto; background: var(--surface); border: 1px solid var(--rule-2); border-radius: 18px; padding: 8px; box-shadow: var(--shadow-lg); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 6px 8px; min-height: 44px; max-height: 160px; line-height: 1.45; }
.composer .tools { display: flex; gap: 6px; align-items: center; } .composer .tools .chip { padding: 5px 10px; font-size: 12.5px; }
@media (min-width: 980px) { .composer { left: var(--side-w); bottom: 0; padding-bottom: 20px; } .thread { padding-bottom: 200px; } }
.stars { display: inline-flex; gap: 2px; } .stars button { border: 0; background: none; cursor: pointer; padding: 2px; color: var(--rule-2); } .stars button.on { color: var(--gold); } .stars .ic { fill: currentColor; stroke: none; }

/* ── Hồ sơ & lá số ─────────────────────────────────────────────────────── */
.profile-hero { display: flex; gap: 14px; align-items: center; } .profile-hero .avatar { width: 58px; height: 58px; font-size: 20px; border-radius: 18px; }
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pillar { border: 1px solid var(--rule); border-radius: 14px; text-align: center; padding: 10px 4px; background: var(--surface-2); }
.pillar .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; } .pillar .can, .pillar .chi { font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.15; }
.pillar .can { color: var(--cinnabar); } .pillar .tt { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; }
.palaces { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, minmax(78px, auto)); gap: 4px; }
.palace { border: 1px solid var(--rule); border-radius: 10px; padding: 6px; font-size: 11.5px; background: var(--surface); overflow: hidden; }
.palace .pn { font-weight: 700; font-size: 11px; color: var(--cinnabar); text-transform: uppercase; letter-spacing: .04em; } .palace .pc { color: var(--muted); font-size: 10.5px; }
.palace .stars-main { font-family: var(--serif); font-weight: 600; font-size: 12.5px; color: var(--ink); }
.palace.menh { border-color: var(--cinnabar); background: var(--cinnabar-soft); }
.palace-center { grid-column: 2 / 4; grid-row: 2 / 4; border: 1px dashed var(--rule-2); border-radius: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 8px; font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.warn { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 9px 11px; border-radius: 10px; background: var(--gold-soft); color: var(--ink-2); } .warn + .warn { margin-top: 6px; }

/* ── Gói dịch vụ ───────────────────────────────────────────────────────── */
.plans { display: grid; gap: 12px; } @media (min-width: 760px) { .plans { grid-template-columns: repeat(3, 1fr); } }
.plan { position: relative; display: flex; flex-direction: column; } .plan.feat { border: 2px solid var(--cinnabar); }
.plan .ribbon { position: absolute; top: -11px; left: 16px; background: var(--cinnabar); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: .06em; }
.plan .price { font-family: var(--serif); font-size: 28px; font-weight: 700; } .plan .per { font-size: 13px; color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 12px 0 16px; font-size: 14px; } .plan li { display: flex; gap: 8px; padding: 4px 0; } .plan li .ic { width: 18px; height: 18px; color: var(--jade); } .plan li.no { color: var(--muted); } .plan li.no .ic { color: var(--rule-2); }
.plan .btn { margin-top: auto; }
.ladder { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; margin: 8px 0 4px; } .ladder i { height: 6px; border-radius: 3px; background: var(--sunk); } .ladder i.on { background: var(--gold); }

/* ── Bảng tính, bảng quản trị ──────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; } @media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi .v { font-family: var(--serif); font-size: 26px; font-weight: 700; } .kpi .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 14px; background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; } table.t th, table.t td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.t th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); } table.t tr:last-child td { border-bottom: 0; } table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
table.t td.wrap { white-space: normal; min-width: 240px; }
pre.code { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 12px; padding: 12px; font-size: 12px; overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word; }
.admin-nav { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; } .admin-nav a { padding: 7px 12px; border-radius: 10px; color: var(--ink-2); font-size: 13.5px; font-weight: 600; white-space: nowrap; border: 1px solid var(--rule); background: var(--surface); } .admin-nav a.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; } .bars div { flex: 1; background: var(--gold); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; } .bars div:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 11px; background: var(--ink); color: var(--paper); padding: 2px 6px; border-radius: 6px; white-space: nowrap; }

/* ── Lớp phủ: sheet, toast, trạng thái ─────────────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(20,18,15,0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.sheet-wrap.open { background: rgba(20,18,15,.45); }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; padding-bottom: var(--safe-b); }
.sheet.wide { max-width: 760px; } .sheet-wrap.open .sheet { transform: none; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; transform: translateY(20px); opacity: 0; transition: transform .2s, opacity .2s; } .sheet-wrap.open .sheet { opacity: 1; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--rule-2); margin: 8px auto 0; } @media (min-width: 700px) { .sheet-grip { display: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 6px 20px; } .sheet-body { overflow-y: auto; padding: 6px 20px 20px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; z-index: 80; background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 14px; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow-lg); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.error { background: var(--cinnabar); color: #fff; }
.skeleton { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; } .sk-line { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--sunk), var(--surface-2), var(--sunk)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 36px 16px; } .empty h4 { margin: 12px 0 6px; } .empty .btn { margin-top: 12px; }
.empty-seal { width: 64px; height: 64px; margin: 0 auto; display: block; object-fit: contain; opacity: .85; }
.paywall { border: 1px solid var(--gold); background: linear-gradient(160deg, var(--gold-soft), var(--surface)); }
.banner { padding: 10px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 12px; } .banner.warn { background: var(--gold-soft); } .banner.err { background: var(--cinnabar-soft); color: var(--cinnabar); } .banner.ok { background: var(--jade-soft); color: var(--jade); }

/* ── Màn chào & xác thực ───────────────────────────────────────────────── */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); background:
  radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--gold-soft) 70%, transparent), transparent), var(--paper); }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 22px; } .auth-brand .brand-mark { width: 84px; height: 84px; margin: 0 auto 14px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.22)); }
.auth-brand h1 { font-size: 22px; letter-spacing: .12em; } .auth-brand p { color: var(--muted); font-family: var(--serif); font-style: italic; margin-top: 4px; }
.slides { display: grid; gap: 10px; margin: 18px 0; } .slide { display: flex; gap: 12px; align-items: flex-start; } .slide .num { width: 30px; height: 30px; border-radius: 10px; background: var(--ink); color: var(--gold); display: grid; place-items: center; font-family: var(--serif); font-weight: 700; flex: none; }
.hex { display: flex; flex-direction: column-reverse; gap: 7px; align-items: center; margin: 12px 0; } .hex i { display: block; width: 140px; height: 10px; border-radius: 3px; background: var(--ink); } .hex i.yin { background: linear-gradient(90deg, var(--ink) 42%, transparent 42%, transparent 58%, var(--ink) 58%); } .hex i.move { background-color: var(--cinnabar); } .hex i.yin.move { background: linear-gradient(90deg, var(--cinnabar) 42%, transparent 42%, transparent 58%, var(--cinnabar) 58%); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
.kpis > .card, .grid2 > .card, .plans > .card, .grid2 > a.card { margin-top: 0; }
.kpi .v { overflow-wrap: anywhere; } .kpi.long .v { font-size: 15px; font-family: var(--sans); font-weight: 600; margin-top: 6px; }

/* Ô đánh dấu tự vẽ: Safari iOS bỏ qua accent-color khi chưa chọn → ô đen trên nền tối */
input[type=checkbox] { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin: 2px 0 0; flex: none; border: 1.5px solid var(--muted); border-radius: 6px;
  background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; transition: background .15s, border-color .15s; }
input[type=checkbox]::before { content: ""; width: 11px; height: 11px; transform: scale(0); transition: transform .12s; background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
input[type=checkbox]:checked { background: var(--cinnabar); border-color: var(--cinnabar); }
input[type=checkbox]:checked::before { transform: scale(1); }
input[type=checkbox]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }
.warn-text { color: var(--gold, #b8860b); font-weight: 600; }
