:root {
  --primary: #ff5a1f;
  --primary-dark: #e34a13;
  --primary-light: #fff0e8;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --green: #10b981;
  --green-light: #d1fae5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
  --header-h: 56px;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }

/* ── Login ── */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #ff5a1f 0%, #ff8a4f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.login-card {
  background: white;
  border-radius: 24px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  margin-bottom: 16px;
}
.login-title { margin: 0 0 4px; font-size: 1.4rem; font-weight: 700; }
.login-subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: .9rem; }
.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color .2s;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  transition: background .2s;
}
.login-btn:active { background: var(--primary-dark); }
.login-error {
  margin: 12px 0 0;
  color: var(--red);
  font-size: .85rem;
  min-height: 1.2em;
}

/* ── App Shell ── */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  z-index: 10;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.header-title { margin: 0; font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background .15s;
}
.header-btn:active { background: rgba(255,255,255,.2); }
.header-btn.spinning svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
}

/* ── Tabbar ── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  box-shadow: 0 -2px 12px rgba(0,0,0,.04);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 500;
  position: relative;
  transition: color .15s;
}
.tab svg { transition: transform .15s; }
.tab.active { color: var(--primary); }
.tab.active svg { transform: scale(1.1); }
.tab:active { background: rgba(0,0,0,.03); }
.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  background: var(--red);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  color: var(--text-muted);
  gap: 12px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 8px; }
.empty p { margin: 4px 0; }

/* ── Stats ── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stat {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-val { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.stat-val.warn { color: var(--yellow); }
.stat-val.ok { color: var(--green); }
.stat-lbl { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ── Filter Chips ── */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--card);
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  border: 1px solid var(--border);
  transition: all .15s;
}
.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Booking Card ── */
.b-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.b-card.pending { border-left-color: var(--yellow); background: #fffbeb; }
.b-card.confirmed { border-left-color: var(--green); }
.b-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.b-date {
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.b-name {
  font-weight: 600;
  font-size: 1.05rem;
  margin: 2px 0;
  color: var(--text);
}
.b-customer {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: .9rem;
}
.b-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.b-tag {
  font-size: .72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
}

.b-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.b-pill {
  font-size: .72rem;
  font-weight: 600;
  color: white;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0,0,0,.15);
}
.b-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--bg);
  border-radius: 8px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Positionen-Liste im Sheet */
.pos-list {
  margin-top: 14px;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px;
}
.pos-head {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.pos {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: white;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: .9rem;
}
.pos-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pos-name {
  flex: 1;
  font-weight: 500;
  word-break: break-word;
}
.pos-price {
  font-weight: 600;
  color: var(--text-muted);
  font-size: .85rem;
}
.pos-ok { color: var(--green); }
.pos-pending { color: var(--yellow); }
.pos-total {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  margin-top: 8px;
  border-top: 2px solid var(--primary);
  font-weight: 700;
  font-size: .95rem;
}

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.pending { background: var(--yellow-light); color: #92400e; }
.badge.ok { background: var(--green-light); color: #065f46; }
.badge.no { background: var(--red-light); color: #991b1b; }
.badge.info { background: var(--blue-light); color: #1e40af; }

/* ── Calendar ── */
.cal {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.cal-title {
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
}
.cal-nav {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-weight: 700;
  color: var(--primary);
}
.cal-nav:active { background: var(--primary-light); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dow {
  text-align: center;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px;
  border-radius: 8px;
  position: relative;
  font-size: .85rem;
  background: transparent;
  color: var(--text);
  transition: background .15s;
}
.cal-day.other { color: var(--text-soft); opacity: .5; }
.cal-day.today { background: var(--primary-light); font-weight: 700; color: var(--primary); }
.cal-day.has { font-weight: 600; }
.cal-day.selected { background: var(--primary); color: white; }
.cal-day:active { background: var(--bg); }
.cal-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}
.cal-day.selected .cal-dot { background: white; }

.day-detail {
  margin-top: 4px;
}
.day-detail h3 {
  margin: 4px 0 10px;
  font-size: 1rem;
  color: var(--text);
}

/* ── Anfrage Card ── */
.a-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--yellow);
}
.a-card.done { border-left-color: var(--green); opacity: .7; }
.a-card.rejected { border-left-color: var(--red); opacity: .6; }
.a-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.a-name { font-weight: 600; font-size: 1.05rem; }
.a-time { font-size: .72rem; color: var(--text-soft); }
.a-grid {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}
.a-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .9rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--bg);
}
.a-row:last-child { border-bottom: 0; }
.a-row .lbl { color: var(--text-muted); flex-shrink: 0; }
.a-row .val { text-align: right; font-weight: 500; word-break: break-word; }
.a-row .val a { color: var(--primary); }
.a-msg {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: .88rem;
  white-space: pre-wrap;
  color: var(--text);
}
.a-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.btn {
  padding: 11px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn-primary { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-ghost { background: var(--bg); color: var(--text); }

.a-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.a-extra {
  font-size: .7rem;
  padding: 2px 8px;
  background: var(--blue-light);
  color: #1e40af;
  border-radius: 6px;
}

/* ── Sheet ── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  animation: fadeIn .2s;
}
.sheet-card {
  position: relative;
  background: white;
  width: 100%;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--safe-bottom);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 8px auto 4px;
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-header h2 { margin: 0; font-size: 1.1rem; }
.sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-muted);
}
.sheet-close:active { background: var(--bg); }
.sheet-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Dialog ── */
.dlg {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.dlg-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  animation: fadeIn .15s;
}
.dlg-card {
  position: relative;
  background: white;
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
.dlg-icon { font-size: 2.4rem; margin-bottom: 8px; }
.dlg-card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.dlg-card p { margin: 0 0 18px; color: var(--text-muted); font-size: .92rem; }
.dlg-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dlg-btn {
  padding: 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .95rem;
}
.dlg-btn-cancel { background: var(--bg); color: var(--text); }
.dlg-btn-ok { background: var(--primary); color: white; }
.dlg-btn-ok.danger { background: var(--red); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  left: 16px;
  right: 16px;
  background: var(--text);
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  text-align: center;
  font-size: .9rem;
  z-index: 50;
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ── Tap helpers ── */
.row-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--card);
  border-radius: 12px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.row-link:active { background: var(--bg); }
