:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --success: #16a34a;
  --error: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --card: #161b26;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #262d3b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
h1 { font-size: 20px; margin: 8px 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=password] {
  width: 100%;
  font-size: 18px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row > .btn { flex: 0 0 auto; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.big { width: 100%; padding: 18px; font-size: 18px; }
#login-form .btn { width: 100%; margin-top: 12px; }
#login-form input + label { margin-top: 12px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.topbar .link { padding: 4px 0; }
.view-wide { max-width: 480px; margin: 0 auto; padding: 12px 16px 0; }
.view-wide + .view { padding-top: 8px; }

.tabs { display: flex; gap: 4px; margin-top: 8px; padding: 4px; border-radius: 12px; background: var(--border); }
.tabs a { flex: 1; text-align: center; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; text-decoration: none; }
.tabs a.active { background: var(--card); color: var(--text); }
#list-count:not(:empty) { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 13px; line-height: 20px; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; }
.list-head .link { padding: 0; }
.delivery { display: flex; gap: 10px; align-items: stretch; padding: 12px; }
.delivery .open { flex: 1; min-width: 0; background: none; border: 0; padding: 4px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.delivery .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 18px; }
.delivery .pos { display: inline-grid; place-items: center; min-width: 26px; height: 26px; margin-right: 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 14px; }
.delivery .handle { display: grid; place-items: center; width: 44px; flex: none; color: var(--muted); font-size: 22px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.delivery.ghost { opacity: .4; }
.delivery.drag { box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.delivery .addr { margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.comment { white-space: pre-line; overflow-wrap: anywhere; }
.comment .hint { text-align: left; }
.delivery .meta { margin-top: 6px; color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }
#photo-step .row { margin-top: 12px; }
#photo-step .row > .btn { flex: 1; }
.link { background: none; border: 0; color: var(--primary); font: inherit; padding: 4px 0 12px; cursor: pointer; }

.actions { display: grid; gap: 12px; }
.hint { color: var(--muted); font-size: 14px; text-align: center; }
.error { color: var(--error); font-size: 14px; min-height: 1em; margin: 8px 0 0; }

.scanner {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35);
}

.order-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.order-title h2 { margin: 0; font-size: 22px; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: #fff; background: var(--muted); white-space: nowrap; }
.field { padding: 8px 0; border-top: 1px solid var(--border); }
.field span { display: block; color: var(--muted); font-size: 13px; }
.field a { color: var(--primary); }

#photo-preview { width: 100%; border-radius: 10px; display: block; }

#toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 448px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--success);
  color: #fff;
  font-weight: 600;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
#toast[hidden] { display: none; }
#toast button { font: inherit; font-weight: 700; color: #fff; background: rgba(255,255,255,.2); border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
#btn-return.armed { border-color: var(--error); color: var(--error); }
