:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #15201e;
  --muted: #5d6b68;
  --border: #d9e0de;
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-text: #ffffff;
  --accent-soft: #d6efec;
  --danger: #c0392b;
  --success: #16794a;
  --warn-bg: #fff4d6;
  --warn-text: #7a5300;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1514;
  --surface: #182120;
  --surface-2: #1f2a29;
  --text: #e6eeec;
  --muted: #94a5a1;
  --border: #2c3a38;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-text: #062a26;
  --accent-soft: #123a36;
  --danger: #f07167;
  --success: #4ade80;
  --warn-bg: #3a2f10;
  --warn-text: #f5d58a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  transition: background-color .2s, color .2s;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 0; margin: .25rem 0 .5rem; font-size: .9rem; }
.error:empty, .success:empty { display: none; }
.success { color: var(--success); font-size: .9rem; }

svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Formulare ---------- */
label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .75rem; }
input, select {
  display: block; width: 100%; margin-top: .3rem;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .65rem .8rem; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.check { display: flex; align-items: center; gap: .5rem; }
label.check input { width: auto; min-height: 0; margin: 0; accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  min-height: 44px; padding: .55rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }
.small-btn { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; margin: -.25rem 0 .5rem -.6rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 50%; border: 1px solid transparent; background: transparent;
  color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; text-align: left; }
.login-card h1 { margin-bottom: .25rem; }
.login-logo { display: block; margin-bottom: 1rem; border-radius: 14px; }
.floating { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
  padding-top: max(.5rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.brand img { border-radius: 7px; }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tabs button {
  font: inherit; font-weight: 600; font-size: .95rem; color: var(--muted);
  background: none; border: 0; padding: .45rem .8rem; border-radius: 999px; cursor: pointer;
}
.tabs button.active { background: var(--accent-soft); color: var(--accent); }
.topbar-actions { display: flex; gap: .1rem; }

@media (max-width: 520px) {
  .brand span { display: none; }
}

/* ---------- Inhalt ---------- */
.panel { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 3rem; display: grid; gap: 1rem; align-content: start; }

.notice { background: var(--warn-bg); color: var(--warn-text); padding: .75rem 1rem; border-radius: 10px; margin: 0; font-size: .9rem; }

.hero { width: 100%; min-height: 60px; font-size: 1.05rem; border-radius: var(--radius); box-shadow: var(--shadow); }

.toolbar { display: flex; gap: .5rem; }
.toolbar input { margin: 0; flex: 1; }
.toolbar select { margin: 0; width: auto; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.dest {
  display: flex; align-items: center; gap: .9rem; width: 100%;
  padding: .85rem 1rem; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, transform .05s;
}
.dest:hover { border-color: var(--accent); }
.dest-row { display: flex; align-items: stretch; gap: .4rem; }
.dest-row .dest { flex: 1; min-width: 0; text-decoration: none; }
.dest-more {
  flex: none; width: 48px; display: grid; place-items: center; cursor: pointer;
  font-size: 1.4rem; line-height: 1; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.dest-more:hover { border-color: var(--accent); color: var(--accent); }
.dest:active { transform: scale(.995); }
.dest-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.dest-main { flex: 1; min-width: 0; }
.dest-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest-meta { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.dest-dist { color: var(--muted); font-size: .85rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 2rem 1rem; }

/* ---------- Admin ---------- */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: end; }
.grid-form .check { margin-bottom: 1.1rem; }
.grid-form .btn { margin-bottom: .75rem; }
@media (max-width: 560px) { .grid-form { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; margin: 0 -1.25rem -1.25rem; }
table.users { width: 100%; border-collapse: collapse; font-size: .92rem; }
.users th, .users td { padding: .6rem 1.25rem; text-align: left; border-top: 1px solid var(--border); white-space: nowrap; }
.users th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.users td:last-child { text-align: right; }
.users .btn { min-height: 34px; padding: .25rem .6rem; font-size: .85rem; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.admin { background: var(--accent-soft); color: var(--accent); }

/* ---------- Dialoge ---------- */
dialog {
  width: min(440px, calc(100vw - 2rem)); padding: 1.4rem;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.dlg-actions.spread { justify-content: space-between; }
.dlg-actions > div { display: flex; gap: .5rem; flex-wrap: wrap; }

@media (max-width: 520px) {
  dialog { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; padding-bottom: max(1.4rem, env(safe-area-inset-bottom)); }
}

.map-choice { display: grid; gap: .6rem; }
.btn.map { min-height: 56px; font-size: 1.05rem; justify-content: flex-start; padding-left: 1.1rem; }
.btn.map svg { width: 1.5em; height: 1.5em; }
.btn.map.option { margin: 0; font-weight: 600; }
.btn.map.option input { width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0 .25rem 0 0; accent-color: var(--accent); flex: none; }
.btn.map.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.btn.map.google svg { color: #ea4335; }
.btn.map.apple svg { color: #0a84ff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(1.25rem, env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 150%); opacity: 0;
  background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 999px;
  font-size: .92rem; font-weight: 500; box-shadow: var(--shadow);
  transition: transform .25s, opacity .25s; pointer-events: none; max-width: calc(100vw - 2rem);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
