:root {
  --brand: #0086AE;
  --brand-hover: #006B8A;
  --brand-soft: rgba(0, 134, 174, .10);

  --text: #1C1F23;
  --muted: #5F6B7A;
  --border: #EEF2F7;
  --shadow-md: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  --shadow-md: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.15), 0 6px 20px 0 rgba(0, 0, 0, 0.1);

  --header-h: 72px;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --f1: var(--brand);
  /* #0086AE */
  --f1b: var(--brand-hover);
  /* #006B8A */
  --f2: #B42318;
  --f2b: #8F1B13;
}

/* ================== BASE / RESET ================== */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: #fff;
}

/* ================== LAYOUT HELPERS ================== */
/* Standard: Content-Bereich kann selbst entscheiden ob scroll oder fixed.
   Graph-Seiten werden automatisch “fixed” (über :has(#flowChart)) */
.main-content {
  /* beide drin: moderne Browser nutzen dvh, fallback vh */
  height: calc(100vh - var(--header-h, 72px));
  height: calc(100dvh - var(--header-h, 72px));
  padding: 16px;

  display: flex;
  flex-direction: column;
  min-height: 0;
  /* wichtig für Flex */
}

/* Für Seiten, die scrollen dürfen: gib dem Wrapper diese Klasse:
   <div class="main-content scroll"> ... */
.main-content.scroll {
  overflow: auto;
}

/* ================== BUTTONS (einheitlich) ================== */
/* Default-Buttons (außer Header-Buttons!) */
button:not(.header-btn),
input[type="button"],
input[type="submit"],
input[type="reset"],
a.btn {
  appearance: none;
  border: 1px solid rgba(0, 134, 174, .22);
  background: var(--brand);
  color: #fff;

  padding: 10px 12px;
  border-radius: 10px;

  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;

  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .08s ease, box-shadow .15s ease, border-color .15s ease, opacity .15s ease;
}

button:not(.header-btn):hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
a.btn:hover {
  background: var(--brand-hover);
}

button:not(.header-btn):active,
input[type="button"]:active,
input[type="submit"]:active,
input[type="reset"]:active,
a.btn:active {
  transform: translateY(1px);
}

/* Sekundär/Outline falls du es irgendwo nutzen willst */
.btn-secondary {
  background: #fff !important;
  color: var(--brand-hover) !important;
  border-color: rgba(0, 134, 174, .30) !important;
  box-shadow: none !important;
}

.btn-secondary:hover {
  background: var(--brand-soft) !important;
}

/* Danger */
.btn-danger {
  background: #B42318 !important;
  border-color: rgba(180, 35, 24, .35) !important;
}

.btn-danger:hover {
  background: #8F1B13 !important;
}

/* “recalc-btn” soll exakt gleich aussehen */
.recalc-btn {
  /* nichts extra nötig – fällt in button:not(.header-btn) */
}

/* Busy-State für recalc */
.recalc-btn.is-busy {
  background: #98A2B3 !important;
  border-color: #98A2B3 !important;
  cursor: not-allowed;
  pointer-events: none;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 134, 174, .35);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(0, 134, 174, .10);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(0, 134, 174, .00);
  }
}

/* ================== FORMS ================== */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="month"],
input[type="week"],
input[type="email"],
input[type="time"],
input:not([type]),
select,
textarea {
  width: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="email"]:focus,
input[type="time"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 134, 174, .35);
  box-shadow: var(--shadow-sm);
}

/* ================== CALENDAR BAR (Graph-Seiten) ================== */
.calendar-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 10px 12px;
  border: 1px groove var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-lg);
  margin-bottom: 2%;
  min-height: 52px;
}

/* StatsBox: nicht die Bar aufblasen */
#statsBox {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-left: 16px !important;
  /* ersetzt dein inline 40px etwas ruhiger */
  font-size: 1.05em;
}

/* ================== GRAPH PAGES: exakt 1 Screen, kein Scroll ================== */
/* Nur wenn auf der Seite ein #flowChart existiert */
.main-content:has(#flowChart) {
  overflow: hidden;
}

/* Flex-Shrink Fix für alle Children */
.main-content:has(#flowChart)>* {
  min-height: 0;
}

/* Der Container um das Canvas soll den Restplatz nehmen.
   In deinem HTML ist das der zweite <div style="flex:1..."> */
.main-content:has(#flowChart)>div:last-child {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Canvas füllt die Resthöhe sauber */
#flowChart {
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ================== SETTINGS: soll scrollen dürfen ================== */
.settings-container {
  /* Settings-Seite nutzt keinen .main-content wrapper -> hier direkt Höhe+Scroll */
  height: calc(100vh - var(--header-h, 72px));
  height: calc(100dvh - var(--header-h, 72px));
  overflow: auto;

  display: flex;
  align-items: flex-start;
  gap: 16px;

  padding: 20px 16px 16px;
  /* oben mehr Abstand -> Kacheln berühren nicht */
  margin: 0;
}

/* Kachel-Design */
.settings-tile {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);

  padding: 20px;
  /* oben ausreichend */
  flex: 1;
  min-width: 300px;
}

/* Kachel-Headings kompakt */
.settings-tile h2 {
  margin: 0 0 12px 0;
  font-size: 1.25rem;
}

.settings-tile h4 {
  margin: 12px 0 10px;
  font-weight: 650;
  color: var(--muted);
}

/* Tabellen */
.swap-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: .95rem;
}

.swap-table th,
.swap-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 10px;
  text-align: left;
}

.swap-table th {
  background: rgba(95, 107, 122, .06);
  color: var(--muted);
  font-weight: 700;
}

/* ================== LOGIN ================== */
.login-container {
  max-width: 420px;
  width: calc(100% - 32px);
  margin: clamp(32px, 12vh, 140px) auto 0 auto;

  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: #fff;
}

.login-container h2 {
  margin: 0 0 14px 0;
  text-align: center;
  font-size: 1.35rem;
}

.login-container label {
  display: block;
  margin: 10px 0 6px 0;
  font-weight: 700;
}

.login-container input {
  width: 100%;
}

/* Fehlermeldung */
.error {
  color: #B42318;
  margin: 10px 0;
  text-align: center;
  font-weight: 700;
}

/* ================== RESPONSIVE ================== */
@media (max-width: 900px) {
  .settings-container {
    flex-direction: column;
  }

  .settings-tile {
    min-width: 0;
  }
}

/* ================== LOGIN PAGE ================== */
.page-login {
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(0, 134, 174, .08), transparent 60%),
    radial-gradient(900px 500px at 80% 0%, rgba(0, 134, 174, .06), transparent 60%),
    #fff;
}

.login-page {
  height: calc(100vh - var(--header-h, 72px));
  height: calc(100dvh - var(--header-h, 72px));
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  backdrop-filter: blur(6px);
}

.login-card h1 {
  margin: 0 0 14px 0;
  font-size: 1.4rem;
}

.form {
  display: grid;
  gap: 10px;
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  margin: 0 0 12px 0;
}

.alert-error {
  background: rgba(180, 35, 24, .08);
  border: 1px solid rgba(180, 35, 24, .18);
  color: #8F1B13;
}

/* kleiner Hinweistext */
.login-hint {
  margin: 12px 0 0 0;
  color: var(--muted);
  font-size: .95rem;
}

/* ================== CONTACT PAGE ================== */
.page-head {
  padding: 6px 0 14px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.6rem;
}

.muted {
  color: var(--muted);
}

.contact-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-lg);
}

.card h2 {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
}

.form {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  font-weight: 700;
  color: var(--text);
}

.form-span-2 {
  grid-column: span 2;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Buttons: falls du die Klassen nutzen willst */
.btn {
  display: inline-flex;
}

.btn-primary {
  /* nutzt deine globalen Button-Regeln */
}

.btn-secondary {
  background: #fff !important;
  color: var(--brand-hover) !important;
  border-color: rgba(0, 134, 174, .30) !important;
  box-shadow: none !important;
}

.btn-secondary:hover {
  background: var(--brand-soft) !important;
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
}

.alert-error {
  background: rgba(180, 35, 24, .08);
  border: 1px solid rgba(180, 35, 24, .18);
  color: #8F1B13;
}

.alert-success {
  background: rgba(2, 122, 72, .08);
  border: 1px solid rgba(2, 122, 72, .18);
  color: #05603A;
}

.kv {
  display: grid;
  gap: 10px;
}

.kv-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
}

.kv-k {
  color: var(--muted);
  font-weight: 700;
}

.kv-v a {
  color: var(--brand-hover);
  text-decoration: none;
}

.kv-v a:hover {
  text-decoration: underline;
}

.soft {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* Honeypot unsichtbar */
.hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

/* Responsive */
@media (max-width: 900px) {
  .contact-grid {
    grid-template-columns: 1fr;
  }

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

  .form-span-2 {
    grid-column: auto;
  }
}

.form select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(95, 107, 122, .9) 50%),
    linear-gradient(135deg, rgba(95, 107, 122, .9) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.form textarea {
  resize: vertical;
  min-height: 140px;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: rgba(0, 134, 174, .35);
  box-shadow: 0 0 0 4px rgba(0, 134, 174, .10);
}

/* Kalenderleiste soll NICHT alles auf 100% ziehen */
.calendar-bar input[type="date"] {
  width: auto;
}

/* Buttons in Formular-Zeile hübsch */
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Honeypot */
.hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

/* Soft divider */
.soft {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}