:root {
  /* ธีมเดียวกับเว็บ "ของฟรีจาก OhmFlow" (OhmFlow/free-apps/style.css) */
  --bg: #f7f9fd; --surface: #fff; --text: #0f172a; --muted: #5b6478; --line: #e3e8f2;
  --brand: #1d4ed8; --brand-2: #0ea5e9; --brand-soft: #e6eeff; --accent: #047857; --err: #b42318; --err-bg: #fdecea;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 12px 32px -12px rgba(15,23,42,.18);
  --radius: 22px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a0f1c; --surface: #121a2b; --text: #e8edf7; --muted: #9aa5bb; --line: #22304a;
    --brand: #5b8cff; --brand-2: #38bdf8; --brand-soft: #17254a; --accent: #6ee7b7; --err: #ff8a80; --err-bg: #3a1c1a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -16px rgba(0,0,0,.7); }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 "IBM Plex Sans Thai", system-ui, sans-serif; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand img { width: 32px; height: 32px; border-radius: 12px; }
.brand b, h1, h2 { font-family: Prompt, "IBM Plex Sans Thai", sans-serif; letter-spacing: -.01em; }
.top h1 { margin: 0 auto 0 4px; padding: 12px 0 12px 14px; border-left: 1px solid var(--line); font-size: 18px; font-weight: 600; line-height: 1.3; }
.top h1 span { display: block; font: 400 12.5px "IBM Plex Sans Thai", sans-serif; color: var(--muted); }
@media (max-width: 520px) { .brand b, .top h1 span { display: none; } }
footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 13.5px; }
footer a { color: var(--brand); }

.top-row { display: flex; align-items: center; gap: 12px; }
.ghost { font: inherit; font-size: 13.5px; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--brand); cursor: pointer; white-space: nowrap; }
.ghost:hover { border-color: var(--brand-2); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 16px 18px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-head .link { color: var(--muted); }
#logsMsg { margin: 8px 0 0; }
.logs-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow: auto; }
.logs-list button { width: 100%; display: flex; justify-content: space-between; gap: 12px; font: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left; }
.logs-list button:hover { border-color: var(--brand-2); }
.logs-list small { color: var(--muted); font-size: 12.5px; }
.layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; padding-top: 24px; padding-bottom: 40px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--brand-soft); padding: 4px; border-radius: 12px; }
.tabs button { border: 0; background: transparent; padding: 8px 2px; border-radius: 9px; font: inherit; font-size: 13px; white-space: nowrap; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
section[data-for] { display: grid; gap: 14px; }
section[hidden] { display: none; }

label { display: grid; gap: 5px; font-weight: 500; font-size: 14px; }
label small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; font-family: "IBM Plex Mono", monospace; font-size: 14px; }
input[type=file] { padding: 7px; font-size: 13px; }
input[type=range] { padding: 0; border: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; }
.hint { margin: -6px 0 0; font-size: 12.5px; color: var(--muted); }
.hint:empty { display: none; }
.error { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--err-bg); color: var(--err); font-size: 14px; white-space: pre-line; }

.logo-box { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-row[hidden] { display: none; }
.logo-row img { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.logo-row .range { flex: 1; font-size: 13px; }
button.link { border: 0; background: none; color: var(--err); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }

select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
.book { display: grid; gap: 6px; }
.badge { justify-self: start; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.badge.dirty { background: #fff4e0; color: #8a5300; }
@media (prefers-color-scheme: dark) { .badge.dirty { background: #3a2c12; color: #f5c46b; } }
.adv { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.adv summary { cursor: pointer; font-size: 13.5px; color: var(--muted); }
.adv[open] { display: grid; gap: 10px; }
.adv[open] summary { margin-bottom: 4px; }
.adv .hint { margin: 0; }
.acct-actions { display: flex; gap: 8px; }
.acct-actions button { flex: 1; font: inherit; font-size: 14px; padding: 9px; border-radius: 10px; border: 1px solid var(--brand-2); background: var(--surface); color: var(--brand); cursor: pointer; font-weight: 500; }
.acct-actions .danger { flex: 0 0 auto; border-color: var(--line); color: var(--err); font-weight: 400; }
.ok { margin: 0; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-size: 14px; }
.primary { border: 0; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font: inherit; font-weight: 600;
  padding: 12px; border-radius: 12px; cursor: pointer; box-shadow: 0 8px 20px -8px rgba(29,78,216,.6); transition: transform .2s, box-shadow .2s; }
.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px rgba(29,78,216,.75); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .primary { transition: none; } .primary:hover { transform: none; } }
.primary:disabled { opacity: .6; cursor: wait; }

.empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 24px 24px; text-align: center; }
.empty[hidden] { display: none; }
.empty h2 { margin: 6px 0 14px; font-size: 19px; font-weight: 600; color: var(--brand); }
.empty .hint { margin: 16px 0 0; }
.empty code { font-size: 12.5px; word-break: break-all; }
.hero { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; }
.steps { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 8px; max-width: 360px; text-align: left; }
.steps li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; }
.steps b { flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 13px Prompt, sans-serif; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.steps em { font-style: normal; font-weight: 600; color: var(--brand); }

/* ภาพประกอบหน้าแรก — สีผูกกับธีมสว่าง/มืด */
.hero { --h-blob: #e6eeff; --h-phone: #1d4ed8; --h-screen: #ffffff; --h-line: #d6dee8; --h-line-strong: #9fb3c8;
  --h-qr: #0b1b2b; --h-coin: #f6c453; --h-coin-side: #d99a1e; --h-coin-mark: #9a6408; --h-card: #ffffff; --h-card-stroke: #d6dee8; }
@media (prefers-color-scheme: dark) {
  .hero { --h-blob: #17254a; --h-phone: #3b6ff0; --h-screen: #eef3f8; --h-line: #cfd9e3; --h-line-strong: #8ea5bd;
    --h-card: #eef3f8; --h-card-stroke: #3a4a5a; }
}
.h-blob { fill: var(--h-blob); }
.h-dot { fill: var(--brand-2); opacity: .35; }
.h-phone { fill: var(--h-phone); }
.h-screen { fill: var(--h-screen); }
.h-notch { fill: var(--h-phone); opacity: .5; }
.h-line { fill: var(--h-line); }
.h-line-strong { fill: var(--h-line-strong); }
.h-qr-bg { fill: #fff; stroke: var(--h-line); }
.h-qr { fill: var(--h-qr); }
.h-scan { fill: var(--brand-2); opacity: .75; animation: scan 2.6s ease-in-out infinite; }
.h-btn { fill: var(--brand); }
.h-btn-text { fill: #fff; opacity: .9; }
.h-card { fill: var(--h-card); stroke: var(--h-card-stroke); stroke-width: 1.5; }
.h-baht { font: 600 17px "IBM Plex Sans Thai", sans-serif; fill: #1d4ed8; }
.h-coin { fill: var(--h-coin); }
.h-coin-side { fill: var(--h-coin-side); }
.h-coin-mark { font: 700 13px sans-serif; fill: var(--h-coin-mark); text-anchor: middle; }
.h-check { fill: var(--accent); }
.h-check-mark { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
@keyframes scan { 0%, 100% { transform: translateY(-34px); } 50% { transform: translateY(38px); } }
@media (prefers-reduced-motion: reduce) { .h-scan { animation: none; } }

/* แถวเลขบัตรประชาชน */
.id-rows { display: grid; gap: 10px; }
.id-row { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.id-row-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.id-rows.single .id-row { padding: 0; border: 0; }
.id-rows.single .id-row-head { display: none; }
.add-row { justify-self: start; font: inherit; font-size: 13.5px; padding: 7px 12px; border-radius: 10px; border: 1px dashed var(--brand-2); background: transparent; color: var(--brand); cursor: pointer; }
.add-row:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card canvas { display: block; width: 100%; height: auto; background: #fff; }
.card .meta { padding: 14px 16px 16px; display: grid; gap: 6px; border-top: 1px solid var(--line); }
.card .who { font-size: 12.5px; color: var(--brand); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card .acct { font-family: "IBM Plex Mono", monospace; font-size: 16px; font-weight: 500; }
.card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13.5px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card details { font-size: 12.5px; color: var(--muted); }
.card summary { cursor: pointer; }
.card .payload { display: block; margin-top: 4px; font-family: "IBM Plex Mono", monospace; word-break: break-all; font-size: 11.5px; }
.card .actions { display: flex; gap: 8px; margin-top: 6px; }
.card .actions button { flex: 1; font: inherit; font-size: 13.5px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--brand); cursor: pointer; }
.card .actions button:hover { border-color: var(--brand-2); }

.bill-box { display: grid; gap: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 6%, transparent); }
.bill-box[hidden], .check[hidden], label[hidden] { display: none; }
.pp-kind { color: var(--brand); font-weight: 500; }
.bill-box .hint { margin: 0; }
.ref-hint { margin-top: -4px; }

/* บล็อกธนาคาร */
.bank-box { margin: 0; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 12px; min-width: 0; }
.bank-box legend { padding: 0 6px; font-weight: 600; font-size: 14px; color: var(--brand); }
.bank-pick { display: flex; align-items: center; gap: 8px; }
.bank-pick select { flex: 1; min-width: 0; }
.swatch { flex: 0 0 22px; height: 22px; border-radius: 6px; background: var(--line); border: 1px solid rgba(0,0,0,.08); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13.5px; cursor: pointer; }
.check input { width: auto; margin-top: 3px; }
.check small { display: inline; }
.acct-actions button:disabled { opacity: .6; cursor: wait; }
.book select { font-weight: 500; }#bookOpen { justify-self: start; color: var(--brand); }
