/* Layout: NOC console — fixed left rail of modules, scannable status summary first, detail tables below; rail becomes a top strip on phones. */
:root{
  --bg:#eef2f5; --surface:#ffffff; --surface-2:#e5ebf0; --fg:#13202b; --muted:#566676; --line:#d3dce4;
  --accent:#1d5fc4; --accent-soft:#dfe9fa; --jacket:#e8c21c;
  --ok:#15804a; --ok-soft:#dcf2e5; --warn:#a8680c; --warn-soft:#fbeed3; --crit:#c2302f; --crit-soft:#fbe0df; --idle:#7b8794;
  --f-display:"Anuphan","IBM Plex Sans Thai",system-ui,sans-serif;
  --f-body:"IBM Plex Sans Thai",system-ui,"Segoe UI",sans-serif;
  --f-mono:"JetBrains Mono",ui-monospace,Consolas,monospace;
  --r:8px;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0d1319; --surface:#141c24; --surface-2:#1b252f; --fg:#e2e9ef; --muted:#8c9cab; --line:#26323e;
  --accent:#6ea6ff; --accent-soft:#1b2c47; --jacket:#e8c21c;
  --ok:#3fc07c; --ok-soft:#173326; --warn:#e4a940; --warn-soft:#3a2c12; --crit:#f2716d; --crit-soft:#3d1a1a; --idle:#7f8c99;
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0d1319; --surface:#141c24; --surface-2:#1b252f; --fg:#e2e9ef; --muted:#8c9cab; --line:#26323e;
  --accent:#6ea6ff; --accent-soft:#1b2c47; --jacket:#e8c21c;
  --ok:#3fc07c; --ok-soft:#173326; --warn:#e4a940; --warn-soft:#3a2c12; --crit:#f2716d; --crit-soft:#3d1a1a; --idle:#7f8c99;
  color-scheme:dark}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%}
body{background:var(--bg);color:var(--fg);font-family:var(--f-body);font-size:14px;line-height:1.55}
h1,h2,h3{font-family:var(--f-display);margin:0;text-wrap:balance;line-height:1.25}
h1{font-size:22px;font-weight:700}
h2{font-size:16px;font-weight:600}
h3{font-size:14px;font-weight:600}
p{margin:0}
.mono{font-family:var(--f-mono);font-size:12.5px;font-variant-numeric:tabular-nums}
.muted{color:var(--muted)}
button,input,select{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

.app{display:grid;grid-template-columns:236px minmax(0,1fr);min-height:100%}
.rail{background:var(--surface);border-right:1px solid var(--line);padding:18px 12px;display:flex;flex-direction:column;gap:18px;position:sticky;top:0;height:100vh;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
.brand{display:flex;gap:10px;align-items:center;padding:0 6px}
.brand-mark{width:34px;height:34px;border-radius:9px;background:url(logo.svg) center/contain no-repeat;flex:none;box-shadow:0 1px 3px rgba(0,0,0,.25)}
.brand-mark::before{content:none}
.brand b{font-family:var(--f-display);font-size:15px;display:block;line-height:1.2}
.brand small{color:var(--muted);font-size:11.5px}
.nav{display:flex;flex-direction:column;gap:2px}
.nav a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:6px;color:var(--fg);text-decoration:none;white-space:nowrap}
.nav a:hover{background:var(--surface-2)}
.nav a[aria-current="page"]{background:var(--accent-soft);color:var(--accent);font-weight:600}
.nav svg{width:18px;height:18px;flex:none;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.nav .count{margin-left:auto;font-family:var(--f-mono);font-size:11px;background:var(--crit);color:#fff;border-radius:10px;padding:0 7px}
.userbox{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 6px;border-top:1px solid var(--line);margin-top:auto;font-size:13px}
.userbox-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.userbox + .rail-foot{margin-top:0}
.rail-foot{margin-top:auto;font-size:12px;color:var(--muted);padding:0 6px;display:flex;flex-direction:column;gap:6px}
.conn{display:flex;align-items:center;gap:6px}
.dot{width:8px;height:8px;border-radius:50%;background:var(--idle);flex:none}
.dot.ok{background:var(--ok)}.dot.warn{background:var(--warn)}.dot.crit{background:var(--crit)}.dot.idle{background:var(--muted)}

main{padding-block:22px 48px;padding-left:max(24px,env(safe-area-inset-left,0px));padding-right:max(24px,env(safe-area-inset-right,0px));display:flex;flex-direction:column;gap:18px;min-width:0}
.head{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end;justify-content:space-between}
.head p{color:var(--muted)}
.sample{font-size:11.5px;border:1px dashed var(--line);border-radius:20px;padding:2px 10px;color:var(--muted);white-space:nowrap}

.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:16px;display:flex;flex-direction:column;gap:12px;min-width:0}
.panel-head{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}
.grid{display:grid;gap:16px}
.g2{grid-template-columns:minmax(0,1.6fr) minmax(0,1fr)}
.g2e{grid-template-columns:repeat(2,minmax(0,1fr))}

.stats{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:1px;background:var(--line);border:1px solid var(--line);border-radius:var(--r);overflow:hidden}
.stat{background:var(--surface);padding:14px 16px;display:flex;flex-direction:column;gap:2px}
.stat .lbl{font-size:12px;color:var(--muted)}
.stat .val{font-family:var(--f-display);font-size:26px;font-weight:700;font-variant-numeric:tabular-nums;line-height:1.2}
.stat .sub{font-size:12px;color:var(--muted)}
.stat.crit .val{color:var(--crit)}.stat.warn .val{color:var(--warn)}.stat.ok .val{color:var(--ok)}

.pill{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:500;padding:1px 9px;border-radius:20px;white-space:nowrap}
.pill.ok{background:var(--ok-soft);color:var(--ok)}
.pill.warn{background:var(--warn-soft);color:var(--warn)}
.pill.crit{background:var(--crit-soft);color:var(--crit)}
.pill.idle{background:var(--surface-2);color:var(--muted)}
.pill.info{background:var(--accent-soft);color:var(--accent)}

.btn{border:1px solid var(--line);background:var(--surface);border-radius:6px;padding:6px 12px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
.btn:hover{background:var(--surface-2)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
.btn.primary:hover{filter:brightness(1.08)}
.btn.danger{color:var(--crit);border-color:var(--crit)}
.btn.sm{padding:3px 9px;font-size:12.5px}
.btn:disabled{opacity:.5;cursor:not-allowed}
.toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.input{border:1px solid var(--line);background:var(--surface);border-radius:6px;padding:6px 10px;min-width:0}
.input:focus{outline:2px solid var(--accent);outline-offset:-1px}

.tablewrap{overflow-x:auto;margin:0 -16px;padding:0 16px}
table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}
th{font-size:12px;font-weight:500;color:var(--muted);text-align:left;padding:6px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:8px 10px;border-bottom:1px solid var(--line);white-space:nowrap;vertical-align:middle}
tr:last-child td{border-bottom:0}
td.num,th.num{text-align:right}
.rx-ok{color:var(--ok)}.rx-warn{color:var(--warn)}.rx-crit{color:var(--crit)}

/* PON heat grid */
.pon-slot{display:grid;grid-template-columns:72px minmax(0,1fr);gap:10px;align-items:center}
.pon-slot + .pon-slot{margin-top:8px}
.pon-cells{display:grid;grid-template-columns:repeat(16,minmax(0,1fr));gap:4px}
.pon-cell{aspect-ratio:1;max-width:100%;border-radius:4px;border:0;cursor:pointer;font-family:var(--f-mono);font-size:10px;display:grid;place-items:center;color:var(--fg)}
.pon-cell.ok{background:var(--ok-soft)}
.pon-cell.warn{background:var(--warn-soft);color:var(--warn);font-weight:600}
.pon-cell.crit{background:var(--crit);color:#fff;font-weight:600}
.pon-cell.empty{background:transparent;border:1px dashed var(--line);cursor:default;color:var(--muted)}
.pon-cell.sel{outline:2px solid var(--accent);outline-offset:1px}
.legend{display:flex;gap:14px;flex-wrap:wrap;font-size:12px;color:var(--muted)}
.legend span{display:inline-flex;gap:6px;align-items:center}
.sw{width:12px;height:12px;border-radius:3px;display:inline-block}

.feed{display:flex;flex-direction:column}
.feed-item{display:grid;grid-template-columns:4px minmax(0,1fr) auto;gap:10px;padding:10px 0;border-bottom:1px solid var(--line)}
.feed-item:last-child{border-bottom:0}
.feed-item.link{color:inherit;text-decoration:none;cursor:pointer}
.feed-item.link:hover,.feed-item.link:active{background:var(--line)}
.sev{border-radius:2px}
.sev.crit{background:var(--crit)}.sev.warn{background:var(--warn)}.sev.ok{background:var(--ok)}.sev.info{background:var(--accent)}
.feed-item time{font-family:var(--f-mono);font-size:11.5px;color:var(--muted)}
.feed-item p{font-size:13px}
.feed-item .meta{font-size:12px;color:var(--muted)}

.chart svg{width:100%;height:auto;display:block}
.chart text{fill:var(--muted);font-family:var(--f-mono);font-size:10px}

.kv{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 16px;font-size:13px}
.kv dt{color:var(--muted)}.kv dd{margin:0;font-family:var(--f-mono);font-size:12.5px}
.meter{height:6px;border-radius:3px;background:var(--surface-2);overflow:hidden}
.meter i{display:block;height:100%;background:var(--accent);border-radius:3px}

/* Chassis */
.chassis{display:grid;grid-template-columns:repeat(auto-fill,minmax(64px,1fr));gap:6px}
.blade{border:1px solid var(--line);border-radius:5px;padding:8px 6px;display:flex;flex-direction:column;gap:2px;align-items:center;text-align:center;min-height:86px;justify-content:center;background:var(--surface)}
.blade.empty{background:var(--surface-2);border-style:dashed;color:var(--muted)}
.blade b{font-family:var(--f-mono);font-size:12px}
.blade small{font-size:11px;color:var(--muted)}
.blade .dot{margin-top:4px}

/* Map */
.mapwrap{display:grid;grid-template-columns:minmax(0,1fr) 290px;gap:16px}
.map{background:var(--surface-2);border-radius:var(--r);overflow:hidden;position:relative}
.map svg{display:block;width:100%;height:auto}
.map .road{stroke:var(--surface);stroke-width:14;fill:none;stroke-linecap:round}
.map .feeder{stroke:var(--accent);stroke-width:3.5;fill:none}
.map .feeder.cut{stroke:var(--crit);stroke-dasharray:8 6}
.map .drop{stroke:var(--muted);stroke-width:1.2;fill:none;opacity:.7}
.map .house{fill:var(--surface);stroke:var(--ok);stroke-width:2}
.map .house.off{stroke:var(--crit);fill:var(--crit-soft)}
.map .house.low{stroke:var(--warn)}
.map .fdt{cursor:pointer}
.map .fdt rect{fill:var(--surface);stroke:var(--fg);stroke-width:1.5}
.map .fdt.sel rect{stroke:var(--accent);stroke-width:3}
.map .fdt text,.map .olt text{fill:var(--fg);font-family:var(--f-mono);font-size:11px}
.map .olt rect{fill:var(--accent)}
.map .olt text.w{fill:#fff;font-weight:600}
.map .lbl{fill:var(--muted);font-size:10px;font-family:var(--f-body)}
.portlist{display:flex;flex-direction:column;gap:4px}
.port{display:grid;grid-template-columns:22px 70px minmax(0,1fr) auto;gap:8px;align-items:center;font-size:12.5px;padding:4px 0;border-bottom:1px solid var(--line)}
.port:last-child{border-bottom:0}
.fc{width:14px;height:14px;border-radius:50%;border:1px solid var(--line)}

/* Jobs + phone */
.jobs{display:grid;grid-template-columns:minmax(0,1fr) 330px;gap:16px;align-items:start}
.job{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:12px 0;border-bottom:1px solid var(--line);cursor:pointer}
.job:last-child{border-bottom:0}
.job.sel{background:var(--accent-soft);margin:0 -16px;padding:12px 16px}
.job .meta{font-size:12px;color:var(--muted)}
.phone{border:10px solid var(--fg);border-radius:30px;background:var(--bg);overflow:hidden;max-width:330px;width:100%;justify-self:center}
.phone-bar{background:var(--accent);color:#fff;padding:12px 14px;display:flex;flex-direction:column;gap:2px}
.phone-bar small{opacity:.85;font-size:11.5px}
.phone-body{padding:12px;display:flex;flex-direction:column;gap:10px}
.step{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:10px 12px;display:flex;flex-direction:column;gap:8px}
.step-h{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:13px;font-weight:600}
.step-h .n{width:20px;height:20px;border-radius:50%;background:var(--surface-2);display:inline-grid;place-items:center;font-size:11px;font-family:var(--f-mono);margin-right:6px}
.step.done .step-h .n{background:var(--ok);color:#fff}
.sn-opt{display:flex;justify-content:space-between;align-items:center;border:1px solid var(--line);border-radius:6px;padding:6px 8px;cursor:pointer;gap:8px}
.sn-opt.sel{border-color:var(--accent);background:var(--accent-soft)}
.photos{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.photo{aspect-ratio:1;max-width:100%;border:1px dashed var(--line);border-radius:6px;display:grid;place-items:center;font-size:11px;color:var(--muted);text-align:center;cursor:pointer;background-size:cover;background-position:center;position:relative;overflow:hidden}
.photo input{position:absolute;inset:0;opacity:0;cursor:pointer}
.bignum{font-family:var(--f-display);font-size:28px;font-weight:700;font-variant-numeric:tabular-nums}

/* Alerts */
.chan{display:flex;gap:12px;align-items:flex-start}
.chan-ico{width:38px;height:38px;border-radius:8px;display:grid;place-items:center;color:#fff;font-weight:700;font-family:var(--f-display);flex:none}
.chan-ico.line{background:#06a54a}.chan-ico.tg{background:#2a9bd6}
.switch{position:relative;display:inline-flex;align-items:center;gap:8px;cursor:pointer;user-select:none}
.switch input{position:absolute;opacity:0;width:1px;height:1px}
.switch .tr{width:36px;height:20px;border-radius:10px;background:var(--line);position:relative;transition:background .15s;flex:none}
.switch .tr::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .15s;box-shadow:0 1px 2px rgba(0,0,0,.25)}
.switch input:checked + .tr{background:var(--accent)}
.switch input:checked + .tr::after{transform:translateX(16px)}
.switch input:focus-visible + .tr{outline:2px solid var(--accent);outline-offset:2px}
.ev td:first-child{white-space:normal;min-width:200px}
.bubble{background:var(--surface-2);border-radius:12px 12px 12px 2px;padding:10px 12px;font-size:13px;max-width:360px;display:flex;flex-direction:column;gap:2px}
.bubble b{color:var(--crit)}

/* Modal */
.overlay{position:fixed;inset:0;background:rgba(8,14,20,.55);display:grid;place-items:center;padding:16px;z-index:50}
.modal{background:var(--surface);border-radius:10px;width:min(640px,100%);max-height:calc(100% - 32px);overflow:auto;display:flex;flex-direction:column}
.modal-h{padding:16px 18px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:10px}
.modal-b{padding:16px 18px;display:flex;flex-direction:column;gap:14px}
.modal-f{padding:12px 18px;border-top:1px solid var(--line);display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.field{display:flex;flex-direction:column;gap:4px;min-width:0}
.field label{font-size:12px;color:var(--muted)}
.fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
pre.cli{margin:0;background:#0f1720;color:#cfe3f7;border-radius:6px;padding:12px;font-family:var(--f-mono);font-size:12px;overflow-x:auto;line-height:1.6}
pre.cli .c{color:#7d8fa1}
.note{font-size:12.5px;color:var(--muted);background:var(--surface-2);border-radius:6px;padding:8px 10px}
.note.warn{background:var(--warn-soft);color:var(--warn)}
.progress{display:flex;flex-direction:column;gap:6px;font-size:13px}
.progress div{display:flex;gap:8px;align-items:center}

fieldset{border:1px solid var(--line);border-radius:8px;padding:12px 14px 14px;margin:0;display:flex;flex-direction:column;gap:12px;min-width:0}
legend{font-family:var(--f-display);font-weight:600;font-size:13.5px;padding:0 6px}
.hint{font-size:12px;color:var(--muted)}
.check{display:flex;gap:8px;align-items:flex-start;font-size:13px;cursor:pointer}
.check input{margin-top:3px;accent-color:var(--accent)}
.syncs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.sync{display:flex;flex-direction:column;gap:4px;padding:12px;border:1px solid var(--line);border-radius:8px}
.sync-h{display:flex;justify-content:space-between;align-items:center;gap:8px}
.linkbtn{border:0;background:none;padding:0;color:var(--accent);font-weight:600;cursor:pointer;text-decoration:underline;text-underline-offset:3px}
.modal.wide{width:min(880px,100%)}
.live{background:var(--ok-soft);color:var(--ok);border-radius:6px;padding:8px 12px;font-family:var(--f-mono);font-size:12.5px}
.kvt{width:100%}.kvt td{white-space:normal}.kvt td:first-child{color:var(--muted);width:34%}
.wifi-row{display:grid;grid-template-columns:120px minmax(0,1fr) auto;gap:10px;align-items:center;padding:8px 0;border-bottom:1px solid var(--line)}
.toast{position:fixed;right:max(16px,env(safe-area-inset-right,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));background:var(--fg);color:var(--bg);padding:10px 14px;border-radius:8px;font-size:13px;z-index:60;max-width:min(360px,calc(100% - 32px))}
.installbar{position:fixed;left:max(16px,env(safe-area-inset-left,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));z-index:55;max-width:min(440px,calc(100% - 32px));display:grid;gap:6px}
.ib-row{display:flex;gap:10px;align-items:flex-start;background:var(--surface);color:var(--fg);border:1px solid var(--line);border-left:4px solid var(--accent);border-radius:8px;padding:10px 12px;font-size:13.5px;line-height:1.45;box-shadow:0 4px 16px rgba(0,0,0,.18)}
.ib-row.ib-plug{border-left-color:var(--warn);background:var(--warn-soft);font-size:15px}
.ib-row.ib-done{border-left-color:var(--ok)}
.ib-ic{font-size:22px;line-height:1}
.ib-x{flex:none;align-self:flex-start;padding:2px 8px}

@media (max-width:1100px){
  .stats{grid-template-columns:repeat(3,minmax(0,1fr))}
  .g2,.mapwrap,.jobs{grid-template-columns:minmax(0,1fr)}
}
@media (max-width:860px){
  .app{grid-template-columns:minmax(0,1fr);grid-template-rows:auto 1fr}  /* หน้าเนื้อหาน้อย: แถบบนไม่ยืดสูง */
  .rail{position:sticky;top:env(safe-area-inset-top,0px);height:auto;flex-direction:row;align-items:center;padding:10px max(16px,env(safe-area-inset-right,0px)) 10px max(16px,env(safe-area-inset-left,0px));border-right:0;border-bottom:1px solid var(--line);z-index:20;gap:12px;overflow:visible}
  body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:10;background:var(--surface)}
  .brand small,.rail-foot{display:none}
  .userbox{margin:0;border:0;padding:0;flex:1 1 auto;min-width:0;justify-content:flex-end}
  .userbox-name{font-size:12.5px;line-height:1.25;text-align:right;max-width:42vw}
  .brand{flex:none}
  .rail{justify-content:space-between}
  .nav{display:none}  /* มือถือใช้แถบเมนูด้านล่างแทน */
  .mnav{display:grid}
  main{padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));padding-bottom:calc(84px + env(safe-area-inset-bottom,0px))}
  .toast{bottom:calc(80px + env(safe-area-inset-bottom,0px))}
  .installbar{left:max(12px,env(safe-area-inset-left,0px));right:max(12px,env(safe-area-inset-right,0px));max-width:none;bottom:calc(76px + env(safe-area-inset-bottom,0px))}
  .g2e,.fields,.syncs{grid-template-columns:minmax(0,1fr)}
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .pon-slot{grid-template-columns:minmax(0,1fr)}
  .pon-cells{grid-template-columns:repeat(8,minmax(0,1fr))}
}
/* ---------- เมนูมือถือ ---------- */
.mnav{display:none;position:fixed;left:0;right:0;bottom:0;z-index:40;grid-template-columns:repeat(5,minmax(0,1fr));background:var(--surface);border-top:1px solid var(--line);padding:0 env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)}
.mnav a,.mnav button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:60px;padding:6px 2px;border:0;background:none;color:var(--muted);font:inherit;font-size:11.5px;text-decoration:none;cursor:pointer}
.mnav [aria-current="page"]{color:var(--accent);font-weight:600}
.mnav [aria-current="page"] svg{stroke-width:2.2}
.mnav svg,.msheet-grid svg{width:24px;height:24px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none}
.msheet{position:fixed;inset:0;z-index:45;background:rgba(8,14,20,.5);display:flex;align-items:flex-end}
.msheet-panel{width:100%;background:var(--surface);border-radius:16px 16px 0 0;padding:14px max(16px,env(safe-area-inset-right,0px)) calc(16px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px));display:flex;flex-direction:column;gap:12px;max-height:85%;overflow:auto}
.msheet-head{display:flex;justify-content:space-between;align-items:center;font-family:var(--f-display);font-size:16px}
.msheet-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.msheet-grid a{display:flex;align-items:center;gap:10px;min-height:56px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;color:var(--fg);text-decoration:none;font-size:14px;position:relative}
.msheet-grid a[aria-current="page"]{border-color:var(--accent);background:var(--accent-soft);color:var(--accent);font-weight:600}
.msheet-grid .count{margin-left:auto;font-family:var(--f-mono);font-size:11px;background:var(--crit);color:#fff;border-radius:10px;padding:0 7px}
@media (max-width:860px){
  .mnav{display:grid}
  .sample{white-space:normal}
}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}

/* ---------- หน้างานติดตั้ง (มือถือช่าง): ปุ่มใหญ่ กดง่ายด้วยนิ้ว ---------- */
.istep h2{display:flex;align-items:center;gap:10px}
.inum{display:inline-grid;place-items:center;width:28px;height:28px;border-radius:50%;background:var(--surface-2);font-size:14px;flex:none}
.istep.done .inum{background:var(--ok);color:#fff}
.ibig{font-size:16px;padding:10px 12px}
.ibtn{width:100%;justify-content:center;font-size:16px;padding:12px 16px;min-height:48px}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{border:1px solid var(--line);background:var(--surface);border-radius:20px;padding:8px 14px;font-size:15px;cursor:pointer}
.chip.on{background:var(--accent);border-color:var(--accent);color:#fff}
.cablist{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin-top:8px}
.cab{display:flex;flex-direction:column;align-items:flex-start;gap:2px;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:10px 12px;cursor:pointer;text-align:left;min-height:56px}
.cab span{font-size:12.5px;color:var(--muted)}
.cab.on{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent) inset}
.ports{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:6px}
.port{min-height:46px;border:1px solid var(--line);border-radius:8px;background:var(--surface);font-weight:600;font-size:16px;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center}
.port small{font-size:10px;font-weight:400;color:var(--muted)}
.port.used{background:var(--surface-2);color:var(--muted)}
.port.on{background:var(--accent);border-color:var(--accent);color:#fff}
.port.on small{color:#fff;opacity:.9}
.port.l3{border-style:dashed}
.photos{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.pbox{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;aspect-ratio:1;border:1px dashed var(--line);border-radius:8px;cursor:pointer;overflow:hidden;font-size:13px;position:relative}
.pbox span{font-size:28px}
.pbox img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.pbox b{position:relative;background:rgba(0,0,0,.55);color:#fff;padding:2px 8px;border-radius:10px;font-weight:500}
.pwrap{display:flex;flex-direction:column;gap:4px;min-width:0}
.pgal{display:block;text-align:center;font-size:13px;padding:6px 4px;border:1px solid var(--line);border-radius:8px;cursor:pointer;color:inherit;background:transparent}
.isave{display:flex;flex-wrap:wrap;gap:8px;align-items:stretch;margin:4px 0 12px;position:sticky;bottom:0;z-index:30;background:var(--bg);padding:10px 0;border-top:1px solid var(--line)}
@media (max-width:860px){.isave{bottom:calc(58px + env(safe-area-inset-bottom,0px))}}  /* ลอยเหนือแถบเมนูล่างของมือถือ */
.isave .ibtn{flex:1;width:auto;min-width:0}
@media (max-width:480px){.ports{grid-template-columns:repeat(4,minmax(0,1fr))}}

/* ---------- ใบงานช่าง ---------- */
.jlist{display:flex;flex-direction:column;gap:10px}
.jcard.urgent{border-left:4px solid var(--crit)}
.jcard h3{font-size:16px}
.chip b{background:var(--crit);color:#fff;border-radius:10px;padding:0 6px;font-size:12px;margin-left:4px}
.timeline{display:flex;flex-direction:column;gap:8px}
.tl{border-left:2px solid var(--line);padding:2px 0 2px 10px}

/* ---------- รูปเส้นทางเข้าบ้าน ---------- */
.photos{grid-template-columns:repeat(2,minmax(0,170px))}
.rlist{display:flex;flex-direction:column;gap:8px}
.ritem{display:flex;gap:10px;align-items:center;border:1px solid var(--line);border-radius:8px;padding:6px}
.ritem img{width:72px;height:72px;object-fit:cover;border-radius:6px;flex:none}
.rbody{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
.rbtns{display:flex;flex-direction:column;gap:4px}
.rsteps{display:flex;flex-direction:column;gap:12px}
.rstep img{width:100%;max-height:340px;object-fit:cover;border-radius:8px}
.rstep b{display:block;margin-top:4px}

/* ---------- แก้ข้อมูลลูกค้า: การ์ดรูป + ตัวเลข ---------- */
.fixgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px}
.fixcard{display:flex;flex-direction:column;gap:6px;margin:0}
.fixcard img{width:100%;height:220px;object-fit:cover;object-position:bottom;border-radius:8px;background:var(--surface-2)}

/* ---------- ดูรูปเต็มจอในแอป ---------- */
.lightbox{position:fixed;inset:0;z-index:100;background:rgba(0,0,0,.92);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:max(12px,env(safe-area-inset-top)) 8px max(12px,env(safe-area-inset-bottom));touch-action:pinch-zoom}
.lightbox[hidden]{display:none}
.lightbox img{max-width:100%;max-height:calc(100% - 60px);object-fit:contain;border-radius:4px}
.lb-x{position:absolute;top:max(10px,env(safe-area-inset-top));right:10px;width:46px;height:46px;border-radius:50%;border:0;background:rgba(255,255,255,.18);color:#fff;font-size:22px;cursor:pointer}
.lb-cap{color:#e5e7eb;font-size:14px;margin-top:10px;text-align:center}

/* ---------- ผลค้นหาบนแผนที่ ---------- */
.mres{display:flex;flex-direction:column;gap:4px;margin-bottom:8px;max-height:300px;overflow:auto}
.mres button{display:flex;flex-wrap:wrap;gap:6px;align-items:baseline;text-align:left;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:10px 12px;cursor:pointer;font-size:15px}
.mres button .hint{width:100%}

/* ค่าแสงใต้สถานะ: แสดงเฉพาะมือถือ (จอใหญ่มีคอลัมน์ Rx อยู่แล้ว) */
.onutable .rx-m{display:none;margin-top:4px;font-size:13px;white-space:nowrap}
/* หน้า ONU บนมือถือ: เหลือ ลูกค้า · ตู้/พอร์ต · สถานะ (ค่าแสงและปุ่มอยู่ในหน้ารายละเอียดเมื่อแตะเลขลูกค้า) */
@media (max-width:640px){
 .onutable th:nth-child(3),.onutable td:nth-child(3),.onutable th:nth-child(5),.onutable td:nth-child(5){display:none}
 .onutable th,.onutable td{padding-left:5px;padding-right:5px;white-space:normal}
 .onutable td:nth-child(2) .mono{word-break:break-all}
 .onutable .rx-m{display:block}
}

/* รายงาน: แท่งชุดเดียว (สีหลัก) ปลายมน 4px ชิดฐาน · ชี้/แตะดูค่า */
.rbars{display:flex;align-items:flex-end;gap:2px;height:140px;padding:6px 0;border-bottom:1px solid var(--line)}
.rbar{flex:1;height:100%;display:flex;align-items:flex-end;min-width:3px;cursor:default}
.rbar span{display:block;width:100%;min-height:1px;background:var(--accent);border-radius:4px 4px 0 0}
.rbar:hover span,.rbar:focus span{filter:brightness(1.25)}
.rbars-x{display:flex;justify-content:space-between;font-size:11.5px;color:var(--muted);margin-top:4px}
.reptable{width:100%;border-collapse:collapse;font-size:13px}
.reptable th{text-align:left;font-weight:500;color:var(--muted);font-size:12px;padding:6px 6px;border-bottom:1px solid var(--line)}
.reptable td{padding:7px 6px;border-bottom:1px solid var(--line);vertical-align:top}
.reptable .num{text-align:right;font-variant-numeric:tabular-nums}
@media (max-width:640px){
 .tablewrap .reptable th:nth-child(5),.tablewrap .reptable td:nth-child(5){display:none}
 .reptable td,.reptable th{padding-left:4px;padding-right:4px}
}
/* อุปกรณ์ที่ต่อเราเตอร์ลูกค้า: มือถือซ่อน MAC / ชนิดการต่อ ให้ชื่อและ IP พอดีจอ */
.cpehosts td{word-break:break-word}
@media (max-width:640px){.cpehosts td:nth-child(3),.cpehosts td:nth-child(4){display:none}}
/* ฟอร์มสองคอลัมน์ (มือถือเหลือคอลัมน์เดียว) */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}
@media (max-width:640px){.grid2{grid-template-columns:1fr}}

/* หน้ารายละเอียดลูกค้าในแผนที่: แถบสรุป · ปุ่มลัด · เราเตอร์ · แผนที่ย่อ · รูปย่อ */
.cu-head{position:sticky;top:0;background:var(--surface);z-index:2}
.cu-sum{display:flex;flex-wrap:wrap;gap:6px}
.cu-chip{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border-radius:999px;font-size:14px;background:var(--surface-2);color:var(--fg);white-space:nowrap}
.cu-chip.ok{background:var(--ok-soft);color:var(--ok)}.cu-chip.warn{background:var(--warn-soft);color:var(--warn)}.cu-chip.crit{background:var(--crit-soft);color:var(--crit)}
.cu-quick{flex-wrap:wrap;gap:6px}
.cu-quick .btn{flex:1 1 auto;justify-content:center;min-height:40px;text-decoration:none}
.cu-card{border:1px solid var(--line);border-radius:8px;padding:12px;display:flex;flex-direction:column;gap:10px}
.cu-cpe-h{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.cu-cpe-g{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 14px}
.cu-cpe-g>div{display:flex;flex-direction:column;min-width:0}.cu-cpe-g b{overflow-wrap:anywhere}
.cu-map{height:230px;border-radius:8px;overflow:hidden;z-index:0;background:var(--surface-2)}
.cu-thumbs{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:8px}
.cu-thumbs a{display:flex;flex-direction:column;gap:2px;text-decoration:none;color:var(--muted);font-size:12px}
.cu-thumbs img{width:100%;aspect-ratio:1;object-fit:cover;border-radius:6px;background:var(--surface-2)}
.cu-issues{display:flex;flex-direction:column;gap:6px}
.cu-issues:empty{display:none}
.cu-iss-h{font-size:15px}
.cu-iss{display:flex;gap:10px;align-items:flex-start;padding:8px 10px;border-radius:8px;background:var(--surface-2);border-left:4px solid var(--idle)}
.cu-iss>div{display:flex;flex-direction:column;min-width:0}.cu-iss .hint{overflow-wrap:anywhere}
.cu-iss.crit{background:var(--crit-soft);border-left-color:var(--crit)}.cu-iss.crit b{color:var(--crit)}
.cu-iss.warn{background:var(--warn-soft);border-left-color:var(--warn)}.cu-iss.warn b{color:var(--warn)}
.cu-iss.ok{background:var(--ok-soft);border-left-color:var(--ok)}.cu-iss.ok b{color:var(--ok)}
.cu-rxres{border:1px solid var(--line);border-radius:8px;padding:10px 12px;display:flex;flex-direction:column;gap:8px}
.cu-rx-ok{color:var(--ok)}.cu-rx-warn{color:var(--warn)}.cu-rx-crit{color:var(--crit)}
.mt-card{display:flex;flex-direction:column;gap:10px;margin-bottom:12px}
.mt-steps{margin:0;padding-left:20px;display:flex;flex-direction:column;gap:6px}
.mt-chart{position:relative;border:1px solid var(--line);border-radius:8px;padding:10px 12px}
.mt-chart-h{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-bottom:6px}
.mt-chart svg{width:100%;height:110px;display:block;touch-action:none}
.mt-line{fill:none;stroke:var(--accent);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.mt-grid{stroke:var(--line);stroke-width:1;stroke-dasharray:3 4}
.mt-cross{stroke:var(--muted);stroke-width:1}
.mt-tip{position:absolute;top:34px;background:var(--surface);border:1px solid var(--line);border-radius:6px;padding:4px 8px;font-size:12.5px;pointer-events:none;white-space:nowrap;box-shadow:0 2px 8px rgba(0,0,0,.15)}
/* หน้า ทราฟฟิก / แอป */
.tr-apps{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:4px 24px}
.tr-app{display:flex;gap:10px;align-items:flex-start;padding:8px 0;border-bottom:1px solid var(--line)}
.tr-rank{font-family:var(--f-mono);color:var(--muted);min-width:1.6em;text-align:right;padding-top:2px}
.tr-logo{flex:none;width:32px;height:32px;border-radius:8px;background:#fff;border:1px solid var(--line);display:grid;place-items:center;overflow:hidden}
.tr-logo img{width:22px;height:22px;object-fit:contain}
.tr-cell{display:flex;align-items:center;gap:8px}.tr-cell .tr-logo{width:24px;height:24px;border-radius:6px}.tr-cell .tr-logo img{width:16px;height:16px}
.tr-logo-txt{background:var(--surface-2);color:var(--muted);font-weight:600;font-size:14px}
.tr-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.tr-row{display:flex;justify-content:space-between;gap:8px}.tr-row b:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tr-bar{height:6px;border-radius:3px;background:var(--surface-2);overflow:hidden}.tr-bar span{display:block;height:100%;background:var(--accent);border-radius:3px}

/* ---------- ตารางแกนไฟเบอร์ (fiber.html) ---------- */
.fb-layout{display:grid;grid-template-columns:minmax(240px,320px) 1fr;gap:16px;align-items:start}
@media (max-width:900px){.fb-layout{grid-template-columns:1fr}}
.fb-list{display:flex;flex-direction:column;gap:8px}
.fb-cable{display:block;width:100%;text-align:left;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:10px 12px;cursor:pointer;font:inherit;color:inherit}
.fb-cable.on{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.fb-row{display:flex;justify-content:space-between;gap:8px}
.fb-bar{display:flex;gap:2px;height:8px;border-radius:4px;background:var(--surface-2);overflow:hidden;margin:8px 0 4px}
.fb-bar span{display:block;height:100%}
.fb-used{background:var(--ok)}.fb-leased{background:var(--accent)}.fb-reserved{background:var(--warn)}.fb-broken{background:var(--crit)}
.fb-cnt{display:flex;flex-wrap:wrap;gap:4px 12px;font-size:12px}
.fb-bad{color:var(--crit)}
.fb-sw{display:inline-block;width:12px;height:12px;border-radius:50%;border:1px solid var(--muted);vertical-align:-1px;flex:none}
.fb-impact{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin:12px 0}
.fb-impact.warn{border-color:var(--warn);background:var(--warn-soft)}
.fb-impact summary{cursor:pointer;margin-top:6px}
.fb-imp{padding:6px 0;border-top:1px solid var(--line)}
.fb-tube{margin-top:14px}
.fb-tube-h{display:flex;align-items:center;gap:6px;font-weight:600;margin-bottom:6px}
.fb-wires{background:#0f1720;border-radius:10px;padding:12px 14px;margin-top:6px;color:#dbe4ee}
.fb-wires-h{display:flex;justify-content:space-between;font-size:12px;color:#93a3b8;margin:0 0 6px 34px}
.fb-wtube{border-left:6px solid var(--t);border-radius:4px;padding:6px 0 6px 8px;margin-bottom:10px;background:#141d29}
.fb-wtube-h{display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;margin-bottom:4px}.fb-wtube-h span:last-child{color:#93a3b8;font-weight:400}
.fb-wire{display:grid;grid-template-columns:26px minmax(80px,1fr) minmax(0,1.4fr);align-items:center;gap:8px;min-height:22px;border-radius:4px}
.fb-wire.click:hover,.fb-wire.click:focus{background:#1f2b3b;outline:none}
.fb-wnum{font-family:var(--f-mono);font-size:12px;color:#93a3b8;text-align:right}
.fb-wl{position:relative;height:5px;border-radius:3px}
.fb-wx{position:absolute;left:50%;top:50%;transform:translate(-50%,-55%);color:#ef4444;font-weight:700;font-size:15px;text-shadow:0 0 3px #000}
.fb-wend{font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fb-wend .hint{color:#64748b}.fb-wn{color:#fbbf24}
@media (max-width:600px){.fb-wire{grid-template-columns:22px 70px minmax(0,1fr)}}
.fb-table td{vertical-align:top}
tr.click{cursor:pointer}
tr.click:hover,tr.click:focus-visible{background:var(--surface-2)}
/* ปุ่มในกล่องที่เด้งบนแผนที่ (พื้นขาวเสมอ): ให้อ่านออกทั้งโหมดมืดและสว่าง */
.leaflet-popup-content .btn{background:#2563eb;color:#fff;border:1px solid #1d4ed8;font-weight:600}
.leaflet-popup-content .btn:hover{background:#1d4ed8}
.leaflet-popup-content .btn.primary{background:#0f172a;border-color:#0f172a}
.leaflet-popup-content .btn.danger{background:#dc2626;border-color:#b91c1c;color:#fff}
.leaflet-popup-content .input{background:#fff;color:#111;border:1px solid #94a3b8}
.leaflet-popup-content .hint{color:#475569}

/* ปุ่มตำแหน่งฉันบนแผนที่ */
.loc-btn{width:34px;height:34px;display:flex!important;align-items:center;justify-content:center;background:#fff;color:#333;cursor:pointer}
.loc-btn.on{color:#2563eb}
/* หน้า OLT: แถบเลือกไซต์ ติดบนจอตอนเลื่อน */
.olt-tabs{position:sticky;top:0;z-index:5;display:flex;flex-wrap:wrap;gap:8px;padding:10px 0;margin:-6px 0;background:var(--bg)}
.olt-tabs .chip{display:inline-flex;align-items:center;gap:6px;min-height:40px}
tr.grp td{background:var(--surface-2);padding-top:10px;padding-bottom:8px}
@media (max-width:860px){.olt-tabs{top:calc(env(safe-area-inset-top,0px) + 55px);overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}.olt-tabs .chip{flex:none}}  /* ใต้แถบหัวของมือถือ · เลื่อนซ้ายขวาได้ถ้าไซต์เยอะ */
/* ---------- เมนูที่ปรับเองได้ ---------- */
.nav-sep{border:0;border-top:1px dashed var(--line);margin:4px 8px}
.nav-pin{margin-left:auto;color:#f59e0b;font-size:11px;line-height:1}
.nav-pin + .count{margin-left:6px}
.nav-more summary{cursor:pointer;padding:8px 10px;color:var(--muted);font-size:13px;border-radius:6px;list-style:none}
.nav-more summary::-webkit-details-marker{display:none}
.nav-more summary::before{content:"▸ "}
.nav-more[open] summary::before{content:"▾ "}
.nav-more summary:hover{background:var(--surface-2)}
.nav-edit{display:flex;align-items:center;gap:10px;margin-top:8px;padding:8px 10px;border:1px dashed var(--line);border-radius:6px;background:none;color:var(--muted);font:inherit;font-size:13px;cursor:pointer;text-align:left}
.nav-edit:hover{color:var(--accent);border-color:var(--accent)}
.msheet-grid .nav-pin{margin-left:auto}
.msheet-edit{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:48px}
.msheet-edit svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.ne-help{display:flex;flex-wrap:wrap;gap:6px 14px;font-size:12.5px;color:var(--muted)}
.ne-k{display:inline-block;min-width:22px;text-align:center;padding:1px 5px;border:1px solid var(--line);border-radius:6px;background:var(--surface-2);color:var(--fg);font-weight:600}
.ne-k.pin{color:#b45309;background:#fef3c7;border-color:#f59e0b}
.ne-target{margin:12px 0 0}
.ne-list{list-style:none;margin:12px 0 0;padding:0;display:flex;flex-direction:column;gap:6px}
.ne-row{display:flex;align-items:center;gap:10px;padding:7px 8px 7px 10px;border:1px solid var(--line);border-radius:10px;background:var(--surface)}
.ne-row.off{background:var(--surface-2)}
.ne-row.off .ne-l,.ne-row.off > svg{opacity:.55}
.ne-row.drag{outline:2px dashed var(--accent);opacity:.6}
.ne-row > svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none;color:var(--accent)}
.ne-grip{color:var(--muted);cursor:grab;font-size:15px;line-height:1}
.ne-l{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
.ne-l small{color:var(--muted);font-size:11.5px}
.ne-btns{display:flex;gap:4px;flex:none}
.ne-b{min-width:34px;height:32px;padding:0 8px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--muted);font:inherit;font-size:12.5px;cursor:pointer;white-space:nowrap}
.ne-b:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
.ne-b.on{background:var(--accent-soft);color:var(--accent);border-color:var(--accent);font-weight:600}
.ne-b.pin.on{background:#fef3c7;color:#b45309;border-color:#f59e0b}
.ne-b.eye:not(.on){color:var(--muted);background:var(--surface-2)}
.ne-b:disabled{opacity:.3;cursor:default}
@media (max-width:640px){
  .ne-grip{display:none}
  .ne-row{gap:8px;padding:6px 6px 6px 8px}
  .ne-btns{gap:3px}
  .ne-b{min-width:30px;padding:0 5px;height:34px}
  .ne-l{font-size:13px;white-space:normal;line-height:1.25}
}

/* สีเมนูตามกลุ่มงาน / ที่แต่ละคนเลือก (core.js NAV_GROUP · NAV_PALETTE) · --nc = สีของเมนูนั้น */
.nav a.nc svg,.mnav a.nc svg,.msheet-grid a.nc svg{color:var(--nc)}
.nav a.nc{box-shadow:inset 3px 0 0 var(--nc)}
.nav a.nc[aria-current="page"]{background:color-mix(in srgb,var(--nc) 16%,transparent);color:var(--fg)}
.msheet-grid a.nc{border-left:5px solid var(--nc)}
.msheet-grid a.nc[aria-current="page"]{border-color:var(--nc);background:color-mix(in srgb,var(--nc) 14%,transparent);color:var(--fg)}
.mnav a.nc[aria-current="page"]{color:var(--nc)}
.ne-c{padding:2px 4px;border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--fg);font:inherit;font-size:12px;max-width:110px}
.ne-sw{display:inline-block;width:12px;height:12px;border-radius:50%;margin-right:4px;vertical-align:-1px;border:1px solid var(--line)}
.ne-row > svg{color:var(--nc,var(--accent))}
