:root {
  --line: #06c755;
  --line-dark: #05a648;
  --line-soft: #e8f9ef;
  --bg: #f5f7f9;
  --card: #ffffff;
  --text: #1a2230;
  --muted: #6b7785;
  --border: #e6eaee;
  --danger: #e5484d;
  --warn: #f5a623;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Sarabun", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; }
code { background: #eef2f6; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* ---------- inputs / buttons ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
input, textarea, select {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--line); box-shadow: 0 0 0 3px var(--line-soft); }
textarea { resize: vertical; }

button { font: inherit; cursor: pointer; border: none; border-radius: 12px; font-weight: 700; }
.btn-primary { background: var(--line); color: #fff; padding: 14px 22px; font-size: 16px; }
.btn-primary:hover { background: var(--line-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-block { width: 100%; display: block; }
.btn-line { background: #fff; color: var(--line-dark); border: 1.5px solid var(--line); padding: 11px 18px; font-size: 15px; }
.btn-line:hover { background: var(--line-soft); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); padding: 8px 14px; font-size: 14px; }
.btn-ghost:hover { background: #fff; color: var(--danger); border-color: #f3c9ca; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--card); width: 100%; max-width: 410px; border-radius: 22px; padding: 30px 26px; box-shadow: 0 10px 40px rgba(16,24,40,.10); }
.brand { text-align: center; margin-bottom: 22px; }
.brand-logo { font-size: 42px; }
.brand h1 { font-size: 26px; margin-top: 4px; color: var(--line-dark); }
.brand p { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.seg-btn { flex: 1; background: transparent; color: var(--muted); padding: 11px; border-radius: 9px; font-size: 15px; }
.seg-btn.active { background: #fff; color: var(--line-dark); box-shadow: var(--shadow); }
.auth-error { color: var(--danger); font-size: 14px; font-weight: 600; text-align: center; min-height: 20px; margin: 12px 0 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.auth-card .btn-primary { margin-top: 6px; }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.shop { display: flex; align-items: center; gap: 9px; min-width: 0; }
.shop-dot { font-size: 22px; }
.shop-name { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { position: sticky; top: 57px; z-index: 19; background: #fff; border-bottom: 1px solid var(--border); }
.nav-in { max-width: 760px; margin: 0 auto; padding: 8px 10px; display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.nav-in::-webkit-scrollbar { display: none; }
.tab { background: transparent; color: var(--muted); padding: 9px 14px; border-radius: 999px; font-size: 14.5px; white-space: nowrap; }
.tab.active { background: var(--line); color: #fff; }

.main { max-width: 760px; margin: 0 auto; padding: 18px 16px 120px; }
.pane-title { font-size: 20px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin: 2px 0 12px; }
.sub-block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.sub-block > b { display: block; margin-bottom: 10px; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .num { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.flag { background: #fffaf0; border-color: #f6d99b; }
.stat.flag .num { color: var(--warn); }
.webhook-card h3 { margin-bottom: 4px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { margin-top: 0; font-size: 13px; }
.copy-row .btn-primary { padding: 13px 18px; white-space: nowrap; }
.steps { margin: 0; padding-left: 20px; color: var(--text); font-size: 14px; }
.steps li { margin-bottom: 8px; }

/* ---------- check + shifts ---------- */
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 8px; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--line); }
.check span { font-weight: 600; }
.shift-head { font-weight: 700; margin: 14px 0 10px; }
.shift-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.shift-row .shift-name { flex: 1 1 130px; margin-top: 0; }
.shift-row input[type="time"] { width: auto; margin-top: 0; flex: 0 0 auto; }
.shift-row .dash { color: var(--muted); }
.shift-del { background: #fff; color: var(--danger); border: 1.5px solid #f3c9ca; width: 38px; height: 42px; border-radius: 10px; font-size: 16px; flex: none; }

/* ---------- test result ---------- */
.testrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.testresult { font-size: 13.5px; font-weight: 600; }
.testresult.ok { color: var(--line); }
.testresult.fail { color: var(--danger); }

/* ---------- customers ---------- */
.clist { margin-top: 14px; }
.ccard { border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; margin-bottom: 11px; background: #fff; box-shadow: var(--shadow); }
.ccard.flag { border-color: var(--warn); background: #fffaf0; }
.chead { font-size: 15.5px; }
.cmeta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.cinfo { font-size: 13px; margin-top: 8px; background: var(--bg); padding: 9px 11px; border-radius: 10px; }
.ctag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: #eef2f6; color: var(--muted); margin-left: 6px; }
.ctag.pending { background: #fef3c7; color: #b45309; }
.ctag.confirmed { background: #fde2e2; color: #b91c1c; }
.ctag.shift { background: var(--line-soft); color: var(--line-dark); }
.ctotal { font-size: 16px; font-weight: 800; margin-top: 6px; }
.cbills { font-size: 13px; margin-top: 8px; background: var(--line-soft); padding: 9px 11px; border-radius: 10px; line-height: 1.7; }
.pkrow { display: flex; gap: 8px; margin-top: 8px; }
.pkrow select { margin-top: 0; flex: 1; padding: 9px 10px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 8px; }
.pimg { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; cursor: zoom-in; transition: transform .12s; }
.pimg:hover { transform: scale(1.04); border-color: var(--line); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 10px 50px rgba(0,0,0,.5); cursor: default; }
.lightbox-close { position: absolute; top: 14px; right: 20px; color: #fff; font-size: 30px; font-weight: 700; cursor: pointer; line-height: 1; }
.btn-reset { background: #fff; color: var(--danger); border: 1.5px solid #f3c9ca; padding: 10px 16px; font-size: 14px; font-weight: 700; border-radius: 10px; }
.btn-reset:hover { background: #fef2f2; }
.ccard .testrow { margin-top: 12px; }

/* ---------- save bar ---------- */
.savebar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--border); padding: 12px 16px; z-index: 30; }
.savebar > .btn-primary { max-width: 760px; margin: 0 auto; }
#status { display: block; text-align: center; font-size: 14px; font-weight: 600; margin-top: 8px; min-height: 18px; }

@media (min-width: 620px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
