:root {
  --navy: #001e50;
  --navy-hover: #0a2f6b;
  --steel: #5b6770;
  --mist: #f4f6f8;
  --line: #d9dee4;
  --ink: #1b2430;
  --success: #1f7a4d;
  --danger: #b42318;
  --warn: #b45309;
  --white: #fff;
  --shadow: 0 8px 24px rgba(0, 30, 80, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overscroll-behavior-y: contain;
}
button, input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  touch-action: manipulation;
}
a { color: var(--navy); }

.topbar {
  background: var(--navy);
  color: var(--white);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 14px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}
.brand img {
  height: 48px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
}
.brand-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
}
.brand h1 {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}

#app {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  padding-bottom: max(48px, calc(24px + env(safe-area-inset-bottom)));
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h2 { margin: 0; color: var(--navy); font-size: 1.55rem; }
.muted { color: var(--steel); margin: 4px 0 0; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card h3 {
  margin: 0 0 14px;
  color: var(--navy);
  font-size: 1.05rem;
}

.grid {
  display: grid;
  gap: 12px;
}
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--navy);
}
.field input,
.field select,
.field textarea {
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--white);
  outline: none;
  min-height: 46px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--navy); }

.types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (min-width: 700px) {
  .types { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
.type-btn {
  min-height: 78px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 12px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  color: var(--navy);
  font-weight: 600;
  line-height: 1.25;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 30, 80, 0.12);
}
.type-btn small {
  display: block;
  font-weight: 400;
  color: var(--steel);
  font-size: 0.78rem;
  margin-top: 2px;
}
.type-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.type-btn.active small { color: rgba(255,255,255,0.75); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 30, 80, 0.14);
  user-select: none;
  -webkit-user-select: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--navy-hover); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-file { position: relative; overflow: hidden; }
.btn-file input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
  border: 0;
  background: transparent;
}

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.photo {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #eef1f4;
  aspect-ratio: 4 / 3;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 0;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.item img, .item .thumb-empty {
  width: 84px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: #e8edf2;
}
.item .thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--steel);
  font-size: 12px;
}
.item h3 { margin: 0; font-size: 1.02rem; color: var(--navy); }
.item p { margin: 3px 0 0; color: var(--steel); font-size: 0.9rem; }
.pill {
  display: inline-block;
  background: #e8eef8;
  color: var(--navy);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.pill-ok {
  background: #e8f6ee;
  color: var(--success);
}
.pdf-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #525659;
  margin-top: 10px;
}
.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--steel);
}

.detail-meta {
  display: grid;
  gap: 8px 18px;
}
@media (min-width: 640px) {
  .detail-meta { grid-template-columns: 1fr 1fr; }
}
.kv { margin: 0; }
.kv dt { color: var(--steel); font-size: 0.82rem; }
.kv dd { margin: 2px 0 8px; font-weight: 600; color: var(--navy); }
.note {
  white-space: pre-wrap;
  margin: 0;
}

.alert {
  background: #fdecec;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.ok {
  background: #e8f6ee;
  color: var(--success);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.scan-box {
  border: 2px dashed var(--navy);
  background: #eef3f9;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.scan-box h3 { margin-bottom: 6px; }
.ausweis-preview {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.ausweis-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #111;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.field.filled input {
  background: #e8f6ee;
  border-color: #8ec9a5;
}

.site-footer {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 16px 28px;
  padding-bottom: max(28px, calc(12px + env(safe-area-inset-bottom)));
  color: var(--steel);
  font-size: 12px;
}

.install-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.install-card p { margin: 0; }
.install-card .muted { margin-top: 4px; font-weight: 400; }
.install-dismiss {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--steel);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  min-height: 44px;
}
.form-sticky {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(244,246,248,0) 0%, var(--mist) 28%, var(--mist) 100%);
}
.form-sticky.kb-open { visibility: hidden; pointer-events: none; }

@media (max-width: 639px) {
  .brand { gap: 10px; }
  .brand img { height: 40px; max-width: min(42vw, 180px); }
  .brand h1 { font-size: 1.02rem; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn,
  .actions .btn,
  .form-sticky .btn { width: 100%; }
  .actions { flex-direction: column; }
  .item {
    grid-template-columns: 72px 1fr;
  }
  .item .pill {
    grid-column: 2;
    justify-self: start;
  }
  .photos { grid-template-columns: repeat(auto-fill, minmax(46vw, 1fr)); }
  .type-btn { min-height: 88px; }
  #app { padding-top: 14px; }
}
@media (max-width: 380px) {
  .brand-kicker { display: none; }
  .types { gap: 8px; }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .types { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .form-sticky .btn { min-width: 160px; }
}
@media (pointer: coarse) {
  .field input,
  .field select,
  .field textarea { min-height: 48px; padding: 12px 14px; }
  .photo button { min-height: 36px; padding: 6px 10px; }
}
@media (hover: none) {
  .btn-primary:hover:not(:disabled) { background: var(--navy); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

@media print {
  .topbar, .site-footer, .no-print, .form-sticky, .install-card { display: none !important; }
  body { background: #fff; }
  #app { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .photos { grid-template-columns: 1fr 1fr; }
  .photo { break-inside: avoid; aspect-ratio: auto; }
  .photo img { max-height: 280px; }
  .print-head {
    display: flex !important;
    align-items: center;
    gap: 16px;
    border-bottom: 3px solid var(--navy);
    padding-bottom: 10px;
    margin-bottom: 16px;
  }
}
.print-head { display: none; }
.print-head img { height: 42px; background: #000; padding: 6px 8px; border-radius: 6px; }
