/* =====================================================================
   NOWILLS SQC ERP — Enterprise Design System
   Dark charcoal • Quarry grey • Construction yellow • White
   ===================================================================== */
:root{
  --accent:#f8c200; --accent-2:#ffd84d; --accent-ink:#1a1c22;
  --green:#22c55e; --amber:#f59e0b; --red:#ef4444; --blue:#3b82f6; --grey:#64748b;
  --green-d:rgba(34,197,94,.14); --amber-d:rgba(245,158,11,.14); --red-d:rgba(239,68,68,.14); --blue-d:rgba(59,130,246,.14); --grey-d:rgba(100,116,139,.18);
  --sb-w:264px; --sb-wc:74px; --tb-h:60px;
  --r:12px; --r-sm:9px; --sh:0 10px 30px rgba(0,0,0,.28);
  --font:"Segoe UI",Inter,system-ui,-apple-system,Roboto,"Helvetica Neue",Arial,sans-serif;
  --mono:ui-monospace,"Cascadia Code",Consolas,monospace;
}
:root[data-theme="dark"]{
  --bg:#121318; --bg-2:#171920; --card:#1d2027; --card-2:#232733; --inset:#14161c;
  --border:#2b303c; --border-2:#3a4050; --text:#e9ebf1; --muted:#9aa3b2; --faint:#6b7382;
  --sb:#17181d; --sb-2:#1e2026; --tb:#171920; --hover:#262a34; --tip:#0d0e12;
  --grid:rgba(255,255,255,.07); --ax:#8b93a3; color-scheme:dark;
}
:root[data-theme="light"]{
  --bg:#eef0f4; --bg-2:#f6f7fa; --card:#ffffff; --card-2:#f4f6f9; --inset:#eef0f4;
  --border:#e2e5ec; --border-2:#cfd5df; --text:#1a2130; --muted:#5c6675; --faint:#8b94a3;
  --sb:#17181d; --sb-2:#21242b; --tb:#ffffff; --hover:#eef0f4; --tip:#ffffff;
  --grid:rgba(15,23,42,.07); --ax:#6b7686; color-scheme:light;
  --sh:0 8px 24px rgba(15,23,42,.08);
}
*{box-sizing:border-box} html,body{height:100%}
body{margin:0;font-family:var(--font);background:var(--bg);color:var(--text);font-size:14px;-webkit-font-smoothing:antialiased;overflow:hidden}
::-webkit-scrollbar{width:9px;height:9px} ::-webkit-scrollbar-thumb{background:var(--border-2);border-radius:8px;border:2px solid var(--bg)} ::-webkit-scrollbar-track{background:transparent}
a{color:var(--blue);text-decoration:none} strong{font-weight:600}
svg{display:block} .mono{font-family:var(--mono)}

/* ---------------- App frame ---------------- */
#app{display:grid;grid-template-columns:var(--sb-w) 1fr;grid-template-rows:var(--tb-h) 1fr;height:100vh;transition:grid-template-columns .25s}
#app.sb-collapsed{grid-template-columns:var(--sb-wc) 1fr}
#app.sb-hidden{grid-template-columns:0 1fr}

/* ---------------- Sidebar ---------------- */
#sidebar{grid-row:1/3;background:var(--sb);border-right:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden;z-index:50;color:#cfd3dc}
.sb-brand{display:flex;align-items:center;gap:10px;padding:14px 14px 10px;min-height:var(--tb-h);border-bottom:1px solid rgba(255,255,255,.06)}
.sb-logo{width:38px;height:38px;flex:0 0 38px;border-radius:10px;background:linear-gradient(135deg,#f8c200,#d99e00);display:grid;place-items:center;color:#16181d;box-shadow:0 4px 14px rgba(248,194,0,.3)}
.sb-logo svg{width:24px;height:24px}
.sb-name{line-height:1.15;white-space:nowrap;overflow:hidden}
.sb-name b{font-size:15px;color:#fff;letter-spacing:.3px}
.sb-name small{display:block;color:#8b93a3;font-size:10.5px;letter-spacing:1.2px;text-transform:uppercase}
.sb-search{padding:10px 12px 6px}
.sb-search input{width:100%;background:var(--sb-2);border:1px solid rgba(255,255,255,.08);color:#e6e9ef;border-radius:8px;padding:8px 10px 8px 32px;font-size:13px;outline:none}
.sb-search{position:relative}
.sb-search svg{position:absolute;left:22px;top:19px;width:15px;height:15px;color:#7d8593;pointer-events:none}
#sbNav{flex:1;overflow-y:auto;padding:4px 8px 10px}
.sb-sec{font-size:10px;letter-spacing:1.4px;text-transform:uppercase;color:#6b7280;padding:12px 12px 5px;white-space:nowrap}
.mi{display:flex;align-items:center;gap:10px;padding:7.5px 10px;border-radius:8px;color:#c3c8d2;cursor:pointer;position:relative;white-space:nowrap;user-select:none}
.mi:hover{background:var(--sb-2);color:#fff}
.mi.active{background:linear-gradient(90deg,rgba(248,194,0,.16),rgba(248,194,0,.05));color:#ffd84d}
.mi.active::before{content:"";position:absolute;left:-8px;top:6px;bottom:6px;width:3px;border-radius:3px;background:var(--accent)}
.mi .ic{width:19px;height:19px;flex:0 0 19px;color:inherit}
.mi .lbl{flex:1;overflow:hidden;text-overflow:ellipsis;font-size:13px}
.mi .bdg{background:var(--accent);color:#1a1c22;font-size:10px;font-weight:700;border-radius:9px;padding:1px 6px}
.mi .bdg.red{background:var(--red);color:#fff}
.mi .star{color:#4b5262;width:15px;height:15px;opacity:0}
.mi:hover .star{opacity:1}
.mi .star.on{opacity:1;color:var(--accent)}
#app.sb-collapsed .mi .lbl,#app.sb-collapsed .mi .bdg,#app.sb-collapsed .mi .star,#app.sb-collapsed .sb-name,#app.sb-collapsed .sb-search,#app.sb-collapsed .sb-sec{display:none}
#app.sb-collapsed .mi{justify-content:center;padding:9px 0}
#app.sb-collapsed .sb-brand{justify-content:center;padding:12px 0}
.sb-foot{border-top:1px solid rgba(255,255,255,.06);padding:10px 12px;font-size:11px;color:#7d8593;line-height:1.7;white-space:nowrap;overflow:hidden}
.sb-foot .dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--green);margin-right:6px}
.sb-foot.off .dot{background:var(--amber)}

/* ---------------- Topbar ---------------- */
#topbar{grid-column:2;background:var(--tb);border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px;padding:0 12px;z-index:40}
.tb-title{display:flex;flex-direction:column;min-width:0;margin-right:4px}
.tb-title b{font-size:14.5px;letter-spacing:.2px;white-space:nowrap}
.tb-title span{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tb-sel{display:flex;gap:6px;margin-left:6px}
select.sel,input.sel{background:var(--card-2);border:1px solid var(--border);color:var(--text);border-radius:8px;padding:6px 8px;font-size:12px;max-width:150px;outline:none;cursor:pointer}
select.sel:focus{border-color:var(--accent)}
.tb-grow{flex:1}
.tb-search{display:flex;align-items:center;gap:7px;background:var(--card-2);border:1px solid var(--border);border-radius:9px;padding:7px 11px;min-width:200px;color:var(--muted);cursor:text;font-size:12.5px}
.tb-search svg{width:14px;height:14px}
.tb-search kbd{margin-left:auto;background:var(--inset);border:1px solid var(--border-2);border-radius:5px;font-size:10px;padding:1px 6px;color:var(--muted)}
.tbtn{position:relative;width:36px;height:36px;border-radius:9px;border:1px solid transparent;background:transparent;color:var(--muted);display:grid;place-items:center;cursor:pointer}
.tbtn:hover{background:var(--hover);color:var(--text)}
.tbtn svg{width:18px;height:18px}
.tbtn.on{color:var(--accent)}
.tbtn .pb{position:absolute;top:3px;right:2px;min-width:16px;height:16px;border-radius:9px;background:var(--red);color:#fff;font-size:9.5px;font-weight:700;display:grid;place-items:center;padding:0 3px;border:2px solid var(--tb)}
.tbtn .pb.amber{background:var(--amber);color:#1a1c22}
.netstat{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);padding:0 6px;white-space:nowrap}
.netstat .dot{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 8px var(--green)}
.netstat.off .dot{background:var(--amber);box-shadow:0 0 8px var(--amber)}
.netstat.off{color:var(--amber)}
#syncTime{font-size:10.5px;color:var(--faint);white-space:nowrap}
.user-chip{display:flex;align-items:center;gap:9px;padding:4px 6px 4px 4px;border-radius:10px;cursor:pointer;border:1px solid transparent}
.user-chip:hover{background:var(--hover)}
.user-chip .av{width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,#f8c200,#b98a00);color:#16181d;font-weight:700;font-size:12px;display:grid;place-items:center}
.user-chip .un{line-height:1.15;text-align:left}
.user-chip .un b{font-size:12px;display:block}
.user-chip .un small{font-size:10px;color:var(--muted)}
#burger{display:none}

/* ---------------- Main ---------------- */
#main{grid-column:2;overflow-y:auto;background:var(--bg);scroll-behavior:smooth}
#app.sb-hidden #main,#app.sb-hidden #topbar{grid-column:1/3}
.page{max-width:1700px;margin:0 auto;padding:16px 18px 90px}
.page-head{display:flex;align-items:flex-end;gap:12px;flex-wrap:wrap;margin:4px 0 14px}
.page-head h1{font-size:21px;margin:0;letter-spacing:.2px}
.page-head .sub{color:var(--muted);font-size:12.5px}
.ph-tools{margin-left:auto;display:flex;gap:7px;flex-wrap:wrap}
.btn{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--border);background:var(--card);color:var(--text);border-radius:9px;padding:8px 13px;font-size:12.5px;cursor:pointer;font-weight:600;font-family:var(--font)}
.btn:hover{border-color:var(--border-2);background:var(--card-2)}
.btn.pri{background:var(--accent);border-color:var(--accent);color:#16181d}
.btn.pri:hover{background:var(--accent-2)}
.btn.ghost{background:transparent}
.btn.sm{padding:5px 9px;font-size:11.5px;border-radius:8px}
.btn.danger{color:var(--red)}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn svg{width:15px;height:15px}
.chip{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--border);background:var(--card);color:var(--muted);border-radius:20px;padding:4px 11px;font-size:11.5px;cursor:pointer;user-select:none;font-weight:600}
.chip:hover{color:var(--text)}
.chip.on{background:var(--accent);border-color:var(--accent);color:#16181d}
.chip .dot{width:7px;height:7px;border-radius:50%}

.offlinebar{display:none;margin:0 0 12px;border:1px solid var(--amber);background:var(--amber-d);color:var(--amber);border-radius:10px;padding:10px 14px;font-size:12.5px;align-items:center;gap:10px}
body.offline .offlinebar{display:flex}

/* ---------------- KPI cards ---------------- */
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(235px,1fr));gap:12px;margin-bottom:14px}
.kpi{background:linear-gradient(180deg,var(--card),var(--card) 70%,var(--card-2));border:1px solid var(--border);border-radius:var(--r);padding:13px 14px 10px;position:relative;cursor:pointer;overflow:hidden;transition:transform .15s,border-color .15s;min-height:118px}
.kpi:hover{transform:translateY(-2px);border-color:var(--border-2)}
.kpi::after{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--grey)}
.kpi.s-green::after{background:var(--green)} .kpi.s-amber::after{background:var(--amber)} .kpi.s-red::after{background:var(--red)} .kpi.s-blue::after{background:var(--blue)}
.kpi-top{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}
.kpi-title{font-size:11px;letter-spacing:.7px;text-transform:uppercase;color:var(--muted);font-weight:700}
.kpi-ic{color:var(--faint);width:17px;height:17px;flex:0 0 17px}
.kpi-val{font-size:23px;font-weight:750;margin-top:5px;letter-spacing:-.4px;display:flex;align-items:baseline;gap:6px}
.kpi-val small{font-size:11px;font-weight:600;color:var(--faint)}
.kpi-sub{display:flex;align-items:center;gap:8px;margin-top:3px;font-size:11px;color:var(--faint);flex-wrap:wrap}
.delta{font-weight:700;font-size:11px;display:inline-flex;align-items:center;gap:3px}
.delta.up{color:var(--green)} .delta.dn{color:var(--red)} .delta.flat{color:var(--grey)}
.kpi-spark{position:absolute;right:10px;bottom:26px;width:92px;height:30px;opacity:.9}
.kpi-tg{margin-top:8px;display:flex;align-items:center;gap:8px}
.kpi-tg .tr{flex:1;height:5px;background:var(--inset);border-radius:4px;overflow:hidden}
.kpi-tg .tr i{display:block;height:100%;border-radius:4px;background:var(--green)}
.kpi-tg .tr i.warn{background:var(--amber)} .kpi-tg .tr i.bad{background:var(--red)}
.kpi-tg em{font-style:normal;font-size:10px;color:var(--faint);white-space:nowrap}
.kpi-masked .kpi-val{filter:blur(6px)}

/* ---------------- Panels & charts ---------------- */
.grid{display:grid;grid-template-columns:repeat(12,1fr);gap:12px;margin-bottom:14px}
.panel{background:var(--card);border:1px solid var(--border);border-radius:var(--r);overflow:hidden;grid-column:span 6;min-width:0;transition:box-shadow .2s}
.panel.wide{grid-column:span 12}.panel.w8{grid-column:span 8}.panel.w4{grid-column:span 4}.panel.w3{grid-column:span 3}.panel.w9{grid-column:span 9}
.panel-h{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border)}
.panel-h h3{margin:0;font-size:13px;letter-spacing:.3px;font-weight:700}
.panel-h .hint{font-size:10.5px;color:var(--faint)}
.panel-t{margin-left:auto;display:flex;gap:4px;align-items:center}
.iconbtn{width:27px;height:27px;border-radius:7px;border:none;background:transparent;color:var(--faint);cursor:pointer;display:grid;place-items:center}
.iconbtn:hover{background:var(--hover);color:var(--text)}
.iconbtn svg{width:14.5px;height:14.5px}
.panel-b{padding:0}
.panel.collapsed .panel-b{display:none}
.live-tag{display:inline-flex;align-items:center;gap:5px;font-size:9.5px;font-weight:800;letter-spacing:1px;color:var(--red)}
.live-tag::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--red);animation:pulse 1.4s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.25}}

.ck{position:relative;padding:6px 8px 8px}
.ck-body{width:100%}
.ck-empty{display:grid;place-items:center;height:200px;color:var(--faint);font-size:12.5px;flex-direction:column;gap:8px}
.ck-tip{position:absolute;pointer-events:none;background:var(--tip);border:1px solid var(--border-2);border-radius:9px;padding:8px 11px;font-size:11.5px;box-shadow:var(--sh);opacity:0;transition:opacity .12s;z-index:20;max-width:260px}
.ck-tip.on{opacity:1}
.ck-tip b{display:block;font-size:12px;margin-bottom:3px}
.ck-tip .row{display:flex;justify-content:space-between;gap:14px;line-height:1.55}
.ck-tip .dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px}
.ck-leg{display:flex;flex-wrap:wrap;gap:6px;padding:2px 10px 8px}
.ck-leg .li{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);cursor:pointer;padding:2px 8px;border-radius:12px;border:1px solid transparent}
.ck-leg .li:hover{border-color:var(--border);color:var(--text)}
.ck-leg .li.off{opacity:.38;text-decoration:line-through}
.ck-leg .sw{width:10px;height:10px;border-radius:3px}
.zoompills{display:inline-flex;gap:3px}
.zoompills .z{border:1px solid var(--border);background:transparent;color:var(--muted);border-radius:6px;font-size:10px;padding:2px 8px;cursor:pointer;font-weight:700}
.zoompills .z.on{background:var(--accent);color:#16181d;border-color:var(--accent)}
.ax text{fill:var(--ax);font-size:10px;font-family:var(--font)}
.ax line{stroke:var(--grid)}
.gridline{stroke:var(--grid);stroke-dasharray:2 4}
.datapt{cursor:pointer}
.datapt:hover{opacity:.85}
.tgtline{stroke:var(--red);stroke-width:1.4;stroke-dasharray:6 4}
.annoline{stroke:var(--blue);stroke-width:1.2;stroke-dasharray:3 3}
.anntext{fill:var(--blue);font-size:9.5px}

/* ---------------- Tables ---------------- */
.tbl-wrap{overflow:auto;max-height:430px}
table.tbl{width:100%;border-collapse:separate;border-spacing:0;font-size:12.5px}
.tbl th{position:sticky;top:0;background:var(--card-2);color:var(--muted);font-size:10.5px;text-transform:uppercase;letter-spacing:.6px;text-align:left;padding:9px 11px;border-bottom:1px solid var(--border);cursor:pointer;white-space:nowrap;z-index:2;user-select:none}
.tbl th .ar{opacity:.5;font-size:9px}
.tbl td{padding:8.5px 11px;border-bottom:1px solid var(--border);white-space:nowrap}
.tbl tbody tr{transition:background .12s}
.tbl tbody tr:hover{background:var(--hover);cursor:pointer}
.tbl tfoot td{background:var(--card-2);font-weight:700;border-top:1px solid var(--border-2)}
.tbl .frozen{position:sticky;left:0;background:var(--card);z-index:1}
.tbl th.frozen{z-index:3;background:var(--card-2)}
.tbl-tools{display:flex;gap:8px;align-items:center;padding:9px 12px;border-bottom:1px solid var(--border);flex-wrap:wrap}
.tbl-tools input[type=search]{background:var(--inset);border:1px solid var(--border);border-radius:8px;color:var(--text);padding:6px 10px;font-size:12px;outline:none;min-width:170px}
.tbl-pager{display:flex;gap:6px;align-items:center;padding:8px 12px;font-size:11.5px;color:var(--muted)}
.tbl-pager button{border:1px solid var(--border);background:var(--card);color:var(--text);border-radius:7px;padding:4px 10px;cursor:pointer;font-size:11px}
.tbl-pager button:disabled{opacity:.4}
.badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:700;padding:2.5px 9px;border-radius:20px;letter-spacing:.3px}
.badge::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.badge.green{background:var(--green-d);color:#4ade80} .badge.amber{background:var(--amber-d);color:#fbbf24}
.badge.red{background:var(--red-d);color:#f87171} .badge.blue{background:var(--blue-d);color:#60a5fa} .badge.grey{background:var(--grey-d);color:#9aa5b3}
:root[data-theme="light"] .badge.green{color:#15803d}:root[data-theme="light"] .badge.amber{color:#b45309}:root[data-theme="light"] .badge.red{color:#b91c1c}:root[data-theme="light"] .badge.blue{color:#1d4ed8}:root[data-theme="light"] .badge.grey{color:#64748b}
select.inline-edit{background:var(--inset);border:1px solid var(--border);color:var(--text);border-radius:6px;font-size:11px;padding:3px 6px}
.num{text-align:right;font-variant-numeric:tabular-nums}
.bulkbar{display:flex;gap:8px;align-items:center;background:var(--accent);color:#16181d;border-radius:9px;padding:8px 12px;font-size:12px;font-weight:700;margin:0 12px 10px}
.bulkbar button{border:1px solid #16181d33;background:#16181d;color:var(--accent);border-radius:7px;padding:4px 10px;font-weight:700;cursor:pointer;font-size:11px}

/* ---------------- Drawers ---------------- */
#backdrop{position:fixed;inset:0;background:rgba(5,6,10,.55);opacity:0;pointer-events:none;transition:opacity .2s;z-index:90;backdrop-filter:blur(2px)}
#backdrop.on{opacity:1;pointer-events:auto}
.drawer{position:fixed;top:0;right:0;bottom:0;width:min(430px,94vw);background:var(--card);border-left:1px solid var(--border);z-index:100;transform:translateX(100%);transition:transform .25s;display:flex;flex-direction:column;box-shadow:var(--sh)}
.drawer.on{transform:translateX(0)}
.drawer-h{display:flex;align-items:center;gap:9px;padding:13px 16px;border-bottom:1px solid var(--border)}
.drawer-h h3{margin:0;font-size:15px}
.drawer-h .x{margin-left:auto}
.drawer-b{flex:1;overflow-y:auto;padding:14px 16px}
.f-group{margin-bottom:14px}
.f-group>label{display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.7px;color:var(--muted);font-weight:700;margin-bottom:6px}
.f-group select,.f-group input[type=text],.f-group input[type=date]{width:100%;background:var(--inset);border:1px solid var(--border);color:var(--text);border-radius:8px;padding:8px 10px;font-size:12.5px;outline:none}
.checks{display:flex;flex-wrap:wrap;gap:6px}
.checks .chip{font-weight:500}
.drawer-f{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--border);flex-wrap:wrap}
.pill-tabs{display:flex;gap:5px;flex-wrap:wrap;margin-bottom:12px}
.notif{display:flex;gap:11px;padding:11px;border:1px solid var(--border);border-radius:10px;margin-bottom:8px;cursor:pointer;background:var(--bg-2)}
.notif:hover{border-color:var(--border-2)}
.notif.unread{background:var(--card-2);border-left:3px solid var(--accent)}
.notif .ni{width:34px;height:34px;flex:0 0 34px;border-radius:9px;display:grid;place-items:center}
.notif .ni svg{width:17px;height:17px}
.notif h5{margin:0 0 2px;font-size:12.5px}
.notif p{margin:0;font-size:11.5px;color:var(--muted);line-height:1.45}
.notif time{font-size:10px;color:var(--faint)}
.notif .sev{margin-left:auto;flex-shrink:0}
.alertcard{border:1px solid var(--border);border-radius:11px;padding:12px;margin-bottom:9px;background:var(--bg-2)}
.alertcard h5{margin:0 0 4px;font-size:13px;display:flex;gap:8px;align-items:center}
.alertcard .meta{font-size:11px;color:var(--muted);line-height:1.7}
.alertcard .acts{display:flex;gap:6px;margin-top:9px}

/* ---------------- Modal ---------------- */
.modal-ov{position:fixed;inset:0;background:rgba(5,6,10,.6);z-index:110;display:grid;place-items:center;padding:18px;backdrop-filter:blur(3px)}
.modal{background:var(--card);border:1px solid var(--border-2);border-radius:14px;width:min(860px,96vw);max-height:92vh;display:flex;flex-direction:column;box-shadow:var(--sh);animation:pop .18s}
@keyframes pop{from{transform:scale(.96);opacity:0}}
.modal-h{display:flex;align-items:center;gap:10px;padding:13px 16px;border-bottom:1px solid var(--border)}
.modal-h h3{margin:0;font-size:15px}
.modal-h .x{margin-left:auto}
.modal-b{padding:16px;overflow-y:auto}
.modal-f{display:flex;gap:8px;justify-content:flex-end;padding:12px 16px;border-top:1px solid var(--border)}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.form-grid .full{grid-column:1/3}
.form-grid label{font-size:10.5px;text-transform:uppercase;letter-spacing:.6px;color:var(--muted);font-weight:700;display:block;margin-bottom:5px}
.form-grid input,.form-grid select,.form-grid textarea{width:100%;background:var(--inset);border:1px solid var(--border);color:var(--text);border-radius:8px;padding:8px 10px;font-size:13px;outline:none;font-family:var(--font)}
.form-grid input:focus,.form-grid select:focus{border-color:var(--accent)}
.toggle{position:relative;width:38px;height:21px;border-radius:12px;background:var(--border-2);cursor:pointer;transition:background .15s;flex-shrink:0}
.toggle::after{content:"";position:absolute;top:2.5px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s}
.toggle.on{background:var(--accent)}
.toggle.on::after{left:19px}
.setrow{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--border)}
.setrow .si{flex:1}
.setrow .si b{font-size:13px;display:block}
.setrow .si small{color:var(--muted);font-size:11px}

/* ---------------- Toasts ---------------- */
#toasts{position:fixed;bottom:18px;right:18px;z-index:130;display:flex;flex-direction:column;gap:8px;max-width:360px}
.toast{background:var(--tip);border:1px solid var(--border-2);border-left:3px solid var(--accent);border-radius:10px;padding:11px 14px;font-size:12.5px;box-shadow:var(--sh);display:flex;gap:10px;align-items:flex-start;animation:slidein .25s}
@keyframes slidein{from{transform:translateX(30px);opacity:0}}
.toast b{display:block;font-size:12.5px}
.toast small{color:var(--muted);font-size:11px}
.toast.green{border-left-color:var(--green)} .toast.red{border-left-color:var(--red)} .toast.amber{border-left-color:var(--amber)} .toast.blue{border-left-color:var(--blue)}

/* ---------------- Specials ---------------- */
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:9px;padding:12px}
.tile{background:var(--bg-2);border:1px solid var(--border);border-radius:10px;padding:12px 10px;text-align:center;cursor:pointer;font-size:12px;font-weight:600;display:flex;flex-direction:column;align-items:center;gap:8px;color:var(--muted)}
.tile:hover{border-color:var(--accent);color:var(--text)}
.tile svg{width:21px;height:21px;color:var(--accent)}
.gis-wrap{position:relative;background:radial-gradient(circle at 30% 20%,rgba(59,130,246,.08),transparent 60%),var(--inset);border-radius:10px;margin:8px}
.crusher-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px;padding:12px}
.crusher{background:var(--bg-2);border:1px solid var(--border);border-radius:11px;padding:12px;position:relative}
.crusher h4{margin:0 0 2px;font-size:13px;display:flex;align-items:center;gap:8px}
.led{width:9px;height:9px;border-radius:50%;background:var(--grey)}
.led.g{background:var(--green);box-shadow:0 0 7px var(--green);animation:pulse 2s infinite}
.led.a{background:var(--amber);box-shadow:0 0 7px var(--amber)}
.led.r{background:var(--red);box-shadow:0 0 7px var(--red);animation:pulse .9s infinite}
.crusher .row{display:flex;justify-content:space-between;font-size:11.5px;color:var(--muted);padding:2.5px 0}
.crusher .row b{color:var(--text);font-variant-numeric:tabular-nums}
.piles{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:10px;padding:12px}
.pile{background:var(--bg-2);border:1px solid var(--border);border-radius:11px;padding:11px;cursor:pointer;transition:border-color .15s}
.pile:hover{border-color:var(--accent)}
.pile .cone{height:52px;display:grid;place-items:end center;margin-bottom:6px}
.pile .cone i{display:block;width:82%;height:46px;background:linear-gradient(180deg,#6b7280,#3f4652);clip-path:polygon(50% 0,100% 100%,0 100%);border-radius:6px 6px 4px 4px}
.pile.warn .cone i{background:linear-gradient(180deg,#f59e0b,#92600a)}
.pile .cap{height:6px;border-radius:4px;background:var(--inset);overflow:hidden;margin:6px 0 4px}
.pile .cap i{display:block;height:100%;background:var(--green)}
.pile .cap i.warn{background:var(--amber)}
.kanban{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;padding:12px}
.kb-col{background:var(--bg-2);border:1px dashed var(--border-2);border-radius:10px;padding:9px;min-height:170px}
.kb-col h6{margin:0 0 8px;font-size:10.5px;text-transform:uppercase;letter-spacing:.8px;color:var(--muted);display:flex;justify-content:space-between}
.kb-card{background:var(--card);border:1px solid var(--border);border-radius:9px;padding:9px 10px;margin-bottom:7px;font-size:12px;cursor:grab;box-shadow:0 2px 6px rgba(0,0,0,.18)}
.kb-card:active{cursor:grabbing}
.kb-card.dragover{opacity:.5}
.kb-col.over{border-color:var(--accent);background:var(--amber-d)}
.reco{border:1px solid var(--border);border-radius:11px;padding:12px;margin-bottom:9px;background:var(--bg-2);border-left:3px solid var(--accent)}
.reco h5{margin:0 0 3px;font-size:12.5px}
.reco p{margin:0 0 8px;font-size:11.5px;color:var(--muted);line-height:1.5}
.reco .conf{font-size:10px;color:var(--faint)}
.reco .acts{display:flex;gap:6px;margin-top:8px}
.confbar{height:5px;background:var(--inset);border-radius:4px;overflow:hidden;width:120px;display:inline-block;vertical-align:middle;margin-right:6px}
.confbar i{display:block;height:100%;background:var(--blue)}
.statement{border:1px solid var(--border);border-radius:10px;margin-bottom:9px;overflow:hidden}
.statement>header{display:flex;justify-content:space-between;align-items:center;padding:11px 13px;cursor:pointer;background:var(--bg-2);font-weight:700;font-size:13px}
.statement .sb-body{padding:4px 12px 12px}
.sr{display:flex;justify-content:space-between;padding:6px 4px;font-size:12.5px;border-bottom:1px dashed var(--border)}
.sr.tot{font-weight:800;border-top:1px solid var(--border-2);border-bottom:none;margin-top:4px;padding-top:9px}
.sr.sub{padding-left:20px;color:var(--muted)}
.statgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:9px;padding:12px}
.statmini{background:var(--bg-2);border:1px solid var(--border);border-radius:10px;padding:10px;text-align:center}
.statmini b{display:block;font-size:18px;margin-top:3px}
.statmini span{font-size:10px;text-transform:uppercase;letter-spacing:.6px;color:var(--muted);font-weight:700}
.plan{position:relative;height:340px;margin:8px;background:var(--inset);border-radius:10px;overflow:hidden;border:1px solid var(--border)}
.plan .zone{position:absolute;border:1px dashed var(--border-2);border-radius:8px;color:var(--faint);font-size:10px;padding:5px;letter-spacing:.5px}
.plan .mk{position:absolute;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;font-size:9px;font-weight:800;color:#0d0e12;cursor:pointer;transform:translate(-50%,-50%);border:2px solid rgba(255,255,255,.25)}
.plan .mk.pulse{animation:pulse 1.2s infinite}
.watermark{position:fixed;inset:0;pointer-events:none;z-index:200;display:none;overflow:hidden}
.watermark.on{display:block}
.watermark span{position:absolute;top:40%;left:12%;transform:rotate(-24deg);font-size:46px;font-weight:800;color:rgba(125,133,147,.06);white-space:nowrap;letter-spacing:8px}
.progressbar{height:7px;border-radius:5px;background:var(--inset);overflow:hidden}
.progressbar i{display:block;height:100%;background:var(--accent);border-radius:5px}
.progressbar.g i{background:var(--green)} .progressbar.a i{background:var(--amber)} .progressbar.r i{background:var(--red)}
.hlist{padding:10px 12px}
.hrow{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px dashed var(--border);font-size:12px}
.hrow:last-child{border-bottom:none}
.hrow .nm{width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:0}
.hrow .bar{flex:1;height:8px;background:var(--inset);border-radius:5px;overflow:hidden}
.hrow .bar i{display:block;height:100%;border-radius:5px}
.hrow .vv{width:88px;text-align:right;font-variant-numeric:tabular-nums;color:var(--muted);flex-shrink:0}
.bigclock{font-size:26px;font-weight:750;font-variant-numeric:tabular-nums}
.drag-handle{cursor:grab;color:var(--faint)}
body.customize .panel{border-style:dashed;border-color:var(--border-2)}
body.customize .panel .panel-h::before{content:"⋮⋮";color:var(--faint);letter-spacing:-2px;cursor:grab}
.panel.dropover{outline:2px dashed var(--accent);outline-offset:-2px}
.empty-state{padding:34px;text-align:center;color:var(--faint);font-size:13px}
.sk{background:linear-gradient(90deg,var(--inset) 25%,var(--card-2) 50%,var(--inset) 75%);background-size:200% 100%;animation:sk 1.3s infinite;border-radius:8px}
@keyframes sk{from{background-position:200% 0}to{background-position:-200% 0}}

/* ---------------- Bottom nav (mobile) ---------------- */
#bottomnav{display:none;position:fixed;bottom:0;left:0;right:0;background:var(--tb);border-top:1px solid var(--border);z-index:80;padding:4px 4px calc(4px + env(safe-area-inset-bottom));justify-content:space-around}
#bottomnav .bni{display:flex;flex-direction:column;align-items:center;gap:2px;font-size:9.5px;color:var(--muted);padding:6px 10px;border-radius:9px;cursor:pointer;position:relative}
#bottomnav .bni.on{color:var(--accent)}
#bottomnav .bni svg{width:19px;height:19px}
#bottomnav .bni .pb{position:absolute;top:0;right:4px;min-width:15px;height:15px;border-radius:8px;background:var(--red);color:#fff;font-size:9px;display:grid;place-items:center;font-weight:800}

/* ---------------- Responsive ---------------- */
@media(max-width:1400px){.tb-search{min-width:150px}}
@media(max-width:1200px){
  .panel,.panel.w8,.panel.w4,.panel.w9,.panel.w3,.panel.wide{grid-column:span 12}
  .tb-sel .hidemd{display:none}
}
@media(max-width:860px){
  #app{grid-template-columns:0 1fr}
  #sidebar{position:fixed;top:0;bottom:0;left:0;width:var(--sb-w);transform:translateX(-100%);transition:transform .25s;box-shadow:var(--sh)}
  body.sb-open #sidebar{transform:translateX(0)}
  #topbar,#main{grid-column:1/3}
  #burger{display:grid}
  .tb-sel{display:none}
  .tb-search{display:none}
  #syncTime,.user-chip .un{display:none}
  #bottomnav{display:flex}
  .kpi-grid{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}
  .kanban{grid-template-columns:repeat(2,1fr)}
  .form-grid{grid-template-columns:1fr}
  .form-grid .full{grid-column:1/2}
  .page{padding:12px 10px 96px}
}
@media(min-width:861px){body.sb-open #backdrop{opacity:0;pointer-events:none}}

/* ---------------- Print / Board pack ---------------- */
#printzone{display:none}
@media print{
  body{overflow:visible;background:#fff;color:#111}
  #app,#toasts,.drawer,.modal-ov,#backdrop,#bottomnav,.watermark{display:none!important}
  #printzone{display:block;color:#111;font-size:12px}
  #printzone .btn{display:none}
  #printzone table{width:100%;border-collapse:collapse;font-size:11px}
  #printzone th,#printzone td{border:1px solid #999;padding:4px 7px;text-align:left}
  #printzone h1{font-size:20px}#printzone h2{font-size:15px;margin:18px 0 6px}
  .pz-cover{text-align:center;padding:80px 0 40px;page-break-after:always}
  .pz-meta{color:#444;font-size:11px;line-height:2}
  .pz-page{page-break-inside:avoid}
}

/* ---------------- Pseudo-fullscreen fallback (when the OS Fullscreen API is blocked, e.g. sandboxed embeds) ---------------- */
html.pseudo-fs, html.pseudo-fs body{height:100%;overflow:hidden}
html.pseudo-fs #app{position:fixed;inset:0;z-index:2147483000;width:100vw;height:100vh;background:var(--bg);box-shadow:0 0 0 2px var(--f8, #f8c200)}
html.pseudo-fs #topbar{border-bottom-color:var(--f8, #f8c200)}
html.pseudo-fs .watermark{display:none}
html.pseudo-fs #bFull{background:var(--f8, #f8c200);color:#16181d}

