/* App shell: sidebar + topbar + content, responsive to phones (bottom nav). */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-elev); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -.03em; color: var(--fg); }
.sidebar .brand img { width: 34px; height: 34px; border-radius: 9px; }
.sidebar .company { margin: 6px 12px 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-sunken); display: flex; align-items: center; gap: 10px; cursor: pointer; border: 1px solid transparent; }
.sidebar .company:hover { border-color: var(--line-2); }
.sidebar .company .avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-fg); display: grid; place-items: center; font-weight: 800; font-size: .85rem; flex: none; }
.sidebar .company .name { font-weight: 700; font-size: .9rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .company .plan { font-size: .72rem; color: var(--fg-3); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; }
.nav .section { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-4); font-weight: 700; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--fg-2); font-weight: 600; font-size: .9rem; transition: background .12s, color .12s; }
.nav a:hover { background: var(--bg-hover); text-decoration: none; color: var(--fg); }
.nav a.active { background: var(--primary-soft); color: var(--primary-soft-fg); }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a .count { margin-left: auto; font-size: .7rem; background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.nav a.locked { opacity: .5; }
.sidebar .foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; font-size: .85rem; }
.sidebar .foot .user { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.25rem; margin: 0; flex: 1; }
.topbar .search { position: relative; width: min(360px, 40vw); }
.topbar .search input { padding-left: 36px; min-height: 38px; }
.topbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--fg-4); }
.content { padding: 22px 24px 90px; max-width: 1400px; width: 100%; margin: 0 auto; animation: fade .2s var(--ease); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; }
.page-head .sub { color: var(--fg-3); font-size: .9rem; }
.banner { padding: 10px 24px; font-size: .9rem; display: flex; gap: 12px; align-items: center; justify-content: center; font-weight: 600; }
.banner.warn { background: var(--accent-soft); color: var(--accent-soft-fg); }
.banner.danger { background: var(--danger-soft); color: var(--danger-soft-fg); }
.banner.info { background: var(--info-soft); color: var(--info-soft-fg); }
.banner a { text-decoration: underline; color: inherit; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--amber-600); color: #fff; text-align: center; font-size: .85rem; padding: 6px; z-index: 500; font-weight: 600; }

.menu-btn { display: none; }
.bottom-nav { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .topbar .search { width: 100%; }
  .content { padding: 14px 14px 100px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-elev); border-top: 1px solid var(--line); z-index: 40; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .65rem; font-weight: 600; color: var(--fg-3); padding: 4px 8px; border-radius: 10px; min-width: 56px; }
  .bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.scan { background: var(--primary); color: var(--primary-fg); border-radius: 16px; margin-top: -18px; width: 58px; height: 58px; justify-content: center; box-shadow: var(--shadow); }
  .bottom-nav a.scan svg { width: 26px; height: 26px; }
}

/* Auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .side { background: radial-gradient(1200px 600px at 10% 10%, rgba(20,184,166,.35), transparent 60%), radial-gradient(800px 500px at 90% 90%, rgba(245,158,11,.25), transparent 60%), #0b1220; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .side h2 { font-size: 2rem; color: #fff; }
.auth .side ul { margin: 0; padding-left: 18px; color: #c7d0dc; line-height: 1.8; }
.auth .form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth .form > div { width: min(100%, 520px); }
.auth .logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; letter-spacing: -.03em; margin-bottom: 20px; }
.auth .logo img { width: 36px; height: 36px; border-radius: 10px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth .side { display: none; } }
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.steps span { flex: 1; height: 5px; border-radius: 99px; background: var(--bg-sunken); }
.steps span.done { background: var(--primary); }

/* Scanner */
.scan-view { max-width: 720px; margin: 0 auto; }
.viewfinder { position: relative; background: #000; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 4/3; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.viewfinder .reticle { position: absolute; inset: 18% 10%; border: 2px solid rgba(255,255,255,.7); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.viewfinder .reticle::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--brand-400); box-shadow: 0 0 12px var(--brand-400); animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-60px); } to { transform: translateY(60px); } }
.viewfinder .status { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; color: #fff; text-align: center; font-size: .85rem; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.scan-result { margin-top: 14px; animation: pop .25s var(--ease); }
.flash { animation: flash .4s; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--brand-400); } 100% { box-shadow: 0 0 0 14px transparent; } }
.big-qty { font-size: 1.6rem; text-align: center; font-weight: 800; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad button { padding: 14px; font-size: 1.2rem; font-weight: 700; }

/* Pricing cards */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.plan-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elev); display: flex; flex-direction: column; gap: 10px; position: relative; transition: transform .15s var(--ease), box-shadow .15s; }
.plan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.plan-card.current { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.plan-card .price { font-family: var(--font-display); font-size: 2.1rem; font-weight: 800; letter-spacing: -.04em; }
.plan-card .price small { font-size: .9rem; color: var(--fg-3); font-weight: 500; letter-spacing: 0; }
.plan-card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--fg-2); }
.plan-card ul li::before { content: "✓"; color: var(--primary); font-weight: 800; margin-right: 8px; }
.plan-card .ribbon { position: absolute; top: -10px; right: 16px; background: var(--accent); color: #1a1200; font-size: .7rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; letter-spacing: .05em; text-transform: uppercase; }

/* Document review layout */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 18px; }
.review .preview { position: sticky; top: 80px; height: calc(100vh - 110px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--bg-sunken); }
.review .preview iframe, .review .preview img { width: 100%; height: 100%; object-fit: contain; border: 0; }
@media (max-width: 1100px) { .review { grid-template-columns: 1fr; } .review .preview { position: static; height: 420px; } }
.line-flag { color: var(--amber-600); font-size: .75rem; }
.match-new { color: var(--blue-500); } .match-unmatched { color: var(--danger); }

/* NIR print */
.nir { background: #fff; color: #000; padding: 24px; font-size: 12px; font-family: Arial, Helvetica, sans-serif; }
.nir h2 { text-align: center; font-size: 16px; margin: 10px 0 14px; font-family: inherit; }
.nir table { width: 100%; border-collapse: collapse; }
.nir .lines th, .nir .lines td { border: 1px solid #000; padding: 4px 6px; }
.nir .lines th { background: #eee; font-size: 11px; }
.nir .num { text-align: right; font-variant-numeric: tabular-nums; }
.nir .sig td { padding-top: 40px; text-align: center; }
@media print { .nir { padding: 0; } }

/* Drag & drop */
.dropzone { border: 2px dashed var(--line-2); border-radius: var(--radius-lg); padding: 34px 20px; text-align: center; color: var(--fg-3); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone.over, .dropzone:hover { border-color: var(--brand-500); background: var(--primary-soft); color: var(--primary-soft-fg); }

/* Timeline (movements) */
.timeline { display: flex; flex-direction: column; }
.timeline .item { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.timeline .item:last-child { border-bottom: 0; }
.timeline .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.ico.in { background: var(--success-soft); color: var(--success-soft-fg); } .ico.out { background: var(--danger-soft); color: var(--danger-soft-fg); } .ico.neutral { background: var(--info-soft); color: var(--info-soft-fg); }

/* Command list / results */
.list { display: flex; flex-direction: column; }
.list .li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .li:hover { background: var(--bg-hover); } .list .li:last-child { border-bottom: 0; }
.avatar-sq { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-sunken); display: grid; place-items: center; font-weight: 800; color: var(--fg-3); flex: none; overflow: hidden; }
.avatar-sq img { width: 100%; height: 100%; object-fit: cover; }
.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.lbl { border: 1px solid #ccc; border-radius: 6px; padding: 8px; text-align: center; background: #fff; color: #000; page-break-inside: avoid; }
.lbl .n { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl .p { font-size: 13px; font-weight: 800; }
