:root {
  --blue: #1f4e8c;
  --blue-dark: #163a69;
  --green: #17703a;
  --green-bg: #e3f4e8;
  --orange: #9a4b00;
  --orange-bg: #fff1dc;
  --red: #a4161a;
  --red-bg: #fde5e5;
  --text: #111;
  --muted: #5b6170;
  --line: #d9dde5;
  --bg: #f4f6f9;
  --card: #fff;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  line-height: 1.4;
}
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--blue); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.15rem; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.15); }

main { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: .2em 0 .6em; }
h2 { font-size: 1.1rem; margin: 1.4em 0 .5em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .9rem; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

button, .button {
  font: inherit; cursor: pointer;
  border: 0; border-radius: 12px;
  padding: 12px 18px;
  background: #e6e9ef; color: var(--text);
  display: inline-block; text-align: center; text-decoration: none;
}
button.primary, .button.primary { background: var(--blue); color: #fff; font-weight: 600; }
button.primary:active { background: var(--blue-dark); }
button.big { width: 100%; padding: 18px; font-size: 1.25rem; }
button.danger { background: var(--red-bg); color: var(--red); }
button.link { background: none; padding: 6px 0; color: var(--blue); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }

/* ---- ticket on the home screen ---- */
.ticket { text-align: center; }
.ticket .label { font-size: 1.2rem; font-weight: 700; margin: 0 0 6px; }
.status-pill {
  display: inline-block; padding: 4px 12px; border-radius: 99px;
  font-weight: 600; font-size: .95rem; margin-bottom: 10px;
}
.status-aktiv { background: var(--green-bg); color: var(--green); }
.status-unbenutzt { background: var(--orange-bg); color: var(--orange); }
.status-abgelaufen { background: #eceef2; color: var(--muted); }

.qr-box {
  display: block; width: 100%; max-width: 380px; margin: 0 auto 12px;
  background: #fff; padding: 0; border: 1px solid var(--line); border-radius: 10px;
  cursor: zoom-in;
}
.qr-box svg, .qr-box img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.countdown { font-size: 1.6rem; font-weight: 700; margin: 4px 0 0; }
.until { font-size: 1.05rem; margin: 2px 0 10px; }
.warn {
  background: var(--red-bg); color: var(--red); font-weight: 600;
  border-radius: 10px; padding: 10px 12px; margin: 10px 0;
}
.note { background: var(--orange-bg); color: var(--orange); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.toggle { margin: 4px 0 8px; }

/* ---- lists ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); cursor: pointer;
}
.list li .meta { color: var(--muted); font-size: .85rem; }
.stats { display: flex; gap: 10px; }
.stats .card { flex: 1; text-align: center; margin: 0; }
.stats .num { font-size: 1.8rem; font-weight: 700; }

/* ---- import ---- */
label.field { display: block; margin: 10px 0; }
label.field span { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="password"] {
  font: inherit; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input[type="file"] { font: inherit; width: 100%; }
progress { width: 100%; height: 14px; }
.result-list { padding-left: 1.2em; }
.result-list li { margin: 3px 0; }
.problem { color: var(--red); }

/* ---- banner ---- */
.banner {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  background: #fff7d6; color: #5c4400; padding: 10px 16px;
}
.banner button { padding: 8px 14px; background: var(--blue); color: #fff; }

/* ---- fullscreen QR ---- */
.fullscreen {
  position: fixed; inset: 0; z-index: 100;
  background: #fff; color: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
  cursor: zoom-out;
}
.fullscreen-code { width: min(96vw, 82vh); }
.fullscreen-code svg, .fullscreen-code img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.fullscreen-label { font-size: 1.2rem; font-weight: 700; margin: 10px 0 0; }
.fullscreen-hint { color: #444; margin: 6px 0 0; }

/* ---- dialog ---- */
dialog {
  border: 0; border-radius: var(--radius); padding: 18px;
  width: min(92vw, 480px); max-height: 88vh;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; }
dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.steps { padding-left: 1.3em; }
.steps li { margin: 4px 0; }
