/* Reset & Grundlayout */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1,h2,h3,h4 { margin: 0 0 var(--sp-3); line-height: 1.2; font-weight: 700; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

/* App-Shell */
#app { min-height: 100%; display: flex; flex-direction: column; }

.app-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.app-header .brand { display: flex; align-items: center; gap: var(--sp-3); font-weight: 800; color: var(--primary-dark); }
.app-header .brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--green-600), var(--green-900));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.app-header .brand small { display: block; font-weight: 500; color: var(--text-muted); font-size: var(--fs-xs); }
.app-header .spacer { flex: 1; }
.app-header .area-switch { display: flex; background: var(--gray-100); border-radius: var(--r-pill); padding: 4px; gap: 4px; }
.app-header .area-switch button {
  border: 0; background: transparent; border-radius: var(--r-pill);
  padding: 8px 16px; font-weight: 600; color: var(--text-muted); cursor: pointer; min-height: 40px;
}
.app-header .area-switch button.active { background: var(--surface); color: var(--primary-dark); box-shadow: var(--sh-1); }

.app-user { display: flex; align-items: center; gap: var(--sp-3); }
/* Benachrichtigungs-Glocke */
.bell-wrap { position: relative; }
.bell-btn { position: relative; font-size: 18px; }
.bell-badge { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--st-storniert, #b91c1c); color: #fff; font-size: 10px; font-weight: 800; line-height: 16px; text-align: center; }
.bell-panel { position: absolute; top: 110%; right: 0; z-index: 100; width: 300px; max-width: 86vw; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: var(--r-md, 10px); box-shadow: 0 8px 30px rgba(0,0,0,.18); overflow: hidden; }
.bell-head { padding: 10px 12px; font-weight: 800; border-bottom: 1px solid var(--border); }
.bell-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--border); }
.bell-item:hover { background: var(--gray-50, #f6f6f6); }
.bell-ic { font-size: 16px; }
.bell-empty { padding: 16px 12px; color: var(--text-muted); text-align: center; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}
.app-user .meta { line-height: 1.1; white-space: nowrap; }
.app-user .meta b { font-size: var(--fs-sm); }
.app-user .meta small { color: var(--text-muted); font-size: var(--fs-xs); }

.app-body { flex: 1; display: flex; min-height: 0; }

/* Offline-Banner (PWA) */
#offline-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 600; background: #ffb300; color: #4e342e; font-weight: 700; font-size: 14px; padding: 8px 18px; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }

.app-nav {
  width: var(--nav-w); flex: none; background: var(--surface);
  border-right: 1px solid var(--border); padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: 4px;
}
.app-nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 12px 14px; border-radius: var(--r-md); color: var(--text);
  font-weight: 600; min-height: var(--touch);
}
.app-nav a .ic { font-size: 20px; width: 24px; text-align: center; }
.app-nav a:hover { background: var(--gray-50); }
.app-nav a.active { background: var(--green-50); color: var(--primary-dark); }
.app-nav .nav-sep { height: 1px; background: var(--border); margin: var(--sp-3) 6px; }
.app-nav .nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); padding: 6px 14px; font-weight: 700; }

.app-main { flex: 1; min-width: 0; overflow: auto; padding: var(--sp-5); }
/* Volle Bildschirmbreite für alle Ansichten (Planung/Dispo brauchen die ganze Breite). */
.view { max-width: none; margin: 0; width: 100%; }
/* Form-/Lese-lastige Ansichten bleiben angenehm lesbar begrenzt. */
.view.view-narrow { max-width: 980px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.view-head h1 { margin: 0; }
.view-head .spacer { flex: 1; }

/* Responsive: Tablet/Mobile -> Nav nach unten als Tab-Bar */
@media (max-width: 900px) {
  :root { --header-h: 58px; }
  .app-body { flex-direction: column; }
  .app-nav {
    width: auto; flex-direction: row; border-right: 0; border-top: 1px solid var(--border);
    order: 2; position: sticky; bottom: 0; z-index: 40; padding: 6px; gap: 4px;
    overflow-x: auto; box-shadow: 0 -2px 10px rgba(0,0,0,.04);
  }
  .app-nav .nav-sep, .app-nav .nav-label { display: none; }
  .app-nav a { flex-direction: column; gap: 2px; font-size: var(--fs-xs); padding: 6px 12px; min-width: 64px; text-align: center; }
  .app-nav a .ic { font-size: 22px; }
  .app-main { order: 1; padding: var(--sp-4); }
  .app-header .area-switch button { padding: 8px 12px; }
}
@media (max-width: 560px) {
  .app-header .brand small { display: none; }
  .app-user .meta { display: none; }
}

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
