:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e3e6eb;
  --brand: #06c755;          /* LINE green */
  --brand-ink: #ffffff;
  --brand-soft: #e6f9ee;
  --accent: #ff6b2c;         /* แคลอรี่ / ไฟ */
  --accent-soft: #fff1ea;
  --warn: #b7791f;
  --warn-soft: #fdf6e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --gold: #e8b100;
  --silver: #9aa3ae;
  --bronze: #c27a45;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --text: #eef0f3; --muted: #9aa1ad;
    --border: #2a2f38; --brand-soft: #0f2b1c; --accent-soft: #33200f; --warn: #e3b341; --warn-soft: #2f2610;
    --danger: #f87171; --danger-soft: #3a1717; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --text: #eef0f3; --muted: #9aa1ad;
  --border: #2a2f38; --brand-soft: #0f2b1c; --accent-soft: #33200f; --warn: #e3b341; --warn-soft: #2f2610;
  --danger: #f87171; --danger-soft: #3a1717; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.wrap.wide { max-width: 1100px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
a { color: inherit; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.hl { background: var(--accent-soft); border-color: transparent; }
.stat.hl .v { color: var(--accent); }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 64px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; user-select: none; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 12px; padding: 12px 16px; cursor: pointer; text-decoration: none; background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }

.photo-drop { border: 2px dashed var(--border); border-radius: 12px; padding: 20px; text-align: center; cursor: pointer; color: var(--muted); background: var(--surface-2); }
.photo-drop img { max-width: 100%; max-height: 280px; border-radius: 8px; display: block; margin: 0 auto; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.approved { background: var(--brand-soft); color: var(--brand); }
.badge.rejected { background: var(--danger-soft); color: var(--danger); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; cursor: zoom-in; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tab { flex: 1; text-align: center; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); border: 0; background: none; font-family: inherit; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; max-width: calc(100% - 32px); opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; z-index: 90; padding: 16px; cursor: zoom-out; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.center-screen { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

@media (max-width: 380px) {
  .stat .v { font-size: 18px; }
  .grid2 { grid-template-columns: 1fr; }
}
