* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0f1a;
  --card: #111827;
  --card-2: #172033;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.06);
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

.screen {
  padding: 16px;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar--doc {
  align-items: flex-start;
}

.title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.doc-head {
  flex: 1;
  min-width: 0;
}

.doc-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: lowercase;
  background: #1f2937;
}

.connection-badge.online {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.connection-badge.offline {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.search {
  width: 100%;
  border: 1px solid var(--border);
  outline: none;
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 16px;
}

.search:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.list {
  margin-top: 12px;
  padding-bottom: 100px;
}

.list--doc {
  padding-bottom: 160px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:active {
  transform: scale(0.985);
}

.doc-title {
  font-size: 16px;
  font-weight: 700;
}

.doc-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.doc-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.back-btn,
.finish-btn {
  border: none;
  outline: none;
  color: white;
  background: var(--card);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
}

.finish-btn {
  background: var(--accent);
}

.finish-btn--top {
  white-space: nowrap;
  min-width: 92px;
}

.progress-wrap {
  margin-bottom: 12px;
}

.progress-box {
  height: 10px;
  background: #1f2937;
  border-radius: 999px;
  overflow: hidden;
}

#progressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.25s ease;
}

.progress-text {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.remaining-hint {
  font-size: 13px;
  color: #fde68a;
  margin-bottom: 10px;
  min-height: 18px;
}

.row {
  position: relative;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 14px 14px 16px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 999px;
  background: #334155;
}

.row.active {
  transform: scale(1.015);
  border-color: rgba(37, 99, 235, 0.45);
}

.row.done::before {
  background: var(--ok);
}

.row.over::before {
  background: var(--err);
}

.row.pending::before {
  background: var(--warn);
}

.row.hidden-row {
  opacity: 0.35;
}

.name {
  font-size: 15px;
  font-weight: 600;
}

.count {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
}

.row-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.row-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.row-badge.done {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.row-badge.pending {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.row-badge.over {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.status {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 90px;
  padding: 16px;
  border-radius: 18px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  background: #1f2937;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.status.ok {
  background: var(--ok);
  color: white;
}

.status.err {
  background: var(--err);
  color: white;
}

.status.warn {
  background: var(--warn);
  color: #111827;
}

.empty-state {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
}

#scanInput {
  position: fixed;
  top: -100px;
  left: -100px;
  opacity: 0;
  pointer-events: none;
}

/* нижняя фиксированная панель */
.bottom-scanbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11, 15, 26, 0), rgba(11, 15, 26, 0.86) 25%, rgba(11, 15, 26, 0.96) 60%, rgba(11, 15, 26, 1) 100%);
  z-index: 60;
}

.scan-btn {
  width: 100%;
  border: none;
  outline: none;
  border-radius: 22px;
  padding: 16px 18px;
  min-height: 60px;
  color: white;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.scan-btn:active {
  transform: scale(0.99);
}

.scan-btn.active {
  background: linear-gradient(180deg, #0ea5e9, #0284c7);
}

.scan-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scan-btn__label {
  display: inline-block;
}

.camera-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.camera-popup.hidden {
  display: none;
}

.camera-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.camera-popup__dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(92vw, 420px);
  transform: translate(-50%, -50%);
  background: #111827;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.camera-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.camera-popup__title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.camera-popup__body {
  padding: 12px;
}

#reader {
  width: 100%;
  min-height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

.camera-popup__message {
  margin-top: 10px;
  font-size: 13px;
  color: #cbd5e1;
  min-height: 18px;
}

.camera-popup__message.ok {
  color: #86efac;
}

.camera-popup__message.err {
  color: #fca5a5;
}

.camera-popup__message.warn {
  color: #fcd34d;
}