/* ESP32 UI Designer — หน้าแรก / เข้าสู่ระบบ / สมัครสมาชิก (โทนเดียวกับหน้าออกแบบ มีโหมดมืด/สว่าง) */
/* โหมดมืด (ค่าเริ่มต้น) - จอจำลอง (.lcd, .shot) ใช้ชุดสีมืดเสมอ เพราะเป็นภาพของจอจริง */
:root,
:root[data-theme="light"] .lcd,
:root[data-theme="light"] .shot {
  --bg: #0b0e13;
  --bg-2: #10141b;
  --panel: #151a22;
  --panel-2: #1b212b;
  --line: #242c38;
  --line-soft: #1d242e;
  --ink: #e6edf3;
  --ink-2: #93a0b0;
  --ink-3: #64707e;
  --gold: #f0a22e;
  --gold-ink: #f0a22e;
  --gold-dim: #8a5c14;
  --gold-line: #8a5c14;
  --gold-soft: #f0a22e14;
  --gold-soft-2: #f0a22e26;
  --sel: #4c8dff;
  --ok: #3fc97a;
  --ok-ink: #8de8b4;
  --ok-line: #2f6b47;
  --warn: #f0554e;
  --warn-ink: #f6c684;
  --err-ink: #ff8d86;
  --err-line: #7a2b28;
  --err-hover: #2a1514;
  --info-ink: #a9c8ff;
  --info-line: #2c4f8f;
  --hover: #222a36;
  --hover-line: #323d4d;
  --warm: #1a1610;
  --warm-line: #3a2a12;
  --shadow: #000b;
  --nav-bg: #0b0e13e6;
  --grid-line: #ffffff05;
  color-scheme: dark;
}
:root {
  --font-ui: "IBM Plex Sans Thai", "Segoe UI", system-ui, sans-serif;
  --font-dis: "Chakra Petch", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;
}
/* โหมดสว่าง - เลือกด้วยปุ่มบนแถบเมนู จำค่าไว้ใน localStorage (ดู public/js/theme.js) */
:root[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-2: #edf0f5;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --line: #d3dae3;
  --line-soft: #e2e7ee;
  --ink: #17202b;
  --ink-2: #4b5868;
  --ink-3: #6b7786;
  --gold: #e8961c;
  --gold-ink: #9a5a00;
  --gold-dim: #d39a3a;
  --gold-line: #d9a548;
  --gold-soft: #f0a22e1f;
  --gold-soft-2: #f0a22e3d;
  --sel: #2f6fe0;
  --ok: #1f9d57;
  --ok-ink: #17753f;
  --ok-line: #9fd6b6;
  --warn: #d63a33;
  --warn-ink: #8a5300;
  --err-ink: #b92d26;
  --err-line: #e5a39f;
  --err-hover: #fdecea;
  --info-ink: #1f55b3;
  --info-line: #a9c3ee;
  --hover: #e3e8ef;
  --hover-line: #b6c0cd;
  --warm: #fff5e2;
  --warm-line: #ecd3a4;
  --shadow: #1b243338;
  --nav-bg: #ffffffe6;
  --grid-line: #0000000a;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* -------------------------------------------------------------------- nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-row { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px; flex: none;
  background: linear-gradient(140deg, var(--gold), #b96f12);
  box-shadow: inset 0 0 0 1px #ffffff26;
  display: grid; place-items: center;
  font-family: var(--font-dis); font-weight: 700; font-size: 14px; color: #1b1206;
}
.brand-name { font-family: var(--font-dis); font-weight: 600; font-size: 16px; letter-spacing: .3px; white-space: nowrap; }

.nav-links { display: flex; gap: 22px; margin-right: auto; margin-left: 12px; }
.nav-links a { color: var(--ink-2); text-decoration: none; font-size: 14px; }
.nav-links a:hover { color: var(--ink); }

.nav-auth { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-auth form { margin: 0; }
/* ---------------------------------------------------- ปุ่มสลับโหมดมืด/สว่าง */
.theme-toggle { padding: 7px 9px; color: var(--ink-2); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .ico-moon { display: none; }
:root[data-theme="light"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="light"] .theme-toggle .ico-moon { display: block; }
.lang-toggle { padding: 6px 8px; color: var(--ink-2); font-size: 12px; font-weight: 600; letter-spacing: .3px; min-width: 38px; justify-content: center; }
.nav-user { color: var(--ink-2); font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
a.nav-user:hover { color: var(--ink); text-decoration: underline; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 14px; cursor: pointer;
  font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--hover); border-color: var(--hover-line); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(180deg, #f3ad42, #dc8c15);
  border-color: #b3700f; color: #201604; font-weight: 600;
}
.btn.primary:hover { background: linear-gradient(180deg, #ffbb56, #e79718); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.big { padding: 11px 22px; font-size: 16px; border-radius: 8px; }
.btn.block { width: 100%; padding: 11px 14px; font-size: 15px; }

/* ------------------------------------------------------------------- hero */
.hero {
  padding: 72px 0 80px;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 28px 100%,
    radial-gradient(900px 420px at 78% 20%, var(--gold-soft), transparent 70%);
  border-bottom: 1px solid var(--line);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 56px; align-items: center; }

.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .6px;
  color: var(--gold-ink); margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--font-dis); font-weight: 700;
  font-size: clamp(30px, 4.2vw, 46px); line-height: 1.25; letter-spacing: -.2px;
  text-wrap: balance;
}
.lead { margin-top: 20px; color: var(--ink-2); font-size: 17px; max-width: 34em; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.hero-note { margin-top: 16px; font-size: 13px; color: var(--ink-3); }

/* ---- ภาพจำลองบอร์ด */
.hero-art { position: relative; padding-bottom: 72px; }

.pcb {
  position: relative;
  padding: 26px 30px 34px;
  background: linear-gradient(150deg, #e2b93b, #c79a1f);
  border-radius: 14px;
  box-shadow: 0 30px 60px -20px var(--shadow), inset 0 0 0 1px #ffffff40, inset 0 -3px 0 #0000002e;
  transform: rotate(-2deg);
}
.pcb-hole {
  position: absolute; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 0 0 3px #b98d17;
}
.pcb-hole.tl { top: 8px; left: 8px; }  .pcb-hole.tr { top: 8px; right: 8px; }
.pcb-hole.bl { bottom: 8px; left: 8px; } .pcb-hole.br { bottom: 8px; right: 8px; }
.pcb-label {
  position: absolute; bottom: 9px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px; color: #5a4408;
}

.lcd {
  position: relative; aspect-ratio: 4 / 3; color: var(--ink);
  background: #0d1117; border-radius: 6px;
  box-shadow: 0 0 0 5px #14171c, 0 0 0 6px #00000080;
  display: flex; flex-direction: column;
  font-size: clamp(10px, 1.25vw, 14px); line-height: 1.3;
  overflow: hidden;
}
.lcd-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7em 1em; background: #161c26; border-bottom: 1px solid #222b38;
  font-weight: 500;
}
.lcd-clock { font-family: var(--font-mono); color: var(--ink-2); }
.lcd-body { flex: 1; display: grid; grid-template-columns: 42% 1fr; gap: 1em; padding: 1em; align-items: center; min-height: 0; }

.lcd-arc { position: relative; aspect-ratio: 1; }
.lcd-arc svg { width: 100%; height: 100%; transform: rotate(135deg); }
.lcd-arc circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.arc-bg { stroke: #232c39; stroke-dasharray: 75 100; }
.arc-fg { stroke: var(--gold); stroke-dasharray: 46 100; }
.lcd-arc-val {
  position: absolute; inset: 0; display: grid; place-content: center;
  font-family: var(--font-dis); font-weight: 600; font-size: 1.7em;
}
.lcd-arc-val small { font-size: .5em; color: var(--ink-2); text-align: center; }

.lcd-col { display: flex; flex-direction: column; gap: .7em; }
.lcd-row { display: flex; justify-content: space-between; align-items: center; }
.lcd-switch { width: 2.6em; height: 1.4em; border-radius: 1em; background: #2a3442; position: relative; flex: none; }
.lcd-switch::after {
  content: ""; position: absolute; top: .18em; left: .2em;
  width: 1.04em; height: 1.04em; border-radius: 50%; background: #e6edf3;
}
.lcd-switch.on { background: var(--ok); }
.lcd-switch.on::after { left: auto; right: .2em; }
.lcd-slider { height: .45em; border-radius: 1em; background: #2a3442; position: relative; margin: .4em 0; }
.lcd-slider span { position: absolute; inset: 0 38% 0 0; border-radius: 1em; background: var(--sel); }
.lcd-slider span::after {
  content: ""; position: absolute; right: -.55em; top: 50%; transform: translateY(-50%);
  width: 1.1em; height: 1.1em; border-radius: 50%; background: #e6edf3;
}
.lcd-btn { position: relative; background: var(--sel); color: #fff; border-radius: .5em; padding: .6em; text-align: center; font-weight: 500; }

/* กรอบเลือกวิดเจ็ตแบบในหน้าออกแบบ ครอบปุ่ม "หน้าถัดไป" */
.sel-box {
  position: absolute; inset: -5px;
  border: 1px dashed var(--gold); pointer-events: none;
}
.sel-box i { position: absolute; width: 7px; height: 7px; background: var(--gold); }
.sel-box i:nth-child(1) { top: -4px; left: -4px; }   .sel-box i:nth-child(2) { top: -4px; right: -4px; }
.sel-box i:nth-child(3) { bottom: -4px; left: -4px; } .sel-box i:nth-child(4) { bottom: -4px; right: -4px; }

.code-chip {
  position: absolute; left: -18px; bottom: 0; max-width: calc(100% - 10px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; box-shadow: 0 16px 30px -12px var(--shadow);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.c-dim { color: var(--ink-3); }
.c-str { color: var(--ok-ink); }

/* --------------------------------------------------------------- sections */
.section { padding: 76px 0; }
.section.alt { background: var(--bg-2); border-block: 1px solid var(--line); }
.section h2, .cta h2 {
  font-family: var(--font-dis); font-weight: 600; font-size: clamp(24px, 3vw, 30px); line-height: 1.3;
  text-wrap: balance;
}
.section-lead { margin-top: 12px; color: var(--ink-2); max-width: 46em; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 34px; }
.feature {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 22px 24px;
  border-top: 2px solid #f0a22e66;
}
.feature h3, .steps h3 { font-family: var(--font-dis); font-weight: 600; font-size: 18px; line-height: 1.35; }
.feature p, .steps p { margin-top: 8px; color: var(--ink-2); font-size: 15px; }
code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}

.steps { list-style: none; margin: 34px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.step-no {
  display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 14px;
  border-radius: 8px; border: 1px solid var(--gold-line); color: var(--gold-ink); background: var(--gold-soft);
  font-family: var(--font-dis); font-weight: 700;
}

.boards { list-style: none; padding: 0; margin: 26px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.boards li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 13px 16px; font-size: 15px;
}

.cta { padding: 56px 0; background: linear-gradient(180deg, var(--warm), var(--bg)); border-top: 1px solid var(--warm-line); }
.cta-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }

.foot { margin-top: auto; border-top: 1px solid var(--line); padding: 22px 0; font-size: 13px; color: var(--ink-2); }
.foot-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot-dim { color: var(--ink-3); font-family: var(--font-mono); font-size: 12px; }

/* ------------------------------------------------------------------- auth */
.page-auth { background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 28px 100%,
    var(--bg);
}
.auth { flex: 1; display: grid; place-items: center; padding: 48px 16px; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px 30px 28px;
  box-shadow: 0 30px 60px -30px var(--shadow);
}
.auth-card h1 { font-family: var(--font-dis); font-weight: 600; font-size: 26px; line-height: 1.3; }
.auth-sub { margin-top: 6px; color: var(--ink-2); font-size: 15px; }
.auth-card form { margin-top: 24px; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.form-row input {
  width: 100%;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; font-size: 16px;
  transition: border-color .12s, box-shadow .12s;
}
.form-row input:focus-visible { outline: none; border-color: var(--sel); box-shadow: 0 0 0 2px #4c8dff33; }
.form-row input[aria-invalid="true"] { border-color: var(--warn); }
.form-hint { margin-top: 5px; font-size: 13px; color: var(--ink-3); }
.form-error { margin-top: 5px; font-size: 13px; color: var(--err-ink); }

.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--gold); }

.form-split { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 20px; font-size: 14px; }
.form-split .check { margin: 0; }
.form-split a, .form-error a { color: var(--gold-ink); }
.notice.error { background: #f0554e14; border-color: var(--err-line); color: var(--err-ink); }
.auth-card .notice { margin-top: 18px; font-size: 14px; }

.auth-alt { margin-top: 20px; text-align: center; font-size: 14px; color: var(--ink-2); }
.auth-alt a { color: var(--gold-ink); }

/* -------------------------------------------------------------- dashboard */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.dash { flex: 1; padding: 44px 0 64px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.dash h1 { font-family: var(--font-dis); font-weight: 600; font-size: 30px; line-height: 1.3; }
.dash-sub { color: var(--ink-2); font-size: 15px; }
.dash h2 { font-family: var(--font-dis); font-weight: 600; font-size: 20px; margin: 40px 0 14px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 28px 0 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.stat dt { color: var(--ink-2); font-size: 14px; }
.stat dd {
  margin: 4px 0 0; font-family: var(--font-dis); font-weight: 600; font-size: 34px; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat dd small { font-family: var(--font-ui); font-weight: 400; font-size: 14px; color: var(--ink-3); }

.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; vertical-align: middle;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500; line-height: 1.6;
  color: var(--gold-ink); background: var(--gold-soft); border: 1px solid var(--gold-line);
}

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.projects { width: 100%; border-collapse: collapse; font-size: 15px; }
.projects th, .projects td { padding: 13px 16px; text-align: left; vertical-align: middle; white-space: nowrap; }
.projects thead th {
  font-weight: 500; font-size: 13px; color: var(--ink-3);
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.projects tbody tr + tr > * { border-top: 1px solid var(--line); }
.projects tbody tr:hover { background: var(--grid-line); }
.projects tbody th { font-weight: 500; }
.projects tbody th a { text-decoration: none; }
.projects tbody th a:hover { color: var(--gold-ink); }
.projects .num { text-align: right; font-variant-numeric: tabular-nums; }
.projects .dim, .projects small.dim { color: var(--ink-2); }
.projects small { font-size: 13px; }
.projects .act { text-align: right; }
.projects .act form { display: inline-block; margin: 0 0 0 6px; }
.btn.danger { color: var(--err-ink); }
.btn.danger:hover { border-color: var(--err-line); background: var(--err-hover); }
.notice {
  margin-top: 24px; padding: 11px 16px; border-radius: 8px; font-size: 15px;
  background: #3fc97a14; border: 1px solid var(--ok-line); color: var(--ok-ink);
}
.projects .board { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.projects tbody th { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- billing */
.wrap.narrow { max-width: 860px; }
.dash h2 .badge { vertical-align: 3px; }
.dash-note.top { margin: 0 0 12px; }
.dash-note a, .notice a { color: var(--gold-ink); }
.notice.info { background: #4c8dff14; border-color: var(--info-line); color: var(--info-ink); }

.balance { display: flex; align-items: baseline; gap: 8px; color: var(--ink-2); font-size: 14px; }
.balance strong { font-family: var(--font-dis); font-weight: 600; font-size: 30px; color: var(--gold-ink); font-variant-numeric: tabular-nums; }

.credit-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--gold-line); background: var(--gold-soft); color: var(--gold-ink);
  font-size: 13px; font-weight: 500; text-decoration: none; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.credit-chip:hover { background: var(--gold-soft-2); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px; margin-top: 24px; }
.panel h2 { margin: 22px 0 12px; font-size: 17px; }
.panel h2:first-of-type { margin-top: 0; }
.panel .form-row input { max-width: 100%; }
.member-status p { margin: 0; }
.member-status .form-hint { margin-top: 8px; }

.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.preset {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px;
  transition: border-color .12s, background .12s;
}
.preset strong { font-family: var(--font-dis); font-weight: 600; font-size: 16px; }
.preset span { font-size: 13px; color: var(--ink-2); }
.preset:hover { border-color: var(--hover-line); }
.preset[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); }
.preset:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }

.amount-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.amount-row input { width: 180px; }
.you-get { color: var(--ink-2); font-size: 15px; }
.you-get strong { color: var(--gold-ink); font-family: var(--font-dis); font-size: 20px; font-variant-numeric: tabular-nums; }

.bank { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.bank dt { font-size: 13px; color: var(--ink-3); }
.bank dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.mono { font-family: var(--font-mono); }
/* QR พร้อมเพย์: พื้นขาวเสมอทั้งโหมดมืดและสว่าง ไม่งั้นแอปธนาคารสแกนไม่ติด */
.pp { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.pp-qr { width: 232px; height: 232px; max-width: 100%; background: #fff; border-radius: 6px; image-rendering: pixelated; flex: none; }
.pp-qr.off { opacity: .25; }
.pp-info { flex: 1; min-width: 200px; }
.pp-info p { margin: 0 0 6px; }
.pp-title { font-weight: 600; }
.pp-amount strong { color: var(--gold-ink); font-family: var(--font-dis); font-size: 24px; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.7;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); white-space: nowrap;
}
.pill.pending { border-color: var(--gold-line); background: var(--gold-soft); color: var(--gold-ink); }
.pill.approved { border-color: var(--ok-line); background: #3fc97a14; color: var(--ok-ink); }
.pill.rejected { border-color: var(--err-line); background: #f0554e14; color: var(--err-ink); }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 8px; }
.section .plans { margin-top: 30px; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin: 0; display: flex; flex-direction: column; }
.plan h3 { font-family: var(--font-dis); font-weight: 600; font-size: 17px; }
.plan-price { font-family: var(--font-dis); font-weight: 600; font-size: 30px; line-height: 1.3; margin-top: 6px; font-variant-numeric: tabular-nums; }
.plan-price small { font-family: var(--font-ui); font-weight: 400; font-size: 14px; color: var(--ink-3); }
.plan-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 16px; }
.plan .btn { margin-top: auto; white-space: normal; text-align: center; }

.account {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap; margin-top: 24px;
  background: linear-gradient(180deg, var(--warm), var(--panel)); border: 1px solid var(--warm-line); border-radius: 10px; padding: 16px 20px;
}
.account-item { display: flex; flex-direction: column; }
.account-label { font-size: 13px; color: var(--ink-2); }
.account-item strong { font-family: var(--font-dis); font-weight: 600; font-size: 24px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.account-item strong.ok { color: var(--ok-ink); }
.account-item small { font-size: 13px; color: var(--ink-3); }
.account-act { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.queue { display: grid; gap: 12px; }
.queue-item { background: var(--panel); border: 1px solid var(--gold-line); border-radius: 10px; padding: 16px 18px; }
.queue-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.queue-main .dim { color: var(--ink-2); font-size: 14px; }
.queue-amt { margin-left: auto; font-family: var(--font-dis); font-weight: 600; color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.queue-meta { display: flex; gap: 24px; flex-wrap: wrap; margin: 10px 0 14px; }
.queue-meta dt { font-size: 12px; color: var(--ink-3); }
.queue-meta dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.queue-act { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.queue-act form { margin: 0; display: flex; gap: 8px; }
.queue-act .reject { margin-left: auto; }
.queue-act input, .bank-form input {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 14px; min-width: 0;
}
.queue-act input { width: 230px; }
.queue-act input:focus-visible { outline: none; border-color: var(--sel); box-shadow: 0 0 0 2px #4c8dff33; }

.fold { margin-top: 14px; }
.fold summary { cursor: pointer; color: var(--ink-2); font-size: 14px; padding: 6px 0; }
.fold .table-wrap { margin-top: 8px; }
.bank-form { margin-top: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; align-items: end; }
.bank-form .form-row input { padding: 9px 11px; font-size: 15px; }
.bank-form .btn, .bank-form .form-hint { grid-column: 1 / -1; justify-self: start; }
.bank-form .form-hint { margin-top: 10px; }
.bank-form.site-ai { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.bank-form .notice { grid-column: 1 / -1; margin-bottom: 14px; }
.bank-form select {
  width: 100%; background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 11px; font-size: 15px;
}
.bank-form select:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
.compare td, .compare th { white-space: normal; }

/* -------------------------------------------------------------- templates */
/* ฟอนต์ชุดเดียวกับจอจำลองในหน้าออกแบบ (ดู public/css/designer.css) */
@font-face { font-family: "LVGL Thai"; src: url("../fonts/NotoSansThaiUI-Regular.ttf") format("truetype"); unicode-range: U+0E00-0E7F; font-display: swap; }
@font-face { font-family: "LVGL Symbols"; src: url("../fonts/lvgl-symbols.woff") format("woff"); font-display: block; }
.lv-sym { font-family: "LVGL Symbols"; font-weight: normal; font-style: normal; line-height: 1; }

.shot { position: relative; overflow: hidden; border-radius: 4px; flex: none; }
.shot-in { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden;
  font-family: "LVGL Thai", "Montserrat", var(--font-ui); font-weight: 500; }
.sw { position: absolute; box-sizing: border-box; }
.sw-c { display: flex; align-items: center; justify-content: center; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.tpl { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.tpl-shot {
  display: grid; place-items: center; padding: 16px; min-height: 228px;
  background: linear-gradient(150deg, #e2b93b, #c79a1f); text-decoration: none;
}
.tpl-shot .shot { box-shadow: 0 0 0 4px #14171c, 0 10px 22px -8px #000a; }
.tpl-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.tpl-body h3 { font-family: var(--font-dis); font-weight: 600; font-size: 18px; line-height: 1.35; }
.tpl-body p { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.tpl-body .tpl-meta { color: var(--ink-3); font-size: 13px; font-family: var(--font-mono); margin: 8px 0 4px; }
.tpl-body .btn { margin-top: auto; }
.tpl-body .fold { margin: 2px 0 12px; }
.tpl-all { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.tpl-all figure { margin: 0; }
.tpl-all figcaption { font-size: 12px; color: var(--ink-3); text-align: center; margin-top: 3px; }

.head-acts { display: flex; gap: 10px; flex-wrap: wrap; }
.tpl-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.tpl-form .wide { grid-column: 1 / -1; }
.tpl-form .btn { justify-self: start; }
.tpl-form .check { margin: 0 0 16px; }
.form-row select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; font: inherit; font-size: 16px; color: inherit;
}
.form-row select:focus-visible { outline: none; border-color: var(--sel); box-shadow: 0 0 0 2px #4c8dff33; }
.form-row select[aria-invalid="true"] { border-color: var(--warn); }
.inline-form { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }

.tpl-admin { display: grid; gap: 10px; }
.tpl-row {
  display: flex; align-items: center; gap: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 16px;
}
.tpl-row.is-hidden { opacity: .62; }
.tpl-thumb { width: 120px; height: 120px; flex: none; display: grid; place-items: center; }
.tpl-thumb .shot { box-shadow: 0 0 0 2px #14171c; }
.tpl-info { flex: 1; min-width: 0; }
.tpl-info h3 { font-family: var(--font-dis); font-weight: 600; font-size: 17px; }
.tpl-info h3 .pill { vertical-align: 2px; margin-left: 4px; font-family: var(--font-ui); }
.tpl-info p { color: var(--ink-2); font-size: 14px; }
.tpl-info .tpl-meta { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.tpl-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tpl-acts form { margin: 0; }
.preview-strip { margin-top: 24px; }

/* -------------------------------------------------------------- โปรไฟล์ */
.profile-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; }
.profile-info dt { font-size: 13px; color: var(--ink-3); }
.profile-info dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.profile-info dd small { font-weight: 400; font-size: 13px; color: var(--ink-2); }
.panel .form-row input[type="password"], .panel .form-row input[type="email"] { max-width: 100%; }
@media (max-width: 640px) { .profile-info { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- สลิปโอนเงิน */
.form-row input[type="file"] { padding: 8px 10px; font-size: 14px; }
.slip-preview { display: block; margin-top: 10px; max-width: 220px; max-height: 300px; border: 1px solid var(--line); border-radius: 8px; }
.slip-thumb {
  display: inline-flex; align-items: flex-end; gap: 10px; margin: 0 0 14px; text-decoration: none;
  color: var(--gold-ink); font-size: 14px;
}
.slip-thumb img { display: block; max-width: 150px; max-height: 210px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.slip-thumb:hover span { text-decoration: underline; }
.slip-none { margin: 0 0 14px; }
.projects td a:not(.btn) { color: var(--gold-ink); }

/* ------------------------------------------------------ เฟิร์มแวร์กล้อง */
.cam-form h3 { margin: 18px 0 10px; font-size: 16px; color: var(--ink-2); }
.cam-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.cam-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cam-checks { display: flex; gap: 22px; flex-wrap: wrap; }
.cam-checks .check { margin: 0 0 6px; }
.cam-pio { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 8px; }
.cam-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cam-status { margin: 14px 0 10px; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.cam-status.run { color: var(--gold-ink); }
.cam-status.ok { color: var(--ok); }
.cam-status.fail { color: var(--err-ink); }
.cam-ready { border: 1px solid var(--ok); border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; }
.cam-ready p { margin: 0 0 8px; }
.cam-ready ul { margin: 0; padding-left: 20px; }
.cam-ready code { font-family: var(--font-mono); overflow-wrap: anywhere; user-select: all; }
.cam-log {
  margin: 0 0 14px; height: 260px; overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.cam-log:empty { display: none; }
@media (max-width: 760px) {
  .cam-grid, .cam-grid.three { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------- รูปของฉัน */
.stat dt a { color: var(--gold-ink); }
.img-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.img-upload input[type="file"] {
  flex: 1; min-width: 220px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 14px;
}
.img-upload input[type="file"]:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
.img-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.img-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
/* พื้นลายตารางให้เห็นส่วนโปร่งใสของรูป */
.img-thumb {
  display: block; height: 170px; padding: 12px; overflow: hidden;
  background: repeating-conic-gradient(#1a2230 0% 25%, #232d3d 0% 50%) 0 0 / 18px 18px;
}
.img-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.img-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.img-body form { margin: 0; }
.img-rename { display: flex; gap: 8px; }
.img-rename input {
  flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; font-size: 15px;
}
.img-rename input:focus-visible { outline: none; border-color: var(--sel); box-shadow: 0 0 0 2px #4c8dff33; }
.img-meta { color: var(--ink-3); font-size: 13px; font-family: var(--font-mono); }
.img-used { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; }
.img-used.none { color: var(--ink-3); }
.img-body .js-delete { margin-top: auto; }

@media (max-width: 760px) {
  .tpl-form { grid-template-columns: 1fr; }
  .tpl-row { flex-wrap: wrap; }
  .tpl-thumb { width: 96px; height: 96px; }
  .tpl-acts { width: 100%; justify-content: flex-start; }
}

.empty {
  background: var(--panel); border: 1px dashed var(--line); border-radius: 10px;
  padding: 40px 20px; text-align: center; color: var(--ink-2);
}
.empty .btn { margin-top: 16px; }
.dash-note { margin-top: 14px; font-size: 13px; color: var(--ink-3); max-width: 60em; }

/* จอแคบ: แต่ละโปรเจกต์เป็นการ์ด แทนตารางที่ต้องเลื่อนแนวนอน */
@media (max-width: 860px) {
  .table-wrap { background: none; border: 0; overflow: visible; }
  .projects, .projects tbody, .projects tr, .projects th, .projects td { display: block; }
  .projects thead { display: none; }
  .projects tbody tr {
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: 14px 16px; margin-bottom: 12px;
  }
  .projects tbody tr + tr > * { border-top: 0; }
  .projects th, .projects td { padding: 0; white-space: normal; max-width: none; }
  .projects tbody th { font-size: 17px; margin-bottom: 8px; overflow-wrap: anywhere; }
  .projects td[data-label] {
    display: flex; justify-content: space-between; gap: 16px;
    padding: 5px 0; text-align: right; font-size: 14px;
  }
  .projects td[data-label]::before { content: attr(data-label); color: var(--ink-3); text-align: left; flex: none; }
  .projects .board { max-width: none; overflow: visible; }
  .projects .act { margin-top: 10px; display: flex; gap: 8px; }
  .projects .act > .btn { flex: 1; padding: 9px; }
  .projects .act form { margin: 0; }
  .projects .act form .btn { padding: 9px 18px; }
}

@media (max-width: 900px) {
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bank, .bank-form { grid-template-columns: 1fr; }
  .account-act { margin-left: 0; width: 100%; }
  .account-act .btn { flex: 1; }
  .queue-act .reject { margin-left: 0; width: 100%; }
  .queue-act .reject input { flex: 1; width: auto; }
  .queue-amt { margin-left: 0; width: 100%; }
  .credit-chip { padding: 4px 8px; font-size: 12px; }
  .stats, .stats.four { grid-template-columns: 1fr; }
  .stat { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px; }
  .stat dd { font-size: 26px; margin: 0; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .hero { padding: 48px 0 56px; }
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .hero-art { max-width: 460px; margin: 0 auto; width: 100%; }
  .lcd { font-size: clamp(10px, 2.9vw, 14px); }
  .code-chip { left: 0; }
  .features, .steps { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .section { padding: 56px 0; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .boards { grid-template-columns: 1fr; }
  .nav-user { display: none; }
  .nav-row { gap: 8px; }
  .nav-auth { gap: 5px; }
  .theme-toggle { padding: 6px 7px; }
  .brand-name { font-size: 13px; }
  .btn { padding: 7px 9px; font-size: 13px; }
  .btn.big { padding: 11px 18px; }
  .auth-card { padding: 26px 20px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn { transition: none; }
}

/* ----------------------------------------------------------- หน้าข้อผิดพลาด (429) */
.errpage { display: grid; align-items: center; }
.err-card {
  max-width: 560px; margin: 0 auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 40px 32px 34px;
}
.err-code {
  margin: 0; font-family: var(--font-dis); font-weight: 700;
  font-size: clamp(72px, 18vw, 112px); line-height: 1; letter-spacing: .04em; color: var(--gold-ink);
}
.err-card h1 { margin: 14px 0 10px; font-size: 26px; }
.err-text { margin: 0 auto; max-width: 440px; color: var(--ink-2); line-height: 1.7; }
.err-wait { margin: 26px auto 0; max-width: 360px; }
.err-count { margin: 0 0 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.err-wait.done .err-count { color: var(--ok-ink); }
.err-bar { height: 6px; border-radius: 3px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; }
.err-bar span { display: block; height: 100%; width: 0; background: var(--gold-ink); transition: width .25s linear; }
.err-wait.done .err-bar span { background: var(--ok-ink); }
.err-acts { margin-top: 28px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.err-acts .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
@media (max-width: 520px) { .err-card { padding: 30px 18px 26px; } .err-acts .btn { flex: 1 1 100%; } }
@media (prefers-reduced-motion: reduce) { .err-bar span { transition: none; } }

/* ----------------------------------------------------------- โปรไฟล์: เชื่อมต่อ AI */
.ai-now { margin: 14px 0 18px; }
.ai-model-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-model-row input { flex: 1 1 220px; min-width: 0; }
#ai select {
  width: 100%; background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 10px; font: inherit;
}
#ai select:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
#ai .form-hint a { color: var(--gold-ink); overflow-wrap: anywhere; }
.ai-disconnect { margin-top: 12px; }
.ai-notes { margin: 20px 0 0; padding-left: 20px; color: var(--ink-3); font-size: 14px; line-height: 1.7; }

/* ปุ่มผู้ช่วย AI บนแดชบอร์ด - โทนเดียวกับปุ่มในหน้าออกแบบ */
.btn.ai { border-color: var(--gold-dim, var(--gold-ink)); color: var(--gold-ink); }
.btn.ai:hover { border-color: var(--gold-ink); }

/* ---------------------------------------------------------------- คู่มือการใช้งาน */
.guide { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 8px; }
.guide-toc { position: sticky; top: 84px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-top: 24px; }
.guide-toc-title { margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.guide-toc ol { margin: 0; padding-left: 20px; color: var(--ink-3); font-size: 14px; line-height: 1.9; }
.guide-toc a { color: var(--ink-2); text-decoration: none; }
.guide-toc a:hover { color: var(--gold-ink); }
.guide-body { min-width: 0; }
.guide-body .panel { scroll-margin-top: 84px; }
.guide-body p, .guide-body li, .guide-body dd { line-height: 1.75; color: var(--ink-2); }
.guide-body h3 { margin: 22px 0 8px; font-size: 15px; color: var(--ink); }
.guide-steps, .guide-list { margin: 0; padding-left: 22px; }
.guide-steps li, .guide-list li { margin: 4px 0; }
.guide-body b { color: var(--ink); font-weight: 600; }
.guide-dl { margin: 12px 0; display: grid; gap: 10px; }
.guide-body .panel > p { margin: 10px 0; }
.guide-dl > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.guide-dl dt { font-weight: 600; color: var(--ink); }
.guide-dl dd { margin: 0; }
.guide-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.guide-table th, .guide-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.guide-table th { color: var(--ink); font-weight: 600; }
.guide-body kbd { font-family: var(--font-mono); font-size: 12px; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--panel-2); color: var(--ink); }
.guide-code { margin: 8px 0 0; padding: 12px 14px; padding-right: 84px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--ink); white-space: pre; }
.guide-code-wrap { position: relative; }
.guide-copy { position: absolute; top: 6px; right: 6px; padding: 4px 10px; font-size: 12px; }
.guide-ex { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 16px; }
.guide-ex:first-of-type { border-top: 0; }
.guide-ex h3 { margin-top: 0; }
.guide-ex-setup, .guide-ex-fn { margin: 4px 0; font-size: 14px; }
.guide-ex-setup > span:first-child, .guide-ex-fn > span:first-child { color: var(--ink); font-weight: 600; }
.guide-ex-note { margin: 8px 0 0; font-size: 14px; color: var(--ink-3); }
@media (max-width: 860px) {
  .guide { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .guide-toc { position: static; }
  .guide-dl > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .guide-table { display: block; overflow-x: auto; }
}
