* { box-sizing: border-box }
:root { --brand:#0d6efd; --bg:#f7f7fb; --text:#222; --muted:#667085; --card:#fff; --ok:#0a7d29; --danger:#d92d20 }
html { height: 100%; }
body.scanner-app { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display:grid; grid-template-rows: auto 1fr; }
body { font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Arial,sans-serif; margin:0; background:var(--bg); color:var(--text) }
header { position: fixed; top: 0; left: 0; right: 0; z-index: 100; display:flex; align-items:center; justify-content:space-between; padding:12px 16px; background:var(--brand); color:#fff }
/* Make header action links visible on brand background */
header .link { color:#fff; border:1px solid rgba(255,255,255,.6); padding:6px 10px; border-radius:10px; font-weight:700 }
header .link:hover { background: rgba(255,255,255,.12) }
.logo { width:22px; height:22px; vertical-align:middle; margin-right:8px }
/* Ensure hidden attribute always hides */
[hidden] { display:none !important }
h1 { font-size:18px; margin:0 }
body.scanner-app main { position: fixed; top: var(--header-h, 60px); left:0; right:0; bottom: 0; padding:16px 16px 96px 16px; display:grid; grid-template-rows: auto 1fr; gap:16px; overflow:hidden }
.scan { z-index: 10; }
.scan,.list { background:var(--card); border-radius:12px; padding:16px; box-shadow:0 1px 3px rgba(0,0,0,.08) }
.list { overflow-y: auto; min-height: 0; padding-bottom: 96px; -webkit-overflow-scrolling: touch }

/* Hero */
.hero { 
  display:grid; 
  place-items:center; 
  text-align:center; 
  padding:28px 16px; 
  margin: 4px 0 8px 0;
  background: linear-gradient(180deg, rgba(13,110,253,.08), rgba(13,110,253,.02));
  border: 1px solid rgba(13,110,253,.12);
  border-radius:16px; 
  box-shadow: 0 6px 18px rgba(13,110,253,.10);
}
.hero-badge {
  display:inline-flex; align-items:center; gap:8px; 
  padding:6px 10px; border-radius:999px; 
  background: rgba(13,110,253,.12); color: var(--brand);
  font-weight:700; font-size:12px;
  margin-bottom:10px;
}
.hero-badge .icon { width:16px; height:16px }
.hero-title { font-size:24px; font-weight:800; margin:4px 0 4px 0 }
.hero-sub { color:var(--muted); font-size:14px; margin:0 }
@media (min-width: 520px) {
  .hero-title { font-size:26px }
}

/* Buttons */
button { padding:12px 16px; border:none; border-radius:10px; background:var(--brand); color:#fff; cursor:pointer; font-weight:600 }
button:disabled { opacity:.6; cursor:not-allowed }
.link { background:transparent; color:var(--brand); padding:6px 8px }
.link.danger { color:var(--danger) }
.icon-btn { background:transparent; border:none; padding:8px; border-radius:10px; color:var(--danger); display:inline-flex; align-items:center; justify-content:center }
.icon-btn:hover { background:rgba(217,45,32,.08) }
.icon { width:20px; height:20px; display:block }

/* Table */
table { width:100%; border-collapse:separate; border-spacing:0 6px }
thead th { font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); text-align:left; padding:0 8px }
tbody tr { background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.05) }
tbody td { padding:10px 8px; border-bottom:1px solid #f0f0f0 }
tbody tr:last-child td { border-bottom:none }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace }

/* Smaller monospace text in table cells (barcode + NC) and allow breaking to avoid overflow */
.list td.mono { font-size:12px; overflow-wrap:anywhere }
@media (min-width: 480px) { .list td.mono { font-size:13px } }

/* Product name (separate row) in items list */
.product-sub { display:block; color:var(--muted); font-size:10px; margin:0 }
.item-name-row td { padding:6px 8px }

.actions { margin-top:12px; display:flex; gap:8px; align-items:center; flex-wrap:wrap }

/* Text input for filename */
.text-input { flex:1; min-width:0; padding:10px 12px; border:1px solid #d0d5dd; border-radius:10px; font-size:16px }
.text-input:focus { outline:none; border-color:#98a2b3; box-shadow:0 0 0 3px rgba(13,110,253,.12) }

/* Toasts */
#toastContainer { position:fixed; left:50%; transform:translateX(-50%); bottom:90px; z-index:2500; display:grid; gap:8px; width:min(92vw, 420px); padding:0 8px }
.toast { background:#101828; color:#fff; padding:12px 14px; border-radius:12px; box-shadow:0 10px 24px rgba(0,0,0,.25); display:flex; align-items:center; gap:10px }
.toast.ok { background:#0a7d29 }
.toast.err { background:#d92d20 }
.toast .icon { width:18px; height:18px }
.toast.fade { opacity:0; transition: opacity .3s ease }

/* Video */
video { width:100%; border-radius:12px; background:#000 }

/* Dialog */
dialog { border:none; border-radius:14px; padding:0; box-shadow:0 16px 48px rgba(0,0,0,.24) }
dialog form { padding:18px; min-width:300px }
.dlg-header { display:flex; flex-direction:column; gap:6px; margin-bottom:14px }
.product-name { font-size:20px; font-weight:800 }
.meta { color:var(--muted); font-size:13px; display:flex; gap:12px }
.qty-btn { background:#eef2ff; color:#1d4ed8; border-radius:10px; padding:10px 14px; font-weight:700 }
.qty-value { min-width:40px; text-align:center; font-size:20px; font-weight:800 }
menu { display:flex; justify-content:flex-end; gap:8px; margin:12px 0 0 0; padding:0 }

/* Bottom Nav with FAB */
.bottom-nav { 
  position:fixed; left:0; right:0; bottom:0; 
  background:rgba(255,255,255,.85); backdrop-filter:saturate(180%) blur(8px); border-top:1px solid rgba(0,0,0,.06); 
  padding:10px 12px; 
  display:grid; grid-template-columns: 1fr auto 1fr; align-items:center; justify-items:center; 
  z-index:1000 
}
.bottom-nav #modeUlazBtn { justify-self:start }
.bottom-nav #modeWebBtn { justify-self:end }
.fab { background:var(--brand); color:#fff; width:64px; height:64px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:800; box-shadow:0 10px 20px rgba(13,110,253,.35) }
/* Side nav buttons */
.nav-btn { background:transparent; color:var(--brand); display:inline-flex; align-items:center; gap:6px; padding:10px 12px; border-radius:10px; border:1px solid transparent; font-weight:700 }
.nav-btn .icon { width:20px; height:20px }
.nav-btn.active { background:rgba(13,110,253,.12); border-color:rgba(13,110,253,.25) }
.nav-btn:disabled { opacity:.5; pointer-events:none }

/* Visual Web mode: hide NC column and price in confirm dialog */
.mode-web .list th:nth-child(3),
.mode-web .list td:nth-child(3),
.mode-web .dlg-header .price { display:none !important }

/* Start menu overlay (Glovo-like) */
.start-menu { position:fixed; inset:0; z-index:1500; background:linear-gradient(180deg, rgba(13,110,253,.12), rgba(13,110,253,.04)); backdrop-filter:saturate(160%) blur(6px); display:grid; place-items:center; }
.start-menu[hidden] { display:none !important }
.start-menu.fade-out { opacity:0; transition:opacity .24s ease; pointer-events:none }
.start-grid { display:grid; grid-template-columns: 1fr 1fr; gap:16px; width:min(520px, 92vw); padding:16px }
@media (max-width:540px){ .start-grid { grid-template-columns: 1fr; } }
.start-card { background:#fff; border-radius:16px; padding:18px; display:flex; flex-direction:column; align-items:center; gap:12px; box-shadow:0 8px 24px rgba(0,0,0,.12); border:1px solid rgba(0,0,0,.06); transition:transform .18s ease, box-shadow .18s ease }
.start-card { background:#fff !important; color:var(--text) !important; border:1px solid rgba(0,0,0,.06) }
.start-card .icon { width:40px; height:40px; max-width:100%; max-height:100% }
.start-card .icon { color: var(--text); }
.start-card .icon path,
.start-card .icon rect,
.start-card .icon circle,
.start-card .icon line,
.start-card .icon polyline {
  stroke: currentColor;
  stroke-width: 2;
}
.start-card .icon-wrap { width:80px; height:80px; border-radius:50%; display:grid; place-items:center; background:rgba(13,110,253,.12); color:var(--brand); }
.start-card.ulaz .icon-wrap { background:rgba(16,185,129,.12); color:#10b981 }
.start-card.web .icon-wrap { background:rgba(14,165,233,.12); color:#0ea5e9 }
.start-card .title { font-size:18px; font-weight:800; color:var(--text) }
.start-card:active { transform:scale(.98) }
.start-card.disabled { opacity:.5; filter:saturate(.2); pointer-events:none }
/* K-folder select styling (admin only, web mode with >1 K folders) */
#kFolderSelectWrap { gap:10px }
#kFolderSelectWrap label { font-size:12px; color:var(--muted) }
#kFolderSelect { padding:10px 12px; border:1px solid #d0d5dd; border-radius:10px; font-size:14px; background:#fff }
#kFolderSelect:focus { outline:none; border-color:#98a2b3; box-shadow:0 0 0 3px rgba(13,110,253,.12) }
/* Force-hide K-folder select for non-admins regardless of markup */
body:not(.is-admin) #kFolderSelectWrap { display:none !important }
/* Auth overlay */
.auth-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); display:grid; place-items:center; z-index:2000 }
.login-card { background:#fff; padding:18px; border-radius:12px; width:min(420px,92vw); box-shadow:0 16px 48px rgba(0,0,0,.24) }
.login-card h2 { margin:0 0 12px 0 }
.login-card form { display:grid; gap:10px }
.login-card input { padding:10px 12px; border:1px solid #d0d5dd; border-radius:10px; font-size:14px }
/* Ensure hidden attribute actually hides overlay even with display rules above */
.auth-overlay[hidden] { display: none !important }

/* Powered by */
.powered-by { margin-top: 8px; display:flex; align-items:center; gap:8px; justify-content:center; color:var(--muted); font-size:12px }
.powered-by .powered-logo { width:100%; height:20px; border-radius:4px; box-shadow:0 2px 6px rgba(0,0,0,.12) }

/* Supply result section */
.supply-result { padding-bottom: 96px; }
.supply-result #resultCard { background: var(--card); border-radius:12px; padding:16px; box-shadow:0 1px 3px rgba(0,0,0,.08); border:1px solid rgba(0,0,0,.06) }
.supply-result .result-header { display:flex; flex-direction:column; gap:6px; margin-bottom:8px }
.supply-result .result-header .submeta { color: var(--muted); font-size:10px }
.supply-result .result-meta { display:flex; gap:8px; flex-wrap:wrap; margin: 6px 0 10px 0 }
.supply-result .supply-chip { background: rgba(13,110,253,.12); color: var(--brand); padding:6px 10px; border-radius:999px; font-weight:700; font-size:12px }
.supply-result .result-qty h3 { margin:12px 0 6px 0; font-size:16px }
.supply-result .qty-table { width:100%; border-collapse:separate; border-spacing:0 6px }
.supply-result .qty-table thead th { font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); text-align:left; padding:0 8px }
.supply-result .qty-table tbody tr { background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.05) }
.supply-result .qty-table tbody td { padding:10px 8px; border-bottom:1px solid #f0f0f0 }
.supply-result .qty-table tbody tr:last-child td { border-bottom:none }
.supply-result .qty-table tbody td:last-child { text-align:right }
.supply-result .qty-table tbody tr.qty-positive { background: rgba(10,125,41,.06); box-shadow:0 1px 2px rgba(10,125,41,.15) }
.supply-result .qty-table tbody tr.qty-positive td:last-child { color: var(--ok); font-weight:800 }
