/* AomSub — สีและตัวอักษรทั้งหมดกำหนดที่ :root แก้ที่นี่ที่เดียว */
:root {
  --bg: #F1F3F8;
  --surface: #FFFFFF;
  --sunken: #E9ECF4;
  --ink: #191C2E;
  --muted: #62687F;
  --line: #E1E4EE;
  --primary: #4A55C7;
  --primary-ink: #FFFFFF;
  --primary-soft: #E6E8F8;
  --in: #14805F;
  --save: #1E8A5C;
  --save-ink: #FFFFFF;
  --save-soft: #E2F3EA;
  --new: #E0583A;
  --new-ink: #FFFFFF;
  --neg: #C2405A;
  --warn: #A96A08;
  --shadow: 0 1px 2px rgb(25 28 46 / .04), 0 12px 32px -18px rgb(25 28 46 / .22);
  --font: "Anuphan", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11131C;
    --surface: #1A1D2B;
    --sunken: #222638;
    --ink: #ECEEF7;
    --muted: #9CA2BC;
    --line: #2B2F45;
    --primary: #959DF5;
    --primary-ink: #12142A;
    --primary-soft: #272B4D;
    --in: #57CBA8;
    --save: #5CC793;
    --save-ink: #0F2219;
    --save-soft: #1B3328;
    --new: #FF8A6B;
    --new-ink: #2A0E06;
    --neg: #F28BA0;
    --warn: #E4B45A;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11131C;
  --surface: #1A1D2B;
  --sunken: #222638;
  --ink: #ECEEF7;
  --muted: #9CA2BC;
  --line: #2B2F45;
  --primary: #959DF5;
  --primary-ink: #12142A;
  --primary-soft: #272B4D;
  --in: #57CBA8;
  --save: #5CC793;
  --save-ink: #0F2219;
  --save-soft: #1B3328;
  --new: #FF8A6B;
  --new-ink: #2A0E06;
  --neg: #F28BA0;
  --warn: #E4B45A;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, dl, dd, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: default; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

.boot { padding: 96px 16px; text-align: center; color: var(--muted); }
.quiet { color: var(--muted); font-size: 14px; }
.alert { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); color: var(--neg); border-radius: 14px; padding: 12px 16px; font-size: 14.5px; margin-bottom: 16px; }

/* ── ปุ่ม ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 14px; font-weight: 600; font-size: 15.5px; white-space: nowrap; transition: background-color .15s, opacity .15s; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); }
.btn-google { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn-google:hover:not(:disabled) { background: var(--sunken); }
.btn-quiet { background: var(--sunken); width: 100%; font-weight: 500; }
.btn-quiet:hover:not(:disabled) { background: var(--line); }
.btn-danger { color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, var(--surface)); }
.btn-danger[data-armed="1"] { background: var(--neg); color: var(--surface); }
.grow { flex: 1; }
.ibtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); flex: none; }
.ibtn:hover { background: var(--sunken); color: var(--ink); }
.link { color: var(--primary); font-weight: 600; font-size: 14.5px; padding: 8px 4px; }
.link:hover { text-decoration: underline; }

/* ── แบรนด์ ── */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.mark { width: 30px; height: 30px; }

/* ── หน้าเข้าสู่ระบบ ── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
.login-in { width: min(440px, 100%); }
.login h1 { font-size: clamp(30px, 8vw, 38px); line-height: 1.3; font-weight: 700; letter-spacing: -.015em; margin: 44px 0 14px; }
.login-lead { color: var(--muted); font-size: 16.5px; max-width: 34em; }
.login .btn { width: 100%; min-height: 52px; }
.login-note { color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.login .alert { margin: 16px 0 0; }
.demo-strip { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 32px 0; padding: 14px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); }
.demo-day { display: grid; justify-items: center; gap: 2px; padding: 5px 0 3px; border-radius: 10px; }
.demo-day b { font-weight: 500; font-size: 13px; color: var(--muted); line-height: 1.5; }
.demo-day span { display: flex; gap: 2px; height: 6px; }
.demo-day i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.demo-day.on { background: var(--primary-soft); }
.demo-day.on b { color: var(--primary); font-weight: 700; }

/* ── แถบบน ── */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.top-in { max-width: 1120px; margin: 0 auto; height: 64px; padding: 0 20px; display: flex; align-items: center; gap: 28px; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tab { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 12px; color: var(--muted); font-weight: 500; font-size: 15px; }
.tab svg { width: 22px; height: 22px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.btn-add { min-height: 40px; padding: 0 16px 0 12px; border-radius: 12px; font-size: 15px; }
.face { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; flex: none; }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face.big { width: 52px; height: 52px; font-size: 20px; }

.bottom, .fab { display: none; }

/* ── ตัวช่วยประหยัด: ปุ่มเด่นแยกจากแท็บ ── */
.save-btn { display: flex; align-items: center; gap: 13px; height: 40px; padding: 0 14px 0 10px; border-radius: 12px; background: var(--save-soft); color: var(--save); font-weight: 600; font-size: 15px; white-space: nowrap; }
.save-btn:hover { background: color-mix(in srgb, var(--save-soft) 70%, var(--save) 12%); }
.save-btn.on { background: var(--save); color: var(--save-ink); }
.sico { position: relative; display: inline-grid; place-items: center; }
.sico svg { width: 22px; height: 22px; }
.sbadge { position: absolute; top: -7px; right: -9px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--save); color: var(--save-ink); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.save-btn.on .sbadge { background: var(--save-ink); color: var(--save); box-shadow: 0 0 0 2px var(--save); }
.bottom .tab-save { color: var(--save); }
.bottom .tab-save .sico { width: 44px; height: 28px; border-radius: 14px; background: var(--save-soft); }
.bottom .tab-save.on .sico { background: var(--save); color: var(--save-ink); }
.bottom .tab-save.on { color: var(--save); font-weight: 600; }

/* สลับ เดือนนี้ / ทั้งหมด */
.vtoggle { display: inline-flex; gap: 2px; padding: 3px; margin: 0 6px 14px; border-radius: 14px; background: var(--sunken); }
.vseg { height: 34px; min-width: 84px; text-align: center; padding: 0 16px; border-radius: 11px; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.vseg:hover { color: var(--ink); }
.vseg.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* แถบชวนดูตัวช่วยประหยัด ใต้ยอดเดือนนี้ */
.save-strip { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 6px 8px 12px; border-radius: 14px; background: var(--save-soft); color: var(--ink); font-size: 14.5px; }
.save-strip .sico { color: var(--save); }
.save-strip .sico svg { width: 20px; height: 20px; }
.save-strip p { flex: 1; min-width: 0; margin: 0; }
.save-strip b { color: var(--save); font-weight: 700; }
.save-strip .link { color: var(--save); font-weight: 600; }
.save-strip .ibtn { width: 32px; height: 32px; color: var(--muted); }
/* ป้ายสินค้าใหม่ */
.snew { font-style: normal; height: 20px; padding: 0 7px; border-radius: 10px; background: var(--new); color: var(--new-ink); font-size: 11.5px; font-weight: 700; line-height: 20px; animation: newpop .5s ease-out; }
.save-btn .snew { margin-left: -5px; }
.sdot { position: absolute; top: -3px; left: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--new); box-shadow: 0 0 0 2px var(--surface); }
.save-btn .sdot { display: none; }
.bottom .tab-save .snew { display: none; }
.bottom .tab-save .sdot { top: -2px; left: 2px; animation: newpop .5s ease-out; }
.pnew { font-style: normal; display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 9px; background: var(--new); color: var(--new-ink); font-size: 11.5px; font-weight: 700; line-height: 18px; vertical-align: 2px; }
@keyframes newpop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .snew, .bottom .tab-save .sdot { animation: none; } }
.promo-more { justify-self: start; color: var(--save); font-size: 14px; }

/* ── โครงหน้า ── */
.page { max-width: 1120px; margin: 0 auto; padding: 8px 20px 72px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.col-side { position: sticky; top: 84px; display: grid; gap: 36px; padding-top: 12px; }

/* ── แผ่นสรุปเดือน ── */
.sheet-month { background: var(--surface); border-radius: 28px; padding: 20px 28px 22px; box-shadow: var(--shadow); }
.mnav { display: flex; align-items: center; gap: 4px; margin-left: -10px; }
.mname { font-size: 18px; font-weight: 600; min-width: 9.2em; text-align: center; }
.mnav .link { margin-left: auto; }

.hero { padding: 22px 0 22px; }
.hero-l { color: var(--muted); font-size: 15px; }
.hero-n { font-size: clamp(42px, 11vw, 60px); line-height: 1.15; font-weight: 600; letter-spacing: -.03em; margin-top: 2px; }
.progress { height: 6px; border-radius: 6px; background: var(--sunken); margin-top: 18px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width .35s ease; }
.hero-s { color: var(--muted); font-size: 14px; margin-top: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 16px 24px; padding: 18px 0; border-top: 1px solid var(--line); }
.stats dt { color: var(--muted); font-size: 13.5px; }
.stats dd { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.stats .in { color: var(--in); }
.stats .neg { color: var(--neg); }

/* ── เส้นเดือน (องค์ประกอบหลักของหน้า) ── */
.strip { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; padding-top: 16px; border-top: 1px solid var(--line); }
.day { display: grid; justify-items: center; align-content: start; gap: 1px; padding: 6px 0 6px; border-radius: 10px; min-width: 0; }
.day-w { font-size: 10.5px; line-height: 1.5; color: var(--muted); opacity: .75; }
.day-n { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: 13.5px; line-height: 1; color: var(--muted); }
.day-dots { display: flex; align-items: center; justify-content: center; gap: 2px; height: 10px; }
.day-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.day-dots i.paid { background: none; box-shadow: inset 0 0 0 1.5px var(--c); }
.day-dots em { font-style: normal; font-size: 9px; color: var(--muted); line-height: 1; }
.day.has .day-n { color: var(--ink); font-weight: 600; }
.day.past:not(.has) { opacity: .5; }
.day.today .day-n { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.day.has:hover { background: var(--sunken); }
.day.sel, .day.sel:hover { background: var(--primary-soft); }
.day:focus-visible { outline-offset: -2px; }

/* ── บล็อกรายการ ── */
.block { margin-top: 36px; }
.block-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 6px 10px; min-height: 40px; }
.block-h h2, .side h2 { font-size: 17px; font-weight: 600; }
.rows { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 4px 0; }
.row { display: flex; align-items: center; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 18px; right: 0; border-top: 1px solid var(--line); }
.check { width: 52px; height: 56px; display: grid; place-items: center; flex: none; margin-left: 6px; }
.check svg { width: 26px; height: 26px; padding: 3px; border-radius: 50%; box-shadow: inset 0 0 0 1.8px color-mix(in srgb, var(--muted) 55%, transparent); color: transparent; transition: background-color .15s, box-shadow .15s; }
.check:hover svg { box-shadow: inset 0 0 0 1.8px var(--primary); }
.check[aria-checked="true"] svg { background: var(--primary); color: var(--primary-ink); box-shadow: none; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 18px 12px 0; border-radius: 12px; }
.row-main:first-child { padding-left: 18px; }
.row-main:hover .row-name { color: var(--primary); }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 13px; display: grid; place-items: center; font-weight: 700; font-size: 16px; background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: color-mix(in srgb, var(--c) 72%, var(--ink)); }
.avatar svg { width: 56%; height: 56%; }
.avatar.sm { width: 22px; height: 22px; border-radius: 7px; font-size: 11px; }
/* โลโก้แอป: พื้นสีแบรนด์ โลโก้สีตัดกัน มีขอบบางๆ ให้ป้ายสีดำยังเห็นขอบในธีมมืด */
.av-brand { background: var(--b); color: var(--f); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 14%, transparent); }
.av-brand svg { fill: currentColor; }
.av-text { font-size: 15px; letter-spacing: -.02em; line-height: 1; }
.av-text.n3 { font-size: 12.5px; }
.av-text.n4, .av-text.n5 { font-size: 10.5px; }
.sm.av-text { font-size: 10px; }
.sm.av-text.n3 { font-size: 8px; }
.sm.av-text.n4, .sm.av-text.n5 { font-size: 6.5px; }
.av-glyph svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.av-img { background: #FFFFFF; overflow: hidden; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 14%, transparent); }
.av-empty { background: var(--sunken); color: var(--muted); }
.av-empty svg { width: 40%; height: 40%; }
.av-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.row-text { flex: 1; min-width: 0; display: grid; }
.row-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .15s; }
.row-meta { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--muted); font-size: 13.5px; }
.st-overdue, .st-missed { color: var(--neg); font-weight: 500; }
.st-today, .st-soon { color: var(--warn); font-weight: 500; }
.row-amt { font-weight: 600; font-size: 16px; text-align: right; white-space: nowrap; display: grid; }
.row-amt.in { color: var(--in); }
.row-amt small { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.row.is-paid .row-name, .row.is-paid .row-amt { color: var(--muted); font-weight: 500; }
.row.is-paid .avatar, .row.is-paused .avatar { opacity: .55; }
.row.is-paid .av-brand, .row.is-paid .av-img { opacity: 1; } /* โลโก้ต้องจำได้เสมอ แม้จ่ายแล้ว */
.row.is-paused .row-name, .row.is-paused .row-amt { color: var(--muted); }

.empty { background: var(--surface); border-radius: 20px; padding: 40px 24px; text-align: center; box-shadow: var(--shadow); }
.empty h3 { font-size: 18px; font-weight: 600; }
.empty p { color: var(--muted); max-width: 30em; margin: 6px auto 0; font-size: 15px; }
.empty .btn { margin-top: 20px; }

/* ── คอลัมน์ข้าง ── */
.side h2 { margin-bottom: 14px; }
.cats { display: grid; gap: 14px; }
.cat-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14.5px; }
.cat-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-name i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.cat-amt { font-weight: 600; }
.meter { height: 5px; border-radius: 5px; background: var(--sunken); margin-top: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 5px; background: var(--c); }

.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.bar { display: grid; gap: 6px; justify-items: center; border-radius: 8px; padding: 4px 0 2px; }
.bar-track { height: 84px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-fill { width: min(14px, 70%); border-radius: 5px; background: color-mix(in srgb, var(--primary) 38%, var(--sunken)); transition: background-color .15s; }
.bar-l { font-size: 10.5px; line-height: 1.4; color: var(--muted); white-space: nowrap; }
.bar:hover .bar-fill { background: color-mix(in srgb, var(--primary) 70%, var(--sunken)); }
.bar.on .bar-fill { background: var(--primary); }
.bar.on .bar-l { color: var(--ink); font-weight: 600; }
.pairs { display: grid; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.pairs div { display: flex; justify-content: space-between; gap: 12px; font-size: 14.5px; }
.pairs dt { color: var(--muted); }
.pairs dd { font-weight: 600; }

/* ── แท็บรายการทั้งหมด ── */
.all { max-width: 720px; margin: 0 auto; }
.all-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 6px 0; }
.all-h h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.search { flex: 1 1 240px; max-width: 320px; }
.all .block:first-child { margin-top: 24px; }
.all .empty { margin-top: 24px; }

/* ── ช่องกรอก ── */
input[type="text"], input[type="search"], select {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input[type="text"]:focus, input[type="search"]:focus, select:focus { border-color: var(--primary); }
input[aria-invalid="true"] { border-color: var(--neg); }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%238088A3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 20px; }

/* ── แผ่นฟอร์ม (dialog) ── */
dialog#sheet { border: 0; padding: 0; margin: auto; width: min(480px, calc(100% - 32px)); max-height: min(92dvh, 780px); border-radius: 26px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgb(10 12 30 / .45); overflow: auto; overscroll-behavior: contain; }
dialog#sheet::backdrop { background: rgb(14 16 32 / .5); }
dialog#sheet[open] { animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } }
.form { padding: 18px 24px 24px; display: grid; gap: 18px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; margin-right: -8px; }
.sheet-h h2 { font-size: 20px; font-weight: 700; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label { font-size: 14px; font-weight: 500; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { color: var(--neg); font-size: 13.5px; }
.hint { color: var(--muted); font-size: 13.5px; }
.under { margin-top: -10px; }
.name-row { display: flex; gap: 10px; align-items: center; }
.name-row input { flex: 1; min-width: 0; }
.icon-pick { position: relative; flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; }
.icon-pick .avatar { width: 48px; height: 48px; border-radius: 14px; font-size: 19px; }
.icon-pick-badge { position: absolute; right: -5px; bottom: -5px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgb(20 22 40 / .15); }
.icon-pick-badge svg { width: 13px; height: 13px; }
.icon-pick:hover .icon-pick-badge { color: var(--primary); }
.field .hint .link { padding: 0; font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px 0 7px; border-radius: 17px; background: var(--sunken); font-size: 14px; }
.chip-more { padding-left: 12px; }
.chip:hover { background: var(--primary-soft); color: var(--primary); }
#presets:not(.open) .chip:nth-child(n+7):not(.chip-more) { display: none; }
#presets.open .chip-more { display: none; }
.chip-more { background: none; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 14px; }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg label { display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; min-height: 40px; padding: 0 4px; border-radius: 10px; font-size: 14.5px; font-weight: 500; color: var(--muted); text-align: center; white-space: nowrap; }
.seg input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgb(20 22 40 / .12); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }

.switch { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; transition: background-color .15s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgb(20 22 40 / .25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch b { display: block; font-weight: 600; font-size: 15px; }
.switch small { display: block; color: var(--muted); font-size: 13.5px; }

.sheet-f { display: flex; gap: 10px; padding-top: 4px; }
.sheet-list { display: grid; gap: 8px; }
.who { display: flex; align-items: center; gap: 14px; }
.who b { display: block; font-weight: 600; }
.who small { display: block; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

/* ── แจ้งเตือนสั้น ── */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 14px; font-size: 14.5px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── แท็บค่าใช้จ่ายในบ้าน ── */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.pair .hero { padding-bottom: 6px; min-width: 0; }
.hero-n.small { font-size: clamp(30px, 8vw, 44px); }
.how { color: var(--muted); font-size: 13.5px; padding-bottom: 16px; }
.rates-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.rates-line .link { margin-left: auto; padding: 4px; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.qbtn { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 12px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); text-align: left; }
.qbtn:hover b { color: var(--primary); }
.q-text { display: grid; min-width: 0; }
.q-text b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-text small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-add { background: none; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); }
.q-add svg { width: 40px; height: 22px; }
.pad { padding: 0 6px; }
.day-h { font-size: 13.5px; font-weight: 600; color: var(--muted); padding: 14px 6px 8px; }
.day-h:first-of-type { padding-top: 0; }
.side-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.side-h h2 { margin-bottom: 0; }
.side-h .link { padding: 4px; }
.apps { display: grid; gap: 2px; margin: 0 -10px; }
.app-row { display: flex; gap: 12px; width: 100%; padding: 10px; border-radius: 14px; align-items: flex-start; }
.app-row:hover { background: var(--surface); }
.avatar.mid { width: 34px; height: 34px; border-radius: 11px; }
.app-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.app-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; }
.app-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-top span { font-weight: 600; white-space: nowrap; }
.app-top .quiet { font-weight: 400; font-size: 13px; }
.app-spec { display: flex; flex-wrap: wrap; gap: 0 10px; color: var(--muted); font-size: 12.5px; }
.app-text .meter { margin-top: 6px; }
.note { font-size: 13px; line-height: 1.55; }
.home-setup { max-width: 560px; margin: 0 auto; padding-top: 24px; }
.home-setup h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.home-setup .lead { color: var(--muted); margin: 8px 0 20px; }
.setup-card { background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); padding: 22px; }
.with-suffix { position: relative; }
.with-suffix input { padding-right: 96px; }
.with-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
input[type="date"] { width: 100%; height: 48px; padding: 0 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); outline: none; }
input[type="date"]:focus { border-color: var(--primary); }
.ac-fields, .rate-group { display: grid; gap: 16px; }
.bill { margin: 0 0 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.bill summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 14.5px; padding: 4px 0; width: fit-content; }
.bill table { width: 100%; border-collapse: collapse; margin: 10px 0 8px; font-size: 14.5px; }
.bill td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.bill td:last-child { text-align: right; font-weight: 500; white-space: nowrap; padding-left: 12px; }
.bill td small { display: block; color: var(--muted); font-size: 12.5px; }
.bill tr.sum td { font-weight: 700; border-bottom: 0; padding-top: 10px; }
.bill .hint { margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .ibtn { width: 48px; height: 48px; border-radius: 14px; background: var(--sunken); color: var(--ink); font-size: 22px; line-height: 1; }
.stepper .ibtn:hover { background: var(--primary-soft); color: var(--primary); }
.stepper input { width: 84px; height: 48px; text-align: center; font-size: 18px; font-weight: 600; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); outline: none; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { border-color: var(--primary); }
.stepper span { color: var(--muted); margin-left: -4px; }
.est { background: var(--sunken); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; }
.chips.center { justify-content: center; margin-top: 16px; }
fieldset.field { display: grid; gap: 6px; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
/* ปุ่มเลือกแบบชิป (radio อยู่ข้างใน) */
label.chip { cursor: pointer; position: relative; }
label.chip input { position: absolute; opacity: 0; pointer-events: none; }
label.chip:has(input:checked) { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--primary); }
label.chip:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── บ้านและการแชร์ ── */
.house-h { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 4px 6px 18px; }
.house-t { min-width: 0; }
.house-t h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: anywhere; }
.house-t p { color: var(--muted); font-size: 14px; }
.btn-soft { min-height: 42px; padding: 0 16px 0 12px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-size: 15px; }
.btn-soft:hover { background: color-mix(in srgb, var(--primary) 16%, var(--surface)); }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 6px 18px; }
.sub { height: 38px; padding: 0 14px; border-radius: 19px; background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font-size: 14.5px; font-weight: 500; }
.sub:hover { color: var(--ink); }
.sub.on { background: var(--ink); color: var(--bg); box-shadow: none; }
.tab-house span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert.info { background: var(--primary-soft); color: var(--ink); }
.alert.notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 6px; }
.alert.notice .ibtn { color: inherit; width: 34px; height: 34px; }
.members { display: grid; gap: 4px; }
.members li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 4px 6px 14px; border-radius: 12px; background: var(--sunken); font-size: 15px; min-width: 0; }
.members li span { overflow-wrap: anywhere; min-width: 0; }
.members li.quiet { background: none; padding-left: 0; }
.members .ibtn { width: 34px; height: 34px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; }
.add-btn { width: auto; flex: none; min-height: 48px; }
input[type="email"] { width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); outline: none; }
input[type="email"]:focus { border-color: var(--primary); }
input[readonly] { color: var(--muted); background: var(--sunken); }
.switches { display: grid; gap: 14px; }
.switch input:disabled + .switch-ui { opacity: .6; }

/* ชื่อเรียกของสมาชิก */
.members li { flex-wrap: wrap; }
.m-email { flex: 1 1 160px; }
.members .m-name { flex: 1 1 120px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14.5px; min-width: 0; outline: none; }
.members .m-name:focus { border-color: var(--primary); }
.btn-quiet-sm { min-height: 38px; padding: 0 14px; border-radius: 12px; background: var(--sunken); color: var(--muted); font-size: 14px; font-weight: 500; }
.btn-quiet-sm:hover { color: var(--neg); }
.btn-quiet-sm[data-armed="1"] { background: var(--neg); color: var(--surface); }

/* ความเคลื่อนไหว */
.feed { display: grid; gap: 12px; }
.feed li { display: grid; gap: 1px; font-size: 14.5px; line-height: 1.5; }
.feed b { font-weight: 600; }
.feed small { color: var(--muted); font-size: 12.5px; }
.row-meta .by { color: var(--primary); }

/* กราฟย้อนหลัง: แท่งเดียวสี ไม่ต้องมีคำอธิบายสี ชื่อหัวข้อบอกว่าเป็นอะไร */
.hist { display: grid; gap: 10px; }
.mini-seg { display: flex; gap: 4px; }
.mini { height: 30px; padding: 0 12px; border-radius: 15px; font-size: 13px; color: var(--muted); background: var(--sunken); }
.mini.on { background: var(--ink); color: var(--bg); font-weight: 600; }
.hbars { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; padding-top: 34px; border-bottom: 1px solid var(--line); }
.hbar { position: relative; display: grid; gap: 6px; justify-items: center; padding: 0 0 4px; border-radius: 8px; }
.hbar-track { height: 96px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.hbar-fill { width: min(18px, 72%); border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--primary) 45%, var(--sunken)); transition: background-color .15s; }
.hbar.nodata .hbar-track::after { content: ""; width: min(18px, 72%); height: 3px; border-radius: 2px; background: var(--line); }
.hbar-l { font-size: 10.5px; line-height: 1.4; color: var(--muted); white-space: nowrap; }
.hbar.on .hbar-fill { background: var(--primary); }
.hbar.on .hbar-l { color: var(--ink); font-weight: 600; }
.hbar:hover .hbar-fill, .hbar:focus-visible .hbar-fill { background: var(--primary); }
.hbar::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: 12px; line-height: 1.4; padding: 4px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; z-index: 2; display: none; }
.hbar.edge-l::after { left: 0; transform: none; }
.hbar.edge-r::after { left: auto; right: 0; transform: none; }
.hbar:hover::after, .hbar:focus-visible::after { display: block; }
.table-view summary { cursor: pointer; color: var(--primary); font-size: 13.5px; font-weight: 600; width: fit-content; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13.5px; }
.table-view td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.table-view td:last-child { text-align: right; color: var(--muted); padding-left: 8px; }

/* รายจ่ายรายวัน */
.daily-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: -6px 0 16px; padding: 10px 14px; border-radius: 14px; background: var(--sunken); font-size: 14px; color: var(--muted); }
.daily-line .link { padding: 2px 0; font-size: 14px; }
.qbtn { position: relative; }
.qbtn.done { box-shadow: var(--shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--in) 45%, transparent); }
.q-done { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; color: var(--in); font-size: 13px; font-weight: 700; flex: none; }
.q-done svg { width: 18px; height: 18px; }
.q-edit { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); margin-left: auto; flex: none; }
.q-edit:hover { background: var(--sunken); color: var(--primary); }
.q-edit svg { width: 16px; height: 16px; }
.q-edit + .grip { margin-left: 0; }
.day-h { display: flex; justify-content: space-between; gap: 8px; }
.day-h span { font-weight: 500; }
.big-input { font-size: 26px !important; font-weight: 600; height: 60px !important; }

/* ลากเรียงเครื่องใช้ */
.qbtn.sorting { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--primary) 40%, var(--line)); }
.qbtn.sorting:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.qbtn.dragging { cursor: grabbing; opacity: .85; box-shadow: 0 12px 28px -10px rgb(20 22 40 / .45), inset 0 0 0 2px var(--primary); transform: scale(1.03); }
.grip { margin-left: auto; color: var(--muted); display: grid; place-items: center; flex: none; }
.grip svg { width: 18px; height: 18px; }
.sort-hint { margin-top: 10px; }

/* ── จอแท็บเล็ตลงมา: คอลัมน์เดียว ── */
@media (max-width: 900px) and (min-width: 641px) {
  .top .tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .top .tab { padding: 0 10px; }
}
@media (max-width: 960px) {
  .cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .col-side { position: static; margin-top: 36px; padding: 0 6px; }
  .stats { grid-template-columns: 1fr 1fr; justify-content: stretch; }
}

/* ── มือถือ ── */
@media (max-width: 640px) {
  .top-in { height: 56px; padding: 0 16px; }
  .top .tabs, .btn-add, .save-btn { display: none; }
  .top-actions { margin-left: auto; }
  .page { padding: 4px 16px calc(156px + env(safe-area-inset-bottom)); }
  .sheet-month { padding: 12px 18px 16px; border-radius: 24px; }
  .hero { padding: 14px 0 18px; }
  .mname { font-size: 17px; }

  /* เส้นเดือนเลื่อนซ้ายขวาได้ ช่องกว้างพอให้นิ้วแตะ */
  .strip { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 42px; overflow-x: auto; margin: 0 -18px; padding: 14px 18px 2px; scrollbar-width: none; scroll-padding: 18px; }
  .strip::-webkit-scrollbar { display: none; }
  .day { padding: 6px 0 8px; }
  .day-n { width: 30px; height: 30px; font-size: 14.5px; }
  .day-w { font-size: 11px; }

  .block { margin-top: 28px; }
  .row-main { gap: 12px; padding-right: 14px; }
  .row-main:first-child { padding-left: 14px; }
  .check { width: 48px; margin-left: 2px; }
  .row + .row::before { left: 14px; }

  .bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(76px, 1fr); overflow-x: auto; scrollbar-width: none; align-items: center; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .bottom .tab { flex-direction: column; gap: 0; height: 52px; justify-content: center; font-size: 12.5px; background: none; min-width: 0; padding: 0 4px; }
  .bottom .tab > span:not(.sico) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom::-webkit-scrollbar { display: none; }
  .house-h { padding-bottom: 14px; }
  .house-t h1 { font-size: 21px; }
  .house-h .btn-soft { width: 100%; justify-content: center; }
  .fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 11; width: 56px; height: 56px; border-radius: 20px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--primary) 70%, transparent); }
  .fab svg { width: 26px; height: 26px; }
  #toast { bottom: calc(152px + env(safe-area-inset-bottom)); }
  .pair { gap: 12px; }
  .quick { grid-template-columns: 1fr 1fr; }
  .home-setup { padding-top: 8px; }

  dialog#sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; max-height: 92dvh; }
  .form { padding: 14px 18px calc(20px + env(safe-area-inset-bottom)); gap: 16px; }
  .seg-4 span { font-size: 13.5px; }
  .all-h h1 { font-size: 22px; }
  .search { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* รายรับรายวัน */
.qbtn.inc small { color: var(--in); }
.day-h b.in { color: var(--in); font-weight: 600; }
.inc-stats { border-top: 1px dashed var(--line); }
.inc-stats .in { color: var(--in); }
.inc-stats .neg { color: var(--neg); }

/* ตัวช่วยประหยัด */
.promo-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 8px; }
.promo-eyebrow { font-size: 12.5px; color: var(--in); font-weight: 600; }
.promo-top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.promo-top b { display: block; font-weight: 600; line-height: 1.4; }
.promo-top small { color: var(--muted); font-size: 13.5px; }
.promo-img { background: #FFFFFF; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.promo-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.promo-pay { font-size: 18px; font-weight: 700; color: var(--in); }
.promo-why, .promo-text { font-size: 14px; color: var(--ink); line-height: 1.55; }
.promo-text { color: var(--muted); }
.promo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.promo-actions .btn-primary { min-height: 40px; padding: 0 16px; border-radius: 12px; font-size: 14.5px; text-decoration: none; }
.promo-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.small { font-size: 13px; }
.save-page { max-width: 960px; margin: 0 auto; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pcard { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; display: grid; gap: 8px; align-content: start; }
.pcard.off { opacity: .6; }
.save-page .note { margin-top: 16px; }

/* แถบเมนูบน: ป้ายไม่ตัดบรรทัด ถ้าแท็บเยอะ (มีบ้านที่แชร์) ให้เลื่อนได้ */
.top .tabs { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top .tabs::-webkit-scrollbar { display: none; }
.top .tab { white-space: nowrap; flex: none; }
