:root {
  --bg: #f6f7f5; --card: #fff; --ink: #17201b; --muted: #5d6a64; --line: #e3e7e4; --line-strong: #d0d8d3;
  --brand: #14583a; --brand-dark: #0f4630; --brand-deep: #0d3d28; --brand-soft: #e6f2ec; --gold: #c4963e;
  --ok-bg: #e6f2ec; --ok: #14583a; --warn-bg: #fff3df; --warn: #8a5300; --bad-bg: #fde8e8; --bad: #a32020;
  --info-bg: #e9f0fa; --info: #1d4f91; --due: #b54708; --due-bg: #fdf0e6; --due-ink: #8a3a06;
  --radius: 18px; --shadow: 0 1px 2px rgba(16, 40, 30, .04);
}
* { box-sizing: border-box; }
/* ขนาดตัวอักษรทั้งเว็บปรับได้ด้วยปุ่ม ก- ก ก+ (--fs = 0.9–1.5) ทุก font-size ใช้หน่วย rem จึงขยายตามกันหมด */
html { -webkit-text-size-adjust: 100%; font-size: calc(18px * var(--fs, 1)); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "IBM Plex Sans Thai", "Prompt", "Leelawadee UI", Tahoma, sans-serif; font-size: 1rem; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 8px 28px 48px; flex: 1; }
.num-font, .bal .num, .tile .num { font-variant-numeric: tabular-nums; }

/* ================================================================ โครงหน้า (เมนูซ้าย + แถบบน + แถบล่างบนมือถือ) */
.shell { display: flex; min-height: 100vh; width: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; width: 248px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line);
           display: flex; flex-direction: column; padding: 18px 12px 14px; overflow-y: auto; view-transition-name: site-sidebar; }
.side-logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: var(--ink); text-decoration: none; }
.logo-mark { width: 46px; height: 46px; border-radius: 13px; background: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.logo-mark img { width: 42px; height: auto; }
.side-logo b { display: block; font-size: 0.944rem; line-height: 1.25; }
.side-logo small { display: block; color: var(--muted); font-size: 0.722rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav > a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #2c3631; text-decoration: none; font-weight: 500; }
.side-nav > a:hover { background: #f1f4f2; }
.side-nav > a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-nav svg, .tabbar svg { width: 22px; height: 22px; flex-shrink: 0; }
.side-sub { display: flex; flex-direction: column; margin: 2px 0 8px 22px; padding-left: 12px; border-left: 2px solid var(--line); }
.side-sub a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 0.889rem; }
.side-sub a:hover { color: var(--ink); background: #f1f4f2; }
.side-sub a.on { color: var(--brand); font-weight: 600; }
.nav-count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--due); color: #fff; font-size: 0.722rem; font-weight: 700; line-height: 20px; text-align: center; }
.side-foot { margin-top: auto; padding-top: 14px; }
.side-cta { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; }
.side-cta:hover { background: var(--brand-dark); color: #fff; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.appbar { position: sticky; top: 0; z-index: 40; background: rgba(246, 247, 245, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); view-transition-name: site-header; }
.appbar-inner { max-width: 1180px; margin: 0 auto; padding: 14px 28px; display: flex; align-items: center; gap: 12px; }
.app-logo { display: none; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.app-logo .logo-mark { width: 40px; height: 40px; border-radius: 12px; }
.app-logo .logo-mark img { width: 36px; }
.app-logo b { font-size: 1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-logo small { display: block; font-size: 0.722rem; color: var(--muted); font-weight: 400; }
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* ค้นบ้าน (Content/ui.js) */
.qs { position: relative; flex: 1; max-width: 480px; }
.qs-input { width: 100%; height: 48px; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; padding: 0 44px 0 46px; font: inherit; font-size: 1rem; color: var(--ink); }
.qs-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 88, 58, .15); }
.qs-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--muted); pointer-events: none; }
.qs-key { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 7px; font-size: 0.722rem; color: var(--muted); pointer-events: none; }
.qs-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 36px rgba(0, 0, 0, .16); padding: 6px; max-height: min(60vh, 440px); overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.qs-item:hover, .qs-item.on { background: var(--brand-soft); }
.qs-item b { font-size: 1.111rem; min-width: 70px; }
.qs-item .qs-meta { flex: 1; min-width: 0; font-size: 0.833rem; color: var(--muted); }
.qs-item .qs-due { color: var(--due); font-weight: 600; }
.qs-pay { flex-shrink: 0; padding: 6px 12px; border-radius: 10px; border: 1px solid #c9d6cf; background: #fff; color: var(--brand); font-size: 0.833rem; font-weight: 600; text-decoration: none; }
.qs-pay:hover { background: var(--brand); color: #fff; }
.qs-empty { padding: 12px; color: var(--muted); font-size: 0.889rem; }

/* ปุ่มปรับขนาดตัวอักษร (ขนาดปุ่มคงที่ ไม่ขยายตาม) */
.fontsize { display: flex; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.fontsize button { width: 40px; height: 44px; border: 0; background: transparent; color: var(--ink); font-family: inherit; font-weight: 600; line-height: 1; cursor: pointer; }
.fontsize button + button { border-left: 1px solid var(--line); }
.fontsize button:hover:not(:disabled) { background: var(--brand-soft); }
.fontsize button.on { background: #f1f4f2; }
.fontsize button:disabled { opacity: .35; cursor: default; }
.fontsize .fs-down { font-size: 14px; }
.fontsize .fs-reset { font-size: 17px; }
.fontsize .fs-up { font-size: 21px; }

/* เมนูผู้ใช้ */
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; user-select: none; color: var(--ink); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: #eaeeeb; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--gold); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; flex-shrink: 0; object-fit: cover; }
.who-text { display: flex; flex-direction: column; line-height: 1.2; }
.who-name { font-size: 0.833rem; font-weight: 600; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 0.722rem; color: var(--muted); }
.caret { opacity: .6; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: #fff; color: var(--ink); border-radius: 16px; box-shadow: 0 14px 36px rgba(0, 0, 0, .18); padding: 6px; z-index: 70; border: 1px solid var(--line); }
.menu-panel form { margin: 0; }
.menu-head { display: flex; flex-direction: column; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-label { padding: 6px 12px 2px; font-size: 0.722rem; color: var(--muted); font-weight: 600; }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: inherit; font-size: 0.889rem; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--brand-soft); }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad-bg); }

/* เมนูย่อยของหมวด (มือถือ) */
.groupnav { display: none; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 14px 10px; }
.groupnav::-webkit-scrollbar { display: none; }
.groupnav a { flex-shrink: 0; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line-strong); color: var(--ink); text-decoration: none; font-size: 0.889rem; white-space: nowrap; }
.groupnav a.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* แถบเมนูล่าง (มือถือ) */
.tabbar { display: none; }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 0.667rem; font-weight: 500; }
.tabbar a.on { color: var(--brand); font-weight: 700; }
.tabbar .nav-count { position: absolute; top: 4px; left: 54%; margin: 0; min-width: 18px; line-height: 17px; font-size: 0.611rem; padding: 0 5px; }

/* หน้าลูกบ้าน / หน้าเข้าระบบ (ไม่มีเมนูซ้าย) */
.appbar.plain { background: #fff; border-bottom: 1px solid var(--line); }
.appbar.plain .app-logo { display: flex; }
.appbar.plain .appbar-inner { max-width: 980px; }
body.plain main { max-width: 980px; padding-top: 20px; }

@media (max-width: 959px) {
  .sidebar { display: none; }
  .app-logo { display: flex; }
  .appbar-inner { padding: 10px 14px; gap: 10px; }
  .has-shell .qs { order: 3; flex-basis: 100%; max-width: none; }
  .has-shell .appbar-inner { flex-wrap: wrap; }
  .qs-key { display: none; }
  .groupnav { display: flex; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: #fff; border-top: 1px solid var(--line);
            height: calc(64px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); view-transition-name: site-tabbar; }
  body.has-shell { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  main { padding: 6px 14px 32px; }
  .who-text, .caret { display: none; }
  .usermenu summary { padding: 2px; }
  .fontsize button { width: 34px; height: 40px; }
  .test-fab { bottom: 84px !important; }
  .test-fab.second { bottom: 132px !important; }
}
@media (max-width: 420px) {
  .app-logo small { display: none; }
  .fontsize button { width: 30px; }
}

/* ---------------------------------------------------------------- เนื้อหา */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { margin: 4px 0 0; }
h1 { font-size: 1.556rem; font-weight: 600; margin: 0 0 6px; }
h2 { font-size: 1.167rem; font-weight: 600; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 40, 30, .1); }
.tile .ico { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--brand-soft); color: var(--brand); }
.tile .ico svg { width: 28px; height: 28px; }
.tile .num { font-size: 1.778rem; font-weight: 700; line-height: 1.15; }
.tile .lbl { color: var(--muted); font-size: 0.889rem; }
.tile.gold .ico { background: #f7efdd; color: #9a7226; }
.tile.blue .ico { background: var(--info-bg); color: var(--info); }
.tile.alert .ico { background: var(--warn-bg); color: var(--warn); }
.tile.alert .num { color: var(--warn); }

.roadmap { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.roadmap li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.roadmap .step { flex-shrink: 0; font-size: 0.778rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 2px 8px; }
.roadmap li.done .step { background: var(--brand); color: #fff; }

.note { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.info { background: var(--info-bg); color: var(--info); }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f7f9f8; color: var(--muted); font-weight: 600; font-size: 0.833rem; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfb; }
.muted { color: var(--muted); }
.small { font-size: 0.833rem; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.778rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.gray { background: #eceeed; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; font: inherit; font-weight: 600;
       border-radius: 12px; border: 2px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.outline { background: #fff; color: var(--brand); }
.btn.outline:hover { background: var(--brand-soft); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.889rem; }
.btn.line { background: #06c755; border-color: #06c755; font-size: 1.056rem; min-height: 56px; width: 100%; }
.btn.line:hover { background: #05a948; border-color: #05a948; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
select, input[type=text] { font: inherit; padding: 8px 10px; border: 2px solid var(--line-strong); border-radius: 10px; background: #fff; }
input.field, textarea.field, button.field, select.field { display: block; width: 100%; font: inherit; font-size: 1.056rem; padding: 10px 14px; border: 2px solid var(--line-strong); border-radius: 12px; background: #fff; }
input.field:focus, textarea.field:focus, button.field:focus, select:focus, input[type=text]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27, 122, 75, .15); }
input.code { font-size: 1.444rem; letter-spacing: 4px; text-align: center; }
form .btn.block { margin-top: 20px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
details.inline summary { cursor: pointer; color: var(--brand); font-size: 0.833rem; margin-top: 6px; }
details.inline form { margin-top: 8px; }

/* หน้าเข้าสู่ระบบ */
.login { max-width: 440px; margin: 24px auto; }
.login .card { padding: 30px 28px; }
.login-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 4px auto 14px; }
.login .note { text-align: left; margin-top: 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.833rem; margin: 20px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.center { text-align: center; }
.gap { height: 12px; }
footer { text-align: center; color: var(--muted); font-size: 0.722rem; padding: 0 16px 24px; }

/* ตัวกรองแบบชิป */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.chips-label { color: var(--muted); font-size: 0.833rem; min-width: 64px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); text-decoration: none; font-size: 0.889rem; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips + .card { margin-top: 14px; }
.unit-link { font-weight: 700; text-decoration: none; }
.unit-link:hover { text-decoration: underline; }
.crumb { margin: 0 0 8px; font-size: 0.889rem; }
.crumb a { text-decoration: none; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 18px; }
.choice-list { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { margin: 0; font-weight: 500; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: 10px 16px; border: 2px solid var(--line-strong); border-radius: 12px; background: #fff; }
.choice input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(27, 122, 75, .25); }
textarea.field { resize: vertical; }

/* ปฏิทินไทย (thaidate.js) */
.td-wrap { position: relative; }
.td-display.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; cursor: pointer; color: var(--ink); }
.td-display.td-empty .td-text { color: var(--muted); }
.td-display.td-invalid { border-color: var(--bad); }
.td-icon { color: var(--brand); display: inline-flex; }
.td-panel { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(360px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 12px; }
.td-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.td-head select { flex: 1; min-width: 0; font-size: 0.889rem; padding: 6px 8px; }
.td-nav { width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 1.444rem; line-height: 1; cursor: pointer; }
.td-nav:hover { background: #d6ebdf; }
.td-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.td-dow { text-align: center; font-size: 0.778rem; font-weight: 600; color: var(--muted); padding: 4px 0; }
.td-sun { color: var(--bad); }
.td-day { height: 42px; border: 0; border-radius: 10px; background: none; font: inherit; font-size: 0.944rem; cursor: pointer; color: var(--ink); }
.td-day.td-sun { color: var(--bad); }
.td-day:hover { background: var(--brand-soft); }
.td-day.td-today { box-shadow: inset 0 0 0 2px var(--gold); font-weight: 600; }
.td-day.td-selected { background: var(--brand); color: #fff; font-weight: 700; }
.td-day:focus-visible, .td-nav:focus-visible, .td-link:focus-visible { outline: 3px solid rgba(27, 122, 75, .35); outline-offset: 1px; }
.td-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.td-link { border: 0; background: none; color: var(--brand); font: inherit; font-size: 0.889rem; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.td-link:hover { background: var(--brand-soft); }
.td-strong { font-weight: 600; }

/* รายชื่อ / เจ้าของ-ผู้เช่า */
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.people { display: grid; gap: 10px; }
.person { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.person-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.person-main .muted { flex-basis: 100%; }
.person-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.person-actions form { margin: 0; }
.end-form { display: grid; gap: 6px; min-width: 240px; }
.end-form label { margin: 4px 0 0; }
.role-tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 0.722rem; font-weight: 600; background: #eceeed; color: var(--muted); }
.role-tag.role-owner { background: var(--brand-soft); color: var(--brand-deep); }
.role-tag.role-tenant { background: #f7efdd; color: #8a6420; }
.role-tag.role-payer { background: var(--info-bg); color: var(--info); }
.subsection-toggle { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.subsection-toggle > summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.subsection { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.ended-list { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.889rem; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin-top: 14px; cursor: pointer; }
label.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.form-card { max-width: 760px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.search { display: flex; gap: 10px; margin-bottom: 16px; }
.search .field { flex: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-line; }
tr.ended td { color: var(--muted); }

/* ค่าส่วนกลาง */
th.num, td.num { text-align: right; white-space: nowrap; }
table.compact th, table.compact td { padding: 8px 12px; }
.card > table.compact { margin: 6px 0 8px; }
.text-warn { color: var(--warn); font-weight: 600; }
.badge.big { font-size: 0.889rem; padding: 4px 12px; }
.linklike { border: 0; background: none; color: var(--bad); font: inherit; font-size: 0.833rem; cursor: pointer; padding: 2px 4px; }
.month-picker { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.confirm-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; margin-bottom: 18px; border-radius: var(--radius); background: var(--brand-soft); border: 1px solid #cfe5d8; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
details.inline.right { text-align: right; }
details.inline.right form { justify-content: flex-end; }
.card-head + .table-wrap { margin: 0 -20px; }

/* รับเงิน */
.pay-line { display: grid; grid-template-columns: 1fr 150px 44px; gap: 8px; margin-bottom: 8px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--muted); cursor: pointer; font-size: 1rem; }
.icon-btn:hover { color: var(--bad); border-color: var(--bad); }
.total-row { margin: 14px 0 4px; padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); font-size: 1.056rem; }
.total-row strong { font-size: 1.333rem; color: var(--brand-deep); }
.balance-bar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 14px; margin-bottom: 18px; }
.bal { flex: 1 1 220px; display: flex; flex-direction: column; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.bal .lbl { color: var(--muted); font-size: 0.833rem; }
.bal .num { font-size: 1.667rem; font-weight: 700; line-height: 1.3; }
.bal .num small { font-size: 0.833rem; font-weight: 500; }
.bal.due .num { color: var(--warn); }
.bal.clear .num { color: var(--ok); }
.bal.credit .num { color: var(--info); }
.balance-bar > .btn { align-self: center; }
.slip-img { max-width: 100%; max-height: 520px; border-radius: 12px; border: 1px solid var(--line); }
.danger-zone > summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: #821818; border-color: #821818; }
.section-title { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 4px 0 10px; }

/* รายงาน */
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 4px 16px; align-items: end; }
.filter-bar label { margin-top: 0; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; font-size: 0.833rem; color: var(--muted); }
.legend i.cell { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: -3px; margin-right: 4px; }
.grid-wrap { padding: 0; overflow: auto; max-height: 72vh; }
table.paygrid { border-collapse: separate; border-spacing: 0; font-size: 0.833rem; }
table.paygrid th, table.paygrid td { padding: 0; border-bottom: 1px solid var(--line); border-right: 1px solid #f0f2f1; text-align: center; white-space: nowrap; }
table.paygrid thead th { position: sticky; top: 0; z-index: 2; background: #f7f9f8; padding: 8px 6px; }
table.paygrid .sticky { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; padding: 6px 12px; border-right: 1px solid var(--line); }
table.paygrid thead .sticky { z-index: 3; background: #f7f9f8; }
table.paygrid .sticky a { font-weight: 700; text-decoration: none; }
table.paygrid td.num { padding: 6px 12px; text-align: right; }
td.cell { width: 44px; min-width: 44px; height: 34px; }
td.cell a { display: block; height: 34px; line-height: 34px; color: inherit; text-decoration: none; font-weight: 700; }
.cell.paid { background: #cdebd8; color: var(--ok); }
.cell.partial { background: #fde7b0; color: var(--warn); }
.cell.unpaid { background: #f8d1d1; color: var(--bad); }
.cell.none { background: #f6f7f7; }
tbody tr:hover td.cell.paid { background: #b9e0c8; }
tbody tr:hover td.cell.unpaid { background: #f2bcbc; }

/* หน้าสำหรับพิมพ์ */
.print-page { background: #fff; }
.print-page main { max-width: 820px; }
.print-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.print-head h1 { margin: 0; font-size: 1.444rem; }
.print-head p { margin: 2px 0 0; color: var(--muted); }
.print-table { border: 1px solid var(--line-strong); }
.print-table th, .print-table td { border: 1px solid var(--line-strong); padding: 8px 12px; }
.print-table tfoot th { background: #f7f9f8; }
.print-note { color: var(--muted); font-size: 0.833rem; }
@media print {
  .no-print, .topbar, .sidebar, .appbar, .tabbar, .groupnav, footer { display: none !important; }
  body { font-size: 14px; }
  main { padding: 0; }
  .print-table th, .print-table td { padding: 5px 8px; }
}

@media (max-width: 720px) { .pay-line { grid-template-columns: 1fr 110px 44px; } }

@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .tile .ico { width: 42px; height: 42px; border-radius: 12px; }
  .tile .ico svg { width: 22px; height: 22px; }
  .card { padding: 16px; }
}

/* M1.6 นำเข้าข้อมูลเดิม */
.small-field { min-height: 38px; padding: 4px 8px; font-size: 0.833rem; width: auto; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; cursor: pointer; }
.import-table td { vertical-align: top; }
.import-table tr.needs-check td { background: #fffaf0; }
.import-table td .badge { font-size: 0.722rem; }
ol.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; }
.import-table td.house { white-space: nowrap; }
.import-table td, .import-table th { padding-left: 8px; padding-right: 8px; }
.import-table .small-field { min-height: 34px; }
.import-table .small-field { min-width: 120px; }
.import-table td:last-child { min-width: 240px; }
.import-table td.num, .import-table th.num { white-space: nowrap; }
.import-table tr.has-note td { border-bottom: 0; }
.import-table tr.note-row td { padding-top: 0; }
.import-table td:last-child { min-width: 0; }

/* M3.3 สรุปการเงินรายเดือน */
.fin-report { max-width: 860px; }
table.fin td, table.fin th { padding: 8px 12px; }
table.fin td:first-child { width: 110px; white-space: nowrap; }
table.fin tr.head th, table.fin tr.head td { font-size: 1.056rem; font-weight: 700; background: var(--brand-soft); }
table.fin tr.head.end th, table.fin tr.head.end td { border-top: 2px solid var(--brand); }
table.fin tr.sec th { background: #f4f6f5; color: var(--muted); font-size: 0.833rem; letter-spacing: .02em; }
table.fin tr.cat td { font-weight: 600; }
table.fin tr.sub td { padding-top: 3px; padding-bottom: 3px; }
table.fin tr.sub td:nth-child(2) { padding-left: 28px; }
table.fin tr.total th, table.fin tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); }

/* ผังหมู่บ้าน */
.map-wrap { overflow: auto; padding: 14px; --cell: 62px; }
.vmap { display: grid; gap: 4px; width: max-content; position: relative; }
.mu { display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 10px; text-decoration: none; color: var(--ink);
      border: 1px solid rgba(0,0,0,.08); line-height: 1.15; font-size: 0.833rem; z-index: 2; user-select: none; }
.mu b { font-weight: 700; font-size: calc(var(--cell) * .235); }
.mu small { font-size: calc(var(--cell) * .17); opacity: .85; white-space: nowrap; }
.mu { border-radius: calc(var(--cell) * .16); }
.mf { font-size: calc(var(--cell) * .2); }
/* หน้าดูผัง: ย่อให้พอดีความกว้าง · กรอบไม่สูงเกินจอ จึงเห็นแถบเลื่อนเสมอเมื่อขยาย */
.map-wrap.fit { padding: 10px; max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); }
.map-wrap.fit .vmap { gap: calc(var(--cell) * .06); }
.map-wrap.tiny .mu small { display: none; }
.map-zoom { display: inline-flex; gap: 4px; align-items: center; }
.map-zoom button { min-width: 36px; }
.map-zoom .z-val { min-width: 48px; text-align: center; font-size: .833rem; color: var(--muted); }
a.mu:hover { outline: 2px solid var(--brand); outline-offset: 1px; }
.mf { display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 0.778rem; color: #5b6660; z-index: 1; text-align: center; overflow: hidden; user-select: none; }
.mf-road { background: repeating-linear-gradient(90deg, #e3e6e4, #e3e6e4 10px, #dcdfdd 10px, #dcdfdd 20px); border-radius: 4px; }
.mf-garden { background: #cfe8d3; color: #2c6b3a; font-weight: 600; }
.mf-building { background: #f6d9b8; color: #8a4b12; font-weight: 600; }
.mf-label { background: transparent; color: var(--muted); font-weight: 600; border: 1px dashed var(--line-strong); }
.p-ok { background: #d8efdf; } .p-warn { background: #fde8b5; } .p-bad { background: #f7c9c4; color: #7a1c14; } .p-off { background: #e7e9e8; color: #6b7570; }
.s-occupied { background: #d8efdf; } .s-vacant { background: #e7e9e8; } .s-renovating { background: #fde8b5; } .s-exempt { background: #dbe7f6; } .s-seized { background: #f7c9c4; } .s-none { background: #fff; }
.t-house { background: #e2eee7; } .t-shop { background: #f3e7cf; }
.legend i.mk { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: -3px; margin-right: 4px; border: 1px solid rgba(0,0,0,.08); }
.map-edit { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .map-edit { grid-template-columns: 1fr; } }
.vmap.editing .mc { border: 1px dashed #e1e5e3; border-radius: 6px; cursor: pointer; }
.vmap.editing .mc:hover { background: var(--brand-soft); }
.vmap.editing .mu, .vmap.editing .mf { cursor: grab; }
.vmap.editing .sel { outline: 3px solid var(--brand); outline-offset: 1px; z-index: 3; }
.vmap.editing .mf { z-index: 1; opacity: .9; }
.map-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.danger-text { color: var(--bad); border-color: var(--bad); }
.cell.prepaid { background: repeating-linear-gradient(135deg, #e3f4ea, #e3f4ea 6px, #d2ecdc 6px, #d2ecdc 12px); color: var(--ok); }

/* คู่มือ และประวัติการปรับปรุง */
.manual { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.manual-toc { position: sticky; top: 12px; font-size: 0.889rem; }
.manual-toc ol { margin: 8px 0 0; padding-left: 1.3em; display: grid; gap: 4px; }
.manual-body section { scroll-margin-top: 12px; }
.manual-body h2 { margin-top: 0; }
.manual-body h3 { margin: 14px 0 4px; font-size: 1rem; }
.manual-body ul, .manual-body ol { padding-left: 1.3em; display: grid; gap: 6px; margin: 6px 0; }
.faq dt { font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }
@media (max-width: 860px) { .manual { grid-template-columns: 1fr; } .manual-toc { position: static; } }
@media print { .manual { display: block; } .manual-toc, .topbar, .subnav, footer, .head-actions { display: none !important; } .manual-body section { break-inside: avoid; box-shadow: none; } }
.timeline { display: grid; gap: 18px; }
.tl-date { font-size: 1rem; color: var(--muted); margin: 0 0 8px; }
.tl-item { margin-bottom: 10px; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-head h3 { margin: 0; font-size: 1.056rem; flex: 1 1 260px; }
.tl-actions { display: inline-flex; gap: 10px; align-items: center; }
.tl-body { margin: 8px 0 0; white-space: pre-line; color: var(--ink); }
footer a { color: inherit; }

/* บ้านของฉัน */
.month-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.month-strip .ms { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 10px; font-size: 0.833rem; }
.month-strip .ms small { font-size: 0.722rem; }
.month-strip .ms.none { background: #f3f5f4; color: var(--muted); }

/* ---------- แถบความคืบหน้าที่ขอบบน (Content/ui.js) ---------- */
.page-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 3000; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.page-progress.is-active { opacity: 1; }
.page-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #C4963E 0%, #f3cf83 100%); box-shadow: 0 0 8px rgba(196, 150, 62, .7); transition: width .22s ease; border-radius: 0 2px 2px 0; }

/* ปุ่มที่กำลังรอเซิร์ฟเวอร์ */
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: btn-spin .7s linear infinite; }
.btn.outline.is-busy::after { border-color: rgba(27, 122, 75, .3); border-top-color: var(--brand); }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ---------- เปลี่ยนหน้าแบบนุ่ม (soft refresh) ----------
   เบราว์เซอร์ที่รองรับ View Transitions (Chrome/Edge/LINE Android, Safari 18.2+): หน้าเก่าค่อยๆ จางเป็นหน้าใหม่ ไม่กระพริบขาว
   แถบหัวเว็บอยู่กับที่ (ชื่อ view-transition เดียวกันทุกหน้า) · เบราว์เซอร์เก่า: เนื้อหาค่อยๆ ปรากฏแทน */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .16s ease-in both; }
::view-transition-new(root) { animation: vt-in .24s ease-out both; }
::view-transition-group(site-header), ::view-transition-group(site-sidebar), ::view-transition-group(site-tabbar) { animation-duration: 0s; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@supports not (view-transition-name: none) {
    main { animation: main-in .22s ease-out both; }
    @keyframes main-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
    main { animation: none !important; }
    .page-progress span, .btn.is-busy::after { transition: none; animation-duration: 1.5s; }
}
@media print { .page-progress { display: none; } }

.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 0.722rem; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px; }
.bank-box { margin: 6px 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); border: 1px solid #cfe5d8; }
.bank-no { font-size: 1.444rem; font-weight: 700; letter-spacing: .04em; color: var(--brand-dark); }
.slip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.slip-list li { padding-bottom: 10px; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.slip-list li:last-child { border-bottom: 0; }

/* ประกาศ/เอกสารอ่าน (PDPA) */
.doc { max-width: 820px; line-height: 1.7; }
.doc h2 { font-size: 1.056rem; margin: 18px 0 6px; }
.doc h2:first-child { margin-top: 0; }
.doc ul { margin: 0 0 8px; padding-left: 1.3em; }
.doc p { margin: 0 0 8px; }
.map-legend-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.map-legend-row .legend { margin-bottom: 0; }

/* ================================================================ หน้าตาใหม่ (M2.6): ทับค่าส่วนประกอบเดิม */
h1 { font-size: 1.667rem; font-weight: 700; letter-spacing: -.005em; }
h2 { font-size: 1.111rem; font-weight: 700; }
.page-head { margin: 4px 0 18px; }
.card { border-radius: var(--radius); box-shadow: none; border-color: var(--line); }
.tile { box-shadow: none; }
.btn { min-height: 48px; border-radius: 14px; border-width: 1px; }
.btn.outline { border-color: #c9d6cf; }
.btn.small { min-height: 40px; border-radius: 12px; }
.btn.lg { min-height: 58px; font-size: 1.111rem; border-radius: 16px; padding: 0 26px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
input.field, textarea.field, button.field, select.field { border-width: 1px; border-radius: 14px; min-height: 50px; }
select, input[type=text] { border-width: 1px; }
.choice span { border-width: 1px; border-radius: 14px; min-height: 48px; display: inline-flex; align-items: center; }
.choice input:checked + span { border-width: 2px; padding: 9px 15px; }
.note { border-radius: 14px; }
.chip { min-height: 40px; display: inline-flex; align-items: center; }
th { background: #f6f8f6; }
footer { padding-top: 8px; }
.crumb { font-size: 0.889rem; }

/* ปุ่มเลือกแบบแถบ (segmented) */
.seg { display: inline-flex; background: #eaeeeb; border-radius: 14px; padding: 4px; gap: 4px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; height: 44px; padding: 0 22px; border-radius: 11px; font-weight: 600; color: #4a5650; cursor: pointer; }
.seg input:checked + span { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(20, 88, 58, .3); }

/* ---------- กล่องเลือกไฟล์ / ลากไฟล์มาวาง (Content/ui.js ใส่ให้ทุก input[type=file].field) ---------- */
.drop { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px; min-height: 84px; border: 2px dashed #b9c8bf; border-radius: 16px;
        background: #fbfcfb; cursor: pointer; transition: border-color .15s ease, background .15s ease; margin: 0; font-weight: 400; }
.drop:hover, .drop:focus-within { border-color: var(--brand); background: var(--brand-soft); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); border-style: solid; }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-ico { width: 48px; height: 48px; border-radius: 14px; background: #fff; border: 1px solid var(--line); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.drop-ico svg { width: 26px; height: 26px; }
.drop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.drop-text b { font-size: 1rem; color: var(--ink); }
.drop-text small { font-size: 0.833rem; color: var(--muted); }
.drop-btn { flex-shrink: 0; padding: 8px 16px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 600; font-size: 0.889rem; }
.drop.has-file { border-style: solid; border-color: var(--brand); background: #fff; }
.drop-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; background: #f1f4f2; }
.drop-clear { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: #fff; color: var(--bad); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.drop-clear:hover { border-color: var(--bad); background: var(--bad-bg); }
@media (max-width: 520px) { .drop-btn { display: none; } .drop { padding: 14px; } }
@media (hover: none) { .drop .drop-drag { display: none; } }

/* ---------- ตัวเลือกยอดเงิน (รับเงิน) ---------- */
.amt-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 4px; }
.amt-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff;
            font: inherit; text-align: left; color: var(--ink); cursor: pointer; min-height: 64px; }
.amt-chip b { font-size: 1.278rem; line-height: 1.25; font-variant-numeric: tabular-nums; }
.amt-chip span { font-size: 0.778rem; color: var(--muted); }
.amt-chip:hover { border-color: var(--brand); }
.amt-chip.on { border: 2px solid var(--brand); background: var(--brand-soft); padding: 9px 13px; }

/* ---------- บล็อกบ้าน (การ์ดบ้านที่เลือก) ---------- */
.house-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; margin-top: 8px; }
.house-pick .hp-no { font-size: 1.667rem; font-weight: 700; line-height: 1.1; }
.house-pick .hp-meta { flex: 1; min-width: 160px; font-size: 0.889rem; color: var(--muted); }
.due-pill { border-radius: 12px; padding: 6px 12px; font-weight: 700; background: var(--due-bg); color: var(--due-ink); text-align: right; line-height: 1.35; }
.due-pill small { display: block; font-weight: 500; font-size: 0.778rem; }
.due-pill.clear { background: var(--ok-bg); color: var(--ok); }
.house-input { display: flex; align-items: center; height: 56px; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; padding: 0 6px 0 16px; }
.house-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 88, 58, .15); }
.house-input .pre { font-size: 1.222rem; font-weight: 600; color: var(--muted); }
.house-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; font: inherit; font-size: 1.222rem; font-weight: 700; background: transparent; padding: 0 4px; }

/* ---------- หน้าหลัก: งานวันนี้ ---------- */
.hello { margin: 4px 0 18px; }
.hello h1 { margin: 0; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; color: var(--ink); text-decoration: none; }
a.kpi:hover { border-color: #c9d6cf; }
.kpi small { color: var(--muted); font-size: 0.833rem; }
.kpi b { display: block; font-size: 1.667rem; line-height: 1.25; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub2 { font-size: 0.778rem; color: var(--muted); margin-top: 4px; }
.kpi .bar { height: 8px; border-radius: 99px; background: #eef1ef; margin-top: 10px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.kpi.due b { color: var(--due); }
.dash { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 18px; }
.dash .card { margin: 0; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }
.ch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 6px; }
.ch h2 { margin: 0; }
.cnt { background: var(--due-bg); color: var(--due); border-radius: 999px; font-size: 0.778rem; font-weight: 700; padding: 1px 10px; }
.ch .r { margin-left: auto; }
.qslip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 0; border-top: 1px solid #eef1ef; }
.qslip .thumb { width: 48px; height: 60px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #f1f4f2; flex-shrink: 0; }
.qslip .hn { font-size: 1.222rem; font-weight: 700; min-width: 64px; text-decoration: none; color: var(--ink); }
.qslip .info { flex: 1; min-width: 200px; }
.qslip .info b { font-size: 1rem; }
.qslip .info div { font-size: 0.833rem; color: var(--muted); }
.qslip .acts { display: flex; gap: 8px; margin-left: auto; }
.qslip form { margin: 0; }
.t-ok { color: var(--ok); font-weight: 600; }
.t-warn { color: var(--due); font-weight: 600; }
.task { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: center; background: #fff8ec; border: 1px solid #f1dfbd; border-radius: var(--radius); padding: 14px 18px; }
.task .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--due-bg); color: var(--due); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.task .tx { flex: 1; min-width: 180px; }
.task b { display: block; }
.task span { font-size: 0.833rem; color: var(--muted); }
.rec-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid #eef1ef; }
.rec-row:first-of-type { border-top: 0; }
.rec-row .nm { flex: 1; min-width: 140px; }
.rec-row .nm b { display: block; font-size: 0.944rem; }
.rec-row .nm span { font-size: 0.778rem; color: var(--muted); }
.rec-row input.amt { width: 110px; height: 44px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 10px; font: inherit; text-align: right; }
.rec-row form { display: flex; gap: 8px; align-items: center; margin: 0; }
.late { display: flex; flex-wrap: wrap; gap: 8px; }
.late a { padding: 8px 14px; border-radius: 12px; background: var(--due-bg); color: var(--due-ink); text-decoration: none; font-weight: 600; font-size: 0.889rem; }
.late a:hover { background: #f9e0cc; }

/* ---------- บ้านทั้งหมด (ช่องสี) ---------- */
.htools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.htools .chip b { margin-left: 4px; }
.hgrid-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .hgrid-wrap { grid-template-columns: 1fr; } .hpanel { display: none !important; } }
.hgroup { font-size: 0.833rem; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; margin-bottom: 16px; }
.ht { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60px; border-radius: 12px; border: 1px solid transparent; text-decoration: none; line-height: 1.15; color: inherit; }
.ht b { font-size: 0.944rem; }
.ht span { font-size: 0.667rem; }
.ht.paid { background: var(--ok-bg); color: var(--ok); }
.ht.due1 { background: var(--warn-bg); color: var(--warn); border-color: #f1d9a8; }
.ht.due3 { background: var(--due); color: #fff; }
.ht.off { background: #eceeed; color: var(--muted); }
.ht:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.ht.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.hpanel { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 12px; }
.hpanel .no { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.hpanel .ty { color: var(--muted); font-size: 0.889rem; }
.hpanel .btn { width: 100%; }

/* ---------- บ้านของฉัน (ลูกบ้าน) ---------- */
.mh { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.mh .card { margin: 0; }
.due-card .lbl { color: var(--muted); font-size: 0.889rem; }
.due-card .big { font-size: 2.444rem; font-weight: 700; line-height: 1.15; color: var(--due); font-variant-numeric: tabular-nums; }
.due-card .big small { font-size: 1.111rem; font-weight: 600; }
.due-card .big.clear { color: var(--ok); }
.due-card .per { font-weight: 600; color: var(--due-ink); }
.due-card .per.clear { color: var(--ok); }
.send-btn { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; margin-top: 14px; border-radius: 18px; background: var(--brand); color: #fff; font-size: 1.222rem; font-weight: 700; cursor: pointer; border: 0; width: 100%; font-family: inherit; }
.send-btn:hover { background: var(--brand-dark); }
.send-btn svg { width: 28px; height: 28px; }
.send-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.send-cap { text-align: center; color: var(--muted); font-size: 0.833rem; margin: 8px 0 0; }
.send-note { margin-top: 10px; }
.send-note summary { cursor: pointer; color: var(--brand); font-size: 0.889rem; text-align: center; list-style: none; }
.send-note summary::-webkit-details-marker { display: none; }
.sending { position: fixed; inset: 0; z-index: 200; background: rgba(255, 255, 255, .9); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 1.111rem; font-weight: 600; }
.sending.on { display: flex; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: btn-spin .8s linear infinite; }
.bank-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.bank-row .bank-no { font-size: 1.444rem; }
.bank-row .copy-btn { margin-left: auto; }
.warn-sheet { border: 1px solid #f1d9a8; border-radius: 20px; overflow: hidden; background: #fff; }
.warn-sheet .top { background: var(--warn-bg); padding: 16px 18px; display: flex; gap: 12px; align-items: flex-start; }
.warn-sheet .ic { width: 40px; height: 40px; border-radius: 50%; background: var(--due); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; font-size: 1.333rem; }
.warn-sheet .top b { display: block; font-size: 1.056rem; color: #6b3300; }
.warn-sheet .top span { font-size: 0.889rem; color: #7a4a12; }
.warn-sheet .acts { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.warn-sheet .acts form { margin: 0; }
.warn-sheet .acts .btn { width: 100%; }
.mh .month-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* ---------- พิมพ์ ---------- */
@media print { .sidebar, .appbar, .tabbar, .groupnav, .test-fab { display: none !important; } body.has-shell { padding: 0; } }

/* รับเงิน: บล็อกบ้านแต่ละหลัง */
.pay-block + .pay-block { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.pay-block label:first-child { margin-top: 0; }
.house-input .icon-btn { border: 0; }
.amt-wrap .field.amount { max-width: 260px; margin-top: 8px; }
details.card > summary { cursor: pointer; }
.qs-input:not(:placeholder-shown) ~ .qs-key, .qs-input:focus ~ .qs-key { display: none; }
@media (max-width: 600px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .kpi { padding: 12px 14px; } .kpi b { font-size: 1.333rem; } .kpi .sub2 { font-size: 0.722rem; } .hello h1 { font-size: 1.333rem; } }
.drop { container-type: inline-size; }
@container (max-width: 400px) { .drop-btn { display: none; } .drop-text b { font-size: 0.944rem; } }
.drop [hidden] { display: none !important; }

/* ปุ่มส่งสลิป (input ซ่อนอยู่ข้างใน): แสดงกรอบเมื่อเลื่อนมาด้วยแป้น Tab */
.send-btn:focus-within { outline: 3px solid var(--accent, #c4963e); outline-offset: 3px; }
