:root{font-family:Inter,"Leelawadee UI",Tahoma,system-ui,sans-serif;color:#192740;background:#f1f5f9;font-synthesis:none;--ink:#101e36;--muted:#5a6a7e;--line:#dce5ee;--green:#00684e;--mint:#56e6b1}*{box-sizing:border-box}body{margin:0;min-height:100vh}button,input,select{font:inherit}button{cursor:pointer}button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #12a979;outline-offset:3px}svg{width:20px;height:20px;vertical-align:middle;flex:none}aside{position:fixed;inset:0 auto 0 0;width:246px;background:#101d32;color:#b6c5d8;display:flex;flex-direction:column;padding:28px 16px 16px}.brand{display:flex;align-items:center;gap:11px;color:white;font-weight:800;font-size:22px;margin:0 9px 40px;letter-spacing:-.7px}.brand div span{display:block;color:#89a0b9;font-size:11px;letter-spacing:3px}.logo,.avatar{display:grid;place-items:center;width:42px;height:42px;border-radius:12px;background:var(--mint);color:#0b332c}.logo svg{width:25px;height:25px}nav{display:grid;gap:6px}.navbutton{width:100%;text-align:left;display:flex;align-items:center;gap:12px;border:0;border-radius:8px;color:inherit;background:none;padding:11px 13px;font-size:15px}.navbutton:hover,.navbutton[aria-current=page]{background:#20364a;color:#8ef5cd}.navbutton[aria-current=page]{box-shadow:inset 3px 0 #56e6b1;font-weight:700}.navlabel{font-size:13px;color:#8fa4bc;margin:0 12px 7px}.sidefoot{display:flex;align-items:center;gap:11px;margin-top:auto;padding:16px 6px 4px;border-top:1px solid #314055;color:#eef6ff;font-size:14px}.avatar{background:#263b52;color:#9decd4;font-weight:800;font-size:13px}.sidefoot small{display:block;color:#aab9ce;margin-top:3px}.shell{margin-left:246px}header{display:flex;justify-content:space-between;align-items:center;gap:10px;background:white;border-bottom:1px solid var(--line);min-height:64px;padding:12px 32px;font-size:14px;color:var(--muted)}header>div,.headright{display:flex;align-items:center;gap:12px}#crumb{color:var(--ink)}#crumb:before{content:"/";color:#75859a;margin-right:12px}.demo{background:#e0f8ee;border-radius:20px;padding:5px 12px;color:var(--green);font-weight:700}main{max-width:1570px;margin:auto;padding:28px 32px 40px}.hero{display:flex;justify-content:space-between;align-items:center;gap:20px;position:relative;overflow:hidden;padding:28px 30px;background:linear-gradient(112deg,#12223c,#16394a);color:white;border-radius:17px}.hero p{color:#c5d5e2}.hero>div{z-index:1}.hero h1{font-size:clamp(26px,3vw,39px);letter-spacing:-.7px}.hero-art{width:252px;height:132px;position:absolute;right:36px;bottom:-4px;color:#88f5cf;opacity:.62;pointer-events:none}.hero .button{margin-top:6px}.hero .primary{background:var(--mint);color:#0d3328}.hero .secondary{background:#263c52;color:white;border-color:#547085}h1,h2,p{margin:0}h1{font-size:31px}h2{font-size:20px}p{margin:5px 0 12px;color:var(--muted)}.metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin:20px 0}.metric,.panel,.location{background:white;border:1px solid var(--line);border-radius:13px;box-shadow:0 3px 10px #11284206}.metric{padding:15px 17px}.metric .top{display:flex;align-items:center;justify-content:space-between;gap:6px;color:var(--muted);font-size:14px}.tileicon{display:grid;place-items:center;width:37px;height:37px;border-radius:10px;background:#e1f6ee;color:#087557;flex:none}.metric:nth-child(2) .tileicon{background:#e2edf9;color:#285e9a}.metric:nth-child(3) .tileicon{background:#fff0d8;color:#975700}.metric:nth-child(4) .tileicon{background:#ebe9fb;color:#5948a8}.metric strong{display:block;margin-top:7px;font-size:27px;line-height:1.2}.panel{overflow:hidden;margin-top:18px}.panelhead,.pagehead,.toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}.panelhead,.toolbar{padding:16px 20px}.panelhead p,.pagehead p{margin-bottom:0}.toolbar{border-top:1px solid var(--line);justify-content:flex-start}.tablewrap{overflow:auto}table{width:100%;border-collapse:collapse;text-align:left;white-space:nowrap}thead{background:#edf3f8;color:#506278;font-size:14px}th,td{padding:12px 17px;border-bottom:1px solid #e9eef4}td{font-size:15px}tbody tr:last-child td{border-bottom:0}tbody tr:hover{background:#f7fbfc}.quantity{text-align:right;font-variant-numeric:tabular-nums;font-weight:700}.subtext{display:block;color:var(--muted);font-size:13px;margin-top:3px}.pill{display:inline-block;padding:4px 10px;border-radius:100px;background:#e0f7eb;color:#146044;font-size:13px;font-weight:700}.low{background:#fff1d7;color:#8b4b0b}.out{background:#fde7e8;color:#982e39}.count{background:#e9e8fc;color:#5143a1}.button{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:1px solid transparent;border-radius:8px;font-weight:700;padding:9px 13px;font-size:14px;white-space:nowrap}.primary{background:#00684e;color:white}.secondary{background:white;border-color:#ccd9e5;color:#243850}.button:hover{filter:brightness(.94)}.actions{display:flex;flex-wrap:wrap;gap:8px}.empty{padding:26px;text-align:center;color:var(--muted)}.input,select{border:1px solid #bdccdb;border-radius:8px;padding:9px 12px;background:#fff;color:var(--ink);min-width:0}.search{width:min(330px,100%)}.locations{display:grid;grid-template-columns:repeat(auto-fit,minmax(217px,1fr));gap:14px;margin-top:18px}.location{padding:17px}.location h2{margin:10px 0 4px}.location p{margin-bottom:14px}.location .subtext{margin-bottom:12px}dialog{border:0;border-radius:14px;padding:22px;max-width:min(520px,calc(100% - 24px));width:100%;color:var(--ink);box-shadow:0 25px 90px #11264044}dialog::backdrop{background:#101d3280}.dialogtop{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.iconbutton{border:0;background:#edf3f8;border-radius:7px;color:var(--ink);width:34px;height:34px;font-size:24px}.field{display:grid;gap:5px;margin-bottom:10px;font-size:14px;font-weight:700}.field>*{font-weight:400}.error{color:#a0202f;font-size:14px}.error:empty{display:none}dialog .actions{justify-content:flex-end;margin-top:15px}#toast{position:fixed;bottom:22px;right:22px;background:#12382e;color:white;padding:12px 18px;border-radius:9px;box-shadow:0 6px 24px #12382e35;z-index:5}#toast:empty{display:none}.link{border:0;background:none;color:#00684e;font-weight:700;padding:5px;text-align:left}
@media(max-width:1050px){aside{width:200px}.shell{margin-left:200px}.brand{font-size:18px}main,header{padding-left:20px;padding-right:20px}.metrics{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:720px){aside{position:static;width:auto;padding:11px}.shell{margin:0}.brand{margin:0 0 10px}.brand div span,.sidefoot{display:none}nav{display:flex;overflow:auto;padding-bottom:3px}.navlabel{display:none}.navbutton{white-space:nowrap;width:auto;padding:7px 9px}.navbutton svg{width:17px;height:17px}header{min-height:48px}#today{display:none}main{padding:14px}.hero{padding:18px}.hero-art{opacity:.18;right:0}.metric{padding:10px}.metrics{gap:8px}.toolbar,.panelhead{padding:12px}.search{width:100%}}

:root {
 --ink:#152743;
 --muted:#596a81;
 --line:#e0e7f1;
 --green:#2156cc;
 --mint:#dce9ff;
 --receive:#2463e7;
 --issue:#17a58a;
 --stock-ok:#17a58a;
 --stock-low:#f4a62c;
 --stock-out:#e76e82;
 background:#f3f6fc;
}
aside {background:#101c33}
.logo {background:#3771f1;color:white}
.navbutton:hover,.navbutton[aria-current=page] {background:#243858;color:#d8e7ff}
.navbutton[aria-current=page] {box-shadow:inset 3px 0 #78a7ff}
.avatar {background:#253a5e;color:#dbe8ff}
.demo {background:#eaf1ff;color:#2357bf}
.hero {min-height:174px;background:radial-gradient(ellipse at 88% 10%,#4a86fa 0,transparent 36%),linear-gradient(112deg,#122849 12%,#1b4085 72%,#2858b7);isolation:isolate}
.hero::after {content:"";position:absolute;z-index:-1;inset:0 0 0 52%;background:repeating-radial-gradient(ellipse at 90% 0%,transparent 0 27px,#a7c8ff28 28px 29px);pointer-events:none}
.hero p {color:#e3edff}
.hero .primary {background:#f0f5ff;color:#163e89}
.hero .secondary {background:#ffffff19;border-color:#a4bce4;color:white}
.primary {background:#245ad2}
.link {color:#234fab}
.metric,.panel,.location {border-radius:16px;box-shadow:0 5px 18px #16345408}
.metric .tileicon {background:#e9f0ff;color:#245ad2}
.pagehead {background:white;border:1px solid var(--line);border-radius:16px;padding:22px 24px}
.dashboard-charts {display:grid;grid-template-columns:minmax(0,1.85fr) minmax(0,1fr);gap:14px;margin-bottom:20px}
.chart-card {margin:0}
.chart-card .panelhead {align-items:flex-start}
.chart-legend {display:flex;flex-wrap:wrap;gap:12px;color:var(--muted);font-size:14px}
.chart-legend span::before,.stock-legend span::before {content:"";display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:7px;background:var(--swatch)}
.receive-key {--swatch:var(--receive)}
.issue-key {--swatch:var(--issue)}
.stock-ok {--swatch:var(--stock-ok)}
.stock-low {--swatch:var(--stock-low)}
.stock-out {--swatch:var(--stock-out)}
.bar-chart {display:grid;grid-template-columns:auto minmax(0,1fr);gap:10px;margin:8px 20px 16px}
.chart-axis {display:flex;flex-direction:column;justify-content:space-between;height:144px;transform:translateY(-9px);font-size:13px;color:var(--muted);text-align:right}
.chart-days {display:grid;grid-template-columns:repeat(7,minmax(0,1fr));background:linear-gradient(var(--line) 1px,transparent 1px) left top / 100% 36px repeat-y;background-clip:content-box}
.chart-day {display:grid;grid-template-rows:144px auto;position:relative;text-align:center;min-width:0;background:linear-gradient(white,white) bottom / 100% 25px no-repeat;border-bottom:1px solid white}
.bar-pair {display:flex;align-items:end;justify-content:center;gap:3px;border-bottom:1px solid var(--line)}
.bar {width:clamp(5px,26%,18px);height:var(--height);border-radius:4px 4px 0 0}
.receive-bar {background:var(--receive)}
.issue-bar {background:var(--issue)}
.day-label {color:var(--muted);font-size:12px;padding-top:7px;white-space:nowrap}
.chart-tip {display:none;position:absolute;z-index:1;bottom:26px;left:50%;transform:translateX(-50%);max-width:200px;width:max-content;background:#152743;color:white;font-size:12px;padding:6px 8px;border-radius:5px}
.chart-day:first-child .chart-tip {left:0;transform:none}
.chart-day:last-child .chart-tip {left:auto;right:0;transform:none}
.chart-day:hover .chart-tip,.chart-day:focus .chart-tip {display:block}
.stock-chart {display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:16px;padding:12px 18px 22px}
.donut {display:grid;place-items:center;width:138px;aspect-ratio:1;border-radius:50%;background:var(--donut-fill);flex:none}
.donut>div {display:grid;place-content:center;text-align:center;background:white;border-radius:50%;width:72%;aspect-ratio:1}
.donut strong {font-size:27px;line-height:1.1}
.donut span {font-size:13px;color:var(--muted)}
.stock-legend {display:grid;gap:10px;list-style:none;margin:0;padding:0;min-width:121px;flex:1;font-size:14px}
.stock-legend li {display:flex;justify-content:space-between;gap:7px}
@media(max-width:1000px) {.dashboard-charts {grid-template-columns:minmax(0,1fr)} .stock-legend {max-width:220px}}
@media(max-width:460px) {.bar-chart {margin-inline:9px;gap:5px} .day-label {font-size:11px} .pagehead {padding:14px}}

fieldset {margin:0 0 14px;padding:12px;border:1px solid var(--line);border-radius:10px}
legend {font-weight:700;padding:0 6px}
.field select {width:100%}
.material-row {display:grid;grid-template-columns:minmax(0,1fr) 125px auto;align-items:end;gap:8px;margin-bottom:10px}
.material-row .field {margin:0}
.trace-materials {margin:0;padding-left:18px;display:grid;gap:5px}
#fifoPreview {margin-bottom:12px}
td .pill+.button,td .subtext+.button {margin-left:6px;padding:3px 7px;font-size:13px}
@media(max-width:490px) {.material-row {grid-template-columns:minmax(0,1fr) auto} .material-row .field:first-child {grid-column:1/-1}}
@media(min-width:721px) {aside nav {overflow:auto;min-height:0}.sidefoot {flex-shrink:0}}

dialog.wide-dialog {max-width:min(1000px,calc(100% - 24px))}
.count-number {width:115px}
.account-actions {display:flex;justify-content:flex-end;margin:16px 0}
#accountReports .tablewrap {max-height:360px}
#accountReports th {position:sticky;top:0;background:#edf3f8;z-index:1}

.opening-errors {margin:8px 20px 20px;padding-left:22px;color:#a12536}
#openingPreview .tablewrap {max-height:420px}
.issue-purpose {min-width:155px;max-width:245px;white-space:normal;overflow-wrap:anywhere}
/* --- เซิร์ฟเวอร์กลาง / สิทธิ์ผู้ใช้ / งานค้าง --- */
.navbadge{margin-left:auto;background:#f59e0b;color:#1f1300;border-radius:20px;padding:1px 8px;font-size:12px;font-weight:800}
.demo.live{background:#fde7e8;color:#982e39}
.sidefoot .logout{margin-left:auto;font-size:18px;background:#263b52;color:#dbe8ff}
.input.locked{background:#eef3f8;color:#334}
/* อ่านอย่างเดียว: ซ่อนปุ่มบันทึกทุกชนิด เหลือเฉพาะการดู ค้นหา และส่งออก (เซิร์ฟเวอร์ตรวจสิทธิ์ซ้ำ) */
body.readonly main [data-action]:not([data-action^="go:"]):not([data-action^="filter:"]):not([data-action^="countExport:"]):not([data-action^="accountExport:"]):not([data-action="export"]):not([data-action="stock"]):not([data-action="movements"]):not([data-action="openingTemplate"]):not([data-action="openingSample"]){display:none}
body.readonly .field:has(#openingFile){display:none}
.loginpage{display:grid;place-items:center;background:linear-gradient(112deg,#12223c,#16394a)}
.loginbox{background:white;border-radius:16px;padding:30px;width:min(400px,calc(100% - 24px));box-shadow:0 25px 90px #0005}
.loginbox .brand{color:#101d32;margin:0 0 18px}.loginbox .button{width:100%;margin-top:6px}
