/* Gastgeber-Portal – mobile zuerst, hell und dunkel */
:root {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #f1ece3;
  --ink: #1d2729;
  --ink-2: #4c5759;
  --muted: #7d8789;
  --line: #e4ddd1;
  --accent: #b9532c;       /* Terrakotta */
  --accent-ink: #ffffff;
  --accent-soft: #f6e3d9;
  --sea: #2a6a83;
  --ok: #2f7d4f;
  --ok-soft: #e1f1e6;
  --warn: #a8670b;
  --warn-soft: #fbefd7;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --closed: #d9d3c8;
  --ch-booking: #2f5fb3;
  --ch-airbnb: #d9485a;
  --ch-fewo: #1b8a8f;
  --ch-direct: #4c8a2f;
  --ch-manual: #6f6a62;
  --ch-other: #8a6fb3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 39, 41, .06), 0 4px 16px rgba(29, 39, 41, .05);
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a1c; --surface: #1c2427; --surface-2: #232d31; --ink: #eef0ee; --ink-2: #c3cbcb;
    --muted: #8f9a9b; --line: #2f3a3e; --accent: #e07a4f; --accent-soft: #3a2a22; --sea: #6fb2cc;
    --ok: #6cc28d; --ok-soft: #1f3327; --warn: #e3a948; --warn-soft: #3a2f1b; --bad: #f08a83; --bad-soft: #3d2322;
    --closed: #39403f; --ch-booking: #6f9ae6; --ch-airbnb: #f07583; --ch-fewo: #4fc0c4; --ch-direct: #85c063;
    --ch-manual: #a59f96; --ch-other: #b39ce0; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a1c; --surface: #1c2427; --surface-2: #232d31; --ink: #eef0ee; --ink-2: #c3cbcb;
  --muted: #8f9a9b; --line: #2f3a3e; --accent: #e07a4f; --accent-soft: #3a2a22; --sea: #6fb2cc;
  --ok: #6cc28d; --ok-soft: #1f3327; --warn: #e3a948; --warn-soft: #3a2f1b; --bad: #f08a83; --bad-soft: #3d2322;
  --closed: #39403f; --ch-booking: #6f9ae6; --ch-airbnb: #f07583; --ch-fewo: #4fc0c4; --ch-direct: #85c063;
  --ch-manual: #a59f96; --ch-other: #b39ce0; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--sea); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Layout */
.app { min-height: 100vh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.back { border: 0; background: none; color: var(--ink); font-size: 26px; line-height: 1; padding: 0 6px 0 0; cursor: pointer; }
main.view { padding: 4px 16px 24px; max-width: 980px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; position: relative;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.active { color: var(--accent); }
.tabbar .dot { position: absolute; top: 9px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

@media (min-width: 900px) {
  .app { padding-bottom: 0; padding-left: 220px; }
  .tabbar {
    top: 0; right: auto; width: 220px; height: auto; flex-direction: column; justify-content: flex-start;
    gap: 4px; padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  nav.tabbar .brand { display: block; }
  .tabbar a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
  .tabbar a.active { background: var(--accent-soft); }
  .tabbar .dot { position: static; margin-left: auto; }
  main.view { padding: 8px 32px 40px; }
  .topbar { padding-left: 32px; padding-right: 32px; }
}
.tabbar .brand { display: none; padding: 4px 12px 18px; font-weight: 700; font-size: 15px; color: var(--ink); }
.tabbar .brand small { display: block; font-weight: 500; }

/* ---------- Karten & Listen */
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.card > h2 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card > h2 .count { font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); padding: 1px 8px; border-radius: 999px; }
.section-title { margin: 22px 2px 10px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none; cursor: pointer;
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--muted); }
.row .chev { color: var(--muted); font-size: 18px; }
.row .right { text-align: right; font-size: 13px; }

.date-badge {
  flex: 0 0 auto; width: 46px; text-align: center; border-radius: 10px; background: var(--surface-2); padding: 5px 0 6px;
}
.date-badge b { display: block; font-size: 18px; line-height: 1.1; }
.date-badge span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 2px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.chip.ch { color: #fff; }
.chip.ch-booking { background: var(--ch-booking); }
.chip.ch-airbnb { background: var(--ch-airbnb); }
.chip.ch-fewo { background: var(--ch-fewo); }
.chip.ch-direct { background: var(--ch-direct); }
.chip.ch-manual { background: var(--ch-manual); }
.chip.ch-other, .chip.ch-expedia, .chip.ch-google { background: var(--ch-other); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Übersicht */
.hero { display: grid; gap: 10px; }
.now { display: flex; gap: 12px; align-items: center; }
.now .icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.now .icon svg { width: 22px; height: 22px; }
.todo-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.todo-item:first-of-type { border-top: 0; }
.todo-item .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.todo-item .ic svg { width: 17px; height: 17px; }
.todo-item.keycode .ic { background: var(--warn-soft); color: var(--warn); }
.todo-item.email .ic { background: var(--surface-2); color: var(--ink-2); }
.todo-item.payment .ic { background: var(--bad-soft); color: var(--bad); }
.todo-item.message .ic { background: var(--accent-soft); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.occ { display: grid; gap: 9px; margin-top: 4px; }
.occ .line { display: grid; grid-template-columns: 82px 1fr 42px; align-items: center; gap: 10px; font-size: 13px; }
.occ .bar { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.occ .bar i { display: block; height: 100%; background: var(--sea); border-radius: 999px; }
.gaps { display: flex; flex-wrap: wrap; gap: 8px; }
.gap {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 7px 11px; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
}
.gap b { display: block; font-size: 13px; }
.gap small { font-size: 12px; }
.gap.short { border-color: var(--warn); background: var(--warn-soft); }

/* ---------- Kalender */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 12px; }
.cal-head h2 { flex: 1; font-size: 18px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); display: grid; place-items: center; cursor: pointer; font-size: 18px;
}
.icon-btn svg { width: 19px; height: 19px; }
.weekdays, .month { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays div { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 0 0 6px; text-transform: uppercase; }
.month { background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.day {
  position: relative; background: var(--surface); min-height: 80px; padding: 5px 5px 4px; cursor: pointer;
  display: flex; flex-direction: column; user-select: none; -webkit-user-select: none;
}
.day.other { background: var(--surface-2); cursor: default; }
.day.other > * { opacity: .35; }
.day .d { font-size: 13px; font-weight: 650; }
.day.today .d { color: var(--accent-ink); background: var(--accent); border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; margin: -2px 0 0 -2px; }
.day .p { margin-top: 24px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.day .ms { font-size: 10px; color: var(--muted); }
.day.past { cursor: default; }
.day.past .p { color: var(--muted); }
.day.closed { background: repeating-linear-gradient(135deg, var(--surface) 0 6px, var(--closed) 6px 8px); }
.day .bk {
  position: absolute; left: 0; right: 0; top: 25px; height: 20px; color: #fff; font-size: 11px; font-weight: 650;
  padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 2;
}
.day .bk.start { left: 50%; border-radius: 7px 0 0 7px; }
.day .bk.end { right: 50%; border-radius: 0 7px 7px 0; }
.day .bk.start.end { left: 50%; right: 0; }
.day .bk.ch-booking { background: var(--ch-booking); }
.day .bk.ch-airbnb { background: var(--ch-airbnb); }
.day .bk.ch-fewo { background: var(--ch-fewo); }
.day .bk.ch-direct { background: var(--ch-direct); }
.day .bk.ch-manual { background: var(--ch-manual); }
.day .bk.ch-other, .day .bk.ch-expedia, .day .bk.ch-google { background: var(--ch-other); }
.day.sel { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); z-index: 1; }
.day.booked .p { visibility: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 2px 0; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.cal-hint { font-size: 13px; color: var(--muted); margin: 10px 2px 0; }
@media (min-width: 700px) { .day { min-height: 96px; padding: 7px; } .day .bk { top: 31px; height: 22px; font-size: 12px; } .day .p { font-size: 13px; margin-top: 30px; } }

/* ---------- Bottom Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 16, .38); z-index: 50; animation: fade .15s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow: auto; animation: up .2s ease; box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 18px; margin-bottom: 4px; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 440px; border-radius: 20px; animation: fade .15s ease; }
  .sheet .grab { display: none; }
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Formulare & Buttons */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 12px 0 0; }
label small { display: block; font-weight: 400; margin-top: 3px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 5px; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 96px; resize: vertical; }
.row-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn svg { width: 17px; height: 17px; }
.btns { display: grid; gap: 8px; margin-top: 16px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 11px; margin: 2px 0 14px; overflow-x: auto; }
.seg button {
  flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font: inherit; font-size: 13px;
  font-weight: 650; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Buchungsdetail */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; overflow-wrap: anywhere; }
.code-box { display: flex; gap: 8px; align-items: flex-end; }
.code-box input { font-size: 22px; font-weight: 700; letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.code-box .btn { flex: 0 0 auto; height: 50px; }
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 14px; overflow-wrap: anywhere; }
.msg .txt { white-space: pre-wrap; }
.msg.guest { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.owner { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.msg.system { align-self: center; background: none; color: var(--muted); font-size: 12px; text-align: center; }
.msg .when { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg .subj { display: block; font-weight: 650; font-size: 12px; margin-bottom: 3px; }

/* ---------- Hinweise, Toast, Laden */
.note { padding: 11px 13px; border-radius: 11px; font-size: 14px; margin: 12px 0; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px;
  font-weight: 550; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); animation: up .2s ease;
}
.toast.err { background: var(--bad); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 24px; left: calc(50% + 110px); } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; margin: 0; border-color: rgba(255,255,255,.4); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }
.spin-icon.spinning svg { animation: spin .8s linear infinite; }

/* ---------- Login & Einrichtung */
.login, .setup { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card, .setup-card { width: 100%; max-width: 400px; }
.setup-card { max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.login-card .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 18px; }
.login-card .logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 26px; }
fieldset { border: 0; padding: 0; margin: 22px 0 0; }
legend { font-weight: 700; font-size: 15px; padding: 0; }
.radio { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.radio input { width: auto; margin-top: 3px; }
.mysql label { margin-left: 26px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.check { font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.check.ok { background: var(--ok-soft); color: var(--ok); }
.check.bad { background: var(--bad-soft); color: var(--bad); }
pre.copy { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 12px; border-radius: 10px; font-size: 13px; user-select: all; }
.log { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.log div { padding: 5px 0; border-top: 1px solid var(--line); }
.log .error { color: var(--bad); }
.log .warn { color: var(--warn); }
