:root {
  --ground: #F4F6F4; --surface: #FFFFFF; --ink: #17231F; --muted: #55635D; --line: #DCE3DF;
  --accent: #1F6B57; --tint: #E2EFE9; --seg: #C9D3CE;
  --taken: #EEF1EF; --taken-ink: #7A8781;
  --amber-bg: #FCEFD9; --amber: #B7791F; --amber-ink: #5E3405; --amber-num: #8A4B07;
  --err-bg: #FDECEA; --err: #B3402F; --err-ink: #6B1D12;
  --side: #17231F; --side-hi: #2A3833;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--ground); color: var(--ink);
  font: 400 16px/1.5 Anuphan, system-ui, 'Noto Sans Thai', sans-serif;
}
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-weight: 500; }
.muted { color: var(--muted); }

/* top bar */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
}
.brand { display: flex; flex-direction: column; margin-right: auto; line-height: 1.35; }
.brand .name { font-size: 17px; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.brand .sub { font-size: 13px; color: var(--muted); }
.badge {
  font-size: 12px; font-weight: 500; padding: 1px 10px; border-radius: 999px; line-height: 1.5;
  background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber);
}
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 14px; background: var(--ground); order: 3; flex: 1 1 240px; }
.seg a {
  flex: 1; min-height: 44px; padding: 0 16px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 15px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.seg a[aria-current="page"] { background: var(--accent); color: #fff; }
.reset {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
@media (min-width: 700px) {
  .seg { order: 0; flex: 0 0 auto; }
  .seg a { min-width: 120px; }
}

#app { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- customer ---------- */
.phone { width: 100%; max-width: 420px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
@media (min-width: 600px) {
  .phone { margin: 20px auto; border: 1px solid var(--line); border-radius: 22px; background: var(--ground); box-shadow: 0 8px 30px rgba(23, 35, 31, .07); }
  .phone .bar { border-radius: 0 0 21px 21px; }
}
.phone-main { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.head h1 { font-size: 22px; font-weight: 700; line-height: 1.4; margin-right: auto; }
.head .mono { font-size: 12px; color: var(--muted); }
.back { width: 44px; height: 44px; margin-left: -8px; border: 0; border-radius: 12px; background: transparent; display: flex; align-items: center; justify-content: center; }
.back:hover { background: var(--taken); }
.card { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 2px; }
.t16 { font-size: 16px; font-weight: 600; }
.t13 { font-size: 13px; color: var(--muted); }
.link { border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; min-height: 44px; padding: 0 4px; }
.lbl { font-size: 14px; font-weight: 600; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 22px; font-size: 15px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--surface);
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--tint); color: var(--accent); }
.days { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.day {
  min-height: 56px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.35;
}
.day span:first-child { font-size: 12px; }
.day span:last-child { font-size: 18px; font-weight: 700; }
.day[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot {
  min-height: 56px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.35;
}
.slot .tm { font-family: var(--mono); font-weight: 500; font-size: 15px; }
.slot .sb { font-size: 11px; }
.slot[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
.slot:disabled { background: var(--taken); border-color: var(--taken); color: var(--taken-ink); }
.slot:disabled .tm { text-decoration: line-through; }
.pkg { border: 1.5px solid var(--accent); display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.pkg.off { border-color: var(--line); }
.pkg .num { font-family: var(--mono); font-weight: 500; font-size: 20px; color: var(--accent); }
.bar10 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.bar10 i { height: 8px; border-radius: 4px; background: var(--tint); }
.bar10 i.used { background: var(--seg); }
.bar10 i.now { background: var(--accent); }
.sw { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; text-align: left; font-size: 15px; font-weight: 600; }
.sw .knob { width: 44px; height: 26px; border-radius: 13px; background: var(--seg); position: relative; flex: none; transition: background .15s; }
.sw .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw[aria-checked="true"] .knob { background: var(--accent); }
.sw[aria-checked="true"] .knob::after { transform: translateX(18px); }
.sw:disabled { opacity: .5; }
.note { font-size: 13px; line-height: 1.55; color: var(--muted); }
.bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.err { background: var(--err-bg); border: 1px solid var(--err); color: var(--err-ink); border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 500; }
.cta {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: 6px 12px; border-radius: 14px; border: 0;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600; text-decoration: none; line-height: 1.35;
}
.cta:disabled { background: var(--taken); color: var(--taken-ink); }
.cta.ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); font-size: 15px; }
.svc-btn {
  width: 100%; min-height: 72px; padding: 12px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; line-height: 1.4;
}
.svc-btn:hover { border-color: var(--accent); }
.price { font-family: var(--mono); font-weight: 500; font-size: 17px; color: var(--accent); flex: none; }
.tag { display: inline-block; margin-top: 2px; font-size: 12px; color: var(--accent); background: var(--tint); border-radius: 999px; padding: 0 8px; width: fit-content; }

/* done */
.done-main { padding: 28px 16px 20px; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.ok { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 8px; }
.ok .circle { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.ok h1 { font-size: 24px; font-weight: 700; line-height: 1.4; }
.sum { background: var(--surface); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.sum .k { font-size: 14px; color: var(--muted); flex: none; }
.sum .v { font-size: 15px; font-weight: 600; text-align: right; }
.hr { height: 1px; background: var(--line); }
.pill { font-size: 14px; font-weight: 600; color: var(--accent); background: var(--tint); padding: 4px 10px; border-radius: 999px; line-height: 1.4; }
.chat { background: #E6EBE8; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat .av { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.bubble { background: var(--surface); border-radius: 4px 14px 14px 14px; padding: 10px 12px; font-size: 14px; line-height: 1.55; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.done-actions { margin-top: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 8px; }

/* ---------- admin ---------- */
.admin-scroll { flex: 1; display: flex; overflow-x: auto; }
.admin { flex: 1; min-width: 1100px; display: flex; }
.side { width: 216px; flex: none; background: var(--side); color: #E6EBE8; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.side .shop { padding: 0 10px 18px; display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.side .shop b { font-size: 18px; color: #fff; }
.side .shop span { font-size: 12px; color: #A9B6B0; }
.nav { min-height: 44px; text-align: left; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: #C9D3CE; font-size: 15px; }
.nav.on { background: var(--side-hi); color: #fff; font-weight: 600; }
.side :focus-visible { outline-color: #fff; }
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--side-hi); display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.me span:first-child { font-size: 14px; color: #fff; }
.me span:last-child { font-size: 12px; color: #A9B6B0; }
.amain { flex: 1; min-width: 0; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.ahead { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.ahead h1 { font-size: 24px; font-weight: 700; line-height: 1.4; }
.nav-btns { display: flex; gap: 8px; flex: none; }
.ibtn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center; }
.ibtn:disabled { opacity: .4; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; line-height: 1.4; }
.tile span:first-child { font-size: 12px; color: var(--muted); }
.tile span:last-child { font-size: 22px; font-weight: 700; }
.grid-card { background: var(--surface); border-radius: 14px; padding: 12px 12px 12px 0; display: flex; flex-direction: column; gap: 10px; }
.grid { display: flex; }
.hours { width: 52px; flex: none; padding-top: 36px; }
.hours div { height: 56px; font-family: var(--mono); font-weight: 500; font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; line-height: 1.2; }
.cols { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.chead { height: 28px; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.chead .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chead small { font-size: 12px; font-weight: 400; color: var(--muted); }
.line { position: relative; height: 560px; border-radius: 10px; background: #F7F9F8 repeating-linear-gradient(to bottom, transparent 0, transparent 55px, #E6EBE8 55px, #E6EBE8 56px); }
.blk {
  position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 4px 8px; margin: 0; border: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 1px; text-align: left; overflow: hidden; line-height: 1.45;
}
.blk .l1 { display: flex; align-items: baseline; gap: 6px; max-width: 100%; white-space: nowrap; overflow: hidden; }
.blk .t { font-family: var(--mono); font-weight: 500; font-size: 11px; flex: none; }
.blk .who { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.blk .l2 { display: block; max-width: 100%; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-done { background: var(--accent); color: #fff; }
.st-booked { background: var(--tint); color: var(--ink); border: 1.5px solid var(--accent) !important; }
.st-pending { background: var(--amber-bg); color: var(--amber-ink); border: 1.5px dashed var(--amber) !important; }
.st-off { background: repeating-linear-gradient(45deg, #EEF1EF 0, #EEF1EF 6px, #E3E8E5 6px, #E3E8E5 12px); color: var(--muted); }
.blk.sel { box-shadow: 0 0 0 3px var(--ink); z-index: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-left: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.panel { width: 300px; flex: none; background: var(--surface); border-left: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.panel .code { font-size: 12px; color: var(--muted); }
.panel h2 { font-size: 20px; font-weight: 700; line-height: 1.4; }
.status { font-size: 12px; font-weight: 600; padding: 0 8px; border-radius: 999px; line-height: 1.6; }
.status.done { background: var(--accent); color: #fff; }
.status.booked { background: var(--tint); color: var(--accent); }
.status.pending { background: var(--amber-bg); color: var(--amber-ink); }
.pcard { background: var(--tint); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pcard .logs { display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.45; }
.log { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; }
.log.new { font-weight: 600; }
.btn { min-height: 48px; padding: 6px 12px; border-radius: 12px; border: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { background: var(--tint); color: var(--accent); }
.btn.ghost { background: var(--surface); border: 1.5px solid var(--line); }
.btn.danger { background: var(--surface); border: 1.5px solid #E7C3BC; color: #8A2D1F; }
.lines { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.lines .row b { color: var(--accent); font-weight: 600; }
.pdpa { margin-top: auto; background: var(--ground); border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px); max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.btn.primary.wait:disabled { background: var(--taken); color: var(--taken-ink); }
