:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-light: #ccfbf1;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 560px; margin: 0 auto; padding: 14px 14px 60px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

/* ── Header ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--teal-light); color: var(--teal-dark); text-transform: uppercase; letter-spacing: .03em;
}
.badge.closed { background: #fee2e2; color: var(--red); }

/* ── Cards ── */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.card h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* ── Balance hero ── */
.hero { text-align: center; padding: 22px 16px; background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; }
.hero .label { font-size: 13px; opacity: .85; }
.hero .amount { font-size: 44px; font-weight: 800; margin: 2px 0; letter-spacing: -.02em; }
.hero .amount.pos { color: #bbf7d0; }
.hero .amount.neg { color: #fecaca; }
.hero .note { font-size: 13px; opacity: .9; }
.hero .meta { display: flex; justify-content: center; gap: 18px; margin-top: 14px; font-size: 12px; opacity: .9; }
.hero .meta b { display: block; font-size: 15px; }

/* ── Stat row ── */
.stats { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--card); border-radius: var(--radius); padding: 13px; text-align: center; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ── Buttons ── */
button, .btn {
  font: inherit; cursor: pointer; border: none; border-radius: 12px;
  padding: 13px 16px; font-weight: 700; background: var(--teal); color: #fff;
  width: 100%; transition: transform .05s, opacity .15s;
}
button:active { transform: scale(.98); }
button.secondary { background: var(--teal-light); color: var(--teal-dark); }
button.ghost { background: #f1f5f9; color: var(--ink); }
button.danger { background: #fee2e2; color: var(--red); }
button.sm { width: auto; padding: 8px 12px; font-size: 13px; border-radius: 10px; }
button:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; }

input, select, textarea {
  font: inherit; width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink); margin-bottom: 10px;
  resize: vertical;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-light); border-color: var(--teal); }

/* ── Ampel (Kassenstand-Warnung) ── */
.ampel { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.ampel .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ampel.green { background: #dcfce7; color: #166534; }
.ampel.green .dot { background: var(--green); }
.ampel.amber { background: #fef3c7; color: #92400e; }
.ampel.amber .dot { background: var(--amber); }
.ampel.red { background: #fee2e2; color: #991b1b; }
.ampel.red .dot { background: var(--red); }

/* ── Schnellbuchungs-Buttons ── */
.qbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.qbtns button { width: auto; padding: 8px 12px; font-size: 13px; border-radius: 999px; background: #f1f5f9; color: var(--ink); font-weight: 600; }
.qbtns button:active { background: var(--teal-light); }

/* ── Galerie ── */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.gallery .thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; background: #e2e8f0; }
.gallery:empty { display: none; }

/* ── Feed ── */
.feed-time { font-size: 12px; color: var(--muted); }

/* ── Beleg-Vorschau ── */
.receipt-thumb { max-width: 90px; border-radius: 8px; margin-top: 6px; display: block; }

/* ── Lightbox (Fullscreen + Swipe) ── */
.lb { position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 100; display: flex; flex-direction: column; touch-action: pan-y; }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: 14px; color: #fff; padding-top: max(14px, env(safe-area-inset-top)); }
.lb-count { font-size: 13px; opacity: .85; }
.lb-top button { width: auto; background: rgba(255,255,255,.16); color: #fff; padding: 8px 14px; border-radius: 10px; font-weight: 700; }
.lb-top button.danger { background: rgba(220,38,38,.85); color: #fff; }
.lb-img { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-user-drag: none; user-select: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: auto !important; background: rgba(255,255,255,.16); color: #fff; font-size: 26px; line-height: 1; padding: 8px 14px; border-radius: 12px; }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-cap { padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); color: #fff; text-align: center; font-size: 14px; min-height: 18px; }

/* ── Karte (Leaflet) ── */
#map { height: 260px; border-radius: 12px; overflow: hidden; position: relative; z-index: 0; background: #e2e8f0; }
.leaflet-container { font: inherit; }
label.fld { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }

/* ── Lists ── */
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row .main { min-width: 0; }
.row .name { font-weight: 600; }
.row .sub { font-size: 12px; color: var(--muted); }
.amount-pos { color: var(--green); font-weight: 700; }
.amount-neg { color: var(--red); font-weight: 700; }
.muted { color: var(--muted); }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.pill.in { background: #dcfce7; color: var(--green); }
.pill.out { background: #f1f5f9; color: var(--muted); }
.pill.me { background: var(--teal-light); color: var(--teal-dark); }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 14px 0; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }

.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox input { margin: 0; font-size: 13px; }
.qr { display: block; margin: 12px auto 0; border-radius: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

dialog { border: none; border-radius: 18px; padding: 18px; width: min(440px, calc(100vw - 28px)); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.4); }
dialog h3 { margin: 0 0 14px; }
.checklist { max-height: 240px; overflow-y: auto; margin-bottom: 10px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.checklist input { width: auto; margin: 0; }
.section-actions { margin-top: 10px; }
.tabbar { display: flex; gap: 6px; margin-bottom: 12px; }
.tabbar button { background: #fff; color: var(--muted); box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.tabbar button.active { background: var(--teal); color: #fff; }
