/* Admin กลาง · colours follow each app: Queuewash blue, SPOON brown, central navy, server grey */
:root {
  --c: #14213D; --dark: #101828; --bg: #EEF2F7; --line: #CBD3DE;
  --qw: #1A56DB; --qw-bg: #EAF2FD; --qw-line: #B9CEF5;
  --sp: #8A5A3B; --sp-bg: #F6EEE7; --sp-line: #E2CDBC;
  --ink: #14213D; --muted: #667085; --soft: #475467; --page: #F4F6FA; --card: #fff; --border: #E3E8EF;
  --ok: #067647; --ok-bg: #ECFDF3; --warn: #7A4100; --warn-bg: #FFF4E0; --bad: #B42318; --bad-bg: #FEE4E2;
  font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--page);
  -webkit-text-size-adjust: 100%;
}
body[data-theme="qw"] { --c: var(--qw); --dark: #163E9E; --bg: var(--qw-bg); --line: var(--qw-line); }
body[data-theme="sp"] { --c: var(--sp); --dark: #5E3B25; --bg: var(--sp-bg); --line: var(--sp-line); }
body[data-theme="srv"] { --c: #475467; --dark: #344054; --bg: #F2F4F7; --line: #D0D5DD; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--page); font-size: 15px; line-height: 1.5; }
a { color: #1546B8; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(26, 86, 219, .4); outline-offset: 2px; }
.sr { position: absolute; left: -9999px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* layout */
#app { min-height: 100vh; display: flex; }
.side { display: none; }
.wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
header.top { background: var(--dark); color: #fff; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; z-index: 5; transition: background .2s; }
header.top h1 { margin: 0; font-size: 19px; line-height: 1.3; }
header.top .sub { font-size: 12px; opacity: .8; }
.back { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 24px; flex: none; }
.systabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: rgba(0,0,0,.2); padding: 4px; border-radius: 12px; }
.systabs button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: rgba(255,255,255,.85); font-size: 14px; }
.systabs button[aria-selected="true"] { background: #fff; font-weight: 700; color: var(--ink); }
.systabs button[data-v="qw"][aria-selected="true"] { color: var(--qw); }
.systabs button[data-v="sp"][aria-selected="true"] { color: var(--sp); }
main { flex: 1; padding: 14px 16px 110px; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 1100px; margin: 0 auto; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: 72px; background: #fff; border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); z-index: 6; padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12.5px; color: var(--muted); border-top: 3px solid transparent; position: relative; }
nav.tabs button[aria-current="page"] { color: var(--c); font-weight: 700; border-top-color: var(--c); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #F04438; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
nav.tabs .badge { position: absolute; top: 6px; left: calc(50% + 6px); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 8px; }
.tag.qw { color: var(--qw); background: var(--qw-bg); } .tag.sp { color: var(--sp); background: var(--sp-bg); } .tag.core { color: var(--soft); background: #EEF2F7; }
.chip { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 8px; white-space: nowrap; }
.chip.on { color: var(--ok); background: var(--ok-bg); } .chip.off { color: var(--bad); background: var(--bad-bg); } .chip.wait { color: var(--warn); background: var(--warn-bg); }

@media (min-width: 960px) {
  .side { display: flex; flex-direction: column; gap: 4px; width: 240px; flex: none; background: #101828; color: #E4E9F1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
  .side .brand b { font-size: 16px; }
  .side button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; color: #E4E9F1; text-align: left; font-size: 15px; }
  .side button:hover { background: rgba(255,255,255,.08); }
  .side button[aria-current="page"] { background: #fff; color: #101828; font-weight: 700; box-shadow: inset 4px 0 0 var(--c); }
  .side .me { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 12px 8px 0; font-size: 13px; }
  nav.tabs { display: none; }
  main { padding: 20px 28px 40px; }
  header.top { padding: 14px 28px; }
  .fab { bottom: 28px !important; }
  .savebar { bottom: 0 !important; left: 240px !important; }
  .sheet-wrap { align-items: center !important; }
  .sheet { border-radius: 20px !important; max-width: 520px; }
}

/* cards & rows */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; }
.pad { padding: 14px; }
.stripe { border-left: 5px solid var(--border); }
.stripe.qw { border-left-color: var(--qw); } .stripe.sp { border-left-color: var(--sp); } .stripe.core { border-left-color: #98A2B3; }
.item { width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 64px; background: #fff; border: 1px solid var(--border); border-radius: 16px; }
.item .chev { font-size: 22px; color: #98A2B3; }
.num { flex: none; min-width: 38px; height: 38px; border-radius: 11px; font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.num.qw { color: var(--qw); background: var(--qw-bg); } .num.sp { color: var(--sp); background: var(--sp-bg); }
.av { flex: none; width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; color: #fff; }
.av.qw { background: var(--qw); } .av.sp { background: var(--sp); }
.ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.ic.qw { color: var(--qw); background: var(--qw-bg); } .ic.sp { color: var(--sp); background: var(--sp-bg); } .ic.core { color: #14213D; background: #EEF2F7; } .ic.srv { color: #475467; background: #F2F4F7; }
.kpi { border-radius: 16px; padding: 10px 12px; border: 1px solid var(--border); }
.kpi.qw { background: var(--qw-bg); border-color: var(--qw-line); } .kpi.sp { background: var(--sp-bg); border-color: var(--sp-line); }
.kpi b { font-size: 26px; display: block; line-height: 1.3; } .kpi.qw b { color: var(--qw); } .kpi.sp b { color: var(--sp); }
.quick { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 2px; border-radius: 14px; border: 1px solid var(--border); background: #fff; font-size: 12.5px; text-align: center; line-height: 1.25; }
.quick .ic { color: var(--c); background: var(--bg); }
.hero { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 18px; }
.hero.qw { background: var(--qw-bg); border: 1px solid var(--qw-line); } .hero.sp { background: var(--sp-bg); border: 1px solid var(--sp-line); }
.hero.core { background: #EEF2F7; border: 1px solid #CBD3DE; } .hero.srv { background: #F2F4F7; border: 1px solid #D0D5DD; }
.stat { background: #fff; border-radius: 10px; padding: 8px; } .stat div { font-size: 11.5px; color: var(--muted); }
.list { background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.list.qw { border-top: 4px solid var(--qw); } .list.sp { border-top: 4px solid var(--sp); } .list.core { border-top: 4px solid #14213D; } .list.srv { border-top: 4px solid #475467; }
.list > .li { width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border: 0; border-bottom: 1px solid #EEF2F7; background: #fff; }
.list > .li:last-child { border-bottom: 0; }
.gh { display: flex; align-items: center; gap: 8px; padding: 0 2px; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; }
.bar { height: 8px; background: #EEF2F7; border-radius: 4px; overflow: hidden; } .bar > i { display: block; height: 100%; background: #475467; }

/* controls */
.btn { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid #CBD3DE; background: #fff; font-size: 14px; font-weight: 600; }
.btn.pri { background: var(--c); border-color: var(--c); color: #fff; }
.btn.okc { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #F3C9C9; }
.btn.dangerf { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.tint { color: var(--c); border-color: var(--line); }
.btn.line { background: #06C755; border-color: #06C755; color: #fff; }
.btn.block { width: 100%; } .btn.lg { min-height: 52px; font-size: 16px; border-radius: 14px; }
.btn:disabled { background: #98A2B3 !important; border-color: #98A2B3 !important; color: #fff !important; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .lbl { font-size: 13.5px; font-weight: 600; color: #344054; }
.input { min-height: 48px; border: 1.5px solid #CBD3DE; border-radius: 12px; padding: 0 12px; font-size: 16px; background: #fff; width: 100%; }
textarea.input { padding: 10px 12px; min-height: 120px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips button { min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid #CBD3DE; background: #fff; font-size: 13.5px; white-space: nowrap; }
.chips button[aria-pressed="true"], .chips button[aria-checked="true"] { background: var(--c); border-color: var(--c); color: #fff; font-weight: 600; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 52px; border: 0; background: transparent; padding: 0; text-align: left; width: 100%; }
.switch .sw { flex: none; position: relative; width: 52px; height: 32px; border-radius: 16px; background: #CBD3DE; transition: background .15s; }
.switch .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.switch[aria-checked="true"] .sw { background: var(--c); } .switch[aria-checked="true"] .sw::after { left: 23px; }
.note { font-size: 13px; color: var(--soft); background: #F7F9FC; border-radius: 10px; padding: 10px 12px; line-height: 1.55; }
.warnbox { background: #FFF8EB; border: 1px solid #F3D49B; border-radius: 14px; padding: 12px 14px; font-size: 13.5px; color: var(--warn); }
.errbox { background: var(--bad-bg); border: 1px solid #F3C9C9; border-radius: 14px; padding: 12px 14px; font-size: 13.5px; color: var(--bad); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: #F4F6FA; border-radius: 10px; padding: 0 10px; min-height: 44px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; min-width: 0; }
pre.msg { white-space: pre-wrap; font: inherit; font-size: 14px; background: #F7F9FC; border-radius: 12px; padding: 12px; margin: 0; max-height: 40vh; overflow: auto; }
.fab { position: fixed; right: 16px; bottom: 88px; min-height: 52px; padding: 0 18px; border-radius: 26px; border: 0; background: var(--c); color: #fff; font-size: 15px; font-weight: 600; box-shadow: 0 8px 20px rgba(16,24,40,.3); z-index: 4; }
.savebar { position: fixed; left: 0; right: 0; bottom: 72px; background: #fff; border-top: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 8px; align-items: center; z-index: 5; box-shadow: 0 -6px 16px rgba(16,24,40,.06); }
.sheet-wrap { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; flex-direction: column; justify-content: flex-end; z-index: 20; }
.sheet-wrap > .shade { flex: 1; }
.sheet { background: #fff; border-radius: 22px 22px 0 0; padding: 18px 16px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 92vh; overflow-y: auto; width: 100%; margin: 0 auto; }
.sheet h2 { margin: 0; font-size: 18px; }
#toast { position: fixed; left: 16px; right: 16px; top: 16px; max-width: 480px; margin: 0 auto; background: #101828; color: #fff; border-radius: 14px; padding: 12px 14px; font-size: 14px; text-align: center; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
#toast[hidden] { display: none; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: 14px; }
.spin { text-align: center; color: var(--muted); padding: 30px 0; }
.login { min-height: 100vh; width: 100%; background: #101828; color: #fff; display: flex; flex-direction: column; align-items: center; padding: 40px 20px; gap: 22px; }
.login .box { background: #fff; color: var(--ink); border-radius: 20px; padding: 22px 18px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: #fff; color: #101828; display: flex; align-items: center; justify-content: center; }
.slipimg { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: #F4F6FA; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { padding: 8px; border-top: 1px solid #EEF2F7; text-align: left; }
/* stripes win over .item / .card borders */
.item.stripe, .card.stripe { border-left-width: 5px; border-left-style: solid; }
.item.stripe.qw, .card.stripe.qw { border-left-color: var(--qw); }
.item.stripe.sp, .card.stripe.sp { border-left-color: var(--sp); }
.item.stripe.core, .card.stripe.core { border-left-color: #98A2B3; }
@media (min-width: 960px) { .systabs { max-width: 460px; } }
