[hidden] { display: none !important; }
:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #6b716d;
  --line: #e3e1da;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --accent-soft: #e3efe8;
  --danger: #b3412f;
  --danger-soft: #f8e5e1;
  --wait: #8a5a00;
  --wait-soft: #fbefd5;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151816;
    --card: #1f2321;
    --text: #e9ece9;
    --muted: #9aa29d;
    --line: #2f3531;
    --accent: #5fb38a;
    --accent-text: #0e1a13;
    --accent-soft: #233a2e;
    --danger: #e6806e;
    --danger-soft: #3a2420;
    --wait: #f0c46c;
    --wait-soft: #3a3020;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .92rem; }
.error { color: var(--danger); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--accent); color: var(--accent-text);
}
.top h1 { flex: 1; font-size: 1.2rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: none; border: 0; color: inherit; font-size: 1.8rem; line-height: 1;
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: rgb(255 255 255 / .15); }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

.btn {
  appearance: none; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; padding: 12px 16px; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 1.1rem; }
.btn:disabled { opacity: .5; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.file-btn { width: 100%; }

input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-top: 4px;
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: .9rem; color: var(--muted); }
label input, label textarea { color: var(--text); font-size: 1rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); font-size: 1.4rem;
}
.num {
  min-width: 56px; height: 56px; padding: 0 6px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-text);
  font-weight: 800; font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.badge { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.badge.out { background: var(--danger-soft); color: var(--danger); }
.badge.wait { background: var(--wait-soft); color: var(--wait); }

/* Daiktai, išsaugoti telefone be ryšio */
#queueBar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  border: 0; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  background: var(--wait-soft); color: var(--wait); padding: 8px 14px; border-radius: 999px;
  max-width: calc(100% - 32px); box-shadow: 0 4px 14px rgb(0 0 0 / .18);
}

.hero-photo { width: 100%; max-height: 50vh; object-fit: contain; border-radius: var(--radius); background: var(--card); }
.photo-pick { position: relative; }
.photo-preview { width: 100%; max-height: 280px; object-fit: contain; border-radius: 12px; margin-top: 8px; background: var(--bg); }
.ai-status { display: flex; gap: 8px; align-items: center; font-size: .92rem; color: var(--accent); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.history li { cursor: default; display: block; }
.history .when { color: var(--muted); font-size: .82rem; }

dialog {
  border: 0; padding: 0; background: transparent; color: var(--text);
  width: 100%; max-width: 560px; margin: auto auto 0; max-height: 92vh;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
@media (min-width: 640px) { dialog { margin: auto; } }
.sheet {
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
@media (min-width: 640px) { .sheet { border-radius: 18px; } }
.sheet > * + * { margin-top: 12px; }
#reader { width: 100%; border-radius: 12px; overflow: hidden; background: #000; min-height: 40px; }
#reader video { border-radius: 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 50;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / .25);
}

.login { max-width: 360px; text-align: center; padding-top: 12vh; }
.login img { margin: 0 auto 8px; }
.login h1 { margin-bottom: 20px; }
.login form { text-align: left; }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* Etikečių spausdinimas */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.label {
  border: 1px dashed var(--line); border-radius: 10px; padding: 10px; text-align: center; background: #fff; color: #000;
  break-inside: avoid;
}
.label .lnum { font-size: 64px; line-height: 1; font-weight: 900; letter-spacing: -.03em; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.label img { width: 120px; height: 120px; margin: 0 auto; }
.label .lname { font-weight: 600; font-size: 13px; margin-top: 4px; min-height: 1em; }
.label-pick { display: flex; align-items: center; gap: 8px; }
.label-pick input { width: auto; margin: 0; }
@media print {
  .top, .no-print { display: none !important; }
  body, main { background: #fff; padding: 0; max-width: none; }
  .label { border: 1px solid #999; }
}
