@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root{
  --bg:#f4f6fb; --surface:#ffffff; --surface-2:#f7f8fc; --surface-3:#eef1f7; --border:#e2e6ee; --border-strong:#ccd3e2;
  --text:#161c2d; --text-dim:#5a6478; --text-faint:#8791a5;
  --primary:#4054e0; --primary-dark:#2f3fc4; --primary-light:#ecefff; --primary-ring:rgba(64,84,224,.20);
  --sidebar-bg:#0e1424; --sidebar-text:#98a2ba; --sidebar-active:#1c2440; --sidebar-accent:#5c72f2;
  --green:#189a5e; --green-bg:#e2f7ee; --orange:#c9720a; --orange-bg:#fcf0dc;
  --red:#d13c3c; --red-bg:#fbe8e8; --blue:#3161d1; --blue-bg:#e9f0fd;
  --purple:#7440cf; --purple-bg:#f1e9fc; --gray:#65708a; --gray-bg:#eef0f5;
  --radius-sm:6px; --radius:10px; --radius-lg:14px;
  --shadow-xs:0 1px 2px rgba(20,30,60,.05);
  --shadow:0 2px 6px rgba(20,30,60,.07),0 1px 2px rgba(20,30,60,.05);
  --shadow-lg:0 16px 40px rgba(20,30,60,.16),0 4px 14px rgba(20,30,60,.08);
  --font:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI Variable','Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  --ease:cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"]{
  --bg:#0b0f1c; --surface:#141a2c; --surface-2:#1a2138; --surface-3:#212a45; --border:#2a3350; --border-strong:#3a4568;
  --text:#e8eaf4; --text-dim:#9aa3ba; --text-faint:#6b7590;
  --primary:#7c8cf5; --primary-dark:#5a6de0; --primary-light:#1e2547; --primary-ring:rgba(124,140,245,.28);
  --sidebar-bg:#080c17; --sidebar-text:#8791ab; --sidebar-active:#1a2240; --sidebar-accent:#7c8cf5;
  --green:#3ec583; --green-bg:#12301f; --orange:#e69a3d; --orange-bg:#3a2712;
  --red:#f0605f; --red-bg:#3a1414; --blue:#6f97f7; --blue-bg:#16233e;
  --purple:#a688f0; --purple-bg:#251b3d; --gray:#9aa3ba; --gray-bg:#232b42;
  --shadow-xs:0 1px 2px rgba(0,0,0,.25);
  --shadow:0 2px 8px rgba(0,0,0,.3),0 1px 3px rgba(0,0,0,.25);
  --shadow-lg:0 20px 48px rgba(0,0,0,.55),0 6px 16px rgba(0,0,0,.4);
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{margin:0;font-family:var(--font);background:var(--bg);color:var(--text);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;}
::-webkit-scrollbar{width:10px;height:10px;}
::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:6px;}
::-webkit-scrollbar-thumb:hover{background:var(--text-faint);}
::-webkit-scrollbar-track{background:transparent;}
button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit;}
a{color:inherit;text-decoration:none;}
h1,h2,h3,h4{margin:0;font-weight:700;letter-spacing:-.01em;}
.app{display:flex;min-height:100vh;}
/* A single, consistent focus ring across every interactive element — inputs, buttons, links,
 * tabs, nav items — none of them had any visible focus indicator before, which is both an
 * accessibility gap and something that reads as unfinished on close inspection. */
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--primary);outline-offset:2px;border-radius:4px;}

/* Sidebar */
.sidebar{width:238px;background:var(--sidebar-bg);color:var(--sidebar-text);flex-shrink:0;display:flex;flex-direction:column;position:fixed;top:0;bottom:0;left:0;z-index:60;transition:transform .25s var(--ease);}
.sidebar-brand{display:flex;align-items:center;gap:10px;padding:19px 18px 15px;border-bottom:1px solid rgba(255,255,255,.07);}
.sidebar-brand .logo{width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,#5c72f2,#9a5cf6);display:flex;align-items:center;justify-content:center;font-size:18px;flex-shrink:0;box-shadow:0 3px 10px rgba(92,114,242,.35);}
.sidebar-brand .name{font-weight:700;color:#fff;font-size:14.5px;letter-spacing:-.01em;}
.sidebar-brand .sub{font-size:11px;color:var(--sidebar-text);}
.sidebar-nav{flex:1;overflow-y:auto;padding:12px 10px;}
.nav-item{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:8px;cursor:pointer;font-size:13.3px;font-weight:500;color:var(--sidebar-text);margin-bottom:2px;white-space:nowrap;transition:background .15s var(--ease),color .15s var(--ease);}
.nav-item:hover{background:rgba(255,255,255,.06);color:#fff;}
.nav-item.active{background:var(--sidebar-active);color:#fff;font-weight:600;box-shadow:inset 3px 0 0 var(--sidebar-accent);}
.nav-item .ic{width:18px;text-align:center;flex-shrink:0;}
.sidebar-foot{padding:12px 16px;border-top:1px solid rgba(255,255,255,.07);font-size:11px;color:var(--text-faint);}
.sidebar-toggle{display:none;}

/* Main */
.main{margin-left:238px;flex:1;display:flex;flex-direction:column;min-width:0;}
.topbar{height:60px;background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;gap:14px;padding:0 20px;position:sticky;top:0;z-index:40;}
.hamburger{display:none;background:none;border:none;font-size:20px;cursor:pointer;color:var(--text);}
.global-search{flex:1;max-width:420px;position:relative;}
.global-search input{width:100%;padding:9px 12px 9px 34px;border:1px solid var(--border);border-radius:8px;background:var(--surface-2);transition:border-color .15s var(--ease),box-shadow .15s var(--ease);}
.global-search input:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-ring);background:var(--surface);}
.global-search .gi{position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--text-faint);}
.topbar-right{margin-left:auto;display:flex;align-items:center;gap:16px;}
.top-datetime{font-size:12.5px;color:var(--text-dim);text-align:right;line-height:1.3;}
.icon-btn{position:relative;background:var(--surface-2);border:1px solid var(--border);width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background .15s var(--ease),border-color .15s var(--ease);}
.icon-btn:hover{background:var(--primary-light);border-color:var(--primary);}
.notif-dot{position:absolute;top:6px;right:6px;width:7px;height:7px;background:var(--red);border-radius:50%;box-shadow:0 0 0 2px var(--surface);}
.profile-menu{position:relative;}
.profile-btn{display:flex;align-items:center;gap:8px;cursor:pointer;padding:5px 8px 5px 5px;border-radius:20px;border:1px solid var(--border);background:var(--surface-2);transition:border-color .15s var(--ease);}
.profile-btn:hover{border-color:var(--border-strong);}
.avatar{width:28px;height:28px;border-radius:50%;background:linear-gradient(135deg,#5c72f2,#9a5cf6);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:12px;}
.dropdown{position:absolute;right:0;top:44px;background:var(--surface);border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow-lg);min-width:210px;padding:6px;display:none;z-index:70;}
.dropdown.open{display:block;animation:dropdownin .12s var(--ease);}
@keyframes dropdownin{from{opacity:0;transform:translateY(-4px);}to{opacity:1;transform:none;}}
.dropdown-item{padding:9px 10px;border-radius:6px;cursor:pointer;font-size:13px;display:flex;align-items:center;gap:8px;transition:background .12s var(--ease);}
.dropdown-item:hover{background:var(--surface-2);}
.dropdown-sep{height:1px;background:var(--border);margin:6px 0;}
.search-results{position:absolute;top:44px;left:0;right:0;background:var(--surface);border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow-lg);max-height:360px;overflow-y:auto;display:none;z-index:70;}
.search-results.open{display:block;}
.search-results .sr-item{padding:10px 12px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .12s var(--ease);}
.search-results .sr-item:last-child{border-bottom:none;}
.search-results .sr-item:hover{background:var(--surface-2);}
.search-results .sr-type{font-size:10.5px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.4px;}

/* Tab strip — an in-app row of open pages, like a browser's own tabs. Sticks just below the
 * topbar so it stays reachable while a tall page scrolls underneath it. */
.tab-strip{display:flex;align-items:flex-end;gap:3px;padding:8px 14px 0;background:var(--surface-2);border-bottom:1px solid var(--border);overflow-x:auto;position:sticky;top:60px;z-index:39;}
.tab-strip::-webkit-scrollbar{height:4px;}
.tab-item{display:flex;align-items:center;gap:7px;padding:8px 8px 8px 12px;background:var(--surface-2);border:1px solid transparent;border-bottom:none;border-radius:8px 8px 0 0;font-size:12.5px;font-weight:600;color:var(--text-dim);cursor:pointer;white-space:nowrap;max-width:200px;flex-shrink:0;transition:background .15s var(--ease),color .15s var(--ease);}
.tab-item:not(.active):hover{background:var(--surface);color:var(--text);}
.tab-item.active{background:var(--surface);border-color:var(--border);color:var(--text);box-shadow:0 -2px 0 var(--primary) inset;}
.tab-item .tab-label{overflow:hidden;text-overflow:ellipsis;}
.tab-close{display:flex;align-items:center;justify-content:center;width:17px;height:17px;border-radius:5px;font-size:11px;color:var(--text-faint);flex-shrink:0;transition:background .12s var(--ease),color .12s var(--ease);}
.tab-close:hover{background:var(--red-bg);color:var(--red);}

.content{padding:24px;flex:1;min-width:0;}
.page{display:none;}
.page.active{display:block;animation:fadein .18s var(--ease);}
@keyframes fadein{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:none;}}

.page-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px;flex-wrap:wrap;gap:10px;}
.page-head h1{font-size:21px;font-weight:800;letter-spacing:-.015em;}
.page-head .desc{font-size:12.5px;color:var(--text-dim);margin-top:3px;}
.page-actions{display:flex;gap:8px;flex-wrap:wrap;}

/* Buttons */
.btn{border:1px solid var(--border);background:var(--surface);padding:8px 14px;border-radius:8px;cursor:pointer;font-weight:600;font-size:13px;display:inline-flex;align-items:center;gap:6px;white-space:nowrap;transition:background .15s var(--ease),border-color .15s var(--ease),color .15s var(--ease),box-shadow .15s var(--ease),transform .08s var(--ease);}
.btn:hover{border-color:var(--primary);color:var(--primary);}
.btn:active{transform:translateY(1px);}
.btn-primary{background:var(--primary);border-color:var(--primary);color:#fff;box-shadow:0 2px 8px rgba(64,84,224,.28);}
.btn-primary:hover{background:var(--primary-dark);border-color:var(--primary-dark);color:#fff;box-shadow:0 4px 12px rgba(64,84,224,.36);}
.btn-danger{background:var(--red);border-color:var(--red);color:#fff;}
.btn-danger:hover{background:#b52d2d;border-color:#b52d2d;color:#fff;}
.btn-outline-danger{color:var(--red);border-color:var(--red);}
.btn-outline-danger:hover{background:var(--red);color:#fff;}
.btn-purple{background:var(--purple);border-color:var(--purple);color:#fff;box-shadow:0 2px 8px rgba(116,64,207,.28);}
.btn-purple:hover{background:#6428b8;border-color:#6428b8;color:#fff;}
.btn-sm{padding:5px 9px;font-size:12px;border-radius:6px;}
.btn:disabled{opacity:.45;cursor:not-allowed;transform:none;box-shadow:none;}
.btn-icon{width:32px;height:32px;padding:0;justify-content:center;}

/* Cards & grid */
.grid{display:grid;gap:16px;}
.kpi-grid{grid-template-columns:repeat(4,1fr);}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:17px 19px;box-shadow:var(--shadow);}
.card h3{font-size:14px;font-weight:700;margin-bottom:12px;}
.kpi-card{cursor:pointer;transition:transform .15s var(--ease),box-shadow .15s var(--ease),border-color .15s var(--ease);}
.kpi-card:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg);border-color:var(--border-strong);}
.kpi-top{display:flex;justify-content:space-between;align-items:flex-start;}
.kpi-label{font-size:11.5px;color:var(--text-dim);font-weight:600;text-transform:uppercase;letter-spacing:.4px;}
.kpi-val{font-size:26px;font-weight:800;margin-top:6px;letter-spacing:-.02em;}
.kpi-sub{font-size:11.5px;margin-top:6px;font-weight:600;}
.kpi-ic{width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:17px;flex-shrink:0;}
.up{color:var(--green);} .down{color:var(--red);}
.charts-grid{grid-template-columns:repeat(2,1fr);align-items:start;}

/* bars */
.bar-row{display:flex;align-items:center;gap:10px;margin-bottom:10px;font-size:12.5px;}
.bar-row .bl{width:110px;flex-shrink:0;color:var(--text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.bar-track{flex:1;height:9px;background:var(--surface-3);border-radius:5px;overflow:hidden;}
.bar-fill{height:100%;border-radius:5px;background:var(--primary);transition:width .3s var(--ease);}
.bar-val{width:64px;text-align:right;font-weight:700;flex-shrink:0;}
.bar-row.clickable{cursor:pointer;}
.bar-row.clickable:hover .bl{color:var(--primary);}

.donut-wrap{display:flex;align-items:center;gap:20px;}
.donut{width:130px;height:130px;border-radius:50%;flex-shrink:0;}
.donut-legend{flex:1;}
.legend-item{display:flex;align-items:center;gap:8px;font-size:12.5px;margin-bottom:7px;}
.legend-dot{width:10px;height:10px;border-radius:3px;flex-shrink:0;}

/* Badges */
.badge{display:inline-flex;align-items:center;gap:4px;padding:3px 9px;border-radius:20px;font-size:11px;font-weight:700;white-space:nowrap;letter-spacing:.1px;}
.b-high{background:var(--red-bg);color:var(--red);}
.b-medium{background:var(--orange-bg);color:var(--orange);}
.b-easy{background:var(--green-bg);color:var(--green);}
.b-available{background:var(--green-bg);color:var(--green);}
.b-issued{background:var(--blue-bg);color:var(--blue);}
.b-pending{background:var(--orange-bg);color:var(--orange);}
.b-returned{background:var(--gray-bg);color:var(--gray);}
.b-completed{background:var(--purple-bg);color:var(--purple);}
.b-manual{background:var(--purple-bg);color:var(--purple);}
.b-auto{background:var(--blue-bg);color:var(--blue);}
.b-active{background:var(--green-bg);color:var(--green);}
.b-inactive{background:var(--gray-bg);color:var(--gray);}
.b-neutral{background:var(--surface-3);color:var(--text-dim);}
.b-urgent{background:var(--red);color:#fff;box-shadow:0 0 0 2px var(--red-bg);}

/* Urgent Kapan highlighting — a solid badge (not the usual pastel) plus a left-edge accent
 * wherever a row/card belongs to a currently-urgent Kapan, so it reads as distinct at a glance
 * rather than blending in with priority/status badges. */
tr.urgent-row td{background:var(--red-bg);}
.worker-pick-item.urgent-kapan{box-shadow:inset 3px 0 0 var(--red);}

/* Tabs */
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--border);margin-bottom:16px;flex-wrap:wrap;}
.tab{padding:9px 14px;cursor:pointer;font-size:13px;font-weight:600;color:var(--text-dim);border-bottom:2px solid transparent;margin-bottom:-1px;transition:color .15s var(--ease),border-color .15s var(--ease);}
.tab:hover{color:var(--text);}
.tab.active{color:var(--primary);border-color:var(--primary);}
.tab-panel{display:none;}
.tab-panel.active{display:block;}

/* Filters bar */
.filter-bar{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px;align-items:center;background:var(--surface);border:1px solid var(--border);padding:12px;border-radius:var(--radius);}
.filter-bar input,.filter-bar select{padding:7px 10px;border:1px solid var(--border);border-radius:7px;background:var(--surface-2);font-size:12.5px;transition:border-color .15s var(--ease),box-shadow .15s var(--ease);}
.filter-bar input:focus,.filter-bar select:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-ring);}
.filter-bar .search-fl{min-width:180px;flex:1;}
/* Same "small label above its input" field pattern as .filter-bar, but usable anywhere —
 * .rule-block's Sort Order row reuses .fl outside a .filter-bar and needs the identical look. */
.fl{display:flex;flex-direction:column;gap:3px;}
.fl label{font-size:10.5px;color:var(--text-faint);font-weight:700;text-transform:uppercase;letter-spacing:.3px;}
.fl input,.fl select{padding:7px 10px;border:1px solid var(--border);border-radius:7px;background:var(--surface-2);font-size:12.5px;transition:border-color .15s var(--ease),box-shadow .15s var(--ease);}
.fl input:focus,.fl select:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-ring);}
.chip{display:inline-flex;align-items:center;gap:5px;background:var(--primary-light);color:var(--primary);padding:4px 8px;border-radius:14px;font-size:11.5px;font-weight:600;}
.chip .x{cursor:pointer;font-weight:900;}

/* Table */
.table-wrap{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden;box-shadow:var(--shadow);}
.table-scroll{overflow:auto;max-width:100%;}
table{width:100%;border-collapse:collapse;font-size:12.6px;min-width:600px;}
thead th{position:sticky;top:0;background:var(--surface-2);text-align:left;padding:10px 12px;font-weight:700;color:var(--text-dim);border-bottom:1px solid var(--border);white-space:nowrap;font-size:11.2px;text-transform:uppercase;letter-spacing:.3px;z-index:5;}
tbody td{padding:9px 12px;border-bottom:1px solid var(--border);vertical-align:middle;white-space:nowrap;}
tbody tr{transition:background .1s var(--ease);}
tbody tr:hover{background:var(--surface-2);}
tbody tr:last-child td{border-bottom:none;}
.table-foot{display:flex;justify-content:space-between;align-items:center;padding:10px 14px;border-top:1px solid var(--border);font-size:12px;color:var(--text-dim);flex-wrap:wrap;gap:8px;}
.pagination{display:flex;gap:4px;}
.pagination button{width:28px;height:28px;border:1px solid var(--border);background:var(--surface);border-radius:6px;cursor:pointer;font-size:12px;transition:background .12s var(--ease),border-color .12s var(--ease);}
.pagination button:hover{border-color:var(--primary);color:var(--primary);}
.pagination button.active{background:var(--primary);color:#fff;border-color:var(--primary);}
.empty-state{padding:50px 20px;text-align:center;color:var(--text-faint);}
.empty-state .ic{font-size:34px;margin-bottom:10px;}

/* Spreadsheet-style grid (Diamond Stock) */
.sheet-wrap{background:var(--surface);border:1px solid var(--border);border-radius:8px;overflow:auto;box-shadow:var(--shadow);max-height:72vh;}
.sheet-table{border-collapse:collapse;font-size:12px;width:100%;}
.sheet-table th,.sheet-table td{border:1px solid var(--border);padding:5px 9px;white-space:nowrap;text-align:left;}
.sheet-table td.sr-num{text-align:right;}
.sheet-table thead th{position:sticky;top:0;background:var(--surface-2);font-weight:700;color:var(--text);z-index:5;user-select:none;font-size:11px;text-transform:uppercase;letter-spacing:.25px;}
.sheet-table thead th .sh-head{display:flex;align-items:center;justify-content:space-between;gap:6px;}
.sheet-table thead th .sh-filter-btn{cursor:pointer;border:1px solid transparent;background:transparent;color:var(--text-dim);padding:1px 5px;border-radius:4px;font-size:10px;line-height:1.6;transition:background .12s var(--ease);}
.sheet-table thead th .sh-filter-btn:hover{background:var(--surface);border-color:var(--border);}
.sheet-table thead th .sh-filter-btn.active{background:var(--primary-light);color:var(--primary);border-color:var(--primary);}
.sheet-table tbody tr:nth-child(even){background:var(--surface-2);}
.sheet-table tbody tr{transition:background .1s var(--ease);}
.sheet-table tbody tr:hover{background:var(--primary-light);}
.sheet-table tbody td{color:var(--text);}
.sheet-table td b[data-details]{font-weight:600;}
/* Stock Report grid: wider than the viewport by design (every process/shape gets its own
 * column), so the Date and Total columns stay pinned (sticky left/right) while everything
 * else scrolls underneath — the one piece of context you always need on screen, whichever
 * process column you're currently looking at. */
/* border-collapse:collapse (the .sheet-table default) leaves a 1px seam of whatever's behind
 * a sticky cell peeking through as it scrolls under neighbouring columns — collapsed borders
 * are painted by the table itself, not the individual cell, and that painting model doesn't
 * account for a cell that's been visually repositioned by position:sticky. border-collapse
 * separate() gives each cell (including the sticky ones) its own fully self-contained border
 * box, which fixes it. */
.stock-report-table{font-size:12.5px;border-collapse:separate;border-spacing:0;}
.stock-report-table th,.stock-report-table td{padding:7px 12px;border-top:none;border-left:none;}
.stock-report-table thead th{text-align:center;border-top:1px solid var(--border);}
.stock-report-table tbody td:first-child{text-align:left;font-weight:600;}
.stock-report-table th:first-child,.stock-report-table td:first-child{border-left:1px solid var(--border);}
.stock-report-table th:first-child,.stock-report-table td:first-child{position:sticky;left:0;z-index:2;background:var(--surface);border-right:2px solid var(--border);}
.stock-report-table th:last-child,.stock-report-table td:last-child{position:sticky;right:0;z-index:2;background:var(--surface);border-left:2px solid var(--border);}
.stock-report-table thead th:first-child,.stock-report-table thead th:last-child{z-index:6;background:var(--surface-2);}
.stock-report-table tbody tr:nth-child(even) td:first-child,.stock-report-table tbody tr:nth-child(even) td:last-child{background:var(--surface-2);}
.stock-report-table tbody tr:hover td:first-child,.stock-report-table tbody tr:hover td:last-child{background:var(--primary-light);}
.stock-report-total-row td{background:var(--surface-2);font-size:13px;}
.stock-report-total-row td:first-child,.stock-report-total-row td:last-child{background:var(--surface-2);}
.stock-report-total-row .sr-cell-wt{color:var(--text-dim);font-weight:700;}
/* Round & Fancy matrix polish: a KPI strip (reusing the Dashboard's own kpi-card) for the
 * headline numbers, a soft per-shape-group tint so Round's and Fancy's columns read as one
 * report instead of two tables glued together, and the grand total called out on its own. */
.stock-report-summary{margin-bottom:14px;}
.stock-report-summary .kpi-val{font-size:21px;}
.stock-report-summary .kpi-card{cursor:default;}
.stock-report-summary .kpi-card:hover{transform:none;box-shadow:var(--shadow);}
.stock-report-toggle{display:flex;align-items:center;gap:7px;font-size:13px;color:var(--text-dim);cursor:pointer;margin-bottom:12px;user-select:none;}
.stock-report-toggle input{cursor:pointer;}
.stock-report-matrix .stk-round-col{background:rgba(64,84,224,0.05);}
.stock-report-matrix .stk-fancy-col{background:rgba(116,64,207,0.05);}
.stock-report-matrix tbody tr:nth-child(even) .stk-round-col{background:rgba(64,84,224,0.09);}
.stock-report-matrix tbody tr:nth-child(even) .stk-fancy-col{background:rgba(116,64,207,0.09);}
.stock-report-matrix tr.stock-report-total-row td.stk-round-col{background:rgba(64,84,224,0.14);}
.stock-report-matrix tr.stock-report-total-row td.stk-fancy-col{background:rgba(116,64,207,0.14);}
.stock-report-total-row td.stock-report-grand-total{background:var(--primary-light);border-left:2px solid var(--primary);}
.stock-report-grand-total .sr-cell b{color:var(--primary);font-size:15px;}
.stock-report-table .sr-cell{display:flex;flex-direction:column;align-items:flex-end;gap:1px;line-height:1.3;}
.stock-report-table .sr-cell b{font-size:13px;}
.stock-report-table .sr-cell-wt{font-size:10.5px;color:var(--text-dim);font-weight:500;}
.stock-report-table .sr-proc-badge{display:inline-block;padding:3px 9px;border-radius:20px;font-size:11.5px;font-weight:700;white-space:nowrap;}

.sheet-filter-pop{position:fixed;background:var(--surface);border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow-lg);width:250px;z-index:200;display:none;font-size:12.5px;}
.sheet-filter-pop.open{display:block;animation:dropdownin .12s var(--ease);}
.sheet-filter-pop .sfp-sort{padding:8px 12px;cursor:pointer;display:flex;align-items:center;gap:8px;transition:background .12s var(--ease);}
.sheet-filter-pop .sfp-sort:hover{background:var(--surface-2);}
.sheet-filter-pop .sfp-sep{height:1px;background:var(--border);margin:4px 0;}
.sheet-filter-pop .sfp-search{padding:6px 12px;}
.sheet-filter-pop .sfp-search input{width:100%;padding:6px 8px;border:1px solid var(--border);border-radius:6px;background:var(--surface-2);}
.sheet-filter-pop .sfp-selectbar{padding:6px 12px;display:flex;justify-content:space-between;color:var(--primary);font-weight:600;}
.sheet-filter-pop .sfp-selectbar span{cursor:pointer;}
.sheet-filter-pop .sfp-selectbar span:hover{text-decoration:underline;}
.sheet-filter-pop .sfp-list{max-height:200px;overflow-y:auto;padding:2px 8px;border-top:1px solid var(--border);border-bottom:1px solid var(--border);}
.sheet-filter-pop .sfp-list label{display:flex;align-items:center;gap:6px;padding:4px;cursor:pointer;border-radius:4px;}
.sheet-filter-pop .sfp-list label:hover{background:var(--surface-2);}
.sheet-filter-pop .sfp-count{padding:6px 4px 2px;color:var(--text-faint);font-size:11px;}
.sheet-filter-pop .sfp-foot{padding:8px 12px;display:flex;justify-content:flex-end;gap:8px;}
.active-filter-chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:10px;}

/* Modal */
.modal-backdrop{position:fixed;inset:0;background:rgba(10,14,26,.6);backdrop-filter:blur(2px);display:none;align-items:flex-start;justify-content:center;z-index:100;padding:40px 16px;overflow-y:auto;}
.modal-backdrop.open{display:flex;}
.modal{background:var(--surface);border-radius:var(--radius-lg);width:100%;max-width:560px;box-shadow:var(--shadow-lg);margin:auto;animation:modalin .18s var(--ease);}
.modal.wide{max-width:900px;}
.modal.xwide{max-width:1150px;}
@keyframes modalin{from{opacity:0;transform:translateY(-10px) scale(.98);}to{opacity:1;transform:none;}}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border);}
.modal-head h3{font-size:15.5px;font-weight:700;}
.modal-close{cursor:pointer;background:none;border:none;font-size:18px;color:var(--text-faint);border-radius:6px;padding:4px;transition:background .12s var(--ease),color .12s var(--ease);}
.modal-close:hover{background:var(--surface-2);color:var(--text);}
.modal-body{padding:20px;max-height:70vh;overflow-y:auto;}
.modal-foot{padding:14px 20px;border-top:1px solid var(--border);display:flex;justify-content:flex-end;gap:8px;}

.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;}
.form-field{display:flex;flex-direction:column;gap:5px;}
.form-field.full{grid-column:1/-1;}
.form-field label{font-size:11.5px;font-weight:700;color:var(--text-dim);letter-spacing:.1px;}
.form-field input,.form-field select,.form-field textarea{padding:8px 10px;border:1px solid var(--border);border-radius:7px;background:var(--surface-2);width:100%;transition:border-color .15s var(--ease),box-shadow .15s var(--ease);}
.form-field input:focus,.form-field select:focus,.form-field textarea:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-ring);background:var(--surface);}
.form-field textarea{resize:vertical;min-height:60px;}
.form-hint{font-size:11px;color:var(--text-faint);}
.checklist{display:flex;flex-wrap:wrap;gap:8px;}
.checklist label{display:flex;align-items:center;gap:5px;font-size:12px;background:var(--surface-2);padding:5px 9px;border-radius:6px;border:1px solid var(--border);cursor:pointer;}

/* Toast */
.toast-root{position:fixed;top:112px;right:20px;z-index:200;display:flex;flex-direction:column;gap:9px;}
.toast{background:var(--surface);border:1px solid var(--border);border-left:4px solid var(--primary);box-shadow:var(--shadow-lg);border-radius:9px;padding:12px 16px;min-width:260px;max-width:340px;font-size:13px;animation:toastin .22s var(--ease);}
.toast.success{border-left-color:var(--green);}
.toast.error{border-left-color:var(--red);}
.toast.warn{border-left-color:var(--orange);}
@keyframes toastin{from{opacity:0;transform:translateX(24px);}to{opacity:1;transform:none;}}
.toast .tt{font-weight:700;margin-bottom:2px;}

/* Smart issue */
.worker-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,190px));gap:14px;}
.ws-item .l{font-size:10.5px;color:var(--text-faint);text-transform:uppercase;font-weight:700;letter-spacing:.3px;}
.ws-item .v{font-size:15px;font-weight:700;margin-top:3px;}
.selection-bar{position:sticky;bottom:0;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-lg);padding:12px 16px;display:flex;align-items:center;gap:18px;flex-wrap:wrap;margin-top:14px;}
.selection-bar .sitem{font-size:12.5px;color:var(--text-dim);}
.selection-bar .sitem b{color:var(--text);font-size:14px;}
.reason-box{background:var(--red-bg);color:var(--red);border-radius:8px;padding:10px 12px;font-size:12.5px;margin:10px 0;}
.reason-box ul{margin:6px 0 0 18px;}
.worker-pick-list{max-height:280px;overflow-y:auto;border:1px solid var(--border);border-radius:8px;}
.worker-pick-item{padding:10px 12px;border-bottom:1px solid var(--border);cursor:pointer;display:flex;justify-content:space-between;align-items:center;gap:10px;transition:background .12s var(--ease);}
.worker-pick-item:hover{background:var(--surface-2);}
.worker-pick-item:last-child{border-bottom:none;}
/* A long employee name must never wrap the avatar row onto a second line — that made some
 * rows taller than others in an otherwise uniform list. Truncate instead, keep every row's
 * height identical, and never let the trailing badge/count column get squeezed. */
.worker-pick-item .row-flex{flex-wrap:nowrap;min-width:0;flex:1;}
.worker-pick-item .row-flex > div:last-child{min-width:0;overflow:hidden;}
.worker-pick-item .row-flex > div:last-child > div:first-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.worker-pick-item > div:last-child{flex-shrink:0;}

/* Grouped-row tables (still used by Rate & Priority) */
tr.ws-group-row td{background:var(--surface-2);font-weight:800;letter-spacing:.03em;font-size:11.5px;text-transform:uppercase;padding:8px 14px;}
td[data-group-toggle-row]{cursor:pointer;user-select:none;}
td[data-group-toggle-row]:hover{color:var(--primary);}
.ws-group-caret{display:inline-block;width:12px;color:var(--text-faint);}
.skill-metrics-note{font-size:11.5px;color:var(--text-faint);margin:2px 0 16px;}

/* Worker Skills — master/detail layout. Capped at a max-width instead of stretching edge to
 * edge on wide monitors — an unbounded 1fr right pane left the process table's Shapes & Sizes
 * column (the only flexible one) ballooning into a wide strip of dead space with its content
 * stranded on the left and the Edit button stranded on the right. */
.ws-shell{display:grid;grid-template-columns:320px minmax(0,1fr);gap:18px;align-items:start;}
@media (max-width:980px){ .ws-shell{grid-template-columns:1fr;} }
.ws-search{position:relative;}
.ws-search input{width:100%;padding:9px 12px 9px 34px;border:1px solid var(--border);border-radius:8px;background:var(--surface-2);font-size:12.5px;transition:border-color .15s var(--ease),box-shadow .15s var(--ease);}
.ws-search input:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-ring);background:var(--surface);}
.ws-search .ic{position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--text-faint);font-size:13px;}
.worker-pick-avatar{width:32px;height:32px;border-radius:50%;background:var(--primary-light);color:var(--primary);display:flex;align-items:center;justify-content:center;font-weight:800;font-size:12px;flex-shrink:0;}
.worker-pick-item.active-worker{background:var(--primary-light);box-shadow:inset 3px 0 0 var(--primary);}
.ws-detail-head h2{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.chip-toggle{padding:4px 10px;border-radius:14px;border:1px solid var(--border);background:var(--surface);font-size:10.5px;font-weight:600;cursor:pointer;color:var(--text-dim);transition:background .12s var(--ease),color .12s var(--ease),border-color .12s var(--ease);}
.chip-toggle.on{background:var(--primary-light);color:var(--primary);border-color:var(--primary);}
.proc-card-summary{font-size:11px;color:var(--text-dim);line-height:1.4;}
table.ws-skill-table tr.ws-row-expanded td{background:var(--primary-light);}
table.ws-skill-table tr.ws-detail-row td{background:var(--surface-2);padding:14px 16px;}
/* Fixed, proportioned columns (instead of auto-width) so Shapes & Sizes no longer swallows
 * almost every spare pixel, and a consistent per-row height (instead of whatever a plain text
 * label or a small button happen to need) so rows read as an even, level table rather than
 * hopping up and down as you scan down the Process column. */
table.ws-skill-table{table-layout:fixed;}
table.ws-skill-table th:nth-child(1),table.ws-skill-table td:nth-child(1){width:34%;}
table.ws-skill-table th:nth-child(2),table.ws-skill-table td:nth-child(2){width:16%;}
table.ws-skill-table th:nth-child(3),table.ws-skill-table td:nth-child(3){width:50%;}
table.ws-skill-table tbody td{height:44px;white-space:normal;}

/* Worker Skills — inline Shape chips, each with its size-range editor always shown beneath it
 * (no per-shape expand/collapse — see shapeChipBlockHtml) laid out as a grid so each shape's
 * block sits in its own cell. auto-fit + minmax(240px,1fr) divides the row's full width evenly
 * among however many shapes there are (no dead gutter left over on the right the way a fixed
 * max-width per block did), while the 240px floor still keeps a lone/leftover block from
 * stretching absurdly wide on its own row. align-items stays at the grid default (stretch,
 * not start) and .range-block below is flex:1, so every card in the same row shares the same
 * height and bottom edge — one shape wrapping an extra quick-fill chip onto a second line no
 * longer leaves it visually taller/shorter than its neighbors. */
.shapes-section{margin-top:4px;display:flex;flex-direction:column;gap:10px;white-space:normal;}
.shape-chips-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;}
.shape-chip-block{display:flex;flex-direction:column;gap:6px;}
.range-block{display:flex;flex-direction:column;gap:8px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:10px;flex:1;}
.range-rows{display:flex;flex-direction:column;gap:6px;}
.range-row{display:flex;align-items:center;gap:6px;}
.range-row input{width:70px;padding:5px 7px;border:1px solid var(--border);border-radius:6px;background:var(--surface-2);font-size:12px;}
.range-remove-btn{width:22px;height:22px;border-radius:6px;border:1px solid var(--border);background:var(--surface-2);color:var(--text-faint);cursor:pointer;font-size:11px;line-height:1;flex-shrink:0;transition:border-color .12s var(--ease),color .12s var(--ease);}
.range-remove-btn:hover{border-color:var(--red);color:var(--red);}
.range-quickfill{display:flex;flex-wrap:wrap;gap:6px;align-items:center;}

/* Rule builder */
.rule-block{background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius);padding:14px;margin-bottom:12px;}
.rule-block .rtitle{font-weight:700;font-size:13px;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center;}
.switch{position:relative;display:inline-block;width:40px;height:22px;flex-shrink:0;}
.switch input{opacity:0;width:0;height:0;}
.slider{position:absolute;cursor:pointer;inset:0;background:var(--border-strong);border-radius:22px;transition:background .15s var(--ease);}
.slider:before{content:"";position:absolute;width:16px;height:16px;left:3px;bottom:3px;background:#fff;border-radius:50%;transition:transform .15s var(--ease);box-shadow:0 1px 3px rgba(0,0,0,.25);}
input:checked + .slider{background:var(--primary);}
input:checked + .slider:before{transform:translateX(18px);}
.row-flex{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}

.small-muted{color:var(--text-faint);font-size:11.5px;}
.divider{height:1px;background:var(--border);margin:16px 0;}
.section-title{font-size:14px;font-weight:700;margin-bottom:10px;letter-spacing:-.005em;}
.two-col{display:grid;grid-template-columns:1fr 1fr;gap:18px;}
.hidden{display:none !important;}
.pill-tabs{display:flex;gap:6px;background:var(--surface-2);padding:4px;border-radius:9px;width:fit-content;margin-bottom:14px;}
.pill-tabs .pt{padding:6px 14px;border-radius:7px;font-size:12.5px;font-weight:600;cursor:pointer;color:var(--text-dim);transition:background .12s var(--ease),color .12s var(--ease),box-shadow .12s var(--ease);}
.pill-tabs .pt.active{background:var(--surface);color:var(--primary);box-shadow:var(--shadow);}
.stat-inline{display:flex;gap:18px;flex-wrap:wrap;margin:10px 0;}
.stat-inline .si{background:var(--surface-2);padding:8px 14px;border-radius:8px;font-size:12px;}
.stat-inline .si b{display:block;font-size:16px;}
.link-btn{background:none;border:none;color:var(--primary);cursor:pointer;font-weight:600;font-size:12.5px;padding:0;}
.link-btn:hover{text-decoration:underline;}
.upload-drop{border:2px dashed var(--border);border-radius:var(--radius);padding:30px;text-align:center;color:var(--text-dim);cursor:pointer;transition:border-color .15s var(--ease),color .15s var(--ease),background .15s var(--ease);}
.upload-drop:hover{border-color:var(--primary);color:var(--primary);background:var(--primary-light);}
.map-row{display:grid;grid-template-columns:1fr 30px 1fr;gap:8px;align-items:center;margin-bottom:8px;font-size:12.5px;}

@media (max-width:1100px){
  .kpi-grid{grid-template-columns:repeat(2,1fr);}
  .charts-grid{grid-template-columns:1fr;}
  .two-col{grid-template-columns:1fr;}
}
@media (max-width:840px){
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0);}
  .main{margin-left:0;}
  .hamburger{display:block;}
  .form-grid{grid-template-columns:1fr;}
  .top-datetime{display:none;}
}
