/* Gin Group: โทนไฟจากโลโก้ แดง-ส้ม-เหลือง บนพื้นครีม ตัวหนังสือดำ */
:root {
  --bg: #fff7e8;
  --panel: #ffffff;
  --panel-2: #fbeed3;
  --line: #f0dfc0;
  --ink: #1d140c;
  --muted: #76675a;
  --red: #c8141c;
  --red-deep: #9e0f16;
  --orange: #e8590c;
  --yellow: #ffc61a;
  --cream: #fdedc4;
  --flame: linear-gradient(90deg, #c8141c 0%, #e8590c 52%, #ffc61a 100%);
  --cash: #e8590c;
  --qr: #1c7ed6;
  --app: #d6336c;
  --good: #1f7a34;
  --good-bg: #e4f5e6;
  --warn: #8a5a00;
  --warn-bg: #fff0c7;
  --bad: #b3121a;
  --bad-bg: #fde5e2;
  color-scheme: light;
  font-family: "Kanit", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-size: 15px; background: var(--bg); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- แถบบน ---------- */
.top { position: sticky; top: 0; z-index: 5; background: #fff; box-shadow: 0 2px 10px rgba(120, 60, 10, .1); }
.top::after { content: ""; display: block; height: 4px; background: var(--flame); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 8px 20px; display: flex; align-items: center; gap: 12px; }
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.brand img { height: 66px; width: auto; display: block; }
.brand small { font-size: 12px; letter-spacing: .14em; color: var(--muted); font-weight: 500; white-space: nowrap; }
.updated { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ghost { padding: 8px 13px; min-height: 38px; border: 1.5px solid var(--red); border-radius: 10px; color: var(--red); font-size: 13.5px; font-weight: 500; background: #fff; white-space: nowrap; }
.ghost:hover { background: var(--bad-bg); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 18px 20px 48px; }
.ranges { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; max-width: 100%; overflow-x: auto; }
.ranges button { padding: 8px 16px; border-radius: 9px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.ranges button.on { background: var(--red); color: #fff; font-weight: 500; }

/* ---------- สาขา ---------- */
.branches { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; margin-bottom: 16px; }
.branch { text-align: left; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); }
.branch:hover { border-color: var(--orange); }
.branch.on { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); background: #fffbf2; }
.branch .head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.branch .name { font-weight: 500; line-height: 1.3; }
.branch .code { font-size: 12px; color: var(--muted); }
.branch .amount { font-size: 26px; font-weight: 600; color: var(--red); margin-top: 8px; }
.branch .meta { font-size: 12.5px; color: var(--muted); }

/* ---------- การ์ด ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-12 { grid-column: span 12; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; min-width: 0; box-shadow: 0 4px 16px rgba(120, 60, 10, .06); }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.panel-title h3 { font-size: 16px; font-weight: 500; }
.panel-title span { font-size: 12.5px; color: var(--muted); text-align: right; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.empty { color: var(--muted); text-align: center; padding: 22px 8px; font-size: 14px; }

/* ---------- ยอดหลัก ---------- */
.hero { border-top: 4px solid var(--red); }
.hero .label { font-size: 14px; color: var(--muted); }
.hero .value { font-size: 54px; line-height: 1.12; font-weight: 600; color: var(--red); letter-spacing: -.01em; margin: 2px 0 14px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.facts b { display: block; font-size: 18px; font-weight: 500; }
.facts span { font-size: 12.5px; color: var(--muted); }
.split { display: flex; gap: 2px; height: 12px; margin-bottom: 10px; }
.split i { display: block; min-width: 4px; }
.split i:first-child { border-radius: 4px 0 0 4px; }
.split i:last-child { border-radius: 0 4px 4px 0; }
.split i:only-child { border-radius: 4px; }
.split.none { background: var(--panel-2); border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend b { font-weight: 500; }

/* ---------- สิ่งที่ควรตรวจสอบ ---------- */
.alert-list { max-height: 300px; overflow-y: auto; padding-right: 6px; }
.alert { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alert:last-child { border-bottom: 0; padding-bottom: 0; }
.alert:first-child { padding-top: 0; }
.alert .ico { flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--warn-bg); color: var(--warn); }
.alert.bad .ico { background: var(--bad-bg); color: var(--bad); }
.alert p { line-height: 1.35; }
.alert small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.all-good { display: flex; align-items: center; gap: 10px; padding: 18px; border-radius: 12px; background: var(--good-bg); color: var(--good); font-weight: 500; }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--red); color: #fff; font-size: 13px; font-weight: 600; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; font-weight: 500; white-space: nowrap; background: #f0ebe2; color: var(--muted); }
.status.on { background: var(--good-bg); color: var(--good); }
.status.bad { background: var(--bad-bg); color: var(--bad); }
.status.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- เงินสด ---------- */
.drawer { padding: 14px 16px; border-radius: 12px; background: var(--cream); border: 1.5px solid var(--yellow); margin-bottom: 14px; }
.drawer .value { font-size: 36px; font-weight: 600; color: var(--red); line-height: 1.2; }
.drawer .hint { color: #65553f; }
.drawer .calc { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin-top: 10px; font-size: 13px; color: #65553f; }
.drawer .calc b { font-weight: 400; color: var(--ink); text-align: right; }

/* ---------- กราฟ ---------- */
.hours { display: flex; align-items: flex-end; gap: 2px; height: 170px; border-bottom: 1px solid var(--line); }
.hours button { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; padding: 0; }
.hours button i { display: block; width: 100%; background: var(--orange); border-radius: 4px 4px 0 0; min-height: 0; }
.hours button:hover i, .hours button:focus-visible i { background: var(--red); }
.hour-axis { display: flex; gap: 2px; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.hour-axis span { flex: 1; min-width: 0; text-align: center; overflow: visible; white-space: nowrap; }
#tip { position: fixed; z-index: 20; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; white-space: nowrap; display: none; }

.rank { margin-bottom: 11px; }
.rank:last-child { margin-bottom: 0; }
.rank .t { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 4px; }
.rank .t b { font-weight: 500; white-space: nowrap; }
.rank .t small { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.meter { height: 7px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--orange); border-radius: 4px; }

/* ---------- ตาราง ---------- */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.r { text-align: right; }
tr.row-bad td { background: var(--bad-bg); }
.foot { margin-top: 16px; }

/* ---------- ล็อกอิน ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(400px, 100%); padding: 24px 26px 28px; background: #fff; border: 1px solid var(--line); border-top: 5px solid var(--red); border-radius: 18px; box-shadow: 0 14px 40px rgba(120, 60, 10, .16); }
.login .mark { display: block; width: 190px; height: auto; margin: 0 auto 8px; }
.login p { margin: 0 0 20px; font-size: 14px; color: var(--muted); text-align: center; }
.login label { display: block; margin-bottom: 5px; font-size: 13.5px; color: var(--muted); }
.login input { width: 100%; padding: 12px 13px; margin-bottom: 14px; font-size: 16px; background: #fffdf8; border: 1px solid #e3cfa8; border-radius: 11px; }
.login button { width: 100%; min-height: 50px; border-radius: 12px; background: var(--red); color: #fff; font-weight: 600; font-size: 16px; }
.login button:hover { background: var(--red-deep); }
.login .err { min-height: 20px; margin-bottom: 8px; font-size: 14px; color: var(--bad); }

@media (max-width: 900px) {
  .span-5, .span-6, .span-7 { grid-column: span 12; }
  .alert-list { max-height: none; }
}
@media (max-width: 560px) {
  .top-in { padding: 6px 14px; gap: 8px; }
  .brand img { height: 48px; }
  .brand small, .updated { display: none; }
  .wrap { padding: 14px 14px 40px; }
  .panel { padding: 15px; }
  .hero .value { font-size: 44px; }
  .hours { height: 130px; }
}

/* ---------- แท็บสต๊อก ---------- */
.stock-tabs { margin-top: 6px; min-width: 0; }
.stock-tabs .ranges { margin-bottom: 0; }
.count-row { border-bottom: 1px solid var(--line); padding: 10px 0; }
.count-row:last-child { border-bottom: 0; }
.count-row summary { cursor: pointer; min-height: 28px; }
.count-row table { margin-top: 8px; }
.sub-title { margin: 16px 0 6px; font-size: 14px; font-weight: 500; }
td { vertical-align: top; }
