:root {
  --radius: 0.5rem;

  /* Page background (gray-100) */
  --background: oklch(0.967 0.003 265);
  --foreground: oklch(0.210 0.032 265);

  /* Card / elevated surface (white) */
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.210 0.032 265);

  /* Popover (white) */
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.210 0.032 265);

  /* Brand: Primary (blue-600) — 5.17:1 AA on white */
  --primary: oklch(0.546 0.215 263);
  --primary-foreground: oklch(1 0 0);

  /* Secondary surface (gray-200) */
  --secondary: oklch(0.928 0.006 265);
  --secondary-foreground: oklch(0.210 0.032 265);

  /* Muted (gray-200) */
  --muted: oklch(0.928 0.006 265);
  --muted-foreground: oklch(0.446 0.026 257);

  /* Accent (gray-200) */
  --accent: oklch(0.928 0.006 265);
  --accent-foreground: oklch(0.210 0.032 265);

  /* Destructive (red-600) — 4.83:1 AA on white */
  --destructive: oklch(0.577 0.215 27);
  --destructive-foreground: oklch(1 0 0);

  /* Success (emerald-700) — 5.06:1 AA on white */
  --success: oklch(0.508 0.105 166);
  --success-foreground: oklch(1 0 0);

  /* Warning (amber-700) — 5.02:1 AA on white */
  --warning: oklch(0.555 0.146 49);
  --warning-foreground: oklch(1 0 0);

  /* Borders (gray-300) — cards heben sich über bg/card vs bg/background ab */
  --border: oklch(0.872 0.009 258);
  --input: oklch(0.872 0.009 258);

  /* Focus ring (blue-700) — deutlichere Absetzung gegen Primary-Buttons */
  --ring: oklch(0.488 0.217 264);

  /* Chart palette */
  --chart-1: oklch(0.546 0.215 263);
  --chart-2: oklch(0.508 0.105 166);
  --chart-3: oklch(0.555 0.146 49);
  --chart-4: oklch(0.577 0.215 27);
  --chart-5: oklch(0.278 0.030 257);

  /* Sidebar (matches page background) */
  --sidebar: oklch(0.967 0.003 265);
  --sidebar-foreground: oklch(0.210 0.032 265);
  --sidebar-primary: oklch(0.546 0.215 263);
  --sidebar-primary-foreground: oklch(1 0 0);
  --sidebar-accent: oklch(0.928 0.006 265);
  --sidebar-accent-foreground: oklch(0.210 0.032 265);
  --sidebar-border: oklch(0.872 0.009 258);
  --sidebar-ring: oklch(0.488 0.217 264);

  /* Logo preview */
  --logo-preview: oklch(1 0 0);
  --logo-preview-checker: oklch(0.872 0.009 258);
}

.dark {
  /* Surface */
  --background: oklch(0.210 0.032 265);
  --foreground: oklch(0.985 0.002 248);

  /* Card */
  --card: oklch(0.278 0.030 257);
  --card-foreground: oklch(0.985 0.002 248);

  /* Popover */
  --popover: oklch(0.278 0.030 257);
  --popover-foreground: oklch(0.985 0.002 248);

  /* Brand: Primary (blue-400) — 5.77:1 AA on surface */
  --primary: oklch(0.714 0.143 255);
  --primary-foreground: oklch(0.210 0.032 265);

  /* Secondary surface (gray-700) */
  --secondary: oklch(0.373 0.031 260);
  --secondary-foreground: oklch(0.985 0.002 248);

  /* Muted */
  --muted: oklch(0.373 0.031 260);
  --muted-foreground: oklch(0.714 0.019 261);

  /* Accent */
  --accent: oklch(0.373 0.031 260);
  --accent-foreground: oklch(0.985 0.002 248);

  /* Destructive (red-400) — 5.31:1 AA on surface */
  --destructive: oklch(0.711 0.166 22);
  --destructive-foreground: oklch(0.210 0.032 265);

  /* Success (emerald-400) — 7.64:1 AA on surface */
  --success: oklch(0.773 0.153 163);
  --success-foreground: oklch(0.210 0.032 265);

  /* Warning (amber-400) — 8.79:1 AA on surface */
  --warning: oklch(0.837 0.164 84);
  --warning-foreground: oklch(0.210 0.032 265);

  /* Borders (gray-600) — sichtbare Trennung im Dark Mode */
  --border: oklch(0.446 0.026 257);
  --input: oklch(0.446 0.026 257);

  /* Focus ring */
  --ring: oklch(0.714 0.143 255);

  /* Chart palette */
  --chart-1: oklch(0.714 0.143 255);
  --chart-2: oklch(0.773 0.153 163);
  --chart-3: oklch(0.837 0.164 84);
  --chart-4: oklch(0.711 0.166 22);
  --chart-5: oklch(0.278 0.030 257);

  /* Sidebar */
  --sidebar: oklch(0.278 0.030 257);
  --sidebar-foreground: oklch(0.985 0.002 248);
  --sidebar-primary: oklch(0.714 0.143 255);
  --sidebar-primary-foreground: oklch(0.210 0.032 265);
  --sidebar-accent: oklch(0.373 0.031 260);
  --sidebar-accent-foreground: oklch(0.985 0.002 248);
  --sidebar-border: oklch(0.446 0.026 257);
  --sidebar-ring: oklch(0.714 0.143 255);

  /* Logo preview */
  --logo-preview: oklch(0.208 0.040 266);
  --logo-preview-checker: oklch(0.373 0.031 260);
}


/* Global Element Styles */
* {
  border-color: var(--border);
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
}
/* Tailwind v4 Theme Integration */
@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-success: var(--success);
  --color-success-foreground: var(--success-foreground);
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);
  --color-logo-preview: var(--logo-preview);
  --color-logo-preview-checker: var(--logo-preview-checker);

  --font-sans: var(--font-sans);
  --font-mono: var(--font-mono);
  --font-serif: var(--font-serif);

  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  --shadow-2xs: var(--shadow-2xs);
  --shadow-xs: var(--shadow-xs);
  --shadow-sm: var(--shadow-sm);
  --shadow: var(--shadow);
  --shadow-md: var(--shadow-md);
  --shadow-lg: var(--shadow-lg);
  --shadow-xl: var(--shadow-xl);
  --shadow-2xl: var(--shadow-2xl);
}


/* Leaflet: Default-z-index (Panes 100–700, Controls 800–1000) liegt über den
   UI-Overlays (BbDialog/BbTooltip/BbToast). Relative Stacking-Reihenfolge
   bleibt erhalten, alle Werte werden auf <10 gedrückt — inklusive
   .leaflet-top/-bottom (z-1000) und der canvas/svg in .leaflet-map-pane. */
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-control,
.leaflet-control-container,
.leaflet-zoom-box,
.leaflet-map-pane canvas,
.leaflet-map-pane svg {
  z-index: 1 !important;
}

.leaflet-tile-pane            { z-index: 1 !important; }
.leaflet-overlay-pane         { z-index: 2 !important; }
.leaflet-shadow-pane          { z-index: 3 !important; }
.leaflet-marker-pane          { z-index: 4 !important; }
.leaflet-tooltip-pane         { z-index: 5 !important; }
.leaflet-popup-pane           { z-index: 6 !important; }
.leaflet-control              { z-index: 7 !important; }
.leaflet-control-container,
.leaflet-top,
.leaflet-bottom,
.leaflet-zoom-box             { z-index: 7 !important; }
.leaflet-map-pane canvas      { z-index: 1 !important; }
.leaflet-map-pane svg         { z-index: 2 !important; }

/* DialogService renders its title and close affordance outside of the supplied
   component. Existing dialog bodies therefore own only the content viewport.
   This shared limit makes their existing overflow-y-auto classes effective and
   keeps the provider's header and each component footer accessible. */
[role="dialog"] > .overflow-y-auto {
  min-height: 0;
  max-height: calc(100dvh - 13rem);
  overscroll-behavior: contain;
}

@media (min-width: 640px) {
  [role="dialog"] > .overflow-y-auto {
    max-height: calc(100dvh - 16rem);
  }
}
