/* Quickpak — custom design layer (clean light enterprise + motion)
   Tailwind CDN provides utilities; this file owns layout shell, brand
   components, keyframes and motion. Brand: firebrick red #b22222. */

:root{
  --brand:#b22222; --brand-600:#b22222; --brand-700:#8b1a1a; --brand-800:#6f1414;
  --ink:#141414; --muted:#6b7280; --line:#e7e5e4;
  --bg:#f7f7f6; --card:#ffffff; --ok:#16a34a;
  --sidebar-w:264px;
  --font-display:'Archivo','Inter',ui-sans-serif,system-ui,sans-serif;
  --ease:cubic-bezier(.22,.61,.36,1);
  --ease-spring:cubic-bezier(.34,1.56,.64,1);
}

*{box-sizing:border-box}
::selection{background:#f4c5c5;color:#591111}

/* Consistent keyboard focus ring across interactive elements */
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,
textarea:focus-visible,[tabindex]:focus-visible{
  outline:2px solid var(--brand); outline-offset:2px; border-radius:8px;
}

/* Animated ambient background — a slow-drifting mesh, very subtle */
.app-bg{
  position:fixed; inset:0; z-index:0; pointer-events:none;
  background:
    radial-gradient(42rem 42rem at 12% -10%, rgba(178,34,34,.10), transparent 60%),
    radial-gradient(38rem 38rem at 100% 0%, rgba(197,48,48,.06), transparent 55%),
    radial-gradient(46rem 46rem at 85% 115%, rgba(22,163,74,.05), transparent 60%);
  animation:bgDrift 24s var(--ease) infinite alternate;
}
@keyframes bgDrift{
  0%{transform:translate3d(0,0,0) scale(1)}
  100%{transform:translate3d(0,-14px,0) scale(1.04)}
}

/* ---------------------------------------------------------------- layout
   Mobile-first: the sidebar is an off-canvas drawer by default; at >=900px
   it becomes a permanent left rail (see the desktop media query at the end). */
.sidebar{
  position:fixed; z-index:40; inset:0 auto 0 0; width:min(280px,82vw);
  display:flex; flex-direction:column; gap:6px;
  padding:20px 16px; background:rgba(255,255,255,.96);
  backdrop-filter:blur(14px); border-right:1px solid var(--line);
  transform:translateX(-100%);
  box-shadow:0 30px 60px -20px rgba(20,20,20,.4);
  transition:transform .35s var(--ease);
}
.sidebar--open{transform:none}
.brand{display:flex; align-items:center; gap:12px; padding:6px 8px 18px}
.brand-mark{
  display:grid; place-items:center; width:40px; height:40px; border-radius:13px;
  color:#fff; background:linear-gradient(135deg,#c53030,#8b1a1a);
  box-shadow:0 8px 20px -8px rgba(139,26,26,.7);
}
.brand-mark svg{width:22px;height:22px}
.brand-text{display:flex; flex-direction:column; line-height:1.1}
.brand-text b{font-family:var(--font-display); font-size:17px; font-weight:800; letter-spacing:-.01em; text-transform:uppercase}
.brand-text em{font-style:normal; font-size:11px; color:var(--muted); font-weight:500}
/* Official logo image (auto-used when a file exists at assets/img/logo.svg) */
.brand-logo{height:34px; width:auto; max-width:180px; display:block}
.topbar-brand .brand-logo{height:26px}

.nav{display:flex; flex-direction:column; gap:2px; flex:1; overflow-y:auto}
.nav-group{
  font-size:10.5px; font-weight:700; letter-spacing:.09em; text-transform:uppercase;
  color:#94a3b8; padding:16px 10px 6px;
}
.nav-link{
  position:relative; display:flex; align-items:center; gap:12px; min-height:44px;
  padding:9px 11px; border-radius:11px; font-size:15px; font-weight:500;
  transition:background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.nav-link:active{transform:scale(.98)}
.nav-ico{display:grid; place-items:center; width:20px; height:20px; flex:none}
.nav-ico svg{width:20px; height:20px}
.nav-label{flex:1}
.nav-dot{width:6px; height:6px; border-radius:99px; background:var(--brand); box-shadow:0 0 0 4px rgba(178,34,34,.15); animation:pop .3s var(--ease-spring)}
@keyframes pop{from{transform:scale(0)}to{transform:scale(1)}}

.side-foot{display:flex; align-items:center; gap:8px; padding-top:14px; border-top:1px solid var(--line)}
.side-user{display:flex; align-items:center; gap:10px; flex:1; min-width:0}
.avatar{
  display:grid; place-items:center; width:38px; height:38px; border-radius:11px; flex:none;
  font-weight:700; color:#fff; background:linear-gradient(135deg,#d76666,#b22222);
}
.side-user-info{display:flex; flex-direction:column; min-width:0}
.side-user-info b{font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.side-user-info em{font-style:normal; font-size:11px; color:var(--muted)}
.logout{display:grid; place-items:center; width:36px; height:36px; border-radius:10px; color:var(--muted); transition:.18s var(--ease)}
.logout:hover{background:#fee2e2; color:#dc2626}

.sidebar-scrim{position:fixed; inset:0; z-index:39; background:rgba(20,20,20,.45)}

.main{flex:1; min-width:0; margin-left:0; position:relative; z-index:1; display:flex; flex-direction:column}

/* ---------------------------------------------------------------- topbar */
.topbar{
  position:sticky; top:0; z-index:30; display:flex; align-items:center; gap:12px;
  padding:12px 16px; background:rgba(247,247,246,.85); backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.burger{display:grid; place-items:center; width:40px; height:40px; margin-left:-6px; color:var(--ink)}
/* Compact brand shown in the utility bar on mobile, where the sidebar is hidden */
.topbar-brand{display:flex; align-items:center; gap:9px; font-weight:800; font-size:15px; letter-spacing:-.02em; color:var(--ink)}
.topbar-brand-mark{display:grid; place-items:center; width:30px; height:30px; border-radius:9px; color:#fff; background:linear-gradient(135deg,#c53030,#8b1a1a)}
.topbar-search{
  margin-left:auto; display:none; align-items:center; gap:9px; width:min(340px,38vw);
  padding:9px 14px; border-radius:12px; background:#fff; border:1px solid var(--line);
  color:var(--muted); transition:.2s var(--ease);
}
.topbar-search:focus-within{border-color:var(--brand-400,#d76666); box-shadow:0 0 0 4px rgba(178,34,34,.12)}
.topbar-search input{border:0; outline:0; background:transparent; width:100%; font-size:14px; color:var(--ink)}
.btn-scan{
  display:inline-flex; align-items:center; gap:8px; padding:9px 15px; border-radius:12px;
  font-weight:600; font-size:14px; color:#fff; background:linear-gradient(135deg,#c53030,#8b1a1a);
  box-shadow:0 10px 22px -12px rgba(139,26,26,.9); transition:transform .18s var(--ease-spring), box-shadow .2s;
}
.btn-scan:hover{transform:translateY(-1px); box-shadow:0 16px 30px -12px rgba(139,26,26,.9)}
.btn-scan:active{transform:translateY(0) scale(.98)}

.content{padding:18px 16px calc(84px + env(safe-area-inset-bottom)); max-width:1240px; width:100%; margin:0 auto; flex:1}

/* ---------------------------------------------------------------- page header */
.page-head{display:flex; align-items:flex-start; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:18px}
.page-head-text{min-width:0}
.page-head h1{font-family:var(--font-display); font-size:clamp(21px,5.5vw,27px); font-weight:800; letter-spacing:-.02em; line-height:1.12}
.page-head p{font-size:13.5px; color:var(--muted); margin-top:5px}
.page-actions{display:flex; align-items:center; gap:8px; flex-wrap:wrap; width:100%}
.page-actions .btn{flex:1}

/* ---------------------------------------------------------------- page motion */
.page-enter{animation:pageIn .4s var(--ease) both}
@keyframes pageIn{from{opacity:0; transform:translateY(10px)}to{opacity:1; transform:none}}

/* Reveal-on-scroll (JS toggles .in) */
.reveal{opacity:0; transform:translateY(16px); transition:opacity .6s var(--ease), transform .6s var(--ease)}
.reveal.in{opacity:1; transform:none}

/* ---------------------------------------------------------------- cards */
.card{background:var(--card); border:1px solid var(--line); border-radius:18px; box-shadow:var(--card,0 1px 2px rgba(15,23,42,.04)); }
.card-pad{padding:20px}

.grid-kpi{display:grid; grid-template-columns:repeat(2,1fr); gap:12px}
.kpi{
  position:relative; overflow:hidden; padding:20px; border-radius:18px;
  background:var(--card); border:1px solid var(--line); box-shadow:0 1px 2px rgba(15,23,42,.04);
  transition:transform .3s var(--ease), box-shadow .3s var(--ease);
}
.kpi:hover{transform:translateY(-2px); box-shadow:0 16px 34px -22px rgba(20,20,20,.24)}
.kpi::after{content:''; position:absolute; right:-30px; top:-30px; width:120px; height:120px; border-radius:50%; background:radial-gradient(circle,var(--kc,rgba(178,34,34,.14)),transparent 70%)}
.kpi-ico{display:grid; place-items:center; width:40px; height:40px; border-radius:12px; color:var(--kf,#b22222); background:var(--kb,rgba(178,34,34,.12))}
.kpi-ico svg{width:22px;height:22px}
.kpi-val{font-family:var(--font-display); font-size:clamp(24px,6vw,32px); font-weight:800; letter-spacing:-.02em; line-height:1; margin-top:12px; font-variant-numeric:tabular-nums}
.kpi-lbl{font-size:12.5px; color:var(--muted); font-weight:500; margin-top:6px}

/* ---------------------------------------------------------------- badges/buttons */
.badge{display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:99px; font-size:12px; font-weight:600; line-height:1.4; ring-width:1px}
.badge::before{content:''; width:6px; height:6px; border-radius:99px; background:currentColor; opacity:.7}
.mono{font-family:'JetBrains Mono',monospace; letter-spacing:-.02em}

.btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:10px 16px; border-radius:12px; font-size:14px; font-weight:600; cursor:pointer; border:1px solid transparent; transition:transform .16s var(--ease-spring), box-shadow .2s, background .2s; }
.btn:active{transform:scale(.97)}
.btn-primary{color:#fff; background:linear-gradient(135deg,#c53030,#8b1a1a); box-shadow:0 10px 22px -12px rgba(139,26,26,.9)}
.btn-primary:hover{transform:translateY(-1px); box-shadow:0 16px 30px -12px rgba(139,26,26,.9)}
.btn-ghost{background:#fff; border-color:var(--line); color:var(--ink)}
.btn-ghost:hover{background:#f8fafc; border-color:#cbd5e1}
.btn-danger{background:#fff; border-color:#fecaca; color:#dc2626}
.btn-danger:hover{background:#fef2f2}
.btn-sm{min-height:40px; padding:8px 13px; font-size:13px; border-radius:10px}

.input,.select,textarea.input{width:100%; min-height:44px; padding:11px 13px; border-radius:12px; border:1px solid var(--line); background:#fff; font-size:16px; color:var(--ink); outline:0; transition:.18s var(--ease)}
textarea.input{min-height:auto}
.input:focus,.select:focus,textarea.input:focus{border-color:#d76666; box-shadow:0 0 0 4px rgba(178,34,34,.12)}
.label{display:block; font-size:12.5px; font-weight:600; color:#475569; margin-bottom:6px}
.field{margin-bottom:16px}

/* ---------------------------------------------------------------- table */
.table{width:100%; border-collapse:separate; border-spacing:0}
.table th{font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:#6b7280; font-weight:700; text-align:left; padding:16px 16px 12px}
.table td{padding:15px 16px; border-top:1px solid var(--line); font-size:14px; vertical-align:middle}
.table tbody tr{transition:background .16s var(--ease)}
.table tbody tr:hover{background:#faf7f6}
.row-link{cursor:pointer}

/* ---------------------------------------------------------------- flash + toast */
.flash{padding:12px 16px; border-radius:13px; font-size:14px; font-weight:500; margin-bottom:18px; border:1px solid; animation:slideDown .4s var(--ease) both}
.flash--success{background:#ecfdf5; border-color:#a7f3d0; color:#047857}
.flash--error{background:#fef2f2; border-color:#fecaca; color:#b91c1c}
.flash--info{background:#eff6ff; border-color:#bfdbfe; color:#1d4ed8}
@keyframes slideDown{from{opacity:0; transform:translateY(-8px)}to{opacity:1; transform:none}}

.toast-host{position:fixed; z-index:80; right:16px; left:16px; bottom:calc(72px + env(safe-area-inset-bottom)); display:flex; flex-direction:column; gap:10px; pointer-events:none}
.toast{pointer-events:auto; display:flex; align-items:center; gap:11px; min-width:260px; max-width:360px; padding:13px 16px; border-radius:14px; background:#fff; border:1px solid var(--line); box-shadow:0 18px 40px -18px rgba(15,23,42,.4); font-size:14px; font-weight:500; animation:toastIn .45s var(--ease-spring) both}
.toast.out{animation:toastOut .3s var(--ease) forwards}
.toast .dot{width:9px; height:9px; border-radius:99px; flex:none}
.toast--success .dot{background:#10b981}.toast--error .dot{background:#ef4444}.toast--info .dot{background:#b22222}
@keyframes toastIn{from{opacity:0; transform:translateX(24px) scale(.96)}to{opacity:1; transform:none}}
@keyframes toastOut{to{opacity:0; transform:translateX(24px)}}

/* ---------------------------------------------------------------- timeline */
.timeline{position:relative; padding-left:30px}
.timeline::before{content:''; position:absolute; left:11px; top:6px; bottom:6px; width:2px; background:linear-gradient(var(--line),transparent)}
.tl-item{position:relative; padding:0 0 22px}
.tl-node{position:absolute; left:-30px; top:0; width:24px; height:24px; border-radius:50%; display:grid; place-items:center; font-size:11px; background:#fff; border:2px solid var(--brand); color:var(--brand)}
.tl-card{background:#fff; border:1px solid var(--line); border-radius:13px; padding:12px 14px}
.tl-item:hover .tl-node{animation:nodePulse 1.2s var(--ease) infinite}
@keyframes nodePulse{0%,100%{box-shadow:0 0 0 0 rgba(139,26,26,.35)}50%{box-shadow:0 0 0 6px rgba(139,26,26,0)}}

/* ---------------------------------------------------------------- scanner */
.scan-stage{position:relative; border-radius:22px; overflow:hidden; background:#0b1020; aspect-ratio:1; max-width:460px; margin:0 auto; box-shadow:0 30px 60px -30px rgba(15,23,42,.6)}
.scan-stage video, .scan-stage img{width:100%; height:100%; object-fit:cover}
.scan-frame{position:absolute; inset:14%; border-radius:18px; pointer-events:none}
.scan-frame span{position:absolute; width:34px; height:34px; border:3px solid #67e8f9}
.scan-frame span:nth-child(1){top:0;left:0;border-right:0;border-bottom:0;border-radius:14px 0 0 0}
.scan-frame span:nth-child(2){top:0;right:0;border-left:0;border-bottom:0;border-radius:0 14px 0 0}
.scan-frame span:nth-child(3){bottom:0;left:0;border-right:0;border-top:0;border-radius:0 0 0 14px}
.scan-frame span:nth-child(4){bottom:0;right:0;border-left:0;border-top:0;border-radius:0 0 14px 0}
.scan-line{position:absolute; left:14%; right:14%; height:3px; border-radius:99px; background:linear-gradient(90deg,transparent,#67e8f9,transparent); box-shadow:0 0 14px #22d3ee; top:14%; animation:scanSweep 2.4s var(--ease) infinite}
@keyframes scanSweep{0%,100%{top:16%}50%{top:82%}}
.scan-pulse{animation:okFlash .6s var(--ease)}
@keyframes okFlash{0%{box-shadow:inset 0 0 0 0 rgba(16,185,129,.9)}30%{box-shadow:inset 0 0 0 8px rgba(16,185,129,.55)}100%{box-shadow:inset 0 0 0 0 rgba(16,185,129,0)}}

/* skeleton */
.skel{position:relative; overflow:hidden; background:#eef1f6; border-radius:10px}
.skel::after{content:''; position:absolute; inset:0; background:linear-gradient(90deg,transparent,rgba(255,255,255,.7),transparent); animation:shimmer 1.3s infinite}
@keyframes shimmer{100%{transform:translateX(100%)}}

/* count-up helper */
.counting{color:var(--ink)}

/* ---------------------------------------------------------------- login */
.auth-wrap{min-height:100dvh; display:grid; grid-template-columns:1.05fr .95fr}
.auth-hero{position:relative; overflow:hidden; color:#fff; padding:56px; display:flex; flex-direction:column; justify-content:space-between; background:linear-gradient(150deg,#591111,#8b1a1a 55%,#b22222)}
.auth-hero::before{content:''; position:absolute; inset:0; background:radial-gradient(30rem 30rem at 80% 10%,rgba(255,190,160,.22),transparent 60%),radial-gradient(28rem 28rem at 10% 100%,rgba(88,17,17,.45),transparent 60%); animation:bgDrift 18s var(--ease) infinite alternate}
.auth-grid-lines{position:absolute; inset:0; background-image:linear-gradient(rgba(255,255,255,.06) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.06) 1px,transparent 1px); background-size:44px 44px; mask-image:radial-gradient(70% 70% at 50% 40%,#000,transparent)}
.auth-form{display:grid; place-items:center; padding:40px}
.float-box{position:absolute; border-radius:14px; border:1px solid rgba(255,255,255,.25); background:rgba(255,255,255,.06); backdrop-filter:blur(4px); animation:floaty 6s var(--ease) infinite alternate}
@keyframes floaty{to{transform:translateY(-16px) rotate(4deg)}}

@media (max-width:1024px){ .auth-wrap{grid-template-columns:1fr} .auth-hero{display:none} }

/* ---------------------------------------------------------------- multi-column helpers
   Mobile-first: everything is a single column by default; columns are added
   back at wider breakpoints further down. */
.scan-cols, .bv-cols, .dash-cols{display:grid; grid-template-columns:1fr; gap:16px}
.grid-2{display:grid; grid-template-columns:1fr; gap:14px}

/* ---------------------------------------------------------------- bottom tab bar (mobile)
   Thumb-reachable primary navigation; hidden on desktop where the rail returns. */
.mobnav{
  position:fixed; left:0; right:0; bottom:0; z-index:45; display:flex;
  background:rgba(255,255,255,.94); backdrop-filter:blur(14px);
  border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
}
.mobnav-item{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3px; min-height:58px; padding:8px 4px 6px;
  color:var(--muted); font-size:10.5px; font-weight:600; letter-spacing:.01em;
  transition:color .18s var(--ease), transform .12s var(--ease);
}
.mobnav-item svg{width:23px; height:23px}
.mobnav-item.is-active{color:var(--brand)}
.mobnav-item:active{transform:scale(.92)}

/* ---------------------------------------------------------------- data table → cards (mobile)
   Each row becomes a labelled card (td[data-label]); restored to a real table at >=600px. */
.table thead{position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0}
.table, .table tbody{display:block; width:100%}
.table tr{
  display:block; background:#fff; border:1px solid var(--line); border-radius:14px;
  padding:12px 14px; margin-bottom:12px; box-shadow:0 1px 2px rgba(20,20,20,.04);
}
.table td{
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  padding:7px 0; border:0; font-size:14px;
}
.table td::before{
  content:attr(data-label); flex:none;
  font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--muted);
}
.table td:not([data-label]):last-child{justify-content:flex-start; flex-wrap:wrap; gap:8px; margin-top:6px; padding:12px 0 2px; border-top:1px solid var(--line)}
.table td:not([data-label]):last-child form{display:inline-flex}
.table td:first-child{font-size:16px}
.table td[data-label=""]::before{display:none}

/* ---------------------------------------------------------------- modal → bottom sheet (mobile) */
.modal-overlay{position:fixed; inset:0; z-index:70; display:flex; align-items:flex-end; justify-content:center}
.modal-card{
  position:relative; width:100%; max-width:none; max-height:92dvh; overflow-y:auto;
  border-radius:20px 20px 0 0; animation:sheetUp .32s var(--ease-spring) both;
}
@keyframes sheetUp{from{transform:translateY(100%)}to{transform:none}}

/* ================================================================ tablet (>=600px) */
@media (min-width:600px){
  .topbar{gap:16px; padding:12px 20px}
  .topbar-search{display:flex}
  .content{padding:24px 22px calc(84px + env(safe-area-inset-bottom))}
  .page-actions{width:auto}
  .page-actions .btn{flex:none}
  .grid-2{grid-template-columns:1fr 1fr}

  /* restore real tables */
  .table, .table tbody{display:table; width:100%}
  .table tbody{display:table-row-group}
  .table thead{position:static; width:auto; height:auto; clip:auto}
  .table tr{display:table-row; background:none; border:0; border-radius:0; padding:0; margin:0; box-shadow:none}
  .table td{display:table-cell; font-size:14px; padding:15px 16px; border-top:1px solid var(--line); border-radius:0}
  .table td::before{display:none}
  .table td:first-child{font-size:14px}

  /* centered modal card */
  .modal-overlay{align-items:center; padding:24px}
  .modal-card{max-width:460px; max-height:88dvh; border-radius:18px; animation:modalPop .24s var(--ease-spring) both}
}
@keyframes modalPop{from{opacity:0; transform:translateY(10px) scale(.98)}to{opacity:1; transform:none}}

/* ================================================================ desktop (>=900px) */
@media (min-width:900px){
  .sidebar{transform:none; width:264px; box-shadow:none; background:rgba(255,255,255,.86)}
  .main{margin-left:264px}
  .burger, .topbar-brand{display:none}
  .sidebar-scrim{display:none !important}
  .mobnav{display:none}
  .topbar{padding:14px 26px}
  .content{padding:30px 26px}
  .scan-cols{grid-template-columns:1fr 1fr; gap:22px; align-items:start}
  .bv-cols{grid-template-columns:1.6fr 1fr; gap:20px}
  .dash-cols{grid-template-columns:1.5fr 1fr; gap:20px}
  .toast-host{left:auto; right:22px; bottom:22px}
}

/* ================================================================ wide (>=1100px) */
@media (min-width:1100px){ .grid-kpi{grid-template-columns:repeat(4,1fr); gap:16px} }

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important}
  .reveal{opacity:1; transform:none}
}
