html {
  overflow-x: hidden;
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

:root {
  --primary: #1e3a8a;
  --secondary: #3b82f6;
  --accent: #60a5fa;
  --bg: #ffffff;
  --bg-sterile: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #10b981;

  /* National Colors DE */
  --flag-de-black: #000000;
  --flag-de-red: #FF0000;
  --flag-de-gold: #FFCC00;

  --flag-at-red: #ED2939;

  /* Nav Swicther */
  --nav-btn-bg: #f1f5f9;
  --nav-btn-active: var(--primary);
  --nav-btn-text: var(--text-muted);
}

/* National Theme Overrides */
body.region-de {
  --primary: #1a1a1a;
  /* Black / Charcoal */
  --secondary: #9b1a1a;
  /* Muted Deep Red (not screaming) */
  --accent: #c9a227;
  /* Warm Gold */
  --accent-soft: rgba(201, 162, 39, 0.1);
}

body.region-at {
  --primary: #8b1a2a;
  /* Muted Burgundy / Institutional Red */
  --secondary: #5c1118;
  /* Dark wine */
  --accent: #e8e0d8;
  /* Warm off-white */
  --accent-soft: rgba(255, 255, 255, 0.1);
  --text-on-primary: #ffffff;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.025em;
  text-transform: uppercase;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Navigation */
nav {
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 80px;
  display: flex;
  align-items: center;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-area img {
  height: 50px;
}

.logo-text {
  font-weight: 800;
  color: var(--primary);
  font-size: 1.1rem;
  line-height: 1.1;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-links>li {
  position: relative;
  height: 80px;
  display: flex;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  transition: color 0.3s ease;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.nav-region-btn {
  background: var(--nav-btn-bg);
  border: 1px solid var(--border);
  color: var(--nav-btn-text);
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.nav-region-btn:hover {
  background: var(--border);
}

.nav-region-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

body.region-de #nav-btn-de {
  background: #000;
  color: #fff;
  border-color: #000;
  box-shadow: 0 0 0 2px var(--flag-de-gold);
}

body.region-de .heritage-ribbon .ribbon-bar {
  background: linear-gradient(90deg, #000 33.3%, #FF0000 33.3%, #FF0000 66.6%, #FFCC00 66.6%);
}

body.region-at .heritage-ribbon .ribbon-bar {
  background: linear-gradient(90deg, #ED2939 33.3%, #FFFFFF 33.3%, #FFFFFF 66.6%, #ED2939 66.6%);
}

body.region-at nav {
  background: var(--primary);
  /* Muted Burgundy from variable */
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

body.region-at .nav-links a,
body.region-at .logo-text,
body.region-at .logo-text span,
body.region-at .menu-toggle {
  color: white !important;
}

body.region-at .logo-circle {
  background: white !important;
  color: var(--primary) !important;
}

body.region-at .nav-region-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}

body.region-at #nav-btn-at {
  background: white;
  color: var(--primary);
  border-color: white;
}

body.region-at .nav-links {
  border-top-color: rgba(255, 255, 255, 0.2);
}

body.region-at .nav-links a:hover {
  color: rgba(255, 255, 255, 0.7) !important;
}

.nav-links a:hover {
  color: var(--primary);
}

/* Dropdown Menu Styles */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  min-width: 250px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  padding: 0.5rem 0;
  z-index: 1001;
}

.nav-links>li:hover .dropdown-menu {
  display: flex;
}

.dropdown-menu li {
  list-style: none;
}

/* Always dark text in dropdowns, regardless of region */
.dropdown-menu a,
body.region-at .dropdown-menu a,
body.region-de .dropdown-menu a {
  padding: 0.75rem 1.5rem;
  display: block;
  font-size: 0.85rem;
  color: var(--text) !important;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 500;
}

.dropdown-menu a:hover,
body.region-at .dropdown-menu a:hover,
body.region-de .dropdown-menu a:hover {
  background: #f8fafc;
  color: var(--primary) !important;
  padding-left: 2rem;
}

.dropdown-menu a:last-child {
  border-bottom: none;
}

.dropdown-menu a:hover {
  background: var(--bg-sterile);
  color: var(--primary);
  padding-left: 1.75rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Sterile Backdrop Pattern */
.sterile-bg {
  background-color: var(--bg-sterile);
  background-image: radial-gradient(var(--border) 0.5px, transparent 0.5px);
  background-size: 24px 24px;
}

/* Typography & Layout */
section {
  padding: 5rem 0;
}

.section-title {
  margin-bottom: 3rem;
  border-left: 4px solid var(--primary);
  padding-left: 1.5rem;
}

.section-title h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.section-title p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Hero Section */
.hero {
  position: relative;
  min-height: 80vh;
  display: flex;
  align-items: center;
  background: linear-gradient(rgba(26, 54, 93, 0.8), rgba(26, 54, 93, 0.8)), url('../assets/hero-lab.png');
  background-size: cover;
  background-position: center;
  color: white;
  padding: 0;
}

.hero-content {
  max-width: 800px;
}

.hero h1 {
  color: white;
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.hero h2 {
  color: var(--secondary);
  font-size: 1.5rem;
  margin-bottom: 2rem;
  text-transform: none;
}

/* Services */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.service-card {
  background: white;
  padding: 2.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.service-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
}

.service-card h3 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

/* IP Switch Overlay */
#ip-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.overlay-content {
  background: white;
  padding: 3rem;
  max-width: 600px;
  width: 90%;
  border-top: 8px solid var(--primary);
  text-align: center;
}

.overlay-content h2 {
  margin-bottom: 1.5rem;
}

.overlay-btn-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

.btn-primary {
  background: var(--primary);
  color: white !important;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-secondary {
  background: var(--secondary);
  color: white !important;
}

.btn-secondary:hover {
  opacity: 0.85;
}

/* Form Styling */
.form-container {
  background: white;
  padding: 3rem;
  border: 1px solid var(--border);
  max-width: 800px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 1rem;
}

.form-control:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

/* Loading Spinner */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: white;
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--secondary);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Mobile Navigation & Responsive Overhaul */
/* ============================================================
   COMPONENT: service-card / step-card
   ============================================================ */
.service-card {
  background: white;
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  padding: 2.5rem 2rem;
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
}

.service-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.step-card {
  background: white;
  border: 1px solid var(--border);
  padding: 2rem;
  border-left: 4px solid var(--accent);
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}


.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

@media (max-width: 992px) {
  .hero h1 {
    font-size: 2.8rem;
  }

  .nav-links {
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  nav .container {
    justify-content: space-between;
  }

  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links li {
    width: 100%;
    border-bottom: 1px solid #f1f5f9;
  }

  .nav-links a {
    display: block;
    padding: 1.25rem 2rem;
    width: 100%;
  }

  .dropdown-menu {
    position: static;
    display: block;
    opacity: 1;
    visibility: visible;
    box-shadow: none;
    padding-left: 2rem;
    background: #f8fafc;
    border: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
  }

  .nav-links li:hover .dropdown-menu {
    max-height: 300px;
    transform: none;
  }

  .hero {
    min-height: auto;
    padding: 8rem 0 5rem;
    text-align: center;
  }

  .hero h1 {
    font-size: 2.3rem;
  }

  .hero-content {
    margin: 0 auto;
  }

  .hero-content div[style*="display: flex"] {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem !important;
    width: 100%;
  }

  .hero-content div[style*="display: flex"] .btn {
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }

  .trust-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .step-grid {
    grid-template-columns: 1fr;
  }

  .services-grid {
    grid-template-columns: 1fr;
  }

  #archiving .container div[style*="display: flex"] {
    flex-direction: column !important;
    text-align: center;
  }

  #archiving .section-title {
    text-align: center;
    border: none;
    padding: 0;
  }

  .privilege-row {
    flex-direction: column;
  }

  .privilege-row>div:first-child {
    flex: 0 0 auto !important;
    border-right: none !important;
    border-bottom: 2px solid #eee;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.9rem;
  }

  .trust-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 1.25rem;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  /* Prevent flex children with min-width or fixed flex-basis from overflowing the viewport */
  [style*="min-width"],
  [style*="flex: 0 0"],
  [style*="flex:0 0"] {
    min-width: 0 !important;
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  /* Ensure all flex containers wrap on very small screens */
  [style*="display: flex"],
  [style*="display:flex"] {
    flex-wrap: wrap !important;
    gap: 1.5rem !important;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Heritage Indicators */
.heritage-ribbon {
  height: 8px;
  width: 100%;
  display: flex;
}

.heritage-ribbon div {
  flex: 1;
}

.region-de .ribbon-bar {
  background: linear-gradient(to right, var(--flag-de-black) 33.3%, var(--flag-de-red) 33.3% 66.6%, var(--flag-de-gold) 66.6%);
}

.region-at .ribbon-bar {
  background: linear-gradient(to right, var(--flag-at-red) 33.3%, #FFFFFF 33.3% 66.6%, var(--flag-at-red) 66.6%);
}

.region-de .service-card {
  border-top: 4px solid var(--flag-de-red);
}

.region-at .service-card {
  border-top: 4px solid var(--flag-at-red);
}

/* Regional Seals */
.regional-seal {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 10px;
  line-height: 1.2;
}

.region-de .regional-seal {
  background: radial-gradient(circle, var(--flag-de-gold) 0%, var(--flag-de-red) 50%, var(--flag-de-black) 100%);
  color: white;
  border: 4px double white;
}

.region-at .regional-seal {
  background: linear-gradient(to bottom, var(--flag-at-red) 0%, #FFFFFF 50%, var(--flag-at-red) 100%);
  color: var(--primary);
  border: 4px solid var(--flag-at-red);
}

/* Trust Bar */
.trust-bar {
  background: var(--primary);
  color: white;
  padding: 1.5rem 0;
  border-bottom: 4px solid var(--accent);
}

.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  text-align: center;
}

.trust-item h4 {
  color: white;
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.trust-item p {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* Stufenplan Section */
.step-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 3rem;
}

.step-card {
  padding: 2rem;
  background: white;
  border: 1px solid var(--border);
  position: relative;
}

.step-num {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 3rem;
  font-weight: 900;
  color: var(--secondary);
  opacity: 0.5;
}

.region-de .step-card {
  border-left: 5px solid var(--flag-de-gold);
}

.region-at .step-card {
  border-left: 5px solid var(--flag-at-red);
}

/* Footer Improvements */
footer {
  background: #0F172A;
  color: white;
  padding: 4rem 0 2rem;
}

footer a {
  color: var(--secondary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 3rem;
}

/* ============================================================
   MOBILE NAVIGATION (Slide-In Sidebar)
   ============================================================ */

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--primary);
  z-index: 1100;
  position: relative;
}

/* Full-screen overlay behind the sidebar */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1199;
  backdrop-filter: blur(2px);
}

.mobile-nav-overlay.open {
  display: block;
}

/* The sidebar itself */
.mobile-nav-sidebar {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(320px, 88vw);
  height: 100%;
  background: white;
  z-index: 1200;
  overflow-y: auto;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
}

.mobile-nav-sidebar.open {
  right: 0;
}

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 3px solid var(--primary);
  background: var(--primary);
  color: white;
}

.mobile-nav-header .logo-circle {
  background: white !important;
  color: var(--primary) !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.75rem;
}

.mobile-nav-header span {
  font-weight: 800;
  font-size: 0.9rem;
  color: white;
}

.mobile-nav-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: white;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.mobile-nav-links {
  list-style: none;
  padding: 1rem 0;
  flex: 1;
}

.mobile-nav-links li {
  border-bottom: 1px solid var(--border);
}

.mobile-nav-links a {
  display: block;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.2s, color 0.2s, padding-left 0.2s;
}

.mobile-nav-links a:hover {
  background: var(--bg-sterile);
  color: var(--primary);
  padding-left: 2rem;
}

.mobile-nav-links .section-label {
  display: block;
  padding: 0.5rem 1.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  background: #f8fafc;
}

.mobile-nav-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.mobile-region-btn {
  padding: 0.6rem 1.2rem;
  font-weight: 800;
  font-size: 0.8rem;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.mobile-region-btn.de {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

.mobile-region-btn.at {
  border-color: #c8102e;
  color: #c8102e;
}

body.region-de .mobile-region-btn.de {
  background: #1a1a1a;
  color: white;
}

body.region-at .mobile-region-btn.at {
  background: var(--primary);
  color: white;
}

/* Show toggle, hide desktop links on mobile */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none !important;
  }

  nav .container {
    flex-direction: row !important;
    align-items: center !important;
  }
}

/* ============================================================
   BACK-TO-TOP BUTTON
   ============================================================ */
#back-to-top {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 998;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: opacity 0.3s, transform 0.2s, background 0.2s;
  opacity: 0;
}

#back-to-top:hover {
  transform: translateY(-3px);
  background: var(--secondary);
}

/* Show toggle, hide desktop links on mobile */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none !important;
  }

  nav .container {
    flex-direction: row !important;
    align-items: center !important;
  }
}