/* PSA-Prüftool – hell, freundlich, auf dem Handy mit einer Hand bedienbar */
:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #1d2b2a;
  --muted: #5d6f6d;
  --line: #dde6e4;
  --brand: #0b7a75;
  --brand-dark: #08605c;
  --brand-soft: #e3f3f1;
  --sun: #f4b740;
  --sun-soft: #fff4dc;
  --ok: #1f8a4c;
  --ok-soft: #e4f5ea;
  --warn: #b26a00;
  --warn-soft: #fff1d6;
  --bad: #c0392b;
  --bad-soft: #fdeceA;
  --off: #6b7280;
  --off-soft: #eef0f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 42, 40, .06), 0 4px 14px rgba(16, 42, 40, .06);
  --tap: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 84px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .7rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
small, .muted { color: var(--muted); }
code { background: var(--brand-soft); padding: 1px 5px; border-radius: 5px; }

/* Kopfzeile */
.topbar {
  background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.topbar .in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--sun); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.topnav { display: flex; gap: 2px; margin-left: 12px; }
.topnav a { color: #e9fbf9; padding: 8px 12px; border-radius: 10px; font-weight: 500; }
.topnav a:hover, .topnav a.active { background: rgba(255, 255, 255, .16); text-decoration: none; color: #fff; }
.topbar .spacer { flex: 1; }
.topbar form.search { display: flex; }
.topbar form.search input { border: 0; border-radius: 10px; padding: 8px 12px; width: 220px; font-size: .95rem; }
.userchip { color: #e9fbf9; font-size: .9rem; }
.btn-scan-top { background: var(--sun); color: var(--ink); border-radius: 10px; padding: 8px 14px;
  font-weight: 700; }
.btn-scan-top:hover { text-decoration: none; filter: brightness(1.05); }

/* Untere Navigation (Handy) */
.bottomnav { display: none; }
@media (max-width: 860px) {
  .topnav, .topbar form.search, .userchip, .btn-scan-top { display: none; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    background: #fff; border-top: 1px solid var(--line); z-index: 30;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
    font-size: .72rem; padding: 4px 0; border-radius: 10px; }
  .bottomnav a svg { width: 24px; height: 24px; }
  .bottomnav a.active { color: var(--brand); }
  .bottomnav a.scan { color: var(--ink); }
  .bottomnav a.scan span.ic { background: var(--sun); border-radius: 14px; width: 52px; height: 40px;
    display: grid; place-items: center; margin-top: -2px; }
  .bottomnav a:hover { text-decoration: none; }
}

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 30px; }

/* Karten und Raster */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  margin-bottom: 14px; border: 1px solid #edf2f1; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, 1fr); } }

.pagehead { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.pagehead h1 { flex: 1; min-width: 200px; margin-bottom: .4rem; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: .9rem; color: var(--muted); margin-bottom: 4px; }

/* Kacheln Startseite */
.tile { display: block; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  border: 1px solid #edf2f1; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--brand); }
.tile .n { font-size: 2rem; font-weight: 800; line-height: 1; }
.tile .l { color: var(--muted); font-size: .92rem; margin-top: 6px; }
.tile.bad .n { color: var(--bad); }
.tile.warn .n { color: var(--warn); }
.tile.ok .n { color: var(--ok); }

.bigactions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 18px; }
@media (max-width: 600px) { .bigactions { grid-template-columns: 1fr; } }
.bigaction { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); color: var(--ink); font-weight: 600; border: 1px solid #edf2f1; }
.bigaction:hover { text-decoration: none; border-color: var(--brand); }
.bigaction .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); flex: none; }
.bigaction.primary { background: var(--sun); border-color: var(--sun); }
.bigaction.primary .ic { background: rgba(255, 255, 255, .6); color: var(--ink); }
.bigaction small { display: block; font-weight: 400; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.sun { background: var(--sun); border-color: var(--sun); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: #f0c4be; }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .9rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }

/* Formulare */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
label .opt { font-weight: 400; color: var(--muted); }
.field { margin-bottom: 14px; }
.hint { font-size: .84rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url],
input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid #cfdad8; border-radius: 11px;
  font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(11, 122, 117, .22); border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 40px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.formactions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.inline-form { display: inline; }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filterbar .field { margin: 0; flex: 1; min-width: 150px; }
input[type=file] { width: 100%; padding: 10px; border: 2px dashed #cfdad8; border-radius: 11px; background: #fbfdfc; }

/* Tabellen */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: .94rem; }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:hover td { background: #fafcfb; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 12px 6px 0; width: 42%;
  vertical-align: top; font-size: .92rem; }
table.kv td { padding: 6px 0; font-weight: 500; }

/* Mobile Karten statt Tabellen */
.rows { display: grid; gap: 10px; }
.row { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; color: var(--ink); }
.row:hover { text-decoration: none; border-color: var(--brand); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 700; }
.row .s { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.off { background: var(--off-soft); color: var(--off); }
.statusbar { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; font-weight: 600;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.statusbar.ok { background: var(--ok-soft); color: var(--ok); }
.statusbar.warn { background: var(--warn-soft); color: var(--warn); }
.statusbar.bad { background: var(--bad-soft); color: var(--bad); }
.statusbar.off { background: var(--off-soft); color: var(--off); }

/* Meldungen */
.flash { border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #bfe3cb; color: #165f36; }
.flash.warn { background: var(--warn-soft); border-color: #f1d49a; color: #7a4a00; }
.flash.bad { background: var(--bad-soft); border-color: #f0c4be; color: #8e2a1f; }

/* Bilder */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery .ph { position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block;
  border: 1px solid var(--line); background: #f0f3f2; }
.gallery form { position: absolute; top: 4px; right: 4px; }
.gallery form button { background: rgba(255, 255, 255, .92); border: 0; border-radius: 8px; width: 30px; height: 30px;
  cursor: pointer; color: var(--bad); font-weight: 700; }

/* Prüfung */
.progress { position: sticky; top: 56px; z-index: 10; background: var(--bg); padding: 8px 0; }
.progress .bar { height: 8px; border-radius: 99px; background: #dfe8e6; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.progress .txt { font-size: .85rem; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 22px 0 8px; flex-wrap: wrap; }
.section-head h3 { margin: 0; flex: 1; }
.point { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow); }
.point.is-io { border-left: 6px solid var(--ok); }
.point.is-nio { border-left: 6px solid var(--bad); background: #fffafa; }
.point.is-entfaellt { border-left: 6px solid #b9c3c1; }
.point .ptext { font-weight: 600; margin-bottom: 10px; }
.point .pnum { color: var(--muted); font-weight: 500; margin-right: 6px; }
.ratings { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.ratings input { position: absolute; opacity: 0; pointer-events: none; }
.ratings label { margin: 0; min-height: 54px; display: grid; place-items: center; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; font-size: 1.05rem; font-weight: 800; cursor: pointer;
  user-select: none; }
.ratings label.r-io:hover { border-color: var(--ok); }
.ratings label.r-nio:hover { border-color: var(--bad); }
.ratings input:checked + label.r-io { background: var(--ok); border-color: var(--ok); color: #fff; }
.ratings input:checked + label.r-nio { background: var(--bad); border-color: var(--bad); color: #fff; }
.ratings input:checked + label.r-entfaellt { background: #8a9795; border-color: #8a9795; color: #fff; }
.ratings input:focus-visible + label { outline: 3px solid rgba(11, 122, 117, .35); }
.nio-extra { margin-top: 12px; display: none; }
.point.is-nio .nio-extra { display: block; }
.point .remark-toggle { margin-top: 8px; font-size: .9rem; }

/* Unterschrift */
.sigwrap { border: 2px dashed #b9c9c6; border-radius: 12px; background: #fff; position: relative; touch-action: none; }
.sigwrap canvas { width: 100%; height: 180px; display: block; border-radius: 12px; }
.sigwrap .sigclear { position: absolute; top: 8px; right: 8px; }
.sigwrap .sighint { position: absolute; left: 14px; bottom: 10px; color: #a7b5b2; font-size: .85rem; pointer-events: none; }
.sigdone img { max-height: 90px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 4px; }

/* Scanner */
#reader { width: 100%; max-width: 520px; margin: 0 auto; border-radius: var(--radius); overflow: hidden;
  background: #000; min-height: 260px; }

/* Historie */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline .when { font-size: .82rem; color: var(--muted); }
.timeline .what { font-weight: 600; }
.timeline .diff { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.timeline .diff b { color: var(--ink); font-weight: 600; }

details.box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
details.box summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; border-bottom: 2px solid var(--line); }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
  margin-bottom: -2px; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.qrbox { text-align: center; }
.qrbox img { width: 180px; height: 180px; }
.prose h3 { color: var(--brand); }
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 10px 0 20px; }
.hide-mobile { }
@media (max-width: 860px) { .hide-mobile { display: none !important; } }
.show-mobile { display: none; }
@media (max-width: 860px) { .show-mobile { display: block; } }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt0 { margin-top: 0; }
.login-wrap { max-width: 400px; margin: 7vh auto 0; }
.login-wrap .brandbig { text-align: center; margin-bottom: 18px; }
.login-wrap .brandbig .logo { width: 60px; height: 60px; border-radius: 18px; background: var(--sun);
  display: inline-grid; place-items: center; font-weight: 800; font-size: 1.3rem; }

@media print {
  .topbar, .bottomnav, .noprint, .footer { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* Kopfzeile auf mittleren Bildschirmen kompakt halten */
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.btn-scan-top, .topnav a { white-space: nowrap; }
.topbar form.search input { width: 180px; }
@media (max-width: 1400px) { .userchip { display: none; } .topbar form.search input { width: 150px; } }
@media (max-width: 1060px) { .topbar form.search { display: none; } }

/* Überschrift direkt nach verstecktem Formularfeld */
.card > input[type=hidden] + h2, .card > input[type=hidden] + h3 { margin-top: 0; }
