:root {
  --green: #1b4332; --green-light: #2d6a4f; --accent: #e0532f; --bg: #f4f6f4; --text: #1c1c1c;
  --muted: #5f6b63; --border: #d5ddd7; --error: #b42318; --online: #2fa84f; --offline: #b9c2bc;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--green-light); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.narrow { max-width: 420px; margin: 80px auto; }
header.bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
h1 { margin: 0; font-size: 26px; color: var(--green); }
h2 { font-size: 18px; margin: 28px 0 10px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.stats { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.stats b { color: var(--text); }
button, .btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
button.danger { color: var(--error); }
button.link { border: 0; background: none; color: var(--green-light); text-decoration: underline; padding: 0; }
input[type="text"], input[type="password"] { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%; }
form.inline { display: flex; gap: 8px; align-items: center; }
form.inline input { width: auto; flex: 1; }
.error { color: var(--error); }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fafbfa; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions > * + * { margin-left: 6px; }
.table-scroll { overflow-x: auto; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--offline); }
.dot.online { background: var(--online); box-shadow: 0 0 0 3px rgba(47,168,79,.2); }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; cursor: zoom-in; background: #e6ebe7; }
.thumbs img.nogps { outline: 2px dashed var(--offline); outline-offset: -2px; }
.more { margin-top: 6px; }

.stack { position: relative; width: 56px; height: 56px; margin: 3px 6px 3px 0; cursor: pointer; }
/* Die beiden Kanten liegen hinter der Vorschau. Ohne z-index malt ::after als letztes Kind
   über das Bild und der Stapel bliebe grau. */
.stack::before, .stack::after { content: ""; position: absolute; inset: 0; border-radius: 6px; background: #cfd8d1; border: 1px solid #fff; }
.stack::before { transform: translate(4px, -4px); z-index: 0; }
.stack::after { transform: translate(2px, -2px); z-index: 1; }
.stack img { position: relative; z-index: 2; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; background: #e6ebe7; display: block; }
.stack .count { position: absolute; z-index: 3; bottom: -6px; right: -6px; background: var(--green); color: #fff; font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 999px; border: 1px solid #fff; }
.stack-photos { padding: 8px; margin-top: 6px; border: 1px dashed var(--border); border-radius: 8px; }
.banner { background: #fff3cd; border: 1px solid #ffe08a; color: #6b4e00; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }

#map { height: 60vh; min-height: 360px; border: 1px solid var(--border); border-radius: 12px; margin-top: 12px; }
.leaflet-popup-content img { width: 160px; height: 120px; object-fit: cover; border-radius: 6px; display: block; cursor: zoom-in; }
.leaflet-popup-content .caption { margin-top: 6px; font-size: 13px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2000; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.lightbox .caption { color: #fff; margin-top: 12px; font-size: 14px; text-align: center; max-width: 800px; }
.lightbox .caption .muted { color: #c5cfc8; }
.lightbox button { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,.15); color: #fff; border: 0; font-size: 20px; width: 40px; height: 40px; border-radius: 50%; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 28px; width: 48px; height: 48px; }
.lightbox .prev { left: 16px; right: auto; }
.lightbox .next { right: 16px; }

.lang-switch { display: flex; gap: 4px; }
.lang-switch .lang { font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .06em; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--muted); cursor: pointer; }
.lang-switch .lang[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }

.qr { text-align: center; }
.qr img { width: min(80vw, 600px); height: auto; }
.qr .code { font-family: ui-monospace, monospace; font-size: 40px; font-weight: 700; letter-spacing: .05em; margin: 12px 0 4px; }
.qr .url { font-family: ui-monospace, monospace; font-size: 18px; word-break: break-all; }
@media print { .no-print { display: none !important; } body { background: #fff; } }
.lightbox .del { position: absolute; top: 16px; left: 16px; right: auto; width: auto; height: auto; padding: 8px 14px; border-radius: 8px; font-size: 14px; background: rgba(180,35,24,.85); }

/* ---------- Posteingang ---------- */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 16px; min-height: 60vh; }
.inbox-list, .inbox-thread { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.inbox-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.inbox-tools select { flex: 1; font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
#conversations { list-style: none; margin: 0; padding: 0; }
#conversations li { padding: 10px 8px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
#conversations li.active { background: #eef4ef; }
#conversations .who { font-weight: 600; }
#conversations .preview { grid-column: 1 / -1; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#conversations .when { color: var(--muted); font-size: 12px; }
#conversations .unread { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); align-self: center; }
.thread-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
#thread-back { display: none; }
.window { font-size: 13px; color: var(--green-light); margin: 0 0 8px; }
.window.closed { color: var(--accent); }
#thread-messages { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
#thread-messages li { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: #eef4ef; align-self: flex-start; white-space: pre-wrap; }
#thread-messages li.out { background: #dcf3e3; align-self: flex-end; }
#thread-messages li.system { align-self: center; background: none; color: var(--muted); font-size: 12px; }
#thread-messages .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
#thread-messages .failed .meta { color: var(--error); }
#compose { display: flex; gap: 8px; margin-top: 10px; }
#compose textarea, #bc-text { flex: 1; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; width: 100%; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 12px; padding: 20px; width: min(560px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 10px; }
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox.threaded .inbox-list { display: none; }
  #thread-back { display: inline; }
}

/* ---------- Einstellungen ---------- */
.narrow-wide { max-width: 760px; }
.settings .field { margin-bottom: 14px; }
.settings label { display: block; font-weight: 600; margin-bottom: 4px; }
.settings .row { display: flex; gap: 8px; }
.settings .row input { flex: 1; }
.settings .source { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.settings .clear { font-size: 12px; margin-top: 2px; }
.settings .actions, .card .actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.state { padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--border); }
.state.ok { border-color: var(--online); }
.state.warn { border-color: var(--accent); }
.settings-page code { background: #eef4ef; padding: 2px 6px; border-radius: 4px; word-break: break-all; }
