:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --ink: #1b1f23;
  --ink-2: #5a6168;
  --line: #d9dcd6;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --focus: #2563eb;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181b; --surface: #1f2327; --ink: #eceeea; --ink-2: #a3aab0; --line: #343a40;
    --accent: #ea580c; --ok: #22c55e; --warn: #f59e0b; --danger: #ef4444; --focus: #60a5fa;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181b; --surface: #1f2327; --ink: #eceeea; --ink-2: #a3aab0; --line: #343a40;
  --accent: #ea580c; --ok: #22c55e; --warn: #f59e0b; --danger: #ef4444; --focus: #60a5fa;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--ink); color: var(--bg);
}
.topbar h1 { font-size: 17px; font-weight: 650; flex: 1; }
.topbar h1 small { font-weight: 400; opacity: .7; margin-left: 6px; }
.topbar a, .topbar button { color: var(--bg); background: none; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #0c0e10; color: var(--ink); } :root:not([data-theme="light"]) .topbar a, :root:not([data-theme="light"]) .topbar button { color: var(--ink); } }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
main.wide { max-width: 1280px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin-bottom: 10px; font-weight: 650; }

label.field { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
}
input.big { font-size: 22px; font-weight: 600; letter-spacing: .02em; }
textarea { min-height: 80px; resize: vertical; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 11px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none;
  min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.block { width: 100%; }
.btn.huge { min-height: 58px; font-size: 18px; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); font-size: 14px; }

/* GPS */
.gps { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.gps .coords { font: 600 17px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--danger); }

/* Fotos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(0,0,0,.65); color: #fff; font-size: 18px; line-height: 30px; cursor: pointer; padding: 0; }
.thumb .state { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: 12px; background: rgba(0,0,0,.6); color: #fff; }
.addphoto { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-2); cursor: pointer; font-size: 14px; background: transparent; font-family: inherit; }
.addphoto span { font-size: 30px; line-height: 1; }
input[type=file].hidden { display: none; }

/* Checks */
.check { border-top: 1px solid var(--line); padding: 12px 0; }
.check:first-of-type { border-top: none; padding-top: 0; }
.check > label.toggle { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; cursor: pointer; min-height: 44px; }
.check input[type=checkbox] { width: 28px; height: 28px; accent-color: var(--accent); flex: none; }
.check .detail { display: grid; grid-template-columns: 96px 1fr; gap: 10px; margin-top: 10px; }
.check .detail[hidden] { display: none; }

/* Schlüsselnummer */
.sn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sn label { display: flex; align-items: center; gap: 10px; padding: 14px 12px; border: 2px solid var(--line); border-radius: 8px; font-weight: 650; cursor: pointer; min-height: 56px; }
.sn input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; margin: 0; }
.sn label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sn small { display: block; font-weight: 500; color: var(--danger); }
@media (max-width: 360px) { .sn { grid-template-columns: 1fr; } }
td.sn-g { color: var(--danger); font-weight: 700; }

/* Meldungen */
.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 600px; margin: 0 auto; padding: 14px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 600; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* Login */
.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }

/* Admin-Tabelle */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 13px; color: var(--ink-2); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; background: var(--bg); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
td.c { text-align: center; }
.tick { color: var(--accent); font-weight: 800; }
td.nr { font-weight: 700; }

/* Dialog */
dialog { width: min(760px, calc(100vw - 16px)); max-height: calc(100vh - 32px); border: none; border-radius: 12px; padding: 0; background: var(--bg); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog .dhead { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
dialog .dhead h2 { flex: 1; font-size: 18px; }
dialog .dbody { padding: 16px; }
dialog .dfoot { position: sticky; bottom: 0; display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); }
