/* Giang Sơn Phong Thủy — giao diện v2 (25/11/2026).
   4 theme: Hiện đại (mặc định), Ngọc bích (tối), Giấy cổ, Tương phản cao.
   Font: Be Vietnam Pro tự lưu (OFL) — cùng họ font với Lỗ Ban V3. Chữ Hán dùng font serif CJK có sẵn trên máy. */

:root, [data-theme="hien-dai"] {
  --bg:#FFFFFF; --bg-side:#F7F9FC; --surface:#FFFFFF; --surface-2:#F3F6FA;
  --line:#DCE3EC; --line-strong:#9AA9BA; --tile-line:#BFD5EE; --tile-bg:#FFFFFF;
  --text:#1B2533; --muted:#5D6878; --icon:#1B2533; --icon-dim:#9AA5B3;
  --acc:#1F6FB2; --acc-strong:#175A93; --acc-ink:#FFFFFF; --acc-soft:#EAF2FB;
  --red:#C0262D; --warn:#7A5200; --warn-bg:#FFF6E0; --warn-line:#E9C46A;
  --focus:#1F6FB2; --bw:1px; --shadow:0 1px 2px rgba(20,40,70,.06), 0 4px 14px rgba(20,40,70,.06);
  --dial-face:#FFFFFF; --dial-band:#F2F6FB; --dial-ink:#16202C; --dial-muted:#5D6878; --dial-line:#2A3442;
  --dial-red:#C0262D; --dial-acc:#1F6FB2; --dial-hair:#C7D1DD;
}
[data-theme="ngoc"] {
  --bg:#0B1F19; --bg-side:#0E241D; --surface:#11291F; --surface-2:#0E2419;
  --line:#2A4A3D; --line-strong:#5C7D6E; --tile-line:#3D6152; --tile-bg:#10261D;
  --text:#EFE8D6; --muted:#B3BBA9; --icon:#D9BC74; --icon-dim:#6F7F72;
  --acc:#C9A55A; --acc-strong:#E2C27A; --acc-ink:#0B1F19; --acc-soft:#1B382D;
  --red:#E8796C; --warn:#E7C46E; --warn-bg:#24301B; --warn-line:#7B6A33;
  --focus:#E2C27A; --bw:1px; --shadow:0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  --dial-face:#0F2A21; --dial-band:#133328; --dial-ink:#E8D29A; --dial-muted:#B5A576; --dial-line:#9C834A;
  --dial-red:#EE7A6C; --dial-acc:#E2C27A; --dial-hair:#3B5A4C;
}
[data-theme="giay"] {
  --bg:#F4EDDD; --bg-side:#EFE6D2; --surface:#FBF7EE; --surface-2:#EFE6D2;
  --line:#D8CBB0; --line-strong:#9C8C6C; --tile-line:#C9B78F; --tile-bg:#FBF7EE;
  --text:#1E2822; --muted:#5D6157; --icon:#1F5C4A; --icon-dim:#A39A86;
  --acc:#1F5C4A; --acc-strong:#174A3B; --acc-ink:#FFFFFF; --acc-soft:#E3EBE2;
  --red:#9A2E22; --warn:#6E4A0C; --warn-bg:#F6E9C9; --warn-line:#C9A55A;
  --focus:#1F5C4A; --bw:1px; --shadow:0 1px 2px rgba(60,45,20,.08), 0 4px 14px rgba(60,45,20,.07);
  --dial-face:#FBF5E6; --dial-band:#F1E7CF; --dial-ink:#1E2822; --dial-muted:#6B6A5E; --dial-line:#6E5B3A;
  --dial-red:#9A2E22; --dial-acc:#1F5C4A; --dial-hair:#D3C4A3;
}
[data-theme="tuong-phan"] {
  --bg:#FFFFFF; --bg-side:#FFFFFF; --surface:#FFFFFF; --surface-2:#F0F0F0;
  --line:#000000; --line-strong:#000000; --tile-line:#000000; --tile-bg:#FFFFFF;
  --text:#000000; --muted:#1E1E1E; --icon:#000000; --icon-dim:#4A4A4A;
  --acc:#0B4F8A; --acc-strong:#083B68; --acc-ink:#FFFFFF; --acc-soft:#E1ECF7;
  --red:#B00000; --warn:#4A3200; --warn-bg:#FFF1C2; --warn-line:#000000;
  --focus:#000000; --bw:2px; --shadow:none;
  --dial-face:#FFFFFF; --dial-band:#F0F0F0; --dial-ink:#000000; --dial-muted:#222222; --dial-line:#000000;
  --dial-red:#B00000; --dial-acc:#0B4F8A; --dial-hair:#777777;
}

:root {
  --font: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-han: "Noto Serif TC", "Songti TC", "Songti SC", "STSong", "Source Han Serif TC", "Noto Serif CJK TC", "PMingLiU", "MingLiU", serif;
  --font-num: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px; --radius-sm: 9px;
  --nav-h: 60px; --top-h: 56px;
  font-size: 16px;
}
html[data-large="1"] { font-size: 19px; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--acc); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5em 1em; z-index: 30; }
.skip:focus { left: .5em; top: .5em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.han { font-family: var(--font-han); }
svg { display: block; }

/* ---------- Thanh trên ---------- */
.topbar { position: sticky; top: 0; z-index: 10; height: var(--top-h); padding: 0 .75em 0 1em;
  display: flex; align-items: center; justify-content: space-between; gap: .75em;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: var(--bw) solid var(--line); padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .6em; text-decoration: none; color: var(--text); min-height: 44px; }
.seal { width: 30px; height: 30px; border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-weight: 600; font-size: .98rem; letter-spacing: -.005em; white-space: nowrap; }
.brand-text .han { font-size: .74rem; color: var(--muted); letter-spacing: .12em; }
.top-actions { display: flex; gap: .25em; }
.icon-btn { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; border-radius: 999px; border: 0;
  background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .ico { width: 22px; height: 22px; display: block; }
.icon-btn.txt { font-weight: 600; font-size: .95rem; letter-spacing: -.02em; }
.icon-btn[aria-pressed="true"] { background: var(--acc-soft); color: var(--acc); }
body[data-route="home"] .topbar { background: transparent; border-bottom-color: transparent; backdrop-filter: none; position: absolute; left: 0; right: 0; }
body[data-route="home"] .topbar .brand { display: none; }
body[data-route="home"] .top-actions { margin-left: auto; }
body[data-route="home"] .topbar .icon-btn { color: #282920; }

/* ---------- Bố cục ---------- */
.layout { flex: 1; display: flex; width: 100%; }
main { flex: 1; min-width: 0; padding: 1rem 1rem 1.5rem; }
.page { max-width: 980px; margin: 0 auto; }
.sidenav { display: none; }
@media (min-width: 900px) {
  .sidenav { display: flex; flex-direction: column; gap: 2px; width: 252px; flex: none; padding: 1rem .6rem;
    background: var(--bg-side); border-right: var(--bw) solid var(--line); position: sticky; top: var(--top-h); height: calc(100dvh - var(--top-h)); overflow: auto; }
  .bottomnav { display: none !important; }
  main { padding: 1.75rem 2.25rem 3rem; }
}
.navlink { display: flex; align-items: center; gap: .7em; min-height: 44px; padding: .45em .75em; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .95rem; }
.navlink .nico { width: 22px; height: 22px; flex: none; color: var(--icon); }
.navlink:hover { background: var(--surface-2); }
.navlink[aria-current="page"] { background: var(--acc-soft); color: var(--acc); font-weight: 600; }
.navlink[aria-current="page"] .nico { color: var(--acc); }
.navlink.dim { color: var(--muted); }
.navlink.dim .nico { color: var(--icon-dim); }
.navlink .badge { margin-left: auto; font-size: .62rem; }
.nav-sep { margin: .8em .75em .3em; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-top: var(--bw) solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .7rem; color: var(--muted); text-decoration: none; font-weight: 500; }
.bottomnav a .nico { width: 24px; height: 24px; }
.bottomnav a[aria-current="page"] { color: var(--acc); font-weight: 600; }
html[data-large="1"] .bottomnav a { font-size: .62rem; }

/* ---------- Chữ ---------- */
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 600; letter-spacing: -.015em; margin: .2em 0 .5em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.4em 0 .6em; letter-spacing: -.005em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.page-head { display: flex; align-items: center; gap: .6em; flex-wrap: wrap; margin-bottom: .6rem; }
.page-head h1 { margin: 0; }
.badge { display: inline-flex; align-items: center; gap: .3em; font-size: .7rem; font-weight: 600; letter-spacing: .01em;
  padding: .18em .6em; border-radius: 999px; background: var(--acc-soft); color: var(--acc); white-space: nowrap; }
.badge.soon { background: var(--surface-2); color: var(--muted); }
.badge.plan { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--text); padding: .65em .85em; border-radius: var(--radius-sm); margin: .6em 0; font-size: .86rem; }
.notice b { color: var(--warn); }

/* ---------- Trang chủ 3.1 ---------- */
.home-stage { position: relative; isolation: isolate; display: flex; flex-direction: column;
  align-items: center; gap: .85rem; min-height: clamp(550px, 78dvh, 720px); overflow: hidden;
  padding: 1rem clamp(.85rem, 3vw, 2rem) 1.15rem; border-radius: var(--radius);
  background: #f4eee3; color: #282920; }
.home-stage .hero-pic, .home-stage .hero-pic img { position: absolute; inset: 0; width: 100%; height: 100%; }
.home-stage .hero-pic { z-index: -2; }
.home-stage .hero-pic img { object-fit: cover; object-position: var(--hero-focus, 50% 55%); }
.home-stage::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, #f9f4eccc 0%, #f9f4ec26 33%, transparent 61%, #f3eee23d 84%, #f3eee297 100%); }
.home-heading { text-align: center; line-height: 1.22; text-shadow: 0 0 15px #fffdf5, 0 2px 6px #fffdf5; }
.home-seal, .home-seal img { display: block; width: 56px; height: 56px; margin: 0 auto; }
.home-han { margin-top: .1rem; letter-spacing: .15em; padding-left: .15em; font-size: clamp(1.9rem, 4vw, 2.45rem); }
.home-heading h1 { color: #852c23; font-size: clamp(.88rem, 2.8vw, 1.08rem); margin: .28rem 0 .3rem;
  font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.home-heading p { font-size: .74rem; margin: 0; color: #453b2f; }
.home-date { display: grid; justify-items: center; gap: .18rem; max-width: 100%; text-align: center; padding: .56rem .82rem;
  border: 1px solid #60544078; border-radius: 10px; color: #2c2a22; text-decoration: none; line-height: 1.32;
  background: #fffcf2d9; font-size: .68rem; }
.home-date strong { font-size: .7rem; text-transform: uppercase; letter-spacing: .045em; }
.home-date:hover { border-color: #852c23; }
.home-links { width: min(100%, 690px); margin-top: auto; display: grid; gap: .52rem; }
.home-pillars, .home-low { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .48rem; }
.home-pillar, .home-low a { display: flex; align-items: center; justify-content: center; color: #2c2a22;
  text-decoration: none; background: #fffbefd4; border: 1px solid #81745d7a; border-radius: 10px; min-height: 48px; }
.home-pillar { gap: .38rem; padding: .5rem .3rem; min-height: 55px; text-align: center; backdrop-filter: blur(9px); }
.home-pillar:hover, .home-low a:hover { border-color: #852c23; background: #fffaf0; }
.home-pillar strong, .home-pillar small { display: block; line-height: 1.2; }
.home-pillar strong { font-size: .94rem; font-weight: 650; }
.home-pillar small { font-size: .65rem; margin-top: .22rem; color: #565044; }
.home-icon, .home-low svg { display: block; flex: none; width: 22px; height: 22px; color: #852c23; }
.home-low a { gap: .35rem; padding: .25rem .32rem; min-height: 44px; font-size: .75rem; font-weight: 600; text-align: center; }
.home-low a span, .home-pillar > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.home-low [data-auth-label] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.home-tray { width: min(100%, 720px); margin-top: auto; padding: 0 .62rem .62rem;
  border-radius: 16px; background: #fff8edeb; border: 1px solid #81745d70; box-shadow: 0 -4px 28px #362d1c22; }
.home-tray:not([open]) { padding-bottom: 0; }
.home-tray summary { display: grid; place-items: center; min-height: 44px; list-style: none; cursor: pointer; touch-action: none; }
.home-tray summary::-webkit-details-marker { display: none; }
.home-tray summary span { width: 36px; height: 4px; border-radius: 10px; background: #988d7b; }
.home-tray .home-links { width: 100%; }
.home-tray .home-pillar, .home-tray .home-low a { background: #fffdfa; }
.hero-credit { color: #484133; font-size: .65rem; }
.hub { max-width: 740px; display: grid; gap: .7rem; }
.hub .panel, .hub .today { max-width: none; margin: 0; }
.hub-links, .hub-schools { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.hub-link { display: flex; align-items: center; gap: .55rem; min-height: 64px; color: var(--text); text-decoration: none; }
.hub-link:hover { border-color: var(--acc); }
.hub-icon, .hub-link > svg { display: block; width: 24px; height: 24px; flex: none; color: var(--acc); }
.hub-link > svg { margin-left: auto; width: 16px; }
.hub-link small { display: block; color: var(--muted); font-size: .73rem; }
.hub-steps { display: flex; flex-wrap: wrap; gap: .4rem 1.7rem; margin-bottom: 0; padding-left: 1.2rem; }
.hub-schools details { padding: .35rem .55rem; border: 1px solid var(--line); border-radius: 9px; }
.hub-schools summary { display: flex; align-items: center; gap: .35rem; min-height: 44px; cursor: pointer; }
.hub-schools summary .badge { margin-left: auto; }
.hub-schools p { margin: .3rem 0; }
@media (min-width: 700px) { .home-stage .hero-pic img { object-position: var(--hero-focus-wide, 50% 52%); } }
@media (min-width: 900px) {
  body[data-route="home"] .sidenav { display: none; }
  body[data-route="home"] main { padding: 0; }
  .home-v3 { max-width: none; }
  .home-stage { min-height: 100dvh; padding-top: calc(var(--top-h) + .75rem);
    padding-bottom: clamp(2rem, 8dvh, 6rem); border-radius: 0; }
}
@media (max-width: 899px) {
  .home-stage { margin: calc(-1rem - env(safe-area-inset-top)) -1rem 0; border-radius: 0 0 var(--radius) var(--radius);
    padding-top: calc(var(--top-h) + env(safe-area-inset-top)); min-height: min(720px, calc(100dvh - var(--nav-h) - 16px)); }
  .home-stage-b .hero-pic img { height: calc(100% - 48px); }
}
@media (max-width: 490px) {
  .home-pillar .home-icon { display: none; }
  .home-low svg { width: 17px; height: 17px; }
  .home-tray { padding-inline: .35rem; }
  html[data-large="1"] .home-low svg { display: none; }
}
.today { max-width: 640px; margin: 1.1rem auto 0; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6em; flex-wrap: wrap; }
.today-head .lbl { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.today-head .date { font-weight: 600; font-size: 1.05rem; }
.lunar-line { margin: .5rem 0 0; font-size: 1rem; font-weight: 500; color: var(--acc); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem 1rem; margin: .8rem 0 .2rem; }
.facts div { min-width: 0; }
.facts dt { font-size: .72rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: .95rem; }
.facts dd .han { font-weight: 500; color: var(--muted); margin-left: .25em; }
.more-link { display: inline-flex; align-items: center; gap: .2em; min-height: 44px; font-weight: 500; text-decoration: none; }
.more-link svg { width: 18px; height: 18px; }
details.basis { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); padding: .1em 1em; }
details.basis summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 500; font-size: .92rem; }
details.basis li { margin: .35em 0; font-size: .86rem; }

/* ---------- Nút, ô nhập ---------- */
.btn { min-height: 44px; min-width: 44px; padding: 0 1rem; border-radius: var(--radius-sm); font: inherit; font-weight: 500; cursor: pointer;
  border: var(--bw) solid var(--line-strong); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: .45em; }
.btn svg { width: 20px; height: 20px; }
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.btn.primary:hover { background: var(--acc-strong); }
.btn[aria-pressed="true"] { background: var(--acc-soft); color: var(--acc); border-color: var(--acc); }
.seg { display: inline-flex; border: var(--bw) solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { min-height: 40px; padding: 0 .8rem; border: 0; background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.seg button + button { border-left: var(--bw) solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); font-weight: 600; }
input, select { min-height: 44px; font: inherit; padding: 0 .7em; border-radius: var(--radius-sm); border: var(--bw) solid var(--line-strong);
  background: var(--surface); color: var(--text); }
input[type="number"] { width: 6.5em; }
input[type="range"] { width: 100%; accent-color: var(--acc); min-height: 32px; }

/* ---------- Lịch ---------- */
.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5em; }
.cal-head .month { font-size: 1.15rem; font-weight: 600; flex: 1; min-width: 10em; }
.cal-wrap { display: grid; gap: 1em; grid-template-columns: minmax(0, 1fr); } /* R10-01: bảng 12 canh giờ không được kéo rộng trang trên điện thoại */
@media (min-width: 1040px) { .cal-wrap { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }
.cal { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal th { font-size: .72rem; color: var(--muted); padding: .55em 0; font-weight: 600; letter-spacing: .02em; background: var(--surface-2); }
.cal td { padding: 2px; border-top: 1px solid var(--line); vertical-align: top; }
.cal .day { width: 100%; min-height: 3.5em; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 8px; padding: .2em 0; }
.cal .day:hover { background: var(--surface-2); }
.cal .day .s { font-size: 1.02rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.cal .day .l { font-size: .68rem; color: var(--muted); }
.cal .day.first .l, .cal .day.full .l { color: var(--red); font-weight: 600; }
.cal .day .t { font-size: .56rem; color: var(--acc); line-height: 1; font-weight: 600; }
.cal .day.today { outline: 3px double var(--acc); outline-offset: -3px; }
.cal .day[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); }
.cal .day[aria-pressed="true"] .l, .cal .day[aria-pressed="true"] .t { color: var(--acc-ink); }
.cal .sun .s { color: var(--red); }
.cal .day.muted { opacity: .45; }
.panel { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.panel h2 { margin-top: 0; }
.panel dl { display: grid; grid-template-columns: max-content 1fr; gap: .35em 1em; margin: .4em 0; }
.panel dt { color: var(--muted); font-size: .88rem; }
.panel dd { margin: 0; font-weight: 600; }
.form-row { display: flex; flex-wrap: wrap; gap: .5em; align-items: end; margin: .5em 0; }
.form-row label { display: flex; flex-direction: column; gap: .2em; font-size: .8rem; color: var(--muted); }
.result { margin-top: .6em; font-weight: 600; }
.result.err { color: var(--red); }

/* ---------- Hồ sơ người ---------- */
.ps-form { display: grid; gap: .7rem; }
.ps-form > label, .ps-row > label { display: flex; flex-direction: column; gap: .25rem; font-size: .84rem; color: var(--muted); }
.ps-form input:not([type="checkbox"]), .ps-form select, .ps-form textarea { width: 100%; color: var(--text); }
.ps-form textarea { font: inherit; padding: .5rem .7rem; border-radius: var(--radius-sm); border: var(--bw) solid var(--line-strong); background: var(--surface); }
.ps-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 420px) { .ps-row { grid-template-columns: 1fr; } }
.err { color: var(--red); font-size: .78rem; min-height: 0; }
.err:empty { display: none; }

/* ---------- Nhắc việc âm lịch ---------- */
.rm-grid { display: flex; flex-wrap: wrap; gap: 0 1.2rem; margin: .4rem 0; }
.rm-add { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .4rem .8rem .7rem; margin: .5rem 0; }
.rm-add legend { padding: 0 .3rem; color: var(--muted); }
.rm-add input[type="text"] { width: 14em; max-width: 100%; }
.rm-list { list-style: none; padding: 0; margin: .4rem 0 0; }
.rm-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-top: 1px solid var(--line); font-size: .9rem; }

/* ---------- La bàn ---------- */
.compass-page { display: grid; gap: .9rem; justify-items: center; }
@media (min-width: 1040px) { .compass-page { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; justify-items: stretch; } }
.readout { width: 100%; max-width: 460px; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.readout-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: .7rem .9rem .55rem; gap: .5rem; }
.readout-main .side { min-width: 0; }
.readout-main .side.r { text-align: right; }
.readout .k { font-size: .68rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.readout .v { font-weight: 600; font-size: 1rem; line-height: 1.25; }
.readout .v .han { font-size: 1.15em; font-weight: 600; margin-right: .2em; }
.readout .deg { text-align: center; }
.readout .deg .num { font-size: 2.3rem; font-weight: 300; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.readout .deg .dir { font-size: .78rem; color: var(--acc); font-weight: 600; margin-top: .15rem; }
.readout-sub { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem .9rem; background: var(--surface-2); border-top: var(--bw) solid var(--line); font-size: .8rem; color: var(--muted); }
.readout-sub b { color: var(--text); font-weight: 600; }
.readout .warnline { padding: .5rem .9rem; border-top: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--text); font-size: .8rem; }
.readout .warnline[hidden] { display: none; }
.dial-stage { position: relative; display: flex; justify-content: center; width: 100%; }
.level { position: absolute; left: 0; top: 0; z-index: 2; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--line-strong); box-shadow: var(--shadow); opacity: .55; }
.level.live { opacity: 1; }
.level .level-ring { position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.level .bubble { width: 12px; height: 12px; border-radius: 50%; background: var(--icon-dim); transition: transform .12s linear; }
.level.live .bubble { background: var(--warn-line); }
.level.ok { border-color: #2E9D57; }
.level.ok .bubble { background: #2E9D57; }
.level.ok .level-ring { border-color: #2E9D57; }
.ghost-link { text-decoration: none; min-height: 44px; font-size: .88rem; color: var(--acc); border-color: var(--line); background: var(--surface); }
.dial-wrap { position: relative; width: min(94vw, 460px); aspect-ratio: 1; }
html[data-large="1"] .dial-wrap { width: min(96vw, 460px); }
.dial { width: 100%; height: 100%; touch-action: none; user-select: none; }
.dial .d-face { fill: var(--dial-face); }
.dial .d-band { fill: var(--dial-band); }
.dial .d-line { stroke: var(--dial-line); fill: none; }
.dial .d-hair { stroke: var(--dial-hair); fill: none; }
.dial .d-ink { fill: var(--dial-ink); }
.dial .d-muted { fill: var(--dial-muted); }
.dial .d-red { fill: var(--dial-red); }
.dial .d-acc { fill: var(--dial-acc); }
.dial .s-ink { stroke: var(--dial-ink); }
.dial .s-red { stroke: var(--dial-red); }
.dial .t-han { font-family: var(--font-han); font-weight: 700; }
.dial .t-lat { font-family: var(--font); font-weight: 600; }
.dial .t-num { font-family: var(--font-num); font-weight: 500; font-variant-numeric: tabular-nums; }
.dial #dial-rot { transition: none; }
.dial .hl { fill: var(--dial-acc); opacity: .14; }
.dial .hl-card { fill: var(--dial-red); opacity: .1; }
.compass-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; width: 100%; max-width: 460px; }
.compass-actions .btn { flex: 1 1 auto; }
.compass-side { width: 100%; max-width: 460px; display: grid; gap: .8rem; }
.compass-side .panel { padding: .85rem 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3em 1em; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.hint { font-size: .82rem; color: var(--muted); text-align: center; margin: 0; max-width: 460px; }

.mode-bar { display: flex; gap: 6px; overflow-x: auto; width: 100%; max-width: 460px; padding: 2px; scrollbar-width: none; }
.mode-bar::-webkit-scrollbar { display: none; }
.mode-bar button { flex: 1 0 auto; min-height: 40px; padding: 0 .85rem; border-radius: 999px; border: var(--bw) solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.mode-bar button[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.zoom-bar { display: flex; gap: 6px; justify-content: center; }
.chip { min-height: 36px; padding: 0 .8rem; border-radius: 999px; border: var(--bw) solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--acc); color: var(--acc); font-weight: 600; background: var(--acc-soft); }
.dial-wrap.zoomed { aspect-ratio: 7 / 6; }
table.layers { width: 100%; border-collapse: collapse; font-size: .86rem; table-layout: fixed; }
table.layers tr.lname th { text-align: left; font-weight: 500; font-size: .74rem; color: var(--muted); padding: .55rem 0 .1rem; border-top: 1px solid var(--line); }
table.layers tr.lname:first-child th { border-top: 0; padding-top: 0; }
table.layers tr.lname .han { font-size: .95em; opacity: .8; }
table.layers td { padding: .1rem .3rem .45rem 0; font-weight: 600; vertical-align: top; overflow-wrap: anywhere; }
table.layers td .k { display: block; font-size: .64rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
table.layers td .han { font-size: 1.08em; }

/* ---------- Lập cực (bản đồ / ảnh) ---------- */
.seg button svg { width: 18px; height: 18px; display: inline-block; vertical-align: -4px; margin-right: .25em; }
.lc-pane { margin: .7rem 0 .5rem; display: grid; gap: .4rem; }
.lc-pane[hidden] { display: none; }
.lc-search { display: flex; gap: .4rem; }
.lc-search input { flex: 1; min-width: 0; }
.lc-pick { display: flex; gap: .5rem; flex-wrap: wrap; }
.lc-pick .btn { cursor: pointer; }
@media (max-width: 480px) { .hide-s { display: none; } }
.lc-stage { position: relative; width: 100%; aspect-ratio: 1; max-height: 78vh; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: var(--bw) solid var(--line); touch-action: none; }
@media (min-width: 900px) { .lc-stage { aspect-ratio: 4 / 3; } }
.lc-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lc-stage img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: center; user-select: none; }
.lc-stage.photo { cursor: grab; }
.lc-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1.5rem; color: var(--muted); font-size: .9rem; }
.lc-empty[hidden] { display: none; }
.lc-dial { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); aspect-ratio: 1; pointer-events: none; }
.lc-dial svg { width: 100%; height: 100%; }
.lc-dial .d-face { fill: transparent; }
.lc-dial .d-band { fill: rgba(255, 255, 255, .16); }
.lc-dial .hl-card { opacity: .16; }
.lc-dial .hl { opacity: 0; }
.lc-dial text { paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 2.4px; stroke-linejoin: round; }
.lc-dial .d-line { stroke: #1b2533; }
.lc-dial.light .d-line, .lc-dial.light .d-hair { stroke: #fff; }
.lc-dial.light text { stroke: rgba(0, 0, 0, .75); fill: #fff; }
.lc-dial.light .d-red { fill: #ff8a7a; }
.lc-dial.light path.d-ink, .lc-dial.light rect.d-ink { fill: #fff; }
.lc-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem 1rem; margin-top: .8rem; }
.lc-ctl { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--muted); }
.lc-ctl[hidden] { display: none; }
.lc-ctl b { color: var(--text); }
.lc-check { flex-direction: row; align-items: center; gap: .5rem; min-height: 44px; }
.lc-check input { min-height: 0; width: 20px; height: 20px; accent-color: var(--acc); }

/* ---------- Lỗ Ban toàn màn hình ---------- */
body[data-route="lo-ban"] .topbar, body[data-route="lo-ban"] .sidenav, body[data-route="lo-ban"] .bottomnav, body[data-route="lo-ban"] .foot { display: none !important; }
body[data-route="lo-ban"] main { padding: 0; }
.lb-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--surface); }
.lb-bar { flex: none; display: flex; align-items: center; gap: .25rem; min-height: 48px; padding: env(safe-area-inset-top) .35rem 0;
  background: var(--surface); border-bottom: var(--bw) solid var(--line); }
.lb-bar .ttl { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5em; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; }
.lb-bar .back { display: inline-flex; align-items: center; gap: .1em; min-height: 44px; padding: 0 .5rem 0 .2rem; color: var(--acc); text-decoration: none; font-weight: 500; font-size: .92rem; border-radius: 8px; }
.lb-bar .back svg { width: 22px; height: 22px; }
@media (max-width: 420px) { .lb-bar .ttl .badge { display: none; } }
.lb-note { flex: none; display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .8rem; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); font-size: .8rem; }
.lb-note p { margin: 0; flex: 1; }
.lb-note[hidden] { display: none; }
.lb-frame { flex: 1; min-height: 0; width: 100%; border: 0; display: block; background: #fff; }

/* ---------- Tiện ích ---------- */
.m0 { margin: 0; } .mt { margin-top: 1rem; } .mt-s { margin: .5rem 0 0; } .narrow { max-width: 640px; }
.ph { margin: 0 0 .5rem; } .steps { margin: .2rem 0 0; padding-left: 1.2rem; } .cols2 { columns: 2; padding-left: 1rem; }
.compass-main { display: grid; gap: .8rem; justify-items: center; width: 100%; }

/* ---------- Cài đặt ---------- */
.opt-list { display: grid; gap: .5rem; }
.opt { display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; min-height: 56px; border-radius: var(--radius-sm);
  border: var(--bw) solid var(--line); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: var(--text); width: 100%; }
.opt[aria-checked="true"] { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.opt .sw { display: flex; flex: none; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.opt .sw i { display: block; width: 14px; height: 30px; }
.opt .on { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.opt[aria-checked="true"] .on { border-color: var(--acc); background: radial-gradient(circle, var(--acc) 0 45%, transparent 50%); }
.opt .od { display: block; font-size: .78rem; color: var(--muted); }
.opt b { font-weight: 600; }

/* ---------- Bảng chọn dưới (theme) & thông báo ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 18, 28, .38); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); color: var(--text);
  border-radius: 16px 16px 0 0; padding: .6rem 1rem calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.18); max-height: 85dvh; overflow: auto; }
.sheet[hidden], .sheet-backdrop[hidden] { display: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto .6rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: .3rem 0 .6rem; }
@media (min-width: 900px) { .sheet { left: 50%; right: auto; bottom: auto; top: 12vh; width: 440px; transform: translateX(-50%); border-radius: 16px; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: min(92vw, 520px); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .86rem; box-shadow: var(--shadow); }
.toast:empty { display: none; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.foot { padding: 1rem 1rem calc(var(--nav-h) + 1.2rem + env(safe-area-inset-bottom)); color: var(--muted); font-size: .74rem; border-top: 1px solid var(--line); text-align: center; background: var(--bg); }
.foot p { margin: .2em 0; }
@media (min-width: 900px) { .foot { padding-bottom: 1.4rem; } }
main + .foot { margin-top: auto; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Lưu số đo, danh sách số đo ---------- */
.save-form { width: 100%; max-width: 460px; display: grid; gap: .6rem; margin-top: .3rem; }
.save-form[hidden] { display: none; }
.save-form .ps-row input, .save-form .ps-row select { width: 100%; color: var(--text); }
.save-form .ph { margin: 0; font-size: 1rem; }
.rd-list { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .45rem; }
.rd-item { display: flex; gap: .6rem; align-items: center; border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .5rem .55rem .5rem .8rem; background: var(--surface); }
.rd-item .rd-main { flex: 1; min-width: 0; }
.rd-item .rd-top { font-weight: 600; font-size: .92rem; }
.rd-item .rd-sub { font-size: .76rem; color: var(--muted); overflow-wrap: anywhere; }
.rd-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.lc-save { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.lc-save .btn { flex: 1 1 auto; }
.lc-check[hidden] { display: none; }
.ps-form > label.lc-check { flex-direction: row; align-items: flex-start; color: var(--text); }
.ps-form > label.lc-check input { margin-top: .15rem; flex: none; }
.icon-btn.lang-btn { font-size: .78rem; letter-spacing: .04em; }
.en-only-note { margin-top: 0; }

/* ---------- Chọn người / Chọn ngày ---------- */
.upper { text-transform: uppercase; letter-spacing: .08em; }
.badge.soft { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 500; }
.cn-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -2px .8rem; padding: 2px; scrollbar-width: none; scroll-snap-type: x proximity; }
.cn-tabs::-webkit-scrollbar { display: none; }
.cn-tabs a { flex: 0 0 auto; scroll-snap-align: start; display: flex; flex-direction: column; gap: .1rem; min-height: 54px; padding: .45rem .8rem; border-radius: var(--radius-sm);
  border: var(--bw) solid var(--line-strong); background: var(--surface); color: var(--text); text-decoration: none; }
.cn-tabs a b { font-size: .9rem; font-weight: 600; }
.cn-tabs a span { font-size: .7rem; color: var(--muted); }
.cn-tabs a[aria-current="page"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.cn-tabs a[aria-current="page"] span { color: var(--acc-ink); opacity: .85; }
.cn-current { display: grid; gap: .2rem; margin-bottom: .8rem; background: var(--surface-2); }
.cn-slot { border: var(--bw) solid var(--line); border-top: 3px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); padding: .8rem 1rem 1rem; margin: 0 0 .8rem; display: grid; gap: .6rem; min-width: 0; }
.cn-slot.accent { border-top-color: var(--acc); }
.cn-slot legend { padding: 0 .3rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.cn-who { font-size: 1.1rem; font-weight: 600; }
.cn-f { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--muted); min-width: 0; }
.cn-f input, .cn-f select { width: 100%; color: var(--text); }
.cn-f input[aria-invalid="true"] { border-color: var(--red); }
.cn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.cn-dmy { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: .6rem; }
.cn-dmy[hidden], .cn-leap[hidden] { display: none; }
.cn-ry { display: grid; gap: .4rem; }
.cn-ry:empty { display: none; }
.cn-rel { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.cn-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: .6rem 0; }
.cn-card { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .7rem .8rem; background: var(--surface-2); display: grid; gap: .15rem; }
.cn-card-v { font-size: 1.2rem; font-weight: 600; }
.cn-card .han { font-size: 1.1rem; color: var(--muted); }
.cn-card details { margin-top: .3rem; } .cn-card summary { cursor: pointer; color: var(--acc); }
.cn-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: stretch; }
.cn-person { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; background: var(--surface-2); min-width: 0; }
.cn-score { text-align: center; padding: .4rem .6rem; display: grid; align-content: center; gap: .1rem; }
.cn-score .big { font-size: 2rem; font-weight: 700; color: var(--acc); line-height: 1.1; }
@media (max-width: 560px) { .cn-pair { grid-template-columns: 1fr; } .cn-score { order: -1; } }
.cn-dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; margin: .8rem 0; }
.cn-dim { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; display: grid; gap: .2rem; }
.cn-dim-h { display: flex; justify-content: space-between; } .cn-dim-h span { font-weight: 700; color: var(--acc); }
.cn-signals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .4rem 1rem; }
.cn-signals ul { margin: .2rem 0; padding-left: 1.1rem; }
.cn-list { list-style: none; counter-reset: cn; padding: 0; margin: .6rem 0 0; display: grid; gap: .5rem; }
.cn-list li { counter-increment: cn; border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .55rem .7rem; display: grid; gap: .15rem; }
.cn-list li::before { content: "#" counter(cn); font-weight: 700; color: var(--acc); font-size: .85rem; }
.cn-li-h { display: flex; justify-content: space-between; gap: .5rem; } .cn-li-s { font-weight: 700; color: var(--acc); }
.cn-tri { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; margin-bottom: .5rem; }
.cn-tri > div { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .5rem .7rem; }
.cn-table { overflow-x: auto; margin: .5rem 0; }
.cn-table table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.cn-table th, .cn-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.cn-table th { color: var(--muted); font-weight: 600; font-size: .75rem; }
.bz-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .5rem 0 .8rem; }
.bz-col { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .6rem .3rem; text-align: center; display: grid; gap: .2rem; }
.bz-gz { display: grid; gap: .1rem; font-size: 1.8rem; line-height: 1.1; color: var(--text); }
.cd-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.cd-act { text-align: left; border: var(--bw) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: .7rem .8rem; cursor: pointer; font: inherit; color: var(--text); display: grid; gap: .1rem; }
.cd-act[aria-pressed="true"] { border-color: var(--acc); background: var(--acc-soft); }
.cd-act.dashed { border-style: dashed; }
.cd-act small { color: var(--muted); }
.cd-days { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .4rem; }
.cd-day { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); padding: .5rem .7rem; display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; }
.cd-day.picked { border-color: var(--acc); background: var(--acc-soft); }
.cd-day .cd-sub { grid-column: 1 / -1; }
.cd-day [data-day-summary] { min-width: 0; }
.cd-day [data-day-summary] .badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.cd-wd { display: flex; flex-wrap: wrap; gap: .35rem; }

/* Chọn người · nhóm, trọng số tự chỉnh (bổ sung theo FUNCDELTA REWORK01, giữ kiểu cũ) */
.cn-w4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
@media (max-width: 420px) { .cn-w4 { grid-template-columns: 1fr 1fr; } }
[data-wbox][hidden] { display: none; }
.badge.ten { background: var(--warn-bg); color: var(--warn); }
.btn.small { padding: .2em .65em; font-size: .8rem; min-height: 0; }

/* Lịch · ngày lễ tết truyền thống (chỉ đánh dấu tên ngày) */
.cal .day { position: relative; }
.cal .day.fest::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.cal .day.fest[aria-pressed="true"]::after { background: var(--acc-ink); }

/* Hôm nay · 12 giờ can chi */
.today .more-link + .more-link { margin-left: 1rem; }
.today-hours { list-style: none; padding: 0; margin: .4rem 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .15rem .8rem; font-size: .88rem; }
.today-hours li { display: flex; justify-content: space-between; gap: .5em; padding: .1rem .35rem; border-radius: 6px; }
.today-hours li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.today-hours li span, .today-hours li b { white-space: nowrap; }
.today-hours li.now { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--acc); }
@media (min-width: 520px) { .today-hours { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* ---------- Dự án nhà · Hiện trạng ---------- */
.pj-list { margin: .3rem 0; padding-left: 1.1rem; display: grid; gap: .35rem; }
.pj-stage { display: block; width: 100%; max-height: 72vh; background: var(--surface-2); border: var(--bw) solid var(--line); border-radius: var(--radius); touch-action: manipulation; cursor: crosshair; }
.pj-stage:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
.pj-noimg { fill: var(--surface-2); }
.pj-m circle { fill: rgba(255, 255, 255, .55); stroke: var(--acc); stroke-width: 2.5; }
.pj-m.pj-center circle { fill: var(--acc); stroke: #fff; }
.pj-m.pj-fixed circle { stroke: var(--red); stroke-dasharray: 3 2; }
.pj-m.pj-sc circle { stroke: #2f6fbf; }
.pj-m.sel circle { stroke-width: 5; }
.pj-lbl { fill: #111; paint-order: stroke; stroke: #fff; stroke-width: 3px; font-weight: 600; }
.pj-north { stroke: var(--red); stroke-width: 3; }
.pj-north-t { fill: var(--red); }
.pj-scale { stroke: #2f6fbf; stroke-width: 2; stroke-dasharray: 6 4; }
.pj-cursor { pointer-events: none; }
.pj-cursor line { stroke: #111; stroke-width: 1.5; }
.pj-marks { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.pj-marks li { display: inline-flex; align-items: center; gap: .15rem; }
.flag { color: var(--red); font-weight: 600; font-size: .85rem; }
.form-row label.lc-check { flex-direction: row; align-items: center; gap: .4em; font-size: .85rem; color: var(--text); }

.pj-outline, .pj-grid line { fill: none; stroke: #333b51; stroke-width: 2; pointer-events: none; }
.pj-grid { pointer-events: none; }
.pj-grid line { stroke-dasharray: 4 3; }
.pj-vertex { fill: #faf9f5; stroke: #333b51; stroke-width: 2; cursor: grab; }
.pj-vertex.sel { fill: #333b51; }
.pj-stage:has(.pj-vertex) { touch-action: none; }
.pj-readonly { max-height: 360px; }

.pj-facts > .lc-check { display: flex; margin-block: .55em; }
.pj-facts summary { cursor: pointer; font-weight: 650; }
.pj-fact-table { width: 100%; border-collapse: collapse; margin-block: .65rem; }
.pj-fact-table :is(td,th) { text-align: start; border-bottom: 1px solid var(--line); padding: .45em; }
.pj-chart { margin: .8rem 0; max-width: 35rem; }
.pj-chart figcaption { margin-bottom: .35rem; font-weight: 650; }
.pj-palaces { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); }
.pj-palaces > div { display: grid; gap: .2em; align-content: start; padding: .4em; border: 1px solid var(--line); overflow-wrap: anywhere; }
.pj-fact-overlay { pointer-events: none; }
.pj-fact-ray { stroke: #333b51; stroke-width: 1.5; stroke-dasharray: 3 3; }

.unit-scroll { overflow-x: auto; }
.unit-scroll table { width: 100%; border-collapse: collapse; }
.unit-scroll td, .unit-scroll th { padding: .5rem; text-align: start; vertical-align: top; white-space: pre-line; }
.unit-scroll td { min-width: 9rem; }
@media (max-width: 440px) {
  .unit-scroll td { min-width: 6.5rem; }
}

.form-row.round9-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .75rem;
}
.round9-fields label { min-width: 0; font-size: .875em; }
.round9-fields :is(input, select) { width: 100%; min-width: 0; max-width: 100%; }
.round9-fields .btn { justify-self: start; }
.unit-panel, .unit-scroll { min-width: 0; max-width: 100%; }
.unit-scroll thead th { overflow-wrap: anywhere; }
/* R9C-01: cột nhãn không được co nhỏ hơn một từ; chỉ bảng cuộn ngang. */
.unit-scroll th[scope="row"] { min-width: 7.5rem; overflow-wrap: normal; word-break: normal; }
@media (max-width: 440px) { .unit-scroll th[scope="row"] { min-width: 6.5rem; } }
@media (min-width: 680px) {
  .form-row.round9-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.unit-charts { display: flex; gap: .4rem; }
.unit-charts .pj-chart { flex: 0 0 7.2rem; margin: 0; font-size: .75rem; }
.unit-charts .pj-palaces > div { padding: .18rem .06rem; text-align: center; }
.unit-charts .pj-palaces span { white-space: nowrap; }

.r10-tet { position: relative; display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.r10-source { margin-block: .25rem .5rem; }
.r10-rules { padding-inline-start: 1.2rem; }
.r10-rules li { margin-block: .45rem; }
.r10-elements { padding: 0; list-style: none; max-width: 24rem; }
.r10-elements li, .r10-elements label { display: flex; gap: .6rem; align-items: center; }
.r10-elements li { margin-block: .35rem; }
.r10-elements label { flex: 1; justify-content: space-between; }
.r10-elements meter { width: 70%; }
.r10-child :is(td,th) { min-width: 8rem; white-space: normal; }
.r10-child th:first-child { min-width: 4rem; }
.r10-maps iframe { width: 100%; min-height: 38rem; border: 0; }
.r10-map-page { padding: .5rem; }
.r10-map { min-height: 22rem; }

/* R10-03: Can Chi trong chi tiết ngày xếp nhãn trên, giá trị dưới để không bóp cột giá trị (cột lịch hẹp cả trên máy tính). */
.panel [data-day-rules] dl { grid-template-columns: minmax(0, 1fr); gap: .1em 0; }
.panel [data-day-rules] dd { margin-bottom: .45em; }

/* Đỏ dấu ấn cho cả bốn giao diện. */
:root:not([data-standalone]), [data-theme="giay"]:not([data-standalone]) { --acc:#a72732; --acc-strong:#851b28; --acc-ink:#fff; --acc-soft:#fae9eb; --focus:#a72732; }
[data-theme="ngoc"] { --acc:#ff9bab; --acc-strong:#ffb2be; --acc-ink:#201015; --acc-soft:#472730; --focus:#ff9bab; }
[data-theme="tuong-phan"] { --acc:#a20f25; --acc-strong:#800a1a; --acc-ink:#fff; --acc-soft:#ffe9ed; --focus:#a20f25; }
.cal .r11-weekend .day:not([aria-pressed="true"]) .s { color:var(--red); }
.cal .day.today[aria-pressed="true"] { outline-color: var(--acc-ink); }
.r11-day-summary { padding:0; list-style:none; }
.r11-day-summary li { margin-block:.35rem; }
.panel .r11-tet-dates { display: block; }
.r11-tet-dates dt { color: var(--muted); }
.r11-tet-dates dd { margin: 0 0 .6em; font-weight: 600; }
.pt-history { display:none; }
@media (max-width:767px), (display-mode:standalone) {
  .pt-history { display:flex; }
  .pt-history .icon-btn { min-width:2.25rem; font-size:1.3rem; }
  .pt-history .icon-btn:disabled { opacity:.45; }
  .topbar .brand { min-width:0; }
  .topbar .brand-text { min-width:0; }
  .topbar .brand-text b { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:block; }
}

/* Foreground/background pairs maintain AA at normal text size across themes. */
[data-ka-tone="support"] { color:#fff; background:#b12435; border-color:#b12435; }
[data-ka-tone="caution"] { color:#fff; background:#30343b; border-color:#30343b; }
[data-theme="ngoc"] [data-ka-tone="support"] { color:#241015; background:#ff9bab; border-color:#ff9bab; }
[data-theme="ngoc"] [data-ka-tone="caution"] { color:#fff; border-color:#b7c4bd; }


.cal-modes { margin-bottom: 1rem; }
.cal-modes .btn.primary[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); }
.cal-modes .btn.primary[aria-pressed="true"]:hover { background: var(--acc-strong); }
.cal-wrap.cal-day, .cal-wrap.cal-year { grid-template-columns: minmax(0,1fr); }
.cal-day .panel { text-align: center; }
.cal-day .panel dl, .cal-day .panel details, .cal-day .panel ul { text-align: start; }
[data-theme="ngoc"] .cal .day[aria-pressed="true"] { background: #a72732; color: #fff; }
[data-theme="ngoc"] .cal .day[aria-pressed="true"] :is(.l,.t) { color: #fff; }
[data-theme="ngoc"] .cal .day.today[aria-pressed="true"] { outline-color: #fff; }
.cal-day #h-day { font-size: clamp(1.8rem, 5vw, 3rem); }
.cal-year > section { min-width: 0; }
div.cal-year { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,19rem),1fr)); gap: 1rem; }
div.cal-year .day { padding-inline: 0; }
div.cal-year .day .t { display: none; }

[data-plan-bearing] canvas { display:block; max-width:100%; height:auto; margin-block:.5rem; cursor:crosshair }
[data-plan-bearing] :is(input, select) { max-inline-size: 100%; }
@media (max-width: 599px) {
  [data-plan-bearing] .panel > label { display: block; margin-block: .5rem; }
  [data-plan-bearing] [data-file] { display: block; inline-size: 100%; }
}

/* Địa lợi V2 */
.r28-progress { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .45rem; }
.r28-progress button { width: 100%; min-height: 3.6rem; text-align: left; padding: .5rem .65rem; border-radius: .55rem; border: 1px solid var(--line, #b0a999); background: transparent; color: inherit; }
.r28-progress button[aria-current="step"] { outline: 2px solid currentColor; outline-offset: -2px; }
.r28-progress button small { display: block; line-height: 1.2; margin-top: .25rem; }
.r28-progress button:disabled { opacity: .65; }
.r28-create .form-row > *, .r28-workflow .form-row > * { min-width: 0; }
.r28-create input, .r28-create select, .r28-workflow input, .r28-workflow select, .r28-workflow textarea { max-width: 100%; }
.r28-survey { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .8rem; }
.r28-survey label, .r28-survey textarea { display: block; width: 100%; }
.r28-survey button { justify-self: start; align-self: end; }
[data-object-mark] { cursor: grab; touch-action: none; }

.r28-workflow [data-step-title] { scroll-margin-top: 4rem; }
@media (max-width: 599px) {
  .r28-progress {
    grid-template-columns: none;
    grid-auto-columns: minmax(8.3rem, 44%);
    grid-auto-flow: column;
    overflow-x: auto;
    padding: .15rem 0 .45rem;
  }
  .r28-progress button { height: 100%; }
}

.north-up-map { position:relative; overflow:hidden; touch-action:none; background:var(--surface-2); min-height:22rem; cursor:crosshair; }
.north-up-map [data-raster] { position:absolute; inset:0; pointer-events:none; }
.north-up-map img, .north-up-map [data-marker] { position:absolute; max-width:none; pointer-events:none; }
.north-up-map [data-marker] { transform:translate(-50%,-50%); border-radius:50%; background:#1f416a; color:white; min-width:1.5rem; text-align:center; font-weight:bold; }
.map-north, .map-credit { position:absolute; z-index:1; background:var(--surface); color:var(--text); padding:.2rem .45rem; border-radius:.3rem; pointer-events:none; }
.map-north { top:.5rem; left:.5rem; }
.map-credit { bottom:.5rem; right:.5rem; max-width:90%; }
.north-up-overlay { margin:0; }
.north-up-overlay .r10-map-page { padding:0; width:100%; max-width:none; }
.north-up-overlay :is(form, [data-aim]) { display:none; }
.north-up-overlay .north-up-map { height:100dvh; min-height:0; cursor:grab; }
.north-up-overlay [data-map-status]:not(:empty) { position:absolute; z-index:2; bottom:1.65rem; left:.5rem; padding:.3rem; background:var(--surface); }

.pj-inline-status:empty { display:none; }
