:root {
  --blau: #34987a; --blau-dunkel: #27735c; --gruen: #1a9f55; --rot: #d33; --grau: #6b7280;
  --bg: #f4f6fa; --card: #fff; --rand: #e3e7ee; --text: #1b1f27;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.4rem; margin: 0 0 .4rem; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
.muted { color: var(--grau); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 10; background: #fff; color: var(--text); border-bottom: 1px solid var(--rand);
  padding: calc(env(safe-area-inset-top) + 6px) 16px 6px; display: flex; justify-content: space-between; align-items: center; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { display: block; padding-top: 3px; }
.topbar-logo img { height: 45px; display: block; }
.topbar-back { font-size: 1.9rem; line-height: 1; color: var(--blau); text-decoration: none; padding: 0 4px; margin-left: -6px; }
.topbar-title { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { font-size: .85rem; color: var(--grau); white-space: nowrap; }
.topbar-logout { color: var(--blau); margin-left: 8px; text-decoration: underline; }

.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 8px 0 20px; }
.tile-link { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--rand); border-radius: 12px;
  padding: 18px 16px; text-decoration: none; color: var(--text); }
.tile-icon { font-size: 2rem; }
.tile-text { font-weight: 600; font-size: 1.05rem; }
.tile-text small { display: block; font-weight: 400; color: var(--grau); font-size: .85rem; }

.info-line { font-size: .85rem; background: #e6f6ee; color: #135c33; border-radius: 8px; padding: 8px 10px; margin: -4px 0 10px; }
.info-line.err { background: #fde8e8; color: #7a1d1d; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #e6f6ee; color: #135c33; border-radius: 999px; padding: 3px 8px 3px 3px; font-size: .85rem; max-width: 100%; }
.chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #fff; }
.toggle-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; margin: 4px 0 2px; font: inherit; font-size: 1rem; font-weight: 600;
  border: 2px solid var(--rand); border-radius: 10px; background: var(--card); color: var(--grau); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s, color .15s, border-color .15s; }
.toggle-btn .tg-check { font-size: 1.2rem; line-height: 1; }
.toggle-btn.on { background: var(--blau); border-color: var(--blau); color: #fff; }
.toggle-btn:active { transform: scale(.985); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: none; color: inherit; font-size: 1rem; line-height: 1; padding: 0 2px; }
.suggest { border: 1px solid var(--rand); border-radius: 10px; background: var(--card); margin: -6px 0 10px; max-height: 320px; overflow: auto; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.suggest-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-top: 1px solid var(--rand);
  background: none; color: var(--text); font: inherit; cursor: pointer; }
.suggest-row:first-child { border-top: 0; }
.suggest-row:active { background: var(--bg); }
.suggest-row.gewaehlt { opacity: .5; }
.suggest-img { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 6px; background: var(--bg); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.suggest-img img { max-width: 100%; max-height: 100%; display: block; }
.suggest-text { min-width: 0; display: flex; flex-direction: column; }
.suggest-text b { font-size: .95rem; }
.suggest-text small { color: var(--grau); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.input-row { display: flex; gap: 8px; margin-top: 4px; }
.input-row input[type=text] { margin-top: 0; flex: 1; min-width: 0; }
.btn-scan { white-space: nowrap; padding: 0 14px; }
.scan-sheet h2 { margin-bottom: 2px; }
.scan-view { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 10px; overflow: hidden; margin: 8px 0; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 8%; right: 8%; top: 32%; bottom: 32%; border: 3px solid rgba(255,255,255,.85); border-radius: 8px; box-shadow: 0 0 0 2000px rgba(0,0,0,.35); pointer-events: none; }
.switch-row { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; }
.switch-row input { width: 20px; height: 20px; }

.banner { padding: 10px 16px; background: #fde68a; color: #5a4300; font-size: .9rem; position: relative; }

.content { padding: 12px 16px calc(env(safe-area-inset-bottom) + 24px); max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--rand); border-radius: 12px; padding: 14px; margin-bottom: 14px; }

label { display: block; font-size: .85rem; color: var(--grau); margin-bottom: 10px; }
input[type=text], input[type=password] { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font-size: 1rem;
  border: 1px solid var(--rand); border-radius: 8px; background: #fff; color: var(--text); }
input:focus { outline: 2px solid var(--blau); border-color: var(--blau); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; font-size: 1rem;
  border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.btn-primary { background: var(--blau); color: #fff; }
.btn-secondary { background: #e8edf5; color: var(--text); }
.btn-success { background: var(--gruen); color: #fff; }
.btn-link { background: none; color: var(--grau); }
.btn-danger { background: var(--rot); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
.btn-big { padding: 16px; font-size: 1.05rem; font-weight: 600; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.pick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }

.queue { list-style: none; margin: 0; padding: 0; }
.queue li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--rand); }
.queue li:first-child { border-top: 0; }
.queue img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: #eee; }
.q-name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-status { font-size: .8rem; color: var(--grau); }
.q-status.ok { color: var(--gruen); }
.q-status.err { color: var(--rot); }
.progress { height: 6px; background: #e8edf5; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress > div { height: 100%; width: 0; background: var(--blau); transition: width .2s; }
.queue-actions { margin-top: 10px; }
.summary { margin-top: 10px; padding: 10px; border-radius: 8px; background: #e6f6ec; color: #135c33; font-size: .95rem; }
.summary.err { background: #fde8e8; color: #7a1d1d; }

.recent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.recent-head h2 { margin: 0; }
.switch { font-size: .85rem; margin: 0; display: flex; align-items: center; gap: 4px; }
.recent { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.recent .tile { position: relative; border-radius: 8px; overflow: hidden; background: #eee; aspect-ratio: 1; }
.recent .tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent .tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 5px; background: rgba(0,0,0,.55); color: #fff;
  font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .tile .st { position: absolute; top: 4px; left: 4px; font-size: .65rem; padding: 1px 5px; border-radius: 6px; background: rgba(255,255,255,.9); color: #333; }
.recent .tile .st.zugeordnet { background: #dbeafe; color: #0b3d91; }
.recent .tile .st.veroeffentlicht { background: #d1fae5; color: #065f46; }
.recent .tile .st.verworfen { background: #fee2e2; color: #7f1d1d; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; }
.sheet { background: #fff; width: 100%; border-radius: 16px 16px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); max-height: 92vh; overflow: auto; }
.sheet img { width: 100%; max-height: 40vh; object-fit: contain; border-radius: 8px; background: #f0f0f0; margin-bottom: 10px; }
.sheet-row { display: flex; gap: 8px; margin-top: 10px; }
.sheet-row .btn { flex: 1; }

body.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: var(--card); border: 1px solid var(--rand); border-radius: 14px; padding: 24px; width: 100%; max-width: 380px; text-align: center; }
.login-box form { text-align: left; margin-top: 14px; }
.login-logo { width: 160px; margin-bottom: 4px; }
.alert { background: #fde8e8; color: #7a1d1d; padding: 10px; border-radius: 8px; font-size: .9rem; margin-top: 10px; }

@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --card: #1b1f26; --rand: #2c323c; --text: #e8ebf0; --grau: #9aa3b2; }
  .topbar { background: #fff; color: #1b1f27; }
  .topbar-user { color: #6b7280; }
  .info-line, .chip { background: #15372a; color: #a7e3c0; }
  .info-line.err { background: #46201f; color: #f3b4b4; }
  input[type=text], input[type=password] { background: #12161c; }
  .btn-secondary { background: #2a313c; color: var(--text); }
  .sheet { background: var(--card); }
  .login-box { background: #fff; color: #1b1f27; }
  .login-box input[type=text], .login-box input[type=password] { background: #fff; color: #1b1f27; }
  .summary { background: #15372a; color: #a7e3c0; }
  .summary.err { background: #46201f; color: #f3b4b4; }
}

/* Touch-Geraete: groessere Schrift und Bedienelemente (Android wirkte zu klein) */
@media (pointer: coarse) and (max-width: 600px) {
  html, body { font-size: 17px; }
  input[type=text], input[type=password] { padding: 13px 14px; font-size: 1.05rem; }
  .btn { padding: 13px 18px; min-height: 50px; }
  .btn-big { padding: 18px; font-size: 1.1rem; min-height: 60px; }
  .btn-sm { min-height: 40px; padding: 8px 12px; }
  .toggle-btn { padding: 16px; min-height: 56px; font-size: 1.05rem; }
  .chip { font-size: .95rem; padding: 4px 10px 4px 4px; }
  .chip img { width: 36px; height: 36px; }
  .chip button { font-size: 1.3rem; padding: 0 6px; }
  .suggest-row { padding: 10px 12px; }
  .suggest-img { width: 56px; height: 56px; flex-basis: 56px; }
  .suggest-text b { font-size: 1.05rem; }
  .suggest-text small { font-size: .9rem; }
  .queue img { width: 72px; height: 72px; }
  .recent { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .recent .tile .cap { font-size: .8rem; padding: 4px 6px; }
  .tile-link { padding: 22px 18px; }
  .topbar-logout { font-size: 1rem; }
}
