:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #fffdfa;
  --surface-2: #f1ece4;
  --ink: #1d1a16;
  --ink-2: #57514a;
  --muted: #8b847a;
  --line: #e4ddd2;
  --accent: #6b3f22;        /* สีกาแฟ */
  --accent-ink: #ffffff;
  --accent-soft: #f3e6da;
  --good: #0c7a2c;
  --bad: #c0362c;
  --warn: #a86a00;
  --card-a: #3b2416;
  --card-b: #8a5a36;
  --grid: #e8e3da;
  --axis: #c9c2b6;
  --series: #2a78d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(60,40,20,.06);
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14120f;
    --surface: #1e1b17;
    --surface-2: #29251f;
    --ink: #f4efe8;
    --ink-2: #c8c0b4;
    --muted: #8f877b;
    --line: #36312a;
    --accent: #d9a57a;
    --accent-ink: #1d1a16;
    --accent-soft: #3a2c20;
    --good: #3cc36a;
    --bad: #f07167;
    --warn: #f0b429;
    --grid: #2c2823;
    --axis: #3d3830;
    --series: #3987e5;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.bonus-banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; box-shadow: 0 6px 20px rgba(239,68,68,.25); }
.bonus-banner .big { font-size: 30px; font-weight: 800; line-height: 1; }
.bonus-banner .txt { font-weight: 700; line-height: 1.3; }
.bonus-banner small { display: block; font-weight: 500; opacity: .9; }
.bonus-tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 700; margin-left: 6px; vertical-align: 2px; }
.wrap { max-width: 480px; margin: 0 auto; padding: 16px; }
.wrap-wide { max-width: 1200px; margin: 0 auto; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none;
}
input[type=date] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; min-height: 48px; text-align: left; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; min-height: 44px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.pill.good { color: var(--good); } .pill.bad { color: var(--bad); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.pts-plus { color: var(--good); font-weight: 700; font-variant-numeric: tabular-nums; }
.pts-minus { color: var(--bad); font-weight: 700; font-variant-numeric: tabular-nums; }
.void { text-decoration: line-through; opacity: .5; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px;
  border-radius: 12px; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600; }
.toast.err { background: var(--bad); color: #fff; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: var(--ink-2); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; max-width: min(520px, calc(100% - 32px)); width: 100%; }
dialog::backdrop { background: rgba(0,0,0,.4); }

/* ---------- ธีมเขียว (เลือกได้ในหน้าตั้งค่า) ---------- */
:root[data-theme="green"] {
  --bg: #f2f6f3;
  --surface: #fbfdfb;
  --surface-2: #e7efe9;
  --ink: #17231c;
  --ink-2: #4a5a50;
  --muted: #7d8a82;
  --line: #d7e2da;
  --accent: #2e7d5b;
  --accent-soft: #dcefe4;
  --card-a: #1d5a41;
  --card-b: #4f9a76;
  --grid: #e1e9e3;
  --axis: #c3d0c7;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="green"] {
    --bg: #0f1411;
    --surface: #171e1a;
    --surface-2: #212a24;
    --ink: #edf4ef;
    --ink-2: #bccac1;
    --muted: #84928a;
    --line: #2d3831;
    --accent: #7cc9a0;
    --accent-ink: #0f1411;
    --accent-soft: #1f3a2c;
    --grid: #26302a;
    --axis: #36423a;
  }
}
