/* หลังบ้านทักคับ: โทนขาว ส้ม สีอ่อน ตามเว็บหลัก และไม่มีโหมดมืด */
@font-face { font-family: Mitr; src: url(/mitr-regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Mitr; src: url(/mitr-medium.woff2) format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --coral: #ff795e;
  --coral-soft: #fff1eb;
  --peach: #ffd9cd;
  --ink: #42243d;
  --muted: #7a6476;
  --line: #f3e4dc;
  --bg: #fffaf6;
  --card: #ffffff;
  --danger: #c8373f;
  --danger-soft: #fdecec;
  --ok: #1f8a5b;
  --ok-soft: #e8f6ef;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 Mitr, system-ui, sans-serif; }
h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.break { overflow-wrap: anywhere; }

button, input, select { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
button:hover:not(:disabled) { background: var(--coral-soft); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--coral); border-color: var(--coral); color: var(--ink); font-weight: 500; }
button.primary:hover:not(:disabled) { background: #ff8c75; }
button.danger { color: var(--danger); border-color: #f2c9cb; }
button.danger:hover:not(:disabled) { background: var(--danger-soft); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 44px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 12px; }
label input, label select { margin-top: 4px; color: var(--ink); font-size: 15px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(#fff, var(--coral-soft)); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.login-card img.logo { width: 56px; height: 56px; display: block; margin-bottom: 12px; }
.login-card button.primary { width: 100%; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 0 0 12px; text-align: center; }
.qr svg { width: 220px; height: 220px; max-width: 100%; }
code { background: var(--coral-soft); padding: 2px 6px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }

.error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; }

.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 500; }
.brand img { width: 32px; height: 32px; }
.side .group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; }
.side button.nav { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; border: 0; background: none; min-height: 40px; }
.side button.nav.active { background: var(--coral-soft); font-weight: 500; }
.side .bottom { margin-top: auto; padding: 12px 8px 0; }
.badge { background: var(--coral); color: var(--ink); border-radius: 999px; font-size: 12px; padding: 0 8px; min-width: 22px; text-align: center; }
.main { padding: 24px; max-width: 1080px; width: 100%; }
.head { margin-bottom: 18px; }
.topbar { display: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat .value { font-size: 26px; font-weight: 500; line-height: 1.25; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.alert { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--coral-soft); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.meter { height: 8px; border-radius: 99px; background: var(--coral-soft); overflow: hidden; margin: 6px 0 2px; }
.meter > div { height: 100%; background: var(--coral); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.grow > input, .row.grow > select { flex: 1 1 200px; width: auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button.active { background: var(--coral-soft); border-color: var(--coral); font-weight: 500; }

.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.item.click { display: block; width: 100%; text-align: left; }
.item-title { display: flex; justify-content: space-between; gap: 10px; font-weight: 500; align-items: baseline; flex-wrap: wrap; }
.quote { background: var(--bg); border-left: 3px solid var(--peach); padding: 8px 10px; border-radius: 6px; margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tag { display: inline-block; font-size: 12px; border-radius: 99px; padding: 1px 9px; background: var(--coral-soft); font-weight: 400; }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0 0 12px; }
.facts div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.facts b { display: block; font-weight: 500; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 400; font-size: 13px; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }

textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; color: inherit; resize: vertical; }
textarea:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.setting { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.setting:first-child { padding-top: 0; }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-text { min-width: 0; flex: 1 1 auto; }
.setting-label { font-weight: 500; }
.setting-warn { color: var(--danger); font-size: 13px; margin-top: 2px; }
.setting-control { flex: 0 0 auto; max-width: 55%; }
.unit { display: inline-flex; align-items: center; gap: 8px; }
.unit[hidden] { display: none; }
.unit input { width: 110px; }
input.switch { appearance: none; width: 46px; min-height: 0; height: 26px; padding: 0; border: 0; border-radius: 99px; background: #e6d8d0; position: relative; cursor: pointer; flex: none; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
input.switch:checked { background: var(--coral); }
input.switch:checked::after { left: 23px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 14px; }
.check input { width: 18px; min-height: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--coral); }

.chart-wrap { position: relative; overflow: hidden; }
svg.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-text { fill: var(--muted); font-size: 12px; }
.chart-bar { fill: #e4572e; }
.chart-tip { position: absolute; top: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 13px; pointer-events: none; white-space: nowrap; }
.share { margin-bottom: 8px; }
.share-head { justify-content: space-between; flex-wrap: nowrap; }
details summary { cursor: pointer; margin-top: 8px; }

dialog { border: 0; border-radius: 16px; padding: 20px; max-width: min(420px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(66, 36, 61, .35); }
dialog .row { justify-content: flex-end; margin-top: 12px; }

@media (max-width: 760px) {
  .layout { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
  .side { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .side.open { display: flex; }
  .side .brand { display: none; }
  .main { padding: 16px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 22px; }
  .setting { flex-direction: column; gap: 8px; }
  .setting-control { max-width: 100%; width: 100%; }
}
