/* ═══════════════════════════════════════════════════════════
   Design Tokens — FW365 (verbindlich, Apple HIG konform)
   ═══════════════════════════════════════════════════════════ */
:root {
  /* ── App Shell ─────────────────────────────────────────── */
  --sidebar-w:          232px;
  --sidebar-bg:         rgba(235, 243, 255, 0.88);
  --sidebar-border:     rgba(0, 102, 204, 0.13);
  --sidebar-hover:      rgba(0, 102, 204, 0.09);
  --sidebar-active-bg:  rgba(0, 102, 204, 0.13);
  --sidebar-active-text:#0051A8;
  --sidebar-label:      rgba(60, 80, 120, 0.45);
  --topbar-h:           48px;
  --topbar-bg:          rgba(255, 255, 255, 0.92);
  --bg-app:             #F2F2F7;
  --bg-card:            #FFFFFF;
  --bg-card-2:          #F8F9FB;

  /* ── Semantische Farben ───────────────────────────────── */
  --red:            #D70015;
  --red-bg:         rgba(215, 0, 21, 0.06);
  --red-border:     rgba(215, 0, 21, 0.18);
  --amber:          #B25000;
  --amber-bg:       rgba(178, 80, 0, 0.07);
  --green:          #1C7C3A;
  --green-bg:       rgba(28, 124, 58, 0.07);
  --blue:           #0066CC;
  --blue-bg:        rgba(0, 102, 204, 0.07);

  /* ── Text ─────────────────────────────────────────────── */
  --t1:             #1C1C1E;
  --t2:             #636366;
  --t3:             #AEAEB2;
  --t-link:         #0066CC;
  --t-active:       #0051A8;

  /* ── Rahmen ───────────────────────────────────────────── */
  --border:         rgba(60, 60, 67, 0.10);
  --border-med:     rgba(60, 60, 67, 0.16);

  /* ── Radius ───────────────────────────────────────────── */
  --r-sm:  6px;
  --r-md:  9px;
  --r-lg:  13px;
  --r-xl:  18px;

  /* ── Kompatibilitäts-Aliases (bestehende Templates) ───── */
  --bg:             #F2F2F7;
  --card:           #FFFFFF;
  --surface:        #FFFFFF;
  --surface-2:      #F8F9FB;
  --text:           #1C1C1E;
  --text-primary:   #1C1C1E;
  --text-secondary: #636366;
  --text-tertiary:  #AEAEB2;
  --muted:          rgba(99, 99, 102, 0.75);
  --muted-solid:    #AEAEB2;
  --brand:          #0066CC;
  --brand-dark:     #0051A8;
  --brand-light:    rgba(0, 102, 204, 0.07);
  --accent:         #0066CC;
  --separator:      rgba(60, 60, 67, 0.10);
  --header-bg:      rgba(255, 255, 255, 0.92);
  --header-text:    #1C1C1E;
  --border-light:   rgba(60, 60, 67, 0.10);
  --border-strong:  rgba(60, 60, 67, 0.16);

  /* ── Status (kompatibel) ──────────────────────────────── */
  --success:        #1C7C3A;
  --success-bg:     rgba(28, 124, 58, 0.07);
  --success-text:   #1C7C3A;
  --warning:        #B25000;
  --warning-bg:     rgba(178, 80, 0, 0.07);
  --warning-text:   #B25000;
  --danger:         #D70015;
  --danger-bg:      rgba(215, 0, 21, 0.06);
  --danger-text:    #D70015;
  --info:           #0066CC;
  --info-bg:        rgba(0, 102, 204, 0.07);
  --info-text:      #0066CC;

  /* ── Buttons ──────────────────────────────────────────── */
  --btn-height:         28px;
  --btn-radius:         var(--r-sm);
  --btn-primary-bg:     #0066CC;
  --btn-destructive-bg: #D70015;

  /* ── Typografie (§21.2) ───────────────────────────────── */
  --font:         -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  --font-display: -apple-system, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:    'SF Mono', 'Menlo', 'Monaco', monospace;

  /* ── Sidebar-Blur (§21.2) ─────────────────────────────── */
  --sidebar-blur: blur(28px) saturate(180%);
  --topbar-blur:  blur(20px);

  /* ── Karten ───────────────────────────────────────────── */
  --card-radius:   var(--r-md);
  --card-border:   1px solid rgba(60, 60, 67, 0.10);
  --card-padding:  13px;
  /* Status (Einsatzdokumentation) */
  --status-draft-bg: #fef3c7;
  --status-draft-text: #92400e;
  --status-progress-bg: #dbeafe;
  --status-progress-text: #1e40af;
  --status-done-bg: #d1fae5;
  --status-done-text: #065f46;
  --status-billed-bg: #e9d5ff;
  --status-billed-text: #6b21a8;
  /* Abstände */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  /* Radien */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  /* ── Fehlende Aliases (für Dashboard und neuere Templates) ── */
  --t-primary:   #1C1C1E;
  --t-secondary: #636366;
  --t-tertiary:  #AEAEB2;
  --surface-1:   #FFFFFF;
  --surface-2:   #F8F9FB;
  --surface-3:   #F2F2F7;

  /* ── Legacy-Farben (nur für alte Templates) ──────────── */
  --fire-red:   #D70015;
  --abc-teal:   #0a7ea4;
  --abc-green:  #1a8a3a;

  /* ── Legacy Text-Größen ───────────────────────────────── */
  --text-caption2: 11px;
  --text-caption1: 12px;
  --text-footnote: 13px;
  --text-subheadline: 15px;
  --text-callout: 16px;
  --text-body: 17px;
  --text-headline: 17px;
  --text-title3: 20px;
  --text-title2: 22px;
  --text-title1: 28px;
  --text-large-title: 34px;

  /* ── Legacy Abstand-Grid ──────────────────────────────── */
  --grid-1: 4px;  --grid-2: 8px;  --grid-3: 12px; --grid-4: 16px;
  --grid-5: 20px; --grid-6: 24px; --grid-8: 32px; --grid-10: 40px; --grid-12: 48px;
}

/* ─── Dark Mode ──────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --sidebar-bg:         rgba(18, 28, 48, 0.92);
    --sidebar-border:     rgba(80, 130, 210, 0.18);
    --sidebar-hover:      rgba(80, 130, 210, 0.12);
    --sidebar-active-bg:  rgba(80, 130, 210, 0.20);
    --sidebar-active-text:#5EAEFF;
    --sidebar-label:      rgba(160, 180, 220, 0.38);
    --bg-app:     #000000;
    --bg-card:    #1C1C1E;
    --bg-card-2:  #2C2C2E;
    --topbar-bg:  rgba(28, 28, 30, 0.92);
    --t1:         #F5F5F7;
    --t2:         #98989D;
    --t3:         #545458;
    --t-link:     #5EAEFF;
    --t-active:   #5EAEFF;
    --red:        #FF453A;
    --red-bg:     rgba(255, 69, 58, 0.10);
    --red-border: rgba(255, 69, 58, 0.22);
    --amber:      #FF9F0A;
    --amber-bg:   rgba(255, 159, 10, 0.10);
    --green:      #30D158;
    --green-bg:   rgba(48, 209, 88, 0.10);
    --blue:       #5EAEFF;
    --blue-bg:    rgba(94, 174, 255, 0.10);
    --border:     rgba(255, 255, 255, 0.08);
    --border-med: rgba(255, 255, 255, 0.14);
    --bg:         #000000;
    --card:       #1C1C1E;
    --surface:    #1C1C1E;
    --surface-2:  #2C2C2E;
    --text:       #F5F5F7;
    --text-primary:  #F5F5F7;
    --text-secondary:#98989D;
    --text-tertiary: #545458;
    --brand:      #5EAEFF;
    --danger:     #FF453A;
    --danger-bg:  rgba(255, 69, 58, 0.10);
    --success:    #30D158;
    --success-bg: rgba(48, 209, 88, 0.10);
    --warning:    #FF9F0A;
    --warning-bg: rgba(255, 159, 10, 0.10);
    --info:       #5EAEFF;
    --info-bg:    rgba(94, 174, 255, 0.10);

    /* ── Fehlende Aliases Dark ── */
    --t-primary:   #F5F5F7;
    --t-secondary: #98989D;
    --t-tertiary:  #545458;
    --surface-1:   #1C1C1E;
    --surface-2:   #2C2C2E;
    --surface-3:   #3A3A3C;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; -webkit-text-size-adjust: 100%; background: var(--bg-app); }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  height: 100%;
  /* overflow: hidden VERBOTEN auf body (§21.19) — nur auf .app-shell */
  background: var(--bg-app);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--t-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Demo-Banner ─────────────────────────────────────────── */
.demo-banner {
  text-align: center; padding: 7px 12px;
  font-size: 11.5px; font-weight: 600;
  background: var(--amber-bg); color: var(--amber);
  border-bottom: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ─── Sidebar Overlay (Mobile) ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s;
}
.sidebar-overlay.visible { opacity: 1; display: block; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  -webkit-backdrop-filter: var(--sidebar-blur);
  backdrop-filter: var(--sidebar-blur);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.sb-header {
  padding: 12px 10px 8px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.tenant-block {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-md);
  cursor: default;
  transition: background 0.15s;
}
.tenant-block:hover { background: var(--sidebar-hover); }
.tenant-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tenant-name { font-size: 12.5px; font-weight: 700; color: var(--t1); line-height: 1.25; }
.tenant-sub  { font-size: 10.5px; color: var(--t2); }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-border) transparent;
}
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 4px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }

.nav-section { margin-bottom: 2px; }
.nav-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-label);
  padding: 11px 8px 3px;
  user-select: none;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6.5px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s;
  color: var(--t2);
  font-size: 12.5px;
  font-weight: 450;
  margin-bottom: 1px;
  user-select: none;
  text-decoration: none;
  min-height: 32px;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--t1); text-decoration: none; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}
.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  display: flex; align-items: center; justify-content: center;
}
.nav-icon svg { width: 16px; height: 16px; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; }
.nav-badge {
  font-size: 9.5px; font-weight: 700;
  background: var(--red); color: white;
  padding: 1px 5px; border-radius: 8px;
  min-width: 17px; text-align: center; line-height: 1.5;
}
.nav-badge.amber { background: var(--amber); }
.nav-badge.green { background: var(--green); }

.sb-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 9px;
  flex-shrink: 0;
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: white;
  flex-shrink: 0; letter-spacing: 0.03em;
}
.user-name { font-size: 12px; font-weight: 600; color: var(--t1); line-height: 1.3; }
.user-role { font-size: 10.5px; color: var(--t2); }
.ms-status {
  margin-left: auto;
  display: flex; align-items: center; gap: 4px;
  font-size: 9.5px; font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  border-radius: 4px;
  padding: 2px 6px;
}
.ms-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ─── Main Area ────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-app);
}

/* ─── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: var(--topbar-blur);
  backdrop-filter: var(--topbar-blur);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
  position: sticky; top: 0;
}
.topbar-menu-btn {
  display: none;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--t-link);
  flex-shrink: 0;
}
.topbar-menu-btn svg { width: 20px; height: 20px; }
.topbar-title {
  font-size: 15px; font-weight: 600;
  color: var(--t1); flex: 1;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Status badge im Topbar */
.status-badge {
  display: flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  color: var(--green); background: var(--green-bg);
  border-radius: 4px; padding: 2px 7px;
}
.status-badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ─── Content Area ─────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px 32px;
  background: var(--bg-app);
  color: var(--t1);
}
.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 3px; }

/* ─── Universal Buttons ────────────────────────────────────── */
.btn {
  height: var(--btn-height);
  padding: 0 11px;
  border-radius: var(--btn-radius);
  border: 1px solid var(--border-med);
  background: var(--bg-card);
  font-size: 11.5px; font-weight: 500;
  color: var(--t1);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit;
  transition: background 0.12s, transform 0.1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:hover { background: var(--bg-card-2); text-decoration: none; }
.btn-primary, .btn.primary { background: var(--blue); border-color: transparent; color: white; }
.btn-primary:hover, .btn.primary:hover { background: #0051A8; }
.btn-danger, .btn.danger { background: var(--red); border-color: transparent; color: white; }
.btn.icon-only { padding: 0; width: 28px; justify-content: center; }

/* ─── Public (unauthenticated) Layout ────────────────────── */
.app-public { display: flex; flex-direction: column; min-height: 100vh; }
.public-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px;
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.public-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.public-brand:hover { text-decoration: none; }
.public-content { flex: 1; padding: 20px clamp(12px, 4vw, 40px) 40px; max-width: 1100px; margin: 0 auto; width: 100%; }
.public-footer { padding: 20px; text-align: center; font-size: 12px; color: var(--t3); border-top: 1px solid var(--border); }

/* ─── Bottom Nav (Mobile) ─────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  background: var(--topbar-bg);
  -webkit-backdrop-filter: var(--topbar-blur);
  backdrop-filter: var(--topbar-blur);
  border-top: 1px solid var(--border);
  z-index: 80;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 56px;
}
.bn-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--t3);
  transition: color 0.15s;
  font-size: 9.5px; font-weight: 500;
  padding: 0 4px;
  background: none; border: none;
  text-decoration: none;
  font-family: var(--font);
  min-height: 44px;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--blue); }
.bn-item:hover { color: var(--t1); text-decoration: none; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
}

@media (max-width: 768px) {
  body { overflow: auto; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    width: 280px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-menu-btn { display: inline-flex !important; }
  /* Bottom-Nav Höhe (56px) + Safe Area */
  .content { padding: 14px 14px calc(56px + env(safe-area-inset-bottom, 0px) + 16px); }
  .status-badge { display: none; }
  .topbar-actions .btn:not(.btn-primary):not(.icon-only) { display: none; }
  .bottom-nav { display: flex; }
  /* KPI-Grid auf Mobile: 2 Spalten */
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; }
  /* Dashboard Widget-Grid: 1 Spalte */
  #dash-grid { grid-template-columns: 1fr !important; }
  /* Page-Header auf Mobile kompakter */
  .page-header { margin-bottom: 12px; }
  .page-header h1 { font-size: 18px; }
  /* Dashboard Edit-Button auf Mobile ausblenden */
  #dash-edit-btn { display: none; }
}

/* ─── Page anim ───────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.content > * { animation: fadeSlideIn 0.18s ease; }

/* SR-only */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ═══════════════════════════════════════════════════════════
   LEGACY / FireOS-Komponenten (Kompatibilität)
═══════════════════════════════════════════════════════════ */
.fire-card {
  background: var(--bg-card);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  padding: 13px;
}
.fire-btn-primary {
  background: var(--blue);
  color: #fff; border: none;
  border-radius: var(--r-md);
  font-weight: 600; min-height: 40px;
  padding: 9px 16px; cursor: pointer;
  font-family: inherit;
}
.fire-btn-primary:hover { opacity: 0.88; }
.fire-btn-danger {
  background: var(--red);
  color: #fff; border: none;
  border-radius: var(--r-md);
  font-weight: 600; min-height: 40px;
  padding: 9px 16px; cursor: pointer;
}
.fire-btn-abc {
  background: #0a7ea4;
  color: #fff; border: none;
  border-radius: var(--r-md);
  font-weight: 600; min-height: 40px;
  padding: 9px 16px; cursor: pointer;
}
.threat-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.threat-low    { background: var(--green-bg); color: var(--green); }
.threat-medium { background: var(--amber-bg); color: var(--amber); }
.threat-high   { background: var(--red-bg);   color: var(--red);   }
.threat-extreme{ background: var(--red);       color: #fff; font-weight: 700; }

/* .topbar — vollständig in App-Shell definiert (style.css Zeile ~380) */
/* Legacy-Compat für Templates die .brand/.brand-title nutzen */
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; color: var(--t1); }
.brand-subtitle { font-size: 11px; color: var(--t2); }
.topbar-actions a, .topbar-actions button {
  opacity: 1;
  transition: opacity .15s;
}
.topbar-actions a:not(.btn), .topbar-actions button:not(.btn) {
  color: var(--t-link);
}
.topbar .topbar-actions a:hover, .topbar .topbar-actions button:hover { opacity: 0.75; text-decoration: none; }
nav a { margin-left: 12px; }
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
/* .grid (legacy compat) */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
/* .list (legacy ul) */
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 6px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
/* legacy btn extensions */
.btn.secondary, .btn-secondary { background: var(--bg-card-2); color: var(--t1); border-color: var(--border-med); }
.btn.ghost { background: transparent; border: 1px solid var(--border-med); color: var(--t-link); }
.btn.warning, .btn-warning { background: var(--amber); color: #fff; border: none; }
.btn.success, .btn-success { background: var(--green); color: #fff; border: none; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 11px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.footer { color: var(--t3); text-align: center; margin: 32px 0; font-size: 12px; }
.link { color: var(--t-link); }
.muted { color: var(--t2); }
.pillbar { display: flex; gap: 6px; flex-wrap: wrap; }
.mail-body img { max-width: 100%; height: auto; }
/* Status-Badges Einsatzdoku */
.status-draft      { background: #fef3c7; color: #92400e; border-radius: 4px; padding: 2px 7px; font-size: 10.5px; font-weight: 600; }
.status-in_progress{ background: #dbeafe; color: #1e40af; border-radius: 4px; padding: 2px 7px; font-size: 10.5px; font-weight: 600; }
.status-completed  { background: #d1fae5; color: #065f46; border-radius: 4px; padding: 2px 7px; font-size: 10.5px; font-weight: 600; }
.status-billed     { background: #e9d5ff; color: #6b21a8; border-radius: 4px; padding: 2px 7px; font-size: 10.5px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Info-Boxen */
.info-box { padding: 12px 16px; border-radius: var(--radius-md); border-left: 4px solid var(--info); background: var(--info-bg); color: var(--info-text); font-size: 14px; margin-bottom: var(--space-md); }
.info-box--success { border-color: var(--success); background: var(--success-bg); color: var(--success-text); }
.info-box--warning { border-color: var(--warning); background: var(--warning-bg); color: var(--warning-text); }
.info-box--danger { border-color: var(--danger); background: var(--danger-bg); color: var(--danger-text); }

/* Formulare */
.form-group { margin-bottom: var(--space-md); }
.form-group label { display: block; margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-top: var(--space-lg); }
.required { color: var(--danger); }

/* Tabellen */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { background: var(--bg); color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; padding: 10px 12px; border-bottom: 2px solid var(--border); text-align: left; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg); }

/* ========== Kacheln / Metric-Cards (einheitlich wie Dashboard) ==========
   Nutzen: .metric-grid > a.metric-card bzw. .kachel-grid > a.kachel
   Icon immer in .metric-icon / .kachel-icon (SVG bevorzugt, 24x24 viewBox).
   Keine beliebigen Emojis oder inline style="background:..." für Kacheln. */
.metric-grid,
.kachel-grid {
  display: grid;
  gap: clamp(8px, 1.5vw, 12px);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) {
  .metric-grid { grid-template-columns: repeat(5, 1fr); }
  .kachel-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

.metric-card,
a.kachel.metric-style {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: clamp(10px, 2vw, 14px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .12s, border-color .12s;
  min-height: 72px;
  box-sizing: border-box;
}
.metric-card:hover,
a.kachel.metric-style:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  border-color: var(--brand);
}

.metric-icon,
.kachel-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  color: var(--brand);
  flex-shrink: 0;
}
.metric-icon svg,
.kachel-icon svg {
  width: 20px;
  height: 20px;
}
.kachel-icon:not(:has(svg)) {
  font-size: 20px;
  line-height: 1;
}

.metric-title,
.kachel-title {
  font-size: clamp(10px, 2.2vw, 12px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 2px;
}
.metric-value,
.kachel-value {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.metric-arrow,
.kachel-arrow {
  margin-top: auto;
  font-size: 12px;
  color: var(--brand);
  font-weight: 600;
}

/* Allgemeine Kachel (ohne metric-Subklassen) – z.B. für Listen wie Löschgruppen */
.kachel {
  display: block;
  padding: clamp(12px, 3vw, 16px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .12s, border-color .12s;
  box-sizing: border-box;
}
.kachel:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  border-color: var(--brand);
}

/* ============================================================
   iOS / Mobile – Safe Area + Tap Targets
   Kein Dark-Mode Override mehr – System-Präferenz wird respektiert
   ============================================================ */

/* Safe Area für iPhone Notch/Home-Indicator */
.app-shell { padding-bottom: env(safe-area-inset-bottom, 0px); }
.tab-bar   { padding-bottom: env(safe-area-inset-bottom, 0px); }
.main-content { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }

/* Mindest-Touch-Target 44px (Apple HIG) */
.nav-item, .tab-bar-item, button, a.btn, .btn {
  min-height: 44px;
}
.nav-item { min-height: 36px; } /* Sidebar kompakter */

/* ─── Shell (base.html) – Apple-ähnliche Navigation & Flächen ─── */
.topbar {
  min-height: 56px;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}
/* Legacy compat — sidebar-nav für alte Templates */
.sidebar-nav a { color: var(--t2); font-size: 12.5px; }
.sidebar-nav a.active { color: var(--sidebar-active-text); }
.sidebar-footer { border-top: 1px solid var(--sidebar-border); }
.footer { border-top: 1px solid var(--border); color: var(--t3); font-size: 12px; padding: 16px; text-align: center; }
.footer a { color: var(--t-link); }
.flash-msg {
  border-radius: var(--radius-md);
  border-width: 0.5px;
  font-size: 15px;
}
.flash-success { background: var(--success-bg); color: var(--success-text); border-color: rgba(52, 199, 89, 0.35); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); border-color: rgba(255, 59, 48, 0.35); }
.flash-warning { background: var(--warning-bg); color: var(--warning-text); border-color: rgba(255, 149, 0, 0.35); }
.flash-info { background: var(--info-bg); color: var(--info-text); border-color: rgba(0, 122, 255, 0.35); }
.kachel-grid .kachel,
.kachel {
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.kachel-grid .kachel:hover,
.kachel:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  border-color: transparent;
}
.demo-banner {
  background: linear-gradient(90deg, #ff9500, #ff6b00) !important;
  color: #fff !important;
}

/* ─── FwDV 500 Hub (Apple-ähnliche Produktseite) ─── */
.fwdv-apple-page {
  max-width: 1060px;
  margin: 0 auto;
  padding: 8px 0 56px;
}
.fwdv-hero {
  position: relative;
  border-radius: 28px;
  padding: clamp(40px, 8vw, 72px) clamp(24px, 5vw, 48px);
  margin-bottom: 28px;
  background: linear-gradient(155deg, #1d1d1f 0%, #2c2c2e 45%, #3a3a3c 100%);
  color: #f5f5f7;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
}
.fwdv-hero__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.5;
  pointer-events: none;
}
.fwdv-eyebrow {
  position: relative;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 12px;
}
.fwdv-headline {
  position: relative;
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.fwdv-tagline {
  position: relative;
  font-size: clamp(17px, 2.5vw, 21px);
  line-height: 1.45;
  color: rgba(245, 245, 247, 0.82);
  max-width: 36rem;
  margin: 0 0 28px;
}
.fwdv-hero__actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.fwdv-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: #f5f5f7;
  color: #1d1d1f;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fwdv-pill-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  text-decoration: none;
}
.fwdv-pill-btn--ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #f5f5f7;
  border: 1px solid rgba(255, 255, 255, 0.22);
}
.fwdv-disclaimer {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 32px;
  max-width: 52rem;
}
.fwdv-bento {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 40px;
}
@media (max-width: 720px) {
  .fwdv-bento { grid-template-columns: 1fr; }
}
.fwdv-bento__large {
  background: var(--card);
  border-radius: 20px;
  padding: 24px 28px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
}
.fwdv-bento__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  color: var(--text);
}
.fwdv-bento__desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}
.fwdv-bento__small {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fwdv-mini-card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px 20px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
}
.fwdv-mini-card__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 6px;
}
.fwdv-mini-card__text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.fwdv-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px 4px;
}
.fwdv-chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fwdv-chapter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--card);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}
.fwdv-chapter-row:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.fwdv-chapter-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
  background: rgba(0, 122, 255, 0.1);
}
.fwdv-chapter-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.fwdv-chapter-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.fwdv-chapter-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.fwdv-chapter-chevron {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted-solid);
  border-bottom: 2px solid var(--muted-solid);
  transform: rotate(-45deg);
  opacity: 0.45;
}
.fwdv-back {
  margin-top: 36px;
  font-size: 15px;
}
.fwdv-back a {
  color: var(--brand);
  font-weight: 500;
}

.fwdv-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-bottom: 28px;
  padding: 16px 18px;
  background: var(--card);
  border-radius: 16px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
}
.fwdv-search-label {
  display: block;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.fwdv-search-input {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  padding: 11px 14px;
  border-radius: 12px;
  border: none;
  background: rgba(118, 118, 128, 0.12);
  font: 16px var(--font-stack);
  color: var(--text);
}
.fwdv-toolbar__btns {
  display: flex;
  gap: 8px;
}
.fwdv-chapter-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fwdv-chapter-details {
  border-radius: 16px;
  background: var(--card);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.fwdv-chapter-details[open] {
  box-shadow: var(--shadow-md);
}
.fwdv-chapter-details > summary {
  list-style: none;
  cursor: pointer;
}
.fwdv-chapter-details > summary::-webkit-details-marker {
  display: none;
}
.fwdv-chapter-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  transition: background 0.15s ease;
}
.fwdv-chapter-summary:hover {
  background: rgba(0, 122, 255, 0.04);
}
.fwdv-chapter-panel {
  padding: 0 20px 18px 84px;
  border-top: 0.5px solid var(--separator);
}
@media (max-width: 560px) {
  .fwdv-chapter-panel {
    padding-left: 20px;
  }
}
.fwdv-chapter-bullets {
  margin: 14px 0 0;
  padding-left: 1.15rem;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.fwdv-chapter-bullets li {
  margin-bottom: 8px;
}
.fwdv-chapter-extra {
  margin: 14px 0 0;
  font-size: 14px;
}

/* ─── Vegetationsbrand-Simulation (Spec UI) ─── */
.fire-sim-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 16px) 0 max(48px, env(safe-area-inset-bottom));
  padding-left: max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}
.fire-sim-hero {
  border-radius: 24px;
  padding: clamp(28px, 5vw, 44px) clamp(20px, 4vw, 40px);
  margin-bottom: 24px;
  background: var(--hero-gradient-fire);
  color: #fff;
  box-shadow: 0 16px 40px rgba(185, 28, 28, 0.28);
  position: relative;
  overflow: hidden;
}
.fire-sim-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 100% 0%, rgba(255, 255, 255, 0.15), transparent 55%);
  pointer-events: none;
}
.fire-sim-hero__label {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
  margin: 0 0 10px;
}
.fire-sim-hero__title {
  position: relative;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.038em;
  line-height: 1.1;
  margin: 0 0 10px;
}
.fire-sim-hero__lead {
  position: relative;
  font-size: clamp(15px, 2vw, 17px);
  line-height: 1.5;
  opacity: 0.92;
  max-width: 42rem;
  margin: 0;
}
.fire-sim-spec {
  background: rgba(0, 122, 255, 0.06);
  border: 0.5px solid rgba(0, 122, 255, 0.2);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.fire-sim-spec strong { color: var(--info-text); }
.fire-sim-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .fire-sim-layout { grid-template-columns: 1fr; }
}
.fire-sim-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.fire-sim-panel {
  background: var(--card);
  border-radius: 20px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
  padding: var(--grid-4);
}
.fire-sim-panel h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
body.fire-sim-map-focus-open {
  overflow: hidden;
  touch-action: none;
  height: 100vh;
  height: 100dvh;
}
.fire-sim-map-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 0.5px solid var(--separator);
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.fire-sim-map-wrap--focus {
  position: fixed !important;
  z-index: 4000;
  inset: 0;
  margin: 0 !important;
  border-radius: 0 !important;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  background: #1c1c1e;
}
.fire-sim-map-wrap--focus #map-container {
  flex: 1;
  min-height: 0 !important;
  height: auto !important;
}
.fire-sim-map-toolbar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.fire-sim-map-tool {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-stack);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fire-sim-map-tool:active { transform: scale(0.98); }
.fire-sim-map-loading {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(28, 28, 30, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.fire-sim-map-loading.is-visible { display: flex; }
.fire-sim-map-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fire-sim-spin 0.75s linear infinite;
}
@keyframes fire-sim-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .fire-sim-map-spinner { animation: none; border-top-color: rgba(255,255,255,0.6); }
}
.fire-sim-wind-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 6px;
}
.fire-sim-details {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.08);
  border: 0.5px solid var(--separator);
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.fire-sim-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.fire-sim-details summary::-webkit-details-marker { display: none; }
.fire-sim-details summary::after {
  content: " ›";
  color: var(--brand);
  font-weight: 700;
}
.fire-sim-details[open] summary::after { content: " ˅"; }
.fire-sim-page .btn-primary-fire {
  background: linear-gradient(180deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 18px;
  cursor: pointer;
  font-family: var(--font-stack);
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35);
}
.fire-sim-page .btn-primary-fire:hover { filter: brightness(1.05); }
.fire-sim-page .btn-primary-fire:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.fire-sim-page .btn-secondary-fire {
  background: rgba(118, 118, 128, 0.14);
  color: var(--text);
  border: none;
  border-radius: 12px;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 18px;
  cursor: pointer;
}
.fire-sim-page .btn-secondary-fire:hover { background: rgba(118, 118, 128, 0.2); }
