/* ==========================================================================
   Flow - glossy theme
   ========================================================================== */
:root {
  --ink: #16213a;
  --ink-2: #44506a;
  --muted: #6b7792;
  --bg: #eef2f9;
  --bg-2: #e3e9f4;
  --panel: #ffffff;
  --line: #dde4ef;
  --line-2: #eef2f8;
  --head: #f2f6fc;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --scan: #fff8e1;
  --ok: #0f8a5f;    --ok-bg: #e2f6ee;
  --warn: #a15c00;  --warn-bg: #fff1d6;
  --bad: #c0262d;   --bad-bg: #fde6e7;
  --info: #1e4fd1;  --info-bg: #e3ecff;
  --sb-w: 248px;
  --sb-w-c: 76px;
  --radius: 14px;
  --shadow-1: 0 1px 2px rgba(18, 32, 72, .06), 0 4px 14px rgba(18, 32, 72, .07);
  --shadow-2: 0 2px 4px rgba(18, 32, 72, .08), 0 14px 34px rgba(18, 32, 72, .12);
  --gloss: linear-gradient(180deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,.12) 48%, rgba(255,255,255,0) 50%);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
/* named accent colours (used by icons, quick actions and KPI cards) */
.c-blue   { --c1: #5b9bff; --c2: #2563eb; --c3: #1e40af; }
.c-green  { --c1: #34d399; --c2: #059669; --c3: #065f46; }
.c-teal   { --c1: #2dd4bf; --c2: #0d9488; --c3: #115e59; }
.c-violet { --c1: #a78bfa; --c2: #7c3aed; --c3: #5b21b6; }
.c-amber  { --c1: #fbbf24; --c2: #d97706; --c3: #92400e; }
.c-rose   { --c1: #fb7185; --c2: #e11d48; --c3: #9f1239; }
.c-indigo { --c1: #818cf8; --c2: #4f46e5; --c3: #3730a3; }
.c-cyan   { --c1: #22d3ee; --c2: #0891b2; --c3: #155e75; }
.c-slate  { --c1: #94a3b8; --c2: #475569; --c3: #1e293b; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: radial-gradient(1200px 600px at 100% -10%, #dfe8ff 0%, rgba(223,232,255,0) 60%), var(--bg); min-height: 100vh; }
a { color: var(--accent); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* ---------- Logo ---------- */
.logo-cube { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--gloss), linear-gradient(160deg, #6aa5ff, #2350d8 60%, #1a3aa6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 4px 12px rgba(37, 99, 235, .45); }

/* ---------- Company logo (white PNG used as a mask, filled with the theme gradient) ---------- */
.brand-logo { display: block; flex: 0 0 auto; aspect-ratio: 969 / 144;
  -webkit-mask: url(/img/logo.png) center / contain no-repeat; mask: url(/img/logo.png) center / contain no-repeat;
  background: linear-gradient(90deg, #13245e 0%, #1d4ed8 55%, #4f8dff 100%); }
.top-logo { height: 24px; background: #000; }
.login-brand { width: 100%; max-width: 300px; justify-self: center; margin: 0 auto 4px; }

/* ---------- Footer ---------- */
.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 22px;
  background: #fff; border-top: 1px solid var(--line); color: #5b6577; font-size: 13px; }
.app-footer .powered { display: inline-flex; align-items: center; gap: 12px; }
.foot-logo { height: 20px; background: linear-gradient(90deg, #2b2f36, #2b2f36); }
/* ==========================================================================
   Login: dark 3D-cube background, smoked-glass card with orange accents
   ========================================================================== */
.login { --orange-1: #ffb03a; --orange-2: #ff7a00; --orange-3: #c95700;
  min-height: 100vh; display: grid; place-items: center; padding: 16px 16px 76px; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(20,20,20,.15) 0%, rgba(10,10,10,.55) 100%), url(/img/login-bg.jpg) center / cover no-repeat, #232323; }
.login-card { position: relative; width: 100%; max-width: 390px; padding: 30px; border-radius: 20px; display: grid; gap: 14px; color: #f2f2f2;
  background: linear-gradient(160deg, rgba(48,48,48,.72), rgba(18,18,18,.78)); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255,255,255,.1); border-top-color: rgba(255,255,255,.18);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); }
.login-card::before { content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, var(--orange-2), var(--orange-1), transparent); }
.login .login-brand { background: linear-gradient(90deg, #ffffff 0%, #ffffff 45%, var(--orange-1) 75%, var(--orange-2) 100%); }
.login-logo { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.login-logo .logo-cube { width: 50px; height: 50px; border-radius: 14px;
  background: var(--gloss), linear-gradient(160deg, var(--orange-1), var(--orange-2) 60%, var(--orange-3)); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 4px 14px rgba(255,122,0,.45); }
.login-logo h1 { margin: 0; font-size: 20px; color: #fff; }
.login-logo p { margin: 2px 0 0; color: #b5b5b5; }
.login-card label { color: #d0d0d0; }
.login-card input { background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 1px 3px rgba(0,0,0,.4); }
.login-card input:focus { border-color: var(--orange-2); box-shadow: 0 0 0 4px rgba(255,122,0,.22), inset 0 1px 3px rgba(0,0,0,.4); }
.login-card input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 40px #1e1e1e inset; caret-color: #fff; }
.login .btn.primary { --b1: var(--orange-1); --b2: var(--orange-2); --b3: var(--orange-3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 3px 0 var(--b3), 0 10px 22px rgba(255,122,0,.35); }
.login-error { color: #ff8a80; min-height: 1em; font-weight: 600; }
/* footer on the sign-in page: all white */
.login-footer { position: absolute; left: 0; right: 0; bottom: 0; color: #fff; background: rgba(0,0,0,.45); border-top: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.login-footer .foot-logo { background: #fff; }

/* ==========================================================================
   Shell: sidebar + main column
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
body.sb-collapsed .shell { grid-template-columns: var(--sb-w-c) minmax(0, 1fr); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; z-index: 40;
  background: linear-gradient(180deg, #13245e 0%, #0d1a47 55%, #0a1338 100%); color: #c9d5f5;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.06), 6px 0 24px rgba(10, 20, 60, .18); }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 14px 16px 8px; text-decoration: none; color: #fff; }
.sb-brand-text { display: grid; min-width: 0; }
.sb-brand-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text small { font-size: 11px; color: #8fa3d9; letter-spacing: .04em; text-transform: uppercase; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 10px; scrollbar-width: thin; scrollbar-color: #2a3c78 transparent; }
.sb-group { margin-top: 6px; }
.sb-title { font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #6f82bd; padding: 4px 10px 3px; white-space: nowrap; }
.sb-link { display: flex; align-items: center; gap: 11px; padding: 4px 8px; margin: 1px 0; border-radius: 11px; color: #d4defa; text-decoration: none;
  font-weight: 400; white-space: nowrap; position: relative; transition: background .15s, transform .15s; }
.sb-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-link.active { color: #fff; background: linear-gradient(90deg, rgba(91,155,255,.32), rgba(91,155,255,.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 4px 14px rgba(0,0,0,.18); }
.sb-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(#7fb0ff, #3b82f6); box-shadow: 0 0 10px #4f8dff; }
.sb-ic { width: 29px; height: 29px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--c2); }
.sb-ic svg { width: 16px; height: 16px; }
.sb-label { overflow: hidden; text-overflow: ellipsis; }
.sb-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #fb7185, #e11d48); box-shadow: 0 0 0 2px #0d1a47, 0 2px 6px rgba(225,29,72,.5); }
body.sb-collapsed .sb-badge { position: absolute; top: 0; right: 10px; min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; margin: 0; }
@media (max-width: 1100px) and (min-width: 769px) { .sb-badge { position: absolute; top: 0; right: 10px; min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; margin: 0; } }

/* notification bell */
.notif-menu { position: relative; }
.bell-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  border: 1px solid var(--line); background: linear-gradient(180deg, #fff, #f1f5fc); box-shadow: inset 0 1px 0 #fff, 0 2px 0 #d8e0ee; }
.bell-btn:hover { color: var(--accent); }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 800; color: #fff; background: linear-gradient(180deg, #fb7185, #e11d48); box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(225,29,72,.45); }
.notif-drop { width: min(380px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.notif-head button { padding: 4px 8px !important; font-size: 12px; color: var(--accent) !important; font-weight: 600; }
.notif-list { max-height: 60vh; overflow-y: auto; padding: 4px; }
.notif { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; position: relative; }
.notif:hover { background: var(--head); }
.notif.unread { background: #eef4ff; }
.notif.unread::after { content: ""; position: absolute; right: 10px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.notif .dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: var(--gloss), linear-gradient(160deg, var(--c1), var(--c2)); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 2px 0 var(--c3); }
.notif .dot svg { width: 16px; height: 16px; }
.notif .nt { display: grid; gap: 2px; min-width: 0; padding-right: 14px; }
.notif .nt b { font-size: 13px; }
.notif .nt small { color: var(--ink-2); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif .nt em { color: var(--muted); font-size: 11px; font-style: normal; }
.notif-foot { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--line-2); font-weight: 600; text-decoration: none; }
.notif-foot:hover { background: var(--head); }
@media (max-width: 768px) { .bell-btn { width: 36px; height: 36px; } .notif-drop { position: fixed; right: 12px; top: 56px; } }

/* receive: serial number grid */
.receive-split { display: grid; grid-template-columns: minmax(300px, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
@media (max-width: 1250px) { .receive-split { grid-template-columns: minmax(0, 1fr); } }
.sn-head { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px 14px; align-items: end; margin-bottom: 12px; }
.sn-head .check { grid-column: span 1; }
.sn-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.sn-bar { flex: 0 0 160px; height: 8px; border-radius: 4px; background: #e6ebf3; overflow: hidden; }
.sn-bar span { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #34d399, #059669); transition: width .2s; }
.sn-grid { max-height: 420px; }
.sn-grid td { padding: 4px 6px; }
.sn-grid .sn-in { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; padding: 6px 8px; background: #fffdf3; border-color: #e5d7a8; }
.sn-grid .sn-in:focus { background: #fff; }
.sn-grid select { padding: 6px 8px; }
.sn-grid tr.sn-ok td { background: #f2fbf6 !important; }
.sn-grid tr.sn-bad td { background: var(--bad-bg) !important; }
.sn-grid tr.sn-bad .sn-in { border-color: #e7a3a7; }
.sn-grid .sn-in { min-width: 140px; }
.sn-st { min-width: 24px; max-width: 220px; font-size: 12px; line-height: 1.3; }
.sn-tick { color: var(--ok); font-weight: 800; }
.sn-msg { color: var(--bad); font-weight: 600; }
.sn-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sn-help { margin: 8px 0 0; }
@media (max-width: 600px) { .sn-head { grid-template-columns: 1fr 1fr; } .sn-st { min-width: 0; } }

/* stock requests */
.req-pri { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.req-pri.low { background: #edf0f5; color: #586379; }
.req-pri.normal { background: var(--info-bg); color: var(--info); }
.req-pri.high { background: var(--warn-bg); color: var(--warn); }
.req-pri.urgent { background: var(--bad-bg); color: var(--bad); }
.req-lines td input { width: 90px; text-align: right; }
.timeline { display: grid; gap: 10px; margin: 6px 0 12px; }
.tl { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.tl .who { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700;
  background: var(--gloss), linear-gradient(160deg, #a78bfa, #6d28d9); }
.tl.status .who { background: var(--gloss), linear-gradient(160deg, #5b9bff, #1f5ae0); }
.tl .bubble { background: var(--head); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.tl.status .bubble { background: #fff; border-style: dashed; }
.tl .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.tl .text { white-space: pre-wrap; word-break: break-word; }
.req-new-line { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 90px 36px; gap: 8px; align-items: end; margin-bottom: 8px; }
@media (max-width: 600px) { .req-new-line { grid-template-columns: 1fr 80px 36px; } .req-new-line .desc { grid-column: 1 / -1; order: 5; } }
.sb-foot { padding: 6px 10px 10px; border-top: 1px solid rgba(255,255,255,.07); }
.sb-collapse { width: 100%; display: flex; align-items: center; gap: 11px; padding: 5px 8px; border: 0; border-radius: 10px; background: transparent; color: #8fa3d9; cursor: pointer; font: inherit; }
.sb-collapse > span:first-child { width: 32px; text-align: center; font-size: 16px; transition: transform .2s; }
.sb-collapse:hover { background: rgba(255,255,255,.07); color: #fff; }
body.sb-collapsed .sb-label, body.sb-collapsed .sb-brand-text, body.sb-collapsed .sb-title { display: none; }
body.sb-collapsed .sb-title + .sb-link, body.sb-collapsed .sb-group { margin-top: 6px; }
body.sb-collapsed .sb-link, body.sb-collapsed .sb-collapse { justify-content: center; }
body.sb-collapsed .sb-brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sb-collapsed .sb-collapse > span:first-child { transform: rotate(180deg); }
.scrim { display: none; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 10px 22px;
  background: rgba(255,255,255,.78); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid rgba(210, 220, 236, .8); }
.icon-btn { display: none; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: #fff; font-size: 18px; cursor: pointer; box-shadow: 0 2px 0 #d3dceb; }
.sr-switch { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border-radius: 999px; background: linear-gradient(180deg, #fff, #f1f5fc);
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 #fff, 0 2px 0 #d8e0ee, 0 4px 10px rgba(18, 32, 72, .06); }
.sr-dot { width: 9px; height: 9px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.sr-switch select { border: 0; background: transparent; font-weight: 600; padding: 5px 4px; max-width: 300px; outline: none; cursor: pointer; }
.spacer { flex: 1; }
.today { color: var(--muted); font-size: 13px; white-space: nowrap; }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font: inherit; color: var(--ink);
  background: linear-gradient(180deg, #fff, #f1f5fc); box-shadow: inset 0 1px 0 #fff, 0 2px 0 #d8e0ee; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px;
  background: var(--gloss), linear-gradient(160deg, #a78bfa, #6d28d9); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.uname { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: 11px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; color: var(--ink); border-radius: 14px; box-shadow: var(--shadow-2); min-width: 220px; padding: 6px; display: grid; z-index: 50; border: 1px solid var(--line); }
.drop-head { padding: 10px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; display: grid; }
.drop-head small { color: var(--muted); }
.dropdown a, .dropdown button { text-align: left; padding: 9px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--head); }

/* ---------- 3D document tabs ---------- */
.tabbar { display: flex; align-items: flex-end; gap: 6px; padding: 12px 22px 0; min-width: 0; }
.tabstrip { flex: 1 1 auto; min-width: 0; display: flex; gap: 5px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding-top: 3px; }
.tabstrip::-webkit-scrollbar { display: none; }
.tab-arrow { display: none; flex: 0 0 auto; width: 28px; height: 32px; margin-bottom: 3px; border-radius: 9px; border: 1px solid #cfd9ea; cursor: pointer; font-size: 18px; line-height: 1; color: var(--ink-2);
  background: linear-gradient(180deg, #fff, #e8eef8); box-shadow: inset 0 1px 0 #fff, 0 2px 0 #cfd9ea; }
.tab-arrow:disabled { opacity: .35; cursor: default; }
.tabbar.overflow .tab-arrow { display: block; }
.tab { flex: 0 1 auto; min-width: 124px; max-width: 220px; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; cursor: pointer; white-space: nowrap; user-select: none; font-size: 13px; font-weight: 600; color: var(--ink-2);
  border-radius: 12px 12px 0 0; border: 1px solid #cfd9ea; border-bottom: 0; position: relative; top: 1px;
  background: linear-gradient(180deg, #ffffff 0%, #e8eef8 100%); box-shadow: inset 0 1px 0 #fff, 0 -2px 6px rgba(18,32,72,.04); transition: transform .12s; }
.tab:hover { transform: translateY(-1px); color: var(--ink); }
.tab.active { color: #fff; border-color: #1d4ed8; transform: translateY(-2px);
  background: var(--gloss), linear-gradient(180deg, #5b9bff 0%, #2563eb 60%, #1d4ed8 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 6px 14px rgba(37, 99, 235, .35); text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.tab .t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tab.active { flex-shrink: 0; max-width: 260px; }
.tab .x { flex: 0 0 auto; border: 0; background: rgba(0,0,0,.06); cursor: pointer; color: inherit; font-size: 11px; line-height: 1; padding: 3px 5px; border-radius: 6px; }
.tab.active .x { background: rgba(255,255,255,.2); }
.tab .x:hover { background: rgba(0,0,0,.15); }

main { padding: 0 22px 28px; flex: 1; }
.view { width: 100%; padding-top: 18px; border-top: 1px solid #cfd9ea; }

/* ==========================================================================
   Panels, forms, buttons
   ========================================================================== */
.panel { background: var(--panel); border: 1px solid rgba(214, 223, 238, .9); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-1); margin-bottom: 16px; }
.panel.tight { padding: 12px 14px; }
.panel[style*="background:#dce9f7"], .panel[style*="background: #dce9f7"] { background: linear-gradient(180deg, #f3f7ff, #e6efff) !important; border-color: #c9d8f5; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2, .panel-head h1 { margin: 0; }
.panel-head .spacer { flex: 1; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }
.step { font-weight: 700; color: var(--accent-2); margin: 2px 0 12px; display: flex; align-items: center; gap: 8px; }
.step::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(#5b9bff, #1d4ed8); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

label { display: grid; gap: 5px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--ink); padding: 8px 11px; border: 1px solid #c8d3e5; border-radius: 10px; background: linear-gradient(180deg, #fbfcff, #fff); min-width: 0; width: 100%;
  box-shadow: inset 0 1px 2px rgba(18,32,72,.06); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #4f8dff; box-shadow: 0 0 0 4px rgba(79,141,255,.18), inset 0 1px 2px rgba(18,32,72,.06); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); box-shadow: none; }
textarea { min-height: 64px; resize: vertical; }
input.scan { background: linear-gradient(180deg, #fffdf3, #fff6d9); border-color: #ecd48b; font-family: "Cascadia Mono", Consolas, monospace; }
input.count { background: linear-gradient(180deg, #fffdf3, #fff6d9); border-color: #ecd48b; text-align: right; width: 84px; }
input:disabled, select:disabled, textarea:disabled { background: #f1f4f9; color: #6b7792; }
.check { display: flex; align-items: center; gap: 7px; font-weight: 500; color: var(--ink); font-size: 13px; }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.split-wide { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }

/* 3D glossy buttons */
.btn { --b1: #ffffff; --b2: #e9eff8; --b3: #c3cfe2; --bt: var(--ink);
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border-radius: 11px; cursor: pointer;
  white-space: nowrap; text-decoration: none; color: var(--bt); border: 1px solid var(--b3); position: relative; top: 0;
  background: var(--gloss), linear-gradient(180deg, var(--b1), var(--b2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75), 0 3px 0 var(--b3), 0 6px 14px rgba(18,32,72,.12);
  transition: top .08s, box-shadow .08s, filter .15s; }
.btn:hover { filter: brightness(1.04) saturate(1.05); }
.btn:active { top: 2px; box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 1px 0 var(--b3), 0 2px 6px rgba(18,32,72,.12); }
.btn:disabled { opacity: .55; cursor: not-allowed; top: 0; }
.btn.primary { --b1: #5b9bff; --b2: #1f5ae0; --b3: #173f9e; --bt: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.25); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 3px 0 var(--b3), 0 8px 18px rgba(37,99,235,.35); }
.btn.danger { --b1: #fff5f5; --b2: #ffe1e3; --b3: #eaa9ad; --bt: var(--bad); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 9px; }
.btn.lg { padding: 11px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.hero { position: relative; overflow: hidden; border-radius: 14px; padding: 10px 14px 10px 18px; margin-bottom: 14px; color: #fff;
  background: radial-gradient(600px 300px at 90% -20%, rgba(167,139,250,.55), transparent 60%),
              radial-gradient(500px 260px at 10% 130%, rgba(34,211,238,.45), transparent 60%),
              linear-gradient(120deg, #0f1f5c 0%, #1e3fa8 55%, #3a6cf0 100%);
  box-shadow: 0 6px 16px rgba(20, 40, 120, .22), inset 0 1px 0 rgba(255,255,255,.2); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hero::after { content: ""; position: absolute; inset: 0 0 50% 0; background: linear-gradient(180deg, rgba(255,255,255,.12), transparent); pointer-events: none; }
.hero-text { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.hero h1 { color: #fff; margin: 0 6px 0 0; font-size: 16px; font-weight: 700; white-space: nowrap; }
.hero p { margin: 0; color: #c9d7ff; }
.hero .chip-sr { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-actions .btn svg { width: 15px; height: 15px; }
.hero-actions .btn { --b1: #ffffff; --b2: #e3ebff; --b3: #9db4f0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; border-radius: 16px; padding: 16px 16px 14px; text-decoration: none; color: #fff; min-height: 104px;
  background: var(--gloss), linear-gradient(150deg, var(--c1) 0%, var(--c2) 60%, var(--c3) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 4px 0 var(--c3), 0 12px 24px rgba(18,32,72,.18); transition: transform .15s, box-shadow .15s; }
.kpi:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 7px 0 var(--c3), 0 18px 30px rgba(18,32,72,.22); }
.kpi .v { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; text-shadow: 0 2px 6px rgba(0,0,0,.18); }
.kpi .l { font-size: 12.5px; opacity: .92; font-weight: 600; margin-top: 4px; }
.kpi .kpi-ic { position: absolute; right: 12px; top: 12px; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.2); box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.kpi .kpi-ic svg { width: 20px; height: 20px; }
.kpi .flag { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.22); }

.dash-grid { display: grid; gap: 16px; }
.dash-grid > .panel { margin-bottom: 0; }
.dash-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: #e8edf5; stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: url(#barGrad); transition: opacity .12s; }
.chart .bar:hover, .chart .hit:hover + .bar { opacity: .8; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip { position: absolute; pointer-events: none; background: #13213f; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: 0 6px 16px rgba(0,0,0,.25); opacity: 0; transition: opacity .1s; }
.chart-tip.show { opacity: 1; }
.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 140px) minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 600; }
.hbar .track { height: 12px; border-radius: 6px; background: #edf1f8; overflow: hidden; box-shadow: inset 0 1px 2px rgba(18,32,72,.08); }
.hbar .fill { height: 100%; border-radius: 6px; background: linear-gradient(180deg, #7cb0ff, #2563eb); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); min-width: 4px; }
.hbar .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.feed { display: grid; gap: 2px; }
.feed-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 10px; }
.feed-item:hover { background: var(--head); }
.feed-item .dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: var(--gloss), linear-gradient(160deg, var(--c1), var(--c2)); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 2px 0 var(--c3); }
.feed-item .dot svg { width: 16px; height: 16px; }
.feed-item .t { min-width: 0; }
.feed-item .t b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .t small { color: var(--muted); }
.feed-item .q { font-weight: 800; font-variant-numeric: tabular-nums; }
.q-pos { color: var(--ok); } .q-neg { color: var(--bad); }

.meter { height: 8px; border-radius: 4px; background: #f1e3e4; overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(180deg, #fb7185, #e11d48); }

/* legacy tiles (reports picker) */
.tiles { display: grid; gap: 8px; }
.tile { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 11px; color: var(--ink); text-decoration: none; font-weight: 600;
  background: linear-gradient(180deg, #ffffff, #eef3fb); border: 1px solid var(--line); box-shadow: inset 0 1px 0 #fff, 0 2px 0 #d5deec; position: relative; top: 0; transition: top .08s; }
.tile:hover { border-color: #9cbcf5; }
.tile:active { top: 2px; box-shadow: inset 0 1px 0 #fff; }

/* ==========================================================================
   Tables & data display
   ========================================================================== */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.table-wrap.tall { max-height: 62vh; }
.table-wrap.mid { max-height: 400px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th { background: linear-gradient(180deg, #f7f9fd, #ecf1f9); text-align: left; font-weight: 700; color: var(--ink-2); padding: 9px 11px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td { padding: 8px 11px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: #fafcff; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef4ff; }
tr.selected td { background: #dce9ff !important; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.var-pos { color: var(--ok); font-weight: 700; }
td.var-neg { color: var(--bad); font-weight: 700; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--info-bg); color: var(--info); white-space: nowrap; box-shadow: inset 0 1px 0 rgba(255,255,255,.6); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.grey { background: #edf0f5; color: #586379; }

.notice { padding: 11px 14px; border-radius: 12px; background: var(--info-bg); margin-bottom: 14px; border: 1px solid #c9d8fb; }
.notice.warn { background: var(--warn-bg); border-color: #f2d49a; }
.notice.bad { background: var(--bad-bg); border-color: #f2b5b8; }
.notice.ok { background: var(--ok-bg); border-color: #a9e0c8; }

.serial-box { border: 1px solid var(--line); border-radius: 12px; max-height: 230px; overflow: auto; background: #fff; }
.serial-box label { display: flex; flex-direction: row; align-items: center; gap: 9px; padding: 7px 11px; border-bottom: 1px solid var(--line-2); color: var(--ink); font-weight: 500; font-size: 13px; cursor: pointer; }
.serial-box label:hover { background: #f2f7ff; }
.serial-box .empty { padding: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--head); border: 1px solid var(--line); font-size: 12px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; }

.scan-log { max-height: 170px; overflow: auto; font-size: 12px; display: grid; gap: 4px; margin-top: 8px; }
.scan-log div { padding: 5px 9px; border-radius: 8px; }
.scan-log .found { background: var(--ok-bg); }
.scan-log .moved, .scan-log .unexpected { background: var(--warn-bg); }
.scan-log .unknown, .scan-log .error { background: var(--bad-bg); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 12px; font-weight: 600; }
dl.facts dd { margin: 0; }

/* ==========================================================================
   Modals & toasts
   ========================================================================== */
.modal-back { position: fixed; inset: 0; background: rgba(10, 18, 45, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 540px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(5,12,40,.35); animation: rise .18s ease-out; overflow: hidden; }
.modal.wide { max-width: 900px; }
.modal-head { padding: 15px 20px; display: flex; align-items: center; color: #fff;
  background: var(--gloss), linear-gradient(120deg, #1e3fa8, #3a6cf0); }
.modal-head h2 { margin: 0; flex: 1; color: #fff; }
.modal-head .btn { color: #fff; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; background: #f8fafd; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 16px; border-radius: 12px; background: linear-gradient(180deg, #2a3a5e, #1b2742); color: #fff; box-shadow: 0 10px 26px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.15); animation: rise .18s ease-out; font-weight: 500; }
.toast.ok { background: linear-gradient(180deg, #17a36d, #0d7a51); }
.toast.bad { background: linear-gradient(180deg, #e2434a, #b0202a); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.sigpad { border: 2px dashed #9bb3dd; border-radius: 12px; background: #fbfdff; touch-action: none; width: 100%; height: 190px; display: block; }
.cam video { width: 100%; border-radius: 12px; background: #000; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 520px) {
  .top-logo { display: none; }
}
@media (max-width: 1200px) {
  .dash-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) and (min-width: 769px) {
  /* tablets: icon-only sidebar */
  .shell { grid-template-columns: var(--sb-w-c) minmax(0, 1fr); }
  .sb-label, .sb-brand-text, .sb-title { display: none; }
  .sb-link, .sb-collapse { justify-content: center; }
  .sb-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .sb-collapse { display: none; }
  .today { display: none; }
}
@media (max-width: 960px) {
  .split, .split-wide, .dash-grid, .dash-grid.three { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  /* phones: off-canvas sidebar */
  .shell, body.sb-collapsed .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-105%); transition: transform .22s ease; }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,18,45,.45); z-index: 35; }
  body.sb-collapsed .sb-label, body.sb-collapsed .sb-brand-text, body.sb-collapsed .sb-title { display: revert; }
  body.sb-collapsed .sb-link { justify-content: flex-start; }
  .sb-collapse { display: none; }
  .icon-btn { display: grid; place-items: center; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .today, .uname, .caret { display: none; }
  .top-logo { height: 16px; }
  .app-footer { padding: 10px 12px; font-size: 12px; justify-content: center; text-align: center; }
  .foot-logo { height: 16px; }
  .user-chip { padding: 3px; }
  .sr-switch select { max-width: 52vw; }
  .tabbar { padding: 10px 12px 0; }
  .tabbar.overflow .tab-arrow { display: none; }
  .tab { min-width: 84px; max-width: 160px; }
  main { padding: 0 12px 20px; }
  .hero { padding: 10px 12px; }
  .hero-actions { margin-left: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .v { font-size: 24px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .panel { padding: 14px; }
}
