/* =====================================================================
   MASARU Admin — design tokens + components
   โทนเย็น (slate) + น้ำเงินกรมท่า-ครามของแบรนด์ + แดง MASARU เป็นสีเน้น
   ===================================================================== */
:root {
  --bg: #F4F6FB;
  --panel: #FFFFFF;
  --panel-2: #F8FAFC;
  --line: #E4E8F0;
  --line-2: #EEF1F6;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --pine: #2F3F94;            /* สีหลัก (น้ำเงินคราม) */
  --pine-2: #4256C7;
  --pine-dark: #0D1330;       /* แถบเมนู / บอร์ด */
  --pine-soft: #EEF1FD;
  --amber: #D63A4A;           /* แดง MASARU */
  --amber-soft: #FDECEE;
  --ok: #16A34A;
  --ok-soft: #DCFCE7;
  --ok-ink: #166534;
  --warn: #F59E0B;
  --warn-soft: #FEF3C7;
  --warn-ink: #92400E;
  --bad: #DC2626;
  --bad-soft: #FEE2E2;
  --bad-ink: #991B1B;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px -8px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px -18px rgba(15, 23, 42, .35);
  --r: 14px;
  --side: 240px;
  color-scheme: light;
  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); }
body {
  -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.6;
  background: radial-gradient(1200px 500px at 85% -10%, #E7ECFF 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
}
a { color: var(--pine); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.2px; }
::selection { background: #C7D2FE; }

/* ---------- scrollbar: บาง โค้งมน ไม่มีปุ่มลูกศร ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #94A3B8; }
.side ::-webkit-scrollbar-thumb, .board-wrap ::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,.16); }
.side ::-webkit-scrollbar-thumb:hover, .board-wrap ::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,.32); }
@supports (-moz-appearance: none) {
  * { scrollbar-width: thin; scrollbar-color: #CBD5E1 transparent; }
  .side *, .board-wrap * { scrollbar-color: rgba(255,255,255,.2) transparent; }
}

/* ---------- login ---------- */
#login { min-height: 100vh; display: flex; background: var(--bg); }
.login-hero {
  flex: 1 1 50%; position: relative; overflow: hidden; color: #fff; padding: 56px 48px;
  background: radial-gradient(700px 400px at 100% 0%, rgba(214,58,74,.35), transparent 60%),
              radial-gradient(600px 500px at 0% 100%, rgba(66,86,199,.55), transparent 60%),
              linear-gradient(160deg, #0B1028 0%, #18225A 100%);
  display: flex; flex-direction: column; justify-content: center;
}
.login-hero::before {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.login-hero h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 700; margin: 22px 0 14px; position: relative; line-height: 1.2; }
.login-hero h1 em { font-style: normal; background: linear-gradient(90deg, #FF8A95, #FFD1D6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero p { color: rgba(255,255,255,.72); max-width: 420px; font-size: 15px; position: relative; }
.login-hero .chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; position: relative; }
.login-hero .chips span { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 99px; padding: 7px 16px; font-size: 13px; font-weight: 500; backdrop-filter: blur(6px); }
.login-side { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: var(--shadow-lg); }
.login-card img { height: 38px; margin-bottom: 22px; }
.login-card h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.login-err { color: var(--bad); min-height: 20px; margin-top: 10px; font-size: 13px; }
@media (max-width: 820px) { #login { flex-direction: column; } .login-hero { padding: 36px 24px; min-height: 260px; } }

/* ---------- layout ---------- */
#app { display: none; min-height: 100vh; }
#app.on { display: flex; }
.side {
  width: var(--side); flex: 0 0 var(--side); color: #fff;
  background: linear-gradient(180deg, #0D1330 0%, #121A42 100%);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 12px 16px;
  border-right: 1px solid rgba(255,255,255,.04);
}
.side .brand { padding: 2px 10px 20px; }
.side .brand img { height: 30px; display: block; }
.side .brand small { display: block; color: rgba(255,255,255,.45); font-size: 11.5px; margin-top: 8px; letter-spacing: .4px; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: rgba(255,255,255,.68); text-decoration: none; font-weight: 500; font-size: 14px; transition: background .15s, color .15s;
}
.nav a .ic { width: 22px; text-align: center; font-size: 15px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(255,255,255,.10); color: #fff; font-weight: 600; }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--amber); }
.nav .sep { height: 1px; background: rgba(255,255,255,.07); margin: 10px 8px; }
.side .me { margin-top: 10px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.05); font-size: 12px; color: rgba(255,255,255,.6); }
.side .me b { color: #fff; display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.side .me button { margin-top: 10px; width: 100%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; }
.side .me button:hover { background: rgba(255,255,255,.12); }

.side { transition: width .2s ease, flex-basis .2s ease, padding .2s ease; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side .brand .logo-mini {
  display: none; width: 38px; height: 38px; border-radius: 11px; place-items: center;
  font-weight: 800; font-size: 19px; font-style: italic; color: #fff; letter-spacing: -1px;
  background: linear-gradient(135deg, #D63A4A 0%, #8E2430 100%); box-shadow: 0 6px 16px -6px rgba(214,58,74,.7);
}
.side-toggle {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.8); cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center;
}
.side-toggle:hover { background: rgba(255,255,255,.14); color: #fff; }
.me-avatar { display: none; }
#logoutBtn .ico { display: none; }

/* เมนูหุบ (จอคอม) — เหลือแค่ไอคอน */
@media (min-width: 961px) {
  body.side-mini { --side: 76px; }
  .side-mini .side { padding: 16px 10px; }
  .side-mini .brand { padding: 2px 0 14px; }
  .side-mini .brand-row { flex-direction: column; gap: 10px; }
  .side-mini .brand small, .side-mini .side .brand .logo-full, .side-mini .nav a .lbl, .side-mini .me-txt, .side-mini #logoutBtn .lbl { display: none; }
  .side-mini .side .brand .logo-mini { display: grid; }
  .side-mini .nav a { justify-content: center; padding: 10px 0; }
  .side-mini .nav a .ic { width: auto; font-size: 18px; }
  .side-mini .nav a .pill { position: absolute; top: 3px; right: 6px; padding: 0 5px; font-size: 10px; margin: 0 !important; }
  .side-mini .nav a.on::before { left: -10px; }
  .side-mini .nav .sep { margin: 8px 6px; }
  .side-mini .side .me { padding: 10px 0 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
  .side-mini .me-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 700; color: #fff; background: linear-gradient(135deg, #D63A4A, #4256C7); cursor: default; }
  .side-mini .side .me #logoutBtn { width: 36px; height: 36px; padding: 0; margin: 0; border-radius: 10px; }
  .side-mini #logoutBtn .ico { display: inline; font-size: 15px; }
}
@media (max-width: 960px) { .side-toggle { display: none; } }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 30; background: rgba(13,19,48,.92); backdrop-filter: blur(10px); color: #fff;
  padding: 10px 16px; align-items: center; justify-content: space-between;
}
.topbar img { height: 24px; }
.topbar button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
.view { padding: 28px 32px 56px; max-width: 1380px; width: 100%; margin: 0 auto; }
.view.full { max-width: none; }

@media (max-width: 960px) {
  .side { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(10,14,30,.45); }
  .topbar { display: flex; }
  .view { padding: 16px 16px 40px; }
}

/* ---------- page header ---------- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.ph h1 { font-size: 26px; font-weight: 700; }
.ph p { margin: 4px 0 0; color: var(--muted); }
.ph .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- primitives ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h3 { font-size: 15.5px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.card h3 .sub { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; padding: 8px 14px; font-weight: 500; cursor: pointer; font-size: 13.5px; white-space: nowrap;
  text-decoration: none; color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: #CBD5E1; background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.pri { background: linear-gradient(180deg, var(--pine-2), var(--pine)); border-color: var(--pine); color: #fff; box-shadow: 0 1px 2px rgba(47,63,148,.3), inset 0 1px 0 rgba(255,255,255,.15); }
.btn.pri:hover { background: linear-gradient(180deg, #3A4DB8, #27357F); }
.btn.red { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.inp, select.inp, textarea.inp {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:hover { border-color: #CBD5E1; }
.inp:focus { border-color: var(--pine-2); box-shadow: 0 0 0 4px rgba(66,86,199,.14); }
.inp.sm { padding: 6px 9px; font-size: 13px; border-radius: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); }
.pill.info { background: var(--pine-soft); color: var(--pine); }
.pill.gray { background: #F1F5F9; color: #475569; }

.seg { display: inline-flex; background: #EEF1F6; border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 500; cursor: pointer; color: var(--muted); font-size: 13px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15,23,42,.10); }

/* ---------- stat tiles ---------- */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.stat label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.hero {
  color: #fff; border: 0; position: relative; overflow: hidden;
  background: radial-gradient(400px 200px at 100% 0%, rgba(214,58,74,.35), transparent 70%), linear-gradient(135deg, #1C2766 0%, #3448B8 100%);
  box-shadow: 0 10px 30px -12px rgba(47,63,148,.55);
}
.stat.hero label, .stat.hero .s { color: rgba(255,255,255,.75); }

.bar { height: 8px; background: #EEF1F6; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--pine), var(--pine-2)); border-radius: 99px; transition: width .4s; }
.bar.ok > i { background: linear-gradient(90deg, #16A34A, #22C55E); }
.bar.warn > i { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.bar.bad > i { background: linear-gradient(90deg, #DC2626, #F87171); }
.stat.hero .bar { background: rgba(255,255,255,.18); }
.stat.hero .bar > i { background: #fff; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
.tbl thead th:first-child { border-top-left-radius: 10px; }
.tbl thead th:last-child { border-top-right-radius: 10px; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:hover td { background: #F8FAFF; }
.tbl .r, .tbl th.r { text-align: right; }
.tbl .c, .tbl th.c { text-align: center; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; background: var(--panel-2); }
.tbl.sticky thead th { position: sticky; top: 0; z-index: 1; }
.tbl td.name { font-weight: 600; white-space: nowrap; }

/* heatmap */
.heat td.h { text-align: center; font-size: 11.5px; padding: 5px 3px; min-width: 34px; border: 2px solid #fff; border-radius: 6px; }
.heat .h0 { background: #F1F5F9; color: #94A3B8; }
.heat .h1 { background: var(--bad-soft); color: var(--bad-ink); }
.heat .h2 { background: var(--warn-soft); color: var(--warn-ink); }
.heat .h3 { background: #BBF7D0; color: var(--ok-ink); }
.heat .h4 { background: var(--ok); color: #fff; font-weight: 600; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ic { font-size: 34px; display: block; margin-bottom: 6px; }
.skel { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, #EEF1F6 25%, #F8FAFC 50%, #EEF1F6 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- modal / toast ---------- */
.ov { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 6vh 16px; overflow-y: auto; }
.ov.show { display: flex; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal.wide { max-width: 880px; }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.modal .mh h3 { font-size: 17px; font-weight: 600; }
.modal .mh button { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; width: 32px; height: 32px; border-radius: 8px; }
.modal .mh button:hover { background: var(--line-2); color: var(--ink); }
.modal .mb { padding: 20px 22px; }
.modal .mf { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; background: var(--panel-2); border-radius: 0 0 18px 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0F172A; color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 200; box-shadow: var(--shadow-lg); display: none; max-width: 92vw; font-weight: 500; }
.toast.show { display: block; animation: up .2s; }
@keyframes up { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- home ---------- */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.hello h1 { font-size: 26px; font-weight: 700; }
.marquee { overflow: hidden; white-space: nowrap; background: linear-gradient(90deg, var(--amber-soft), #FFF5F6); color: #9F1D2B; border: 1px solid #F9D3D8; border-radius: 12px; padding: 9px 0; font-weight: 600; margin-bottom: 16px; }
.marquee span { display: inline-block; padding-left: 100%; animation: mq 22s linear infinite; }
@keyframes mq { to { transform: translateX(-100%); } }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.quick a { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: var(--ink); display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.quick a:hover { border-color: #C7D2FE; transform: translateY(-2px); box-shadow: 0 12px 28px -14px rgba(47,63,148,.35); }
.quick .ic { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #EEF1FD, #E0E7FF); display: grid; place-items: center; font-size: 20px; flex: 0 0 42px; }
.quick b { display: block; font-size: 14px; font-weight: 600; }
.quick small { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { .quick { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.incoming-day { border-left: 3px solid #C7D2FE; padding: 6px 0 6px 14px; margin-bottom: 12px; }
.incoming-day.today { border-color: var(--amber); }
.incoming-day .d { font-weight: 600; font-size: 13.5px; }
.sku { display: inline-block; background: var(--pine-soft); color: var(--pine); border-radius: 7px; padding: 2px 9px; margin: 4px 4px 0 0; font-size: 12.5px; font-weight: 600; }
.sku.new { background: linear-gradient(135deg, #D63A4A, #EF5B6A); color: #fff; }
.notice { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.notice:last-child { border-bottom: 0; }
.notice .e { font-size: 18px; }
.notice b { display: block; font-weight: 600; }

/* ---------- board ---------- */
.board-wrap {
  border-radius: 18px; padding: 20px; color: #fff;
  background: radial-gradient(800px 300px at 100% 0%, rgba(66,86,199,.35), transparent 60%), linear-gradient(180deg, #0B1028, #111A44);
  box-shadow: 0 20px 50px -20px rgba(13,19,48,.6);
}
.board-row {
  display: grid; grid-template-columns: 54px minmax(120px, 1.2fr) minmax(90px, .8fr) minmax(90px, .8fr) minmax(110px, 1fr) minmax(150px, 1.3fr) 96px;
  gap: 12px; align-items: center; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.06); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  transition: transform .5s, background .2s;
}
.board-row:hover { background: rgba(255,255,255,.08); }
.board-row.head { background: none; border: 0; cursor: default; font-size: 12px; color: rgba(255,255,255,.5); font-weight: 600; padding-top: 0; padding-bottom: 4px; }
.board-row .rk { font-size: 22px; font-weight: 700; text-align: center; }
.board-row.r1 { background: linear-gradient(90deg, rgba(250,204,21,.22), rgba(255,255,255,.04)); border-color: rgba(250,204,21,.3); }
.board-row.r2 { background: linear-gradient(90deg, rgba(203,213,225,.2), rgba(255,255,255,.04)); border-color: rgba(203,213,225,.25); }
.board-row.r3 { background: linear-gradient(90deg, rgba(251,146,60,.2), rgba(255,255,255,.04)); border-color: rgba(251,146,60,.25); }
.board-row .nm { font-size: 17px; font-weight: 700; }
.board-row .nm small { display: block; font-size: 11.5px; font-weight: 500; color: rgba(255,255,255,.55); }
.board-row .money { font-size: 16px; font-weight: 600; text-align: right; }
.board-row .money small { display: block; font-size: 11px; color: rgba(255,255,255,.5); font-weight: 500; }
.board-row .total { font-size: 20px; font-weight: 700; text-align: right; color: #FDE68A; }
.board-row .tg .bar { background: rgba(255,255,255,.12); height: 9px; }
.board-row .tg small { display: flex; justify-content: space-between; font-size: 11.5px; color: rgba(255,255,255,.65); margin-top: 4px; }
.board-row .st { text-align: right; }
.board-row .st .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
.board-row .st .btn:hover { background: rgba(255,255,255,.16); }
.board-row .mv { font-size: 12px; margin-left: 4px; }
.board-row .mv.up { color: #86EFAC; }
.board-row .mv.down { color: #FCA5A5; }
.board-stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.board-stats .stat { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); color: #fff; box-shadow: none; }
.board-stats .stat label, .board-stats .stat .s { color: rgba(255,255,255,.6); }
.board-stats .stat.main { background: linear-gradient(135deg, #D63A4A, #9F1D2B); border: 0; box-shadow: 0 10px 30px -12px rgba(214,58,74,.6); }
.board-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.board-dots button { width: 9px; height: 9px; border-radius: 50%; border: 0; background: rgba(255,255,255,.25); cursor: pointer; padding: 0; }
.board-dots button.on { background: #fff; }
.board-banner { position: fixed; top: 18px; right: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.board-banner div { background: #fff; color: var(--ink); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; animation: up .3s; }
.board-banner .upr { border-left: 4px solid var(--ok); }
.board-banner .dnr { border-left: 4px solid var(--amber); }
.board-full .side, .board-full .topbar { display: none !important; }
.board-full .view { max-width: none; padding: 14px; }
@media (max-width: 900px) {
  .board-row { grid-template-columns: 40px 1fr 1fr; }
  .board-row .hide-m { display: none; }
  .board-row.head { display: none; }
  .board-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---------- plus entry ---------- */
.entry { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px; align-items: end; }
.entry .inp { font-size: 17px; padding: 12px 14px; }
@media (max-width: 640px) { .entry { grid-template-columns: 1fr 1fr; } .entry .btn { grid-column: 1 / -1; justify-content: center; } }
.who { display: flex; flex-wrap: wrap; gap: 6px; }
.who button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font-weight: 500; cursor: pointer; transition: all .15s; }
.who button:hover { border-color: #C7D2FE; background: var(--pine-soft); }
.who button.on { background: var(--pine); border-color: var(--pine); color: #fff; font-weight: 600; box-shadow: 0 4px 12px -4px rgba(47,63,148,.5); }

/* ---------- phase chips ---------- */
.phases { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.phase { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; background: #fff; box-shadow: var(--shadow); }
.phase.on { border-color: var(--pc, var(--pine)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc, var(--pine)) 14%, transparent), var(--shadow); }
.phase .t { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.phase .t i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); display: inline-block; }
.phase .v { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.4px; }
.phase small { color: var(--muted); }
@media (max-width: 700px) { .phases { grid-template-columns: 1fr; } }

/* ---------- KPI ---------- */
.kpi-card { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.kpi-card:last-child { border-bottom: 0; }
.kpi-card .no { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #EEF1FD, #E0E7FF); color: var(--pine); display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.kpi-card .tt { font-weight: 600; }
.kpi-card .df { font-size: 12px; color: var(--muted); }
.kpi-card .val { text-align: right; }
.kpi-card .val b { font-size: 19px; font-weight: 700; display: block; }
.steps { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.steps span { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #F1F5F9; color: var(--muted); font-weight: 500; }
.steps span.on { background: var(--pine); color: #fff; }
.score-big { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.score-dot { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 700; color: #fff; }
.s5 { background: var(--ok); } .s4 { background: #4ADE80; } .s3 { background: var(--warn); } .s2 { background: #FB923C; } .s1 { background: var(--bad); } .s0 { background: #CBD5E1; }

/* ---------- settings tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--pine); border-color: var(--pine); font-weight: 600; }

.drop { border: 1.5px dashed #CBD5E1; border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: var(--panel-2); transition: all .15s; }
.drop:hover, .drop.over { border-color: var(--pine-2); color: var(--pine); background: var(--pine-soft); }
.drop b { color: var(--ink); font-weight: 600; }

/* ---------- รายงานการทำงาน ---------- */
.report-tbl td { vertical-align: top; }
.report-tbl tr.missing td { background: #FFFBEB; }
.clamp { white-space: pre-wrap; font-size: 12.5px; line-height: 1.6; max-height: 6em; overflow: hidden; cursor: pointer; position: relative; color: var(--ink-2); }
.clamp:not(.open)::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1.6em; background: linear-gradient(transparent, var(--panel)); }
.clamp.open { max-height: none; }
.clamp:empty { display: none; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
#eDrop .thumb { cursor: pointer; margin: 0 auto; }

/* ---------- help ---------- */
.help-quick { margin-bottom: 16px; }
.help-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.help-steps a { display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; align-items: center; text-decoration: none; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; transition: border-color .15s, background .15s; }
.help-steps a:hover { border-color: #C7D2FE; background: var(--pine-soft); }
.help-steps span { grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--pine), var(--pine-2)); color: #fff; display: grid; place-items: center; font-weight: 700; }
.help-steps small { color: var(--muted); font-size: 12px; }
.help-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-toc { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; box-shadow: var(--shadow); }
.help-toc a { padding: 8px 10px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 13.5px; }
.help-toc a:hover, .help-toc a.on { background: var(--pine-soft); color: var(--pine); }
.help-sec { scroll-margin-top: 16px; }
.help-sec + .help-sec { margin-top: 16px; }
.help-item { border-top: 1px solid var(--line-2); }
.help-item summary { cursor: pointer; padding: 12px 4px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.help-item summary::-webkit-details-marker { display: none; }
.help-item summary::after { content: '▾'; color: var(--muted); transition: transform .15s; }
.help-item[open] summary::after { transform: rotate(180deg); }
.help-item[open] summary { color: var(--pine); }
.help-body { padding: 0 4px 14px; color: var(--ink-2); }
.help-body p { margin: 6px 0; }
.help-body ol, .help-body ul { margin: 6px 0; padding-left: 22px; }
.help-body li { margin: 3px 0; }
.help-body .tbl td { padding: 7px 10px; }
.help-body code { background: #F1F5F9; border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }
.help-body .tip { background: var(--pine-soft); color: #27357F; border-radius: 10px; padding: 9px 12px; font-size: 13px; }
@media (max-width: 900px) {
  .help-grid { grid-template-columns: 1fr; }
  .help-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .help-steps { grid-template-columns: 1fr; }
}

.kb-frame { width: 100%; height: calc(100vh - 56px); border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--shadow); }
@media (max-width: 960px) { .kb-frame { height: calc(100vh - 90px); } }
