:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #1f5fae;
  --primary-2: #174a86;
  --primary-3: #0f2f57;
  --primary-soft: #e8f0fb;
  --accent: #f59e0b;
  --accent-soft: #fff7e6;
  --success: #067647;
  --success-soft: #e8f8ef;
  --danger: #d92d20;
  --danger-soft: #fef1f0;
  --warning: #b45309;
  --warning-soft: #fff8eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .16);
  --radius: 16px;
  --radius-sm: 11px;
  --top-h: 58px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
p { margin: 0; }
svg { display: block; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.grow { flex: 1; }
.w-full { width: 100%; }

/* === Splash === */
.splash {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: radial-gradient(1200px 600px at 50% -10%, #dbeafe 0%, transparent 60%), var(--bg);
  color: var(--primary-3);
}
.splash-logo { width: 64px; height: 64px; color: var(--primary); }
.splash-title { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.splash-sub { color: var(--muted); font-size: 14px; }

/* === Spinner === */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(31, 95, 174, .22);
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
.spinner.light { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === App shell === */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: var(--safe-t);
  background: linear-gradient(135deg, #0d2b4e 0%, #123a6b 55%, #1a4d86 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(6, 24, 44, .22);
}
.topbar-inner {
  height: var(--top-h);
  max-width: 720px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand-name { white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; flex: 0 0 auto; }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 18px; }
.brand-tag { font-size: 11px; opacity: .65; margin-left: 2px; }
.topbar-spacer { flex: 1; }
.topbar-session {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16);
  font-size: 12.5px; max-width: 44vw; overflow: hidden; flex: 0 1 auto; min-width: 0;
}
.topbar-session .dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.2); flex: 0 0 auto; }
.topbar-session .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user {
  display: flex; align-items: center; gap: 8px; border: 0; background: rgba(255,255,255,.1);
  color: #fff; padding: 6px 10px 6px 6px; border-radius: 999px; font-size: 13px;
}
.topbar-chat {
  position: relative; width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.1); color: #fff;
  display: grid; place-items: center; padding: 0;
}
.topbar-chat:hover { background: rgba(255,255,255,.18); }
.chat-badge {
  position: absolute; right: -4px; top: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: #f59e0b; color: #211500;
  font-size: 9.5px; font-weight: 850; line-height: 17px; text-align: center;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #f59e0b; color: #1a2b45;
  display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: 0 0 auto;
  object-fit: cover; overflow: hidden;
}
.avatar-img { display: block; }
.avatar-lg { width: 72px; height: 72px; font-size: 22px; }
.avatar-list { width: 40px; height: 40px; font-size: 14px; }
.avatar-sm { width: 32px; height: 32px; font-size: 11px; }
.online-users { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.online-user {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 4px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); font-size: 12.5px; font-weight: 650;
}
.profile-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.profile-avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar-edit {
  position: absolute; right: -3px; bottom: -3px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; background: var(--primary); color: #fff;
  display: grid; place-items: center; padding: 0; box-shadow: var(--shadow-sm);
}
.avatar-edit:hover { background: var(--primary-2); }
.photo-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.photo-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.photo-categories { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.photo-category {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  font-size: 12.5px; font-weight: 700;
}
.photo-category b { color: var(--primary); font-size: 11px; }
.photo-category.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.photo-count { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-thumb {
  position: relative; aspect-ratio: 1; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
}
.photo-thumb a, .photo-thumb img { display: block; width: 100%; height: 100%; }
.photo-thumb img { object-fit: cover; }
.photo-remove {
  position: absolute; right: 4px; top: 4px; width: 24px; height: 24px;
  border: 0; border-radius: 50%; background: rgba(15,23,42,.72); color: #fff;
  font-size: 18px; line-height: 1; display: grid; place-items: center; padding: 0;
}
.photo-add {
  aspect-ratio: 1; border: 1.5px dashed var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--muted); font-size: 28px; line-height: 1;
}
.photo-add:hover { border-color: var(--primary); color: var(--primary); }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.photo-thumbs a { display: block; width: 42px; height: 42px; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.photo-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.desktop-nav { display: none; gap: 4px; margin-left: 8px; }
.desktop-nav a {
  display: inline-flex; align-items: center; gap: 5px;
  color: rgba(255,255,255,.78); text-decoration: none; padding: 8px 12px; border-radius: 9px;
  font-size: 14px; font-weight: 600;
}
.desktop-nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.desktop-nav a.active { background: rgba(255,255,255,.16); color: #fff; }

.view {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 104px);
  animation: fade-in .18s ease-out;
}
body.scanner-active .view { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 176px); }
.view.admin-view { max-width: 1120px; }
body.has-dock .view { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 160px); }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(255,255,255,.96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.bottom-nav-inner {
  height: var(--nav-h); max-width: 720px; margin: 0 auto;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600;
  border: 0; background: none; padding: 0 2px;
}
.nav-item:hover { text-decoration: none; color: var(--primary); }
.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { width: 23px; height: 23px; display: grid; place-items: center; }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-item.active .nav-icon::after {
  content: ""; position: absolute; margin-top: 26px; width: 18px; height: 3px; border-radius: 3px; background: var(--primary);
}

/* === Cards and layout === */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px; }
.card-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.card-title .icon { display: inline-block; vertical-align: -3px; margin-right: 4px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); cursor: pointer;
}
.switch-row span { min-width: 0; }
.switch-row span b { display: block; font-size: 14px; }
.switch-row small { display: block; max-width: 540px; margin-top: 3px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.switch-row input[type="checkbox"] {
  appearance: none; position: relative; flex: 0 0 auto;
  width: 46px; height: 26px; margin: 0; border: 0; border-radius: 999px;
  background: #cbd5e1; cursor: pointer; transition: background .15s;
}
.switch-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.25); transition: transform .15s;
}
.switch-row input[type="checkbox"]:checked { background: var(--primary); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.switch-row input[type="checkbox"]:disabled { opacity: .55; cursor: default; }
.ocr-test-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: stretch; }
.ocr-test-row .input { flex: 1 1 240px; min-height: 44px; padding: 7px 10px; font-size: 13px; }
.ocr-result { margin-top: 12px; }
.ocr-summary { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.ocr-candidates { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ocr-candidate {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); font-size: 13px; min-width: 0;
}
.ocr-candidate .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-zone { border-color: #fecdca; background: linear-gradient(180deg, #fff, #fffafa); }
.danger-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.install-debug { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.install-debug summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 650; }
.install-debug-grid {
  display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 4px 12px;
  margin-top: 8px; font-size: 12.5px;
}
.install-debug-grid span { color: var(--muted); }
.install-debug-grid b { min-width: 0; word-break: break-word; }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 2px 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* === Session strip === */
.session-strip {
  border-radius: var(--radius);
  background: linear-gradient(135deg, #123a6b, #1f5fae 70%, #2c74c9);
  color: #fff; padding: 14px 16px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  box-shadow: 0 10px 24px rgba(18, 58, 107, .22);
}
.session-strip h1 { font-size: 17px; font-weight: 800; }
.session-strip-main { flex: 1; min-width: 0; }
.session-strip .meta { font-size: 12.5px; opacity: .8; margin-top: 3px; }
.session-strip .stats { display: flex; gap: 16px; text-align: right; flex: 0 0 auto; }
.session-strip .stat b { display: block; font-size: 19px; line-height: 1.1; }
.session-strip .stat span { font-size: 10.5px; opacity: .75; text-transform: uppercase; letter-spacing: .05em; }
.session-strip .progress-block { margin-top: 8px; }
.session-strip .progress-track { background: rgba(255,255,255,.2); }
.session-strip .progress-fill { background: #fbbf24; }
.session-strip .progress-label { color: rgba(255,255,255,.82); }
.session-strip .progress-percent { background: rgba(255,255,255,.92); color: #123a6b; }
.session-strip .rating-chip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 7px; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #fff;
  font-size: 11.5px; font-weight: 800; text-decoration: none;
}
.session-strip .rating-chip .icon { color: #fbbf24; }
.session-strip .rating-chip:hover { background: rgba(255,255,255,.22); text-decoration: none; }
.progress-block { width: 100%; }
.progress-track {
  position: relative; height: 18px; width: 100%; overflow: hidden; border-radius: 999px;
  background: #e2e8f0; box-shadow: inset 0 1px 2px rgba(15,23,42,.08);
}
.progress-fill {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #2c74c9);
  transition: width .25s ease;
}
.progress-percent {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  padding: 1px 6px; border-radius: 999px;
  background: rgba(255,255,255,.88); color: var(--text);
  font-size: 10px; font-weight: 850; line-height: 1.45;
  box-shadow: 0 1px 3px rgba(15,23,42,.16);
}
.progress-label { margin-top: 5px; color: var(--muted); font-size: 12px; }

/* === Camera === */
.camera-card {
  position: relative; border-radius: 20px; overflow: hidden;
  background: #0b1220; height: clamp(210px, 42dvh, 380px); max-height: none;
  box-shadow: var(--shadow); margin-bottom: 12px;
  transition: height .2s ease, max-height .2s ease;
  isolation: isolate;
}
#cameraVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0b1220; }
.camera-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 20px; text-align: center; color: #eaf2ff;
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(56, 130, 220, .35), transparent 65%),
    linear-gradient(150deg, #0b1c33, #0a1524);
}
.camera-placeholder .big-icon { width: 54px; height: 54px; opacity: .85; }
.camera-placeholder h3 { font-size: 17px; font-weight: 750; }
.camera-placeholder p { font-size: 13px; color: #9fb3cc; max-width: 340px; line-height: 1.45; }
.camera-placeholder .btn { margin-top: 6px; }
.camera-actions-top { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; align-items: center; z-index: 4; }
.auto-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 38px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22); background: rgba(8,18,32,.55); color: #fff;
  font-size: 12px; font-weight: 750; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.auto-btn svg { flex: 0 0 auto; }
.auto-btn.active { background: rgba(245,158,11,.92); color: #211500; border-color: rgba(255,255,255,.4); }
.auto-btn:active { transform: scale(.97); }
.scan-preview {
  position: absolute; left: 10px; top: 10px; z-index: 4;
  width: 96px; height: 48px; object-fit: cover;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.6);
  background: #0b1220; box-shadow: 0 2px 12px rgba(0,0,0,.35);
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2);
  background: rgba(8, 18, 32, .55); color: #fff; display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.icon-btn:hover { background: rgba(8, 18, 32, .8); }
.icon-btn:active { transform: scale(.96); }
.icon-btn[disabled] { opacity: .35; cursor: default; }
.scan-reticle {
  position: absolute; left: 10%; top: 33%; width: 80%; height: 34%;
  border: 1.5px solid rgba(255,255,255,.9); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(2, 8, 18, .38);
  z-index: 3; pointer-events: none;
}
.scan-reticle::before, .scan-reticle::after {
  content: ""; position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(245, 158, 11, .95), transparent);
  animation: scanline 2.2s ease-in-out infinite;
}
.scan-reticle::before { top: -1px; }
.scan-reticle::after { bottom: -1px; animation-direction: reverse; }
@keyframes scanline { 0%,100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(calc(100% + 0px)); } }
.camera-hint {
  position: absolute; left: 0; right: 0; bottom: 82px; z-index: 3; text-align: center;
  color: rgba(255,255,255,.82); font-size: 12px; text-shadow: 0 1px 6px rgba(0,0,0,.6);
  pointer-events: none;
}
.scan-btn {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-width: 230px; height: 54px; padding: 0 24px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #ffb328, var(--accent)); color: #211500;
  font-size: 17px; font-weight: 850; letter-spacing: -.01em;
  box-shadow: 0 6px 20px rgba(245, 158, 11, .38), inset 0 1px 0 rgba(255,255,255,.5);
}
.scan-btn:active { transform: translateX(-50%) scale(.98); }
.scan-btn[disabled] { opacity: .55; }
.scan-btn .spinner { border-color: rgba(33, 21, 0, .25); border-top-color: #211500; }
.camera-compact-bar { display: none; }
.camera-card.compact {
  position: sticky; top: calc(var(--top-h) + var(--safe-t) + 6px); z-index: 25;
  aspect-ratio: auto; height: 96px; max-height: 96px; margin-bottom: 10px;
  box-shadow: 0 10px 30px rgba(2, 8, 18, .28);
}
.camera-card.compact .camera-placeholder,
.camera-card.compact .scan-reticle, .camera-card.compact .camera-hint,
.camera-card.compact .scan-preview, .camera-card.compact .frame-size-panel,
.camera-card.compact .scan-btn, .camera-card.compact .camera-actions-top { display: none; }
.camera-card.compact #cameraVideo {
  display: block; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 68px; height: 68px; border-radius: 13px; object-fit: cover; z-index: 1;
}
.camera-card.compact .camera-compact-bar {
  display: flex; position: absolute; inset: 0; align-items: center; justify-content: space-between;
  padding: 0 10px 0 88px; color: #dbeafe; gap: 8px; z-index: 2;
}
.camera-compact-bar .left { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.camera-compact-bar .left span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-compact-bar .compact-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.camera-compact-bar .compact-actions .btn { min-height: 38px; padding: 0 10px; font-size: 12.5px; }
.camera-compact-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.2); }
.camera-fallback { font-size: 12.5px; color: #9fb3cc; text-align: center; }
.camera-fallback button { background: none; border: 0; color: #fbbf24; font-weight: 700; text-decoration: underline; }
.frame-size-panel {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 7;
  display: flex; flex-direction: column; gap: 9px;
  padding: 12px 13px 13px; border-radius: 14px;
  background: rgba(8, 18, 32, .95); color: #eaf2ff;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 8px 30px rgba(2,8,18,.35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.frame-size-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.frame-size-head .btn { min-height: 32px; padding: 0 10px; color: #dbeafe; }
.frame-size-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 650; color: #cbd9ea;
}
.frame-size-row span { width: 92px; flex: 0 0 auto; }
.frame-size-row input { flex: 1; min-width: 0; accent-color: var(--accent); }
.frame-size-panel > .btn { align-self: flex-start; min-height: 34px; }
.camera-card.configuring .scan-btn,
.camera-card.configuring .camera-hint,
.camera-card.configuring .scan-preview,
.camera-card.configuring .camera-actions-top { display: none; }

/* === Forms === */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 13px;
  font-size: 16px; color: var(--text); background: #fff;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px rgba(31, 95, 174, .12);
}
.input::placeholder, .textarea::placeholder { color: #94a3b8; }
.input[disabled], .select[disabled] { background: var(--surface-2); color: var(--muted); }
.textarea { min-height: 84px; resize: vertical; }
.article-input {
  font-family: var(--mono); font-size: 21px; font-weight: 700; letter-spacing: .04em;
  min-height: 56px; text-transform: uppercase;
}
.article-input::-webkit-search-cancel-button,
.article-input::-webkit-search-decoration,
.input[type="search"]::-webkit-search-cancel-button,
.input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.article-row { display: flex; gap: 8px; }
.article-row .input { flex: 1; min-width: 0; }
.input-addon { min-width: 86px; white-space: nowrap; }
#partialBtn { min-width: 44px; padding: 0 12px; font-size: 18px; font-weight: 850; }
.partial-search { display: flex; flex-direction: column; gap: 10px; }
.partial-results { display: flex; flex-direction: column; gap: 7px; max-height: 42vh; overflow-y: auto; }
.partial-result {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; text-align: left;
}
.partial-result:hover { border-color: var(--primary); background: var(--primary-soft); }
.partial-result-name { font-size: 13.5px; line-height: 1.35; min-width: 0; }
.form-error {
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px;
  background: var(--danger-soft); color: #912018; border: 1px solid #fecdca;
}
.form-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.checkbox { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; line-height: 1.4; }
.checkbox input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--primary); flex: 0 0 auto; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 11px;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  font-size: 14.5px; font-weight: 750; text-decoration: none;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(31,95,174,.2); }
.btn-primary:hover { background: var(--primary-2); }
.btn-accent { background: var(--accent); color: #211500; }
.btn-accent:hover { background: #e08c00; }
.btn-secondary { background: var(--primary-soft); color: var(--primary-2); border-color: #cfe0f7; }
.btn-secondary:hover { background: #dce9fa; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b42318; }
.btn-danger-soft { background: var(--danger-soft); color: #912018; border-color: #fecdca; }
.btn-success { background: var(--success); color: #fff; }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 14px; padding: 0 22px; }
.btn-sm { min-height: 36px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-icon { width: 44px; padding: 0; flex: 0 0 auto; }
.btn-block { width: 100%; }
.btn .spinner { margin-right: 2px; }

/* === Lookup result === */
.lookup-status { margin-top: 8px; }
.found-card { margin-top: 10px; border-radius: var(--radius); border: 1px solid #cfe0f7; background: linear-gradient(180deg, #f7fbff, #fff); padding: 14px; }
.found-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.article-pill {
  display: inline-flex; align-items: center; min-height: 30px; padding: 3px 10px;
  border-radius: 8px; background: var(--primary-3); color: #fff;
  font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: .03em;
}
.found-name { font-size: 17px; font-weight: 800; line-height: 1.32; flex: 1 1 220px; letter-spacing: -.01em; }
.found-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.found-meta b { color: var(--text); }
.warn-box, .info-box, .error-box, .success-box {
  border-radius: 11px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5;
}
.warn-box { background: var(--warning-soft); border: 1px solid #fde68a; color: #7c4508; }
.info-box { background: var(--primary-soft); border: 1px solid #cfe0f7; color: #1d4a80; }
.error-box { background: var(--danger-soft); border: 1px solid #fecdca; color: #912018; }
.success-box { background: var(--success-soft); border: 1px solid #abefc6; color: #05603a; }
.warn-box .btn, .info-box .btn, .error-box .btn { margin-top: 6px; }
.ocr-variants {
  display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; margin-top: 8px;
  overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.ocr-variants > .small { flex: 0 0 auto; white-space: nowrap; }
.variant-chip {
  flex: 0 0 auto; white-space: nowrap;
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 5px 10px; font-family: var(--mono); font-size: 12.5px; font-weight: 700;
}
.variant-chip:hover { border-color: var(--primary); color: var(--primary); }

/* === Quantity === */
.qty-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.qty-btn {
  width: 58px; height: 58px; flex: 0 0 auto; border-radius: 15px;
  border: 1.5px solid var(--border); background: #fff; color: var(--primary);
  font-size: 30px; font-weight: 500; line-height: 1; display: grid; place-items: center;
}
.qty-btn:active { background: var(--primary-soft); transform: scale(.97); }
.qty-input {
  flex: 1; min-width: 0; height: 58px; text-align: center;
  font-size: 28px; font-weight: 850; border: 1.5px solid var(--border); border-radius: 15px;
  background: #fff; outline: none; font-variant-numeric: tabular-nums;
}
.qty-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(31,95,174,.12); }
.qty-unit { font-size: 13px; color: var(--muted); min-width: 32px; }
.qty-barrel {
  width: 50px; height: 58px; flex: 0 0 auto; border-radius: 15px;
  border: 1.5px solid #fde68a; background: var(--accent-soft); color: var(--warning);
  display: grid; place-items: center; padding: 0;
}
.qty-barrel:hover, .qty-barrel[aria-expanded="true"] { background: #fef3c7; border-color: var(--accent); }
.barrel-tally { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.barrel-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px 4px 6px; border-radius: 999px;
  border: 1px solid #fde68a; background: var(--accent-soft); color: var(--warning);
  font-size: 12px; font-weight: 700;
}
.barrel-chip b { font-weight: 850; }
.quick-qty { margin-top: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.quick-qty-label { font-size: 11.5px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 7px; }
.quick-qty-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.quick-qty-grid button {
  min-height: 38px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--text); font-size: 13px; font-weight: 750;
}
.quick-qty-grid button:hover { border-color: var(--primary); color: var(--primary); }
.quick-qty-grid button:active { transform: scale(.97); }
.comment-wrap { margin-top: 12px; }

/* === Confirm dock === */
.confirm-dock {
  position: fixed; left: 0; right: 0; z-index: 45;
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--kb-inset, 0px));
  background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .06);
}
.confirm-dock-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.confirm-dock .summary { min-width: 0; flex: 1; }
.confirm-dock .summary b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.confirm-dock .summary span { font-size: 12px; color: var(--muted); }
.confirm-dock .btn { flex: 0 0 auto; min-width: 160px; }
.dock-photo-btn {
  position: relative; width: 46px; height: 46px; flex: 0 0 auto;
  border-radius: 50%; border: 1.5px solid #fde68a;
  background: var(--accent-soft); color: var(--warning);
  display: grid; place-items: center; padding: 0;
}
.dock-photo-btn:hover { background: #fef3c7; }
.dock-photo-btn:disabled { opacity: .5; cursor: default; }
.dock-photo-btn span {
  position: absolute; right: -4px; top: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 18px; text-align: center;
}
.edit-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--warning-soft); border: 1px solid #fde68a; color: #7c4508;
  border-radius: 11px; padding: 8px 10px; margin-top: 10px; font-size: 13px;
}

/* === Chat === */
.chat-page {
  display: flex; flex-direction: column; gap: 10px;
  height: calc(100dvh - var(--top-h) - var(--nav-h) - 54px);
  min-height: 420px;
}
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-title { display: flex; align-items: center; gap: 7px; font-size: 20px; }
.chat-title .icon { color: var(--primary); }
.chat-card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.chat-message { display: flex; align-items: flex-start; gap: 8px; }
.chat-message.own { flex-direction: row-reverse; }
.chat-bubble { max-width: min(82%, 520px); min-width: 0; padding: 8px 10px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); }
.chat-message.own .chat-bubble { background: var(--primary-soft); border-color: #cfe0f7; }
.chat-meta { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.chat-meta b { color: var(--text); font-size: 12.5px; }
.chat-text { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; white-space: normal; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chat-image { display: block; width: 120px; height: 88px; overflow: hidden; border-radius: 8px; border: 1px solid var(--border); }
.chat-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-file-link {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px;
  background: #fff; color: var(--text); font-size: 12px; text-decoration: none;
}
.chat-file-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-link small { color: var(--muted); flex: 0 0 auto; }
.chat-composer { border-top: 1px solid var(--border); padding: 9px 10px; background: #fff; }
.chat-input-row { display: flex; align-items: flex-end; gap: 6px; }
.chat-attach { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.chat-input-row textarea {
  flex: 1; min-width: 0; min-height: 42px; max-height: 120px; resize: none;
  border: 1.5px solid var(--border); border-radius: 11px; padding: 10px 11px;
  font: inherit; font-size: 14px; outline: none; background: #fff;
}
.chat-input-row textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,95,174,.1); }
.chat-send { width: 44px; height: 42px; min-width: 44px; padding: 0; display: grid; place-items: center; }
.chat-files { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.chat-file-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; max-width: 100%; }
.chat-file-chip button { border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 1px; }
.chat-empty { padding: 30px 10px; text-align: center; }
.chat-load-more { align-self: center; margin-bottom: 4px; }
@media (max-width: 640px) {
  .chat-page { height: calc(100dvh - var(--top-h) - var(--nav-h) - 38px); }
  .chat-header { padding: 12px; }
  .chat-title { font-size: 18px; }
  .chat-bubble { max-width: 88%; }
}

/* === Rating === */.rating-title { display: flex; align-items: center; gap: 8px; }
.rating-title .icon { color: var(--accent); }
.rating-podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-bottom: 12px; }
.podium-card {
  flex: 0 1 210px; min-width: 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 14px 10px; border: 1px solid var(--border); border-radius: 15px;
  background: #fff; box-shadow: var(--shadow-sm);
}
.podium-card.place-1 { padding-top: 20px; padding-bottom: 20px; border-color: #fcd34d; background: linear-gradient(180deg, #fffbeb, #fff); }
.podium-card.place-2 { border-color: #cbd5e1; }
.podium-card.place-3 { border-color: #fdba74; }
.podium-card.is-me { box-shadow: 0 0 0 3px rgba(31,95,174,.14); }
.podium-rank { font-size: 24px; line-height: 1; }
.podium-name { max-width: 100%; font-size: 13.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-qty { font-size: 16px; font-weight: 850; }
.podium-qty span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.rating-list { display: flex; flex-direction: column; margin-top: 8px; }
.rating-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid #f1f5f9; min-width: 0;
}
.rating-row:last-child { border-bottom: 0; }
.rating-row.is-me { background: var(--primary-soft); border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.rating-place {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--surface-2);
  color: var(--muted); font-size: 12px; font-weight: 850;
}
.rating-place.rank-1 { background: #fef3c7; color: #92400e; }
.rating-place.rank-2 { background: #e2e8f0; color: #475569; }
.rating-place.rank-3 { background: #ffedd5; color: #9a3412; }
.rating-person { flex: 1; min-width: 0; }
.rating-name { font-size: 14px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rating-login { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rating-numbers { flex: 0 0 auto; text-align: right; }
.rating-numbers b { display: block; font-size: 17px; line-height: 1.1; }
.rating-numbers span { display: block; color: var(--muted); font-size: 11px; }
@media (max-width: 640px) {
  .rating-podium { gap: 6px; }
  .podium-card { padding: 10px 6px; }
  .podium-card .avatar-lg { width: 52px; height: 52px; font-size: 17px; }
  .podium-name { font-size: 12px; }
  .podium-qty { font-size: 14px; }
}
/* === Lists / entries === */
.my-toolbar { display: flex; gap: 8px; margin-bottom: 10px; align-items: stretch; }
.my-search { position: relative; flex: 1; min-width: 0; }
.my-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.my-search .input { padding-left: 38px; }
.my-sort { flex: 0 0 auto; width: auto; min-height: 48px; }
.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-size: 14px; font-weight: 750; line-height: 1.35; }
.entry-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.entry-qty { font-size: 17px; font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.entry-actions .btn { min-height: 32px; width: 32px; padding: 0; }
.empty {
  text-align: center; padding: 26px 16px; color: var(--muted);
}
.empty .big-icon { width: 48px; height: 48px; margin: 0 auto 10px; opacity: .5; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 5px; }
.empty p { font-size: 13.5px; line-height: 1.5; max-width: 360px; margin: 0 auto; }

/* === Badges / chips === */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 750; line-height: 1.4;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.green { background: var(--success-soft); color: #05603a; border-color: #abefc6; }
.badge.amber { background: var(--warning-soft); color: #7c4508; border-color: #fde68a; }
.badge.red { background: var(--danger-soft); color: #912018; border-color: #fecdca; }
.badge.blue { background: var(--primary-soft); color: #1d4a80; border-color: #cfe0f7; }
.badge.gray { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* === Stats === */
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.stat-card .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.stat-card .v { font-size: 24px; font-weight: 850; margin-top: 3px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-card .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* === Tables === */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: #fff; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.table th {
  text-align: left; padding: 10px 12px; background: var(--surface-2); color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfdff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .name { max-width: 420px; }
.table .article { font-family: var(--mono); font-weight: 700; white-space: nowrap; }

/* === Admin === */
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-header h1 { font-size: 24px; letter-spacing: -.03em; }
.admin-header .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hub-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--border); color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: transform .1s, box-shadow .15s, border-color .15s;
}
.hub-card:hover { text-decoration: none; border-color: #cfe0f7; box-shadow: var(--shadow); transform: translateY(-1px); }
.hub-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.hub-card h3 { font-size: 15px; font-weight: 800; }
.hub-card p { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.hub-arrow { margin-left: auto; color: #94a3b8; }
.hub-arrow .icon { transform: rotate(-90deg); }

/* === Login === */
.login-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 22px 16px calc(22px + var(--safe-b));
  background:
    radial-gradient(1000px 520px at 50% -10%, rgba(59, 130, 246, .28), transparent 65%),
    radial-gradient(700px 500px at 100% 110%, rgba(245, 158, 11, .14), transparent 60%),
    linear-gradient(160deg, #07182b 0%, #0d2b4e 55%, #123a6b 100%);
}
.login-card {
  width: 100%; max-width: 430px; background: rgba(255,255,255,.98);
  border-radius: 22px; padding: 26px 22px; box-shadow: 0 30px 90px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.4);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.login-brand .logo { width: 42px; height: 42px; color: var(--primary); }
.login-brand h1 { font-size: 26px; font-weight: 850; letter-spacing: -.04em; }
.login-brand p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.login-card h2 { font-size: 19px; margin-bottom: 14px; }
.login-card .field { margin-bottom: 12px; }
.login-card .btn { margin-top: 4px; }
.login-foot { margin-top: 14px; font-size: 11.5px; color: var(--muted); line-height: 1.5; text-align: center; }
.login-foot a { color: var(--primary); }
.server-warning {
  margin: 12px 0; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.45;
  background: var(--warning-soft); border: 1px solid #fde68a; color: #7c4508;
}
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; background: none; color: var(--muted);
  display: grid; place-items: center; border-radius: 8px;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }

/* === Toasts === */
.toast-container {
  position: fixed; z-index: 100; left: 12px; right: 12px;
  top: calc(var(--top-h) + var(--safe-t) + 10px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%; max-width: 520px;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  background: #0f172a; color: #fff; box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}
.toast.success { background: #05603a; }
.toast.error { background: #912018; }
.toast.warn { background: #7c4508; }
.toast .toast-msg { flex: 1; line-height: 1.35; }
.toast .toast-action { background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 7px; padding: 6px 9px; font-weight: 750; font-size: 12.5px; }
.toast .toast-close { background: none; border: 0; color: rgba(255,255,255,.7); padding: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* === Network status (overlay, no layout shift) === */
.net-banner {
  position: fixed; left: 12px; right: 12px;
  top: calc(var(--top-h) + var(--safe-t) + 8px);
  z-index: 85; max-width: 520px; margin: 0 auto;
  padding: 10px 13px; border-radius: 12px;
  color: #fff; font-size: 13px; font-weight: 650; text-align: center;
  box-shadow: var(--shadow-lg); pointer-events: none;
}
.net-banner.offline { background: #912018; }
.net-banner.online { background: #05603a; }

/* === Modal / sheet === */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(2, 8, 18, .55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: backdrop-in .15s ease-out; padding: 0;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto;
  background: #fff; border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: sheet-up .2s ease-out;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { font-size: 18px; letter-spacing: -.02em; }
.modal-close { width: 36px; height: 36px; border: 0; background: var(--surface-2); border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: 0 0 auto; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 auto; }
.crop-modal { max-width: 640px; }
.crop-body { display: flex; flex-direction: column; gap: 10px; }
.crop-wrap {
  position: relative; display: inline-block; align-self: center;
  max-width: 100%; line-height: 0; overflow: hidden; border-radius: 10px;
  touch-action: none; user-select: none;
}
.crop-image { display: block; max-width: 100%; max-height: 56vh; width: auto; height: auto; }
.crop-frame {
  display: none; position: absolute; border: 2px solid #f59e0b; border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(2,8,18,.45); cursor: move; touch-action: none;
}
.crop-frame.ready { display: block; }
.crop-size {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 650; color: var(--muted);
}
.crop-size input { flex: 1; accent-color: var(--accent); }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; animation: modal-in .16s ease-out; }
  @keyframes modal-in { from { transform: translateY(8px) scale(.98); opacity: .5; } to { transform: none; opacity: 1; } }
}

/* === Misc === */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pagination .page-info { font-size: 12.5px; color: var(--muted); min-width: 110px; text-align: center; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 34px 10px; color: var(--muted); font-size: 14px; }
.error-block { padding: 20px; text-align: center; color: var(--danger); }
.hr { height: 1px; background: var(--border); margin: 14px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 2px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }

@media (min-width: 900px) {
  :root { --nav-h: 0px; }
  .bottom-nav { display: none; }
  .desktop-nav { display: flex; flex-wrap: nowrap; }
  .topbar-inner { padding: 0 20px; }
  body.admin-shell .topbar-inner { max-width: 1120px; }
  .brand-tag { display: none; }
  .topbar-user .user-name { display: none; }
  .topbar-session { display: none; }
  .desktop-nav a { padding: 8px 10px; }
  body.admin-shell .brand-tag { display: inline; }
  body.admin-shell .topbar-user .user-name { display: inline; }
  body.admin-shell .topbar-session { display: inline-flex; }
  .view { padding: 22px 20px 64px; }
  body.has-dock .view { padding-bottom: 180px; }
  body.scanner-active .view { padding-bottom: 200px; }
  .camera-card { height: 420px; max-height: 420px; }
  .confirm-dock { bottom: var(--kb-inset, 0px); }
  .session-strip { padding: 18px 20px; }
  .session-strip h1 { font-size: 20px; }
}
@media (max-width: 640px) {
  .brand-tag { display: none; }
  .topbar-session { display: none; }
  .topbar-user .user-name { display: none; }
  .my-toolbar { flex-direction: column; }
  .my-sort { width: 100%; }
  .article-row { flex-wrap: wrap; }
  .article-row .article-input { order: 2; flex: 1 1 100%; }
  .article-row .input-addon { order: 1; flex: 1 1 auto; }
  #partialBtn { order: 1; flex: 0 0 44px; }
  .quick-qty-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .quick-qty-grid button { min-height: 54px; font-size: 17px; border-radius: 11px; }
  .confirm-dock .btn { min-width: 136px; padding: 0 14px; font-size: 15px; }
  .dock-photo-btn { width: 42px; height: 42px; }
  .session-strip { padding: 12px 14px; }
  .session-strip h1 { font-size: 15.5px; }
  .session-strip .stats { gap: 10px; }
  .scan-btn { min-width: 200px; height: 50px; font-size: 16px; }
  .found-name { font-size: 16px; }
}
@media (max-width: 440px) {
  .camera-card.compact { height: 86px; max-height: 86px; }
  .camera-card.compact #cameraVideo { width: 60px; height: 60px; left: 8px; }
  .camera-card.compact .camera-compact-bar { padding: 0 8px 0 76px; }
  .camera-compact-bar .left span:last-child { display: none; }
  .camera-compact-bar .compact-actions .btn { min-height: 36px; padding: 0 8px; font-size: 12px; }
  .scan-preview { width: 74px; height: 40px; }
  .auto-btn { width: 42px; padding: 0; }
  .auto-btn span { display: none; }
  .camera-actions-top { gap: 6px; }
  .entry-item { flex-wrap: wrap; }
  .entry-qty { margin-left: auto; }
  .entry-actions { margin-left: auto; }
}
@media (max-width: 370px) {
  .scan-preview { display: none !important; }
  .frame-size-row span { width: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
